:root {
  color-scheme: light;
  --bg: #f4f6f8;
  --panel: #ffffff;
  --panel-soft: #f8fafc;
  --border: #d9e0e7;
  --border-strong: #b8c2cc;
  --text: #1f2933;
  --muted: #607080;
  --muted-strong: #495866;
  --blue: #1d6fc8;
  --blue-soft: #e8f2ff;
  --green: #1f8a5b;
  --green-soft: #e7f6ef;
  --amber: #b7791f;
  --amber-soft: #fff4db;
  --red: #c33131;
  --red-soft: #ffe8e8;
  --violet: #6d4cc2;
  --violet-soft: #f0ebff;
  --shadow: 0 12px 28px rgba(27, 42, 61, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 14px;
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 20px 28px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 20;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--blue);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: 24px;
  line-height: 1.2;
}

h2 {
  margin-bottom: 4px;
  font-size: 16px;
}

h3 {
  margin-bottom: 8px;
  font-size: 14px;
}

.role-switch,
.filters,
.detail-actions,
.timeline-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.session-bar {
  display: flex;
  align-items: center;
  gap: 8px;
}

.session-bar span {
  color: var(--muted-strong);
  font-weight: 700;
}

.role-button:disabled {
  cursor: default;
  opacity: 0.55;
}

.auth-screen {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(248, 250, 252, 0.96);
}

.signed-out #auth-screen,
.password-screen-open #password-screen {
  display: flex;
}

.signed-out .shell,
.password-required .shell {
  display: none;
}

.login-panel {
  width: min(420px, 100%);
  display: grid;
  gap: 14px;
  padding: 22px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.login-panel h1 {
  margin: 0;
}

.helper-text {
  margin: 0;
  color: var(--muted-strong);
  line-height: 1.45;
}

.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.role-button,
.filter-button,
.secondary-button,
.action-button {
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text);
  border-radius: 6px;
  min-height: 36px;
  padding: 7px 11px;
  font-weight: 650;
}

.role-button.active,
.filter-button.active {
  border-color: var(--blue);
  background: var(--blue);
  color: #ffffff;
}

.secondary-button {
  background: var(--panel-soft);
  color: var(--muted-strong);
}

.secondary-button.danger {
  border-color: #efb3b3;
  color: var(--red);
}

.action-button {
  background: var(--blue);
  border-color: var(--blue);
  color: #ffffff;
}

.action-button.done {
  background: var(--green);
  border-color: var(--green);
}

.action-button.warn {
  background: var(--amber);
  border-color: var(--amber);
}

.shell {
  width: min(1540px, 100%);
  margin: 0 auto;
  padding: 20px 24px 40px;
}

.summary-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(150px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.metric {
  min-height: 84px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.metric.warning strong {
  color: var(--red);
}

.metric-label {
  display: block;
  color: var(--muted);
  font-weight: 650;
  margin-bottom: 6px;
}

.metric strong {
  font-size: 30px;
  line-height: 1;
}

.toolbar {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 16px;
  margin-bottom: 16px;
}

.search-field {
  display: grid;
  gap: 6px;
  min-width: 260px;
  color: var(--muted);
  font-weight: 650;
}

.search-field input {
  min-height: 38px;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 10px;
  background: var(--panel);
  color: var(--text);
}

.work-area {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 420px;
  gap: 16px;
  align-items: start;
}

.table-panel,
.panel,
.side-panel {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.table-panel,
.panel {
  overflow: hidden;
}

.panel-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px;
  border-bottom: 1px solid var(--border);
}

.panel-title-row.compact {
  align-items: baseline;
}

#table-caption,
.small-note {
  margin-bottom: 0;
  color: var(--muted);
}

.table-wrap {
  overflow: auto;
}

table {
  width: 100%;
  min-width: 1120px;
  border-collapse: collapse;
}

th,
td {
  padding: 11px 12px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: top;
}

th {
  color: var(--muted);
  background: var(--panel-soft);
  font-size: 12px;
  text-transform: uppercase;
}

.sort-button {
  width: 100%;
  border: 0;
  padding: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  font-weight: 800;
  text-align: left;
  text-transform: uppercase;
  cursor: pointer;
}

.sort-button span {
  display: inline-block;
  min-width: 12px;
  color: var(--blue);
}

.column-filter-row th {
  padding: 7px 8px;
  background: #ffffff;
  text-transform: none;
}

.column-filter-row input,
.column-filter-row select {
  width: 100%;
  min-height: 30px;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 5px 7px;
  background: var(--panel);
  color: var(--text);
  font-size: 12px;
}

tbody tr {
  transition: background 0.15s ease;
}

tbody tr:hover,
tbody tr.selected {
  background: #eef6ff;
}

tbody tr {
  cursor: pointer;
}

.car-main {
  display: grid;
  gap: 3px;
}

.car-main strong {
  font-size: 14px;
}

.vin {
  color: var(--muted);
  font-size: 12px;
  word-break: break-all;
}

.badge,
.stage-badge,
.role-badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: 999px;
  padding: 3px 8px;
  font-size: 12px;
  font-weight: 750;
  white-space: nowrap;
}

.stage-badge {
  background: var(--blue-soft);
  color: var(--blue);
}

.stage-badge.payment {
  background: var(--amber-soft);
  color: var(--amber);
}

.stage-badge.export {
  background: var(--green-soft);
  color: var(--green);
}

.stage-badge.tax,
.stage-badge.passport {
  background: var(--violet-soft);
  color: var(--violet);
}

.stage-badge.alert {
  background: var(--red-soft);
  color: var(--red);
}

.role-badge {
  background: var(--panel-soft);
  color: var(--muted-strong);
  border: 1px solid var(--border);
}

.alert-text {
  color: var(--red);
  font-weight: 750;
}

.muted {
  color: var(--muted);
}

.side-panel {
  display: grid;
  gap: 0;
  position: sticky;
  top: 92px;
  max-height: calc(100vh - 116px);
  overflow: auto;
}

.queue-block,
.detail-block {
  padding: 16px;
}

.queue-block {
  border-bottom: 1px solid var(--border);
  background: var(--panel-soft);
}

.queue-list,
.passport-list,
.log-list,
.issue-list,
.comments-list,
.timeline,
.files-list {
  display: grid;
  gap: 8px;
}

.queue-item,
.passport-item,
.log-item,
.issue-item,
.comment-item,
.file-item {
  display: grid;
  gap: 4px;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--panel);
}

.file-item {
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
}

.file-item strong,
.file-item span {
  display: block;
}

.file-item strong {
  word-break: break-word;
}

.file-item.legacy {
  background: var(--panel-soft);
}

.file-actions {
  display: flex;
  gap: 6px;
  align-items: center;
}

.queue-item.alert,
.passport-item.alert,
.issue-item.open {
  border-color: #efb3b3;
  background: #fff6f6;
}

.issue-item.resolved {
  background: var(--panel-soft);
}

.queue-item button {
  justify-self: start;
  margin-top: 4px;
}

.detail-head {
  display: grid;
  gap: 8px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}

.detail-block {
  transition: background 0.25s ease, box-shadow 0.25s ease;
}

.detail-block.detail-focus {
  background: #f5faff;
  box-shadow: inset 4px 0 0 var(--blue);
}

.detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin: 12px 0;
}

.data-tile {
  padding: 9px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--panel-soft);
}

.data-tile span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 3px;
}

.timeline {
  margin: 12px 0;
}

.timeline-row {
  display: grid;
  grid-template-columns: 22px 1fr;
  gap: 8px;
  align-items: start;
}

.dot {
  width: 16px;
  height: 16px;
  margin-top: 2px;
  border-radius: 50%;
  border: 2px solid var(--border-strong);
  background: var(--panel);
}

.timeline-row.done .dot {
  border-color: var(--green);
  background: var(--green);
}

.timeline-row.current .dot {
  border-color: var(--blue);
  background: var(--blue-soft);
}

.timeline-title {
  font-weight: 750;
}

.timeline-sub {
  color: var(--muted);
  font-size: 12px;
}

.task-summary-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin: 14px 0;
}

.task-card {
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--panel-soft);
  overflow: hidden;
}

.task-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 9px;
  border-bottom: 1px solid var(--border);
}

.task-card-head h3 {
  margin: 0;
}

.task-card-head span {
  min-width: 24px;
  border-radius: 999px;
  padding: 3px 7px;
  background: var(--panel);
  color: var(--muted-strong);
  font-size: 12px;
  font-weight: 800;
  text-align: center;
}

.task-list {
  display: grid;
  gap: 6px;
  padding: 8px;
}

.task-pill {
  display: grid;
  gap: 2px;
  padding: 7px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--panel);
}

.task-pill.done {
  border-color: #acd8be;
  background: #f4fbf6;
}

.task-pill.current {
  border-color: #9dc6f8;
  background: #f3f8ff;
}

.task-pill strong {
  font-size: 12px;
}

.task-pill span {
  color: var(--muted);
  font-size: 12px;
}

.action-form,
.document-panel,
.comments-panel,
.files-panel,
.file-upload-form,
.review-form {
  display: grid;
  gap: 10px;
}

.action-box,
.available-actions {
  display: grid;
  gap: 8px;
}

.action-box {
  margin: 10px 0 12px;
}

.action-box.compact {
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--panel-soft);
}

.action-box.compact strong,
.action-box.compact span {
  display: block;
}

.action-box.compact strong {
  margin-bottom: 3px;
}

.action-form,
.document-panel,
.comments-panel,
.files-panel {
  margin: 10px 0 12px;
}

.file-upload-form {
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--panel-soft);
}

.review-form {
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--panel-soft);
}

.field {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.field input,
.field select,
.field textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 9px;
  background: var(--panel);
  color: var(--text);
  font: inherit;
}

.field textarea {
  resize: vertical;
}

.file-field input {
  padding: 7px;
}

.validation-note {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
}

.empty-state.compact {
  padding: 10px;
}

.bottom-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-top: 16px;
}

.launch-section {
  margin-top: 16px;
}

.passport-list,
.log-list,
.readiness-list {
  padding: 16px;
}

.readiness-list {
  display: grid;
  grid-template-columns: repeat(3, minmax(220px, 1fr));
  gap: 10px;
}

.readiness-item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: start;
  min-height: 92px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--panel);
}

.readiness-item strong,
.readiness-item span {
  display: block;
}

.readiness-item div > span {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.readiness-badge {
  border-radius: 999px;
  padding: 4px 8px;
  background: var(--panel-soft);
  color: var(--muted-strong);
  font-size: 11px;
  font-weight: 800;
  white-space: nowrap;
}

.readiness-item.ready {
  border-color: #acd8be;
  background: #f4fbf6;
}

.readiness-item.ready .readiness-badge {
  background: var(--green-soft);
  color: var(--green);
}

.readiness-item.partly-ready,
.readiness-item.manual-confirm {
  border-color: #f1d29b;
  background: #fff9ee;
}

.readiness-item.partly-ready .readiness-badge,
.readiness-item.manual-confirm .readiness-badge {
  background: var(--amber-soft);
  color: var(--amber);
}

.readiness-item.needed {
  border-color: #efb3b3;
  background: #fff6f6;
}

.readiness-item.needed .readiness-badge {
  background: var(--red-soft);
  color: var(--red);
}

.empty-state {
  padding: 18px;
  border: 1px dashed var(--border-strong);
  border-radius: 6px;
  color: var(--muted);
  background: var(--panel-soft);
}

@media (max-width: 1120px) {
  .topbar,
  .toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .work-area,
  .bottom-grid,
  .readiness-list {
    grid-template-columns: 1fr;
  }

  .side-panel {
    position: static;
    max-height: none;
  }
}

@media (max-width: 720px) {
  .shell {
    padding: 14px;
  }

  .summary-strip {
    grid-template-columns: 1fr 1fr;
  }

  .panel-title-row {
    align-items: stretch;
    flex-direction: column;
  }

  .role-button,
  .filter-button,
  .secondary-button,
  .action-button {
    width: 100%;
  }

  .detail-grid {
    grid-template-columns: 1fr;
  }

  .task-summary-grid {
    grid-template-columns: 1fr;
  }

  .file-item {
    grid-template-columns: 1fr;
  }

  .file-actions {
    align-items: stretch;
    flex-direction: column;
  }
}
