:root {
  color-scheme: light;
  --bg: #d8dde5;
  --surface: #ffffff;
  --panel: #ffffff;
  --panel-soft: #f7f8fb;
  --line: #d7dde7;
  --line-strong: rgba(221, 162, 89, 0.46);
  --text: #121821;
  --muted: #5f6978;
  --accent: #dda259;
  --accent-dark: #c48235;
  --accent-soft: rgba(221, 162, 89, 0.14);
  --danger: #fb7185;
  --success: #34d399;
  --warning: #fbbf24;
  --shadow: 0 18px 44px rgba(0, 0, 0, 0.34);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: linear-gradient(180deg, #c9d0da 0%, #dbe0e7 36%, #cbd2dc 100%);
  color: var(--text);
  font: 14px/1.45 Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
select {
  font: inherit;
}

button {
  border: 1px solid #b9c2cf;
  background: #ffffff;
  color: var(--text);
  border-radius: 5px;
  min-height: 25px;
  padding: 0 9px;
  cursor: pointer;
  font-weight: 650;
}

button:hover {
  border-color: rgba(221, 162, 89, 0.7);
  background: #fff7ec;
}

button.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #06080b;
}

button.primary:hover {
  background: var(--accent-dark);
}

button.danger {
  color: var(--danger);
}

button:disabled {
  cursor: wait;
  opacity: 0.62;
}

input,
select {
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  background: #ffffff;
  color: var(--text);
  min-height: 36px;
  padding: 0 10px;
}

input:focus,
select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(221, 162, 89, 0.16);
  outline: 0;
}

input[type="file"] {
  padding: 7px 10px;
}

option {
  background: #ffffff;
  color: var(--text);
}

a {
  color: inherit;
  text-decoration: none;
}

.loader-screen {
  align-items: center;
  background:
    radial-gradient(circle at 50% 44%, rgba(221, 162, 89, 0.18), transparent 18rem),
    radial-gradient(circle at 20% 15%, rgba(196, 82, 40, 0.08), transparent 26rem),
    linear-gradient(145deg, #f8fafc 0%, #eef2f7 48%, #f7efe4 100%);
  display: grid;
  min-height: 100vh;
  place-items: center;
}

.loader-screen img {
  display: block;
  height: auto;
  filter: drop-shadow(0 18px 32px rgba(15, 23, 42, 0.18));
  width: min(360px, 54vw);
}

.login-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 18px;
}

.login-card {
  width: min(390px, 100%);
  background: var(--panel);
  border: 1px solid #d7dde7;
  border-radius: 12px;
  box-shadow: var(--shadow);
  padding: 22px;
}

.login-card h1,
.page-title h1 {
  margin: 0;
  font-size: 24px;
  line-height: 1.15;
}

h2 {
  margin: 0 0 12px;
  font-size: 16px;
  line-height: 1.2;
}

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

.form-grid {
  display: grid;
  gap: 12px;
  align-items: start;
}

.form-grid label {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-weight: 650;
}

.form-grid button {
  justify-self: start;
}

.login-card button {
  width: 100%;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-rows: auto 1fr;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: rgba(255, 255, 255, 0.76);
  border-bottom: 1px solid rgba(148, 163, 184, 0.45);
  backdrop-filter: blur(12px);
  padding: 12px 18px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 16px;
  font-weight: 800;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.content {
  min-width: 0;
  overflow-x: hidden;
  width: 100%;
  padding: 22px 18px;
}

.solo-content {
  margin: 0 auto;
}

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

.grid {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: 14px;
}

.panel {
  background: var(--panel);
  border: 1px solid #d7dde7;
  border-radius: 8px;
  box-shadow: 0 14px 28px rgba(15, 23, 42, 0.08);
  padding: 14px;
  overflow: auto;
}

.span-4 {
  grid-column: span 4;
}

.span-8 {
  grid-column: span 8;
}

.span-12 {
  grid-column: span 12;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-bottom: 12px;
}

.toolbar > * {
  width: auto;
}

.table-card {
  background: #ffffff;
  border-radius: 8px;
  color: #121821;
  max-width: 100%;
  overflow: hidden;
}

.table-card .muted {
  color: #5f6978;
}

.table-card-header {
  align-items: center;
  background: var(--accent);
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 14px;
  padding: 12px 20px 10px;
}

.table-card-header h2,
.table-card-header p {
  margin: 0;
}

.table-card-header .muted {
  color: rgba(20, 20, 20, 0.72);
}

.table-card-header input {
  background: #fff;
  border-color: #aeb7c4;
  color: #111827;
  flex: 1 1 280px;
  max-width: 420px;
}

.table-scroll {
  max-width: 100%;
  overflow-x: auto;
  overflow-y: visible;
  overscroll-behavior-x: contain;
}

.section-title {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.section-title h2,
.section-title p {
  margin: 0;
}

.truck-doc-panel {
  margin-top: 14px;
}

.truck-doc-layout {
  display: grid;
  grid-template-columns: minmax(260px, 340px) minmax(0, 1fr);
  gap: 14px;
}

.compact-form {
  align-content: start;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
}

.doc-table-wrap {
  min-width: 0;
  overflow: auto;
}

.objects-toolbar {
  margin-bottom: 12px;
  max-width: 580px;
}

.folder-name {
  color: var(--accent);
  font-weight: 800;
}

.table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  border: 0;
  border-radius: 0;
  overflow: hidden;
  background: transparent;
}

.truck-table {
  min-width: 1040px;
  table-layout: fixed;
}

.truck-table .col-truck {
  width: 78px;
}

.truck-table .col-vin {
  width: 168px;
}

.truck-table .col-class {
  width: 120px;
}

.truck-table .col-files {
  width: 78px;
}

.truck-table .col-company {
  width: 112px;
}

.truck-table .col-driver {
  width: 160px;
}

.truck-table .col-location {
  width: 282px;
}

.truck-table .col-actions {
  width: 124px;
}

.table th,
.table td {
  border-bottom: 1px solid #d9dee7;
  padding: 3px 10px;
  text-align: left;
  vertical-align: middle;
  height: 28px;
  line-height: 1.05;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.table tbody tr:last-child td {
  border-bottom: 0;
}

.table tbody tr:hover {
  background: #eef3f8;
}

.table tbody tr.selected,
.table tbody tr.selected:nth-child(even),
.table tbody tr.selected:hover,
.table tbody tr.selected:nth-child(even):hover {
  background: #ffe0ad;
  box-shadow: inset 3px 0 0 var(--accent);
}

.table th {
  background: var(--accent);
  border-bottom-color: #b77a2f;
  color: #141414;
  font-size: 12px;
  height: 28px;
  padding: 3px 10px;
  text-transform: uppercase;
  letter-spacing: 0;
}

.table td,
.table td strong {
  font-size: 13px;
}

.table tbody tr:nth-child(even) {
  background: #f0f3f8;
}

.table tbody tr:nth-child(even):hover {
  background: #e8eef6;
}

.pill {
  display: inline-flex;
  align-items: center;
  width: max-content;
  min-height: 24px;
  padding: 0 8px;
  border-radius: 999px;
  background: #eef2f7;
  color: #364152;
  font-size: 12px;
  font-weight: 700;
}

.pill.public {
  background: rgba(52, 211, 153, 0.14);
  color: var(--success);
}

.pill.truck {
  background: rgba(221, 162, 89, 0.15);
  color: var(--accent);
}

.actions:not(td) {
  display: flex;
  gap: 6px;
  justify-content: flex-end;
  min-width: 0;
  align-items: center;
}

.actions button,
td.actions button {
  max-width: none;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

td.actions {
  display: table-cell;
  min-width: 0;
  overflow: visible;
  text-align: right;
  white-space: nowrap;
}

.action-menu {
  display: inline-block;
  position: relative;
}

.action-menu summary {
  background: #f8fafc;
  border: 1px solid #cbd5e1;
  border-radius: 4px;
  cursor: pointer;
  font-weight: 800;
  line-height: 22px;
  list-style: none;
  min-width: 76px;
  padding: 0 8px;
  text-align: center;
}

.action-menu summary::-webkit-details-marker {
  display: none;
}

.action-menu[open] summary,
.action-menu summary:hover {
  background: #e8edf4;
  border-color: #94a3b8;
}

.action-menu div {
  background: #ffffff;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  box-shadow: 0 14px 32px rgba(15, 23, 42, 0.18);
  display: grid;
  gap: 2px;
  min-width: 158px;
  padding: 5px;
  position: absolute;
  right: 0;
  top: calc(100% + 4px);
  z-index: 8;
}

.action-menu a,
.action-menu button {
  background: transparent;
  border: 0;
  border-radius: 4px;
  color: #111827;
  display: block;
  font-weight: 750;
  min-height: 28px;
  padding: 5px 8px;
  text-align: left;
  text-decoration: none;
  width: 100%;
}

.action-menu a:hover,
.action-menu button:hover {
  background: #eef2f7;
}

.sort-button {
  background: transparent;
  border: 0;
  color: inherit;
  font-size: inherit;
  font-weight: 850;
  justify-content: flex-start;
  min-height: auto;
  padding: 0;
  text-transform: inherit;
  width: 100%;
}

.sort-button:hover {
  background: transparent;
  color: #000;
}

.sort-button span {
  font-size: 9px;
  margin-left: 6px;
}

.file-status {
  border: 0;
  border-radius: 999px;
  font-weight: 900;
  min-height: 22px;
  min-width: 34px;
  padding: 0 9px;
}

.file-status.complete {
  background: #dcfce7;
  color: #047857;
}

.file-status.missing {
  background: #fee2e2;
  color: #b91c1c;
}

.files-row td {
  height: auto;
  padding: 0;
  white-space: normal;
}

.files-panel {
  background: #ffffff;
  border-bottom: 1px solid #d9dee7;
  box-shadow: inset 3px 0 0 var(--accent);
  max-width: 100%;
  overflow: hidden;
  padding: 14px;
}

.files-panel-head {
  align-items: baseline;
  display: flex;
  gap: 12px;
  margin-bottom: 12px;
}

.files-panel-head span {
  color: var(--muted);
}

.files-columns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  min-width: 0;
}

.file-dir {
  border: 1px solid #d9dee7;
  border-radius: 8px;
  min-width: 0;
  overflow: hidden;
}

.file-dir header {
  align-items: center;
  background: #f8fafc;
  border-bottom: 1px solid #d9dee7;
  display: flex;
  justify-content: space-between;
  padding: 8px 10px;
}

.missing-count {
  color: #b91c1c;
}

.complete-count {
  color: #047857;
}

.file-items {
  display: grid;
}

.file-item {
  border-bottom: 1px solid #e5e9f0;
}

.file-item:last-child {
  border-bottom: 0;
}

.file-item summary {
  align-items: center;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  gap: 10px;
  list-style: none;
  padding: 8px 10px;
}

.file-item summary::-webkit-details-marker {
  display: none;
}

.file-item-actions {
  align-items: center;
  display: inline-flex;
  gap: 8px;
}

.item-ready {
  align-items: center;
  background: #dcfce7;
  border: 1px solid #16a34a;
  border-radius: 999px;
  color: #166534;
  display: inline-flex;
  font-size: 12px;
  font-weight: 900;
  height: 22px;
  justify-content: center;
  line-height: 1;
  width: 22px;
}

.item-missing {
  color: #dc2626;
  font-weight: 900;
  text-transform: lowercase;
}

.file-item-actions button {
  min-height: 22px;
}

.file-list {
  display: grid;
  gap: 6px;
  padding: 0 10px 10px;
}

.file-row {
  align-items: center;
  background: #f8fafc;
  border: 1px solid #e5e9f0;
  border-radius: 6px;
  display: flex;
  gap: 10px;
  justify-content: space-between;
  padding: 6px 8px;
}

.file-row span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-row div {
  align-items: center;
  display: inline-flex;
  flex: 0 0 auto;
  gap: 8px;
}

.file-list a,
.file-row a {
  color: #1d4ed8;
  font-weight: 700;
}

.file-row button {
  background: transparent;
  border: 0;
  color: #b91c1c;
  font-weight: 700;
  min-height: auto;
  padding: 0;
}

.file-row button:hover {
  background: transparent;
  color: #7f1d1d;
}

.file-list em {
  color: var(--muted);
}

.upload-modal {
  align-items: center;
  background: rgba(15, 23, 42, 0.35);
  display: grid;
  inset: 0;
  padding: 18px;
  position: fixed;
  z-index: 20;
}

.upload-card {
  background: #ffffff;
  border-radius: 10px;
  box-shadow: 0 24px 80px rgba(15, 23, 42, 0.22);
  display: grid;
  gap: 12px;
  margin: auto;
  max-width: 420px;
  padding: 18px;
  width: 100%;
}

.upload-card h2,
.upload-card p {
  margin: 0;
}

.upload-card label {
  display: grid;
  gap: 5px;
  font-weight: 750;
}

.modal-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

.doc-group {
  display: grid;
  gap: 8px;
  margin-bottom: 18px;
}

.doc-group:last-child {
  margin-bottom: 0;
}

.binder-page {
  width: 100%;
  min-height: 100vh;
  margin: 0;
  padding: 18px clamp(10px, 3vw, 34px) 40px;
}

.binder-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
  margin: 0 0 16px;
}

.simple-view-toggle {
  background: #111827;
  border-color: #111827;
  color: #ffffff;
  min-height: 34px;
  white-space: nowrap;
}

.simple-view-toggle:hover {
  background: #374151;
  border-color: #374151;
}

.binder-header h1 {
  margin: 0;
  font-size: 26px;
}

.binder-header p {
  margin: 5px 0 0;
  color: var(--muted);
}

.binder-group {
  background: var(--panel);
  border: 1px solid #cfd6e1;
  border-radius: 8px;
  box-shadow: var(--shadow);
  margin-bottom: 10px;
  overflow: hidden;
}

.binder-group summary {
  align-items: center;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  list-style: none;
  min-height: 52px;
  padding: 0 14px;
}

.binder-group summary::-webkit-details-marker {
  display: none;
}

.binder-group summary span {
  font-size: 16px;
  font-weight: 800;
}

.binder-group summary small {
  align-items: center;
  background: #eef2f7;
  border-radius: 999px;
  color: #475569;
  display: inline-flex;
  font-weight: 800;
  min-width: 28px;
  justify-content: center;
  min-height: 24px;
  padding: 0 8px;
}

.metadata-group.loading {
  position: relative;
}

.metadata-group.loading::after {
  align-items: center;
  background: linear-gradient(90deg, rgba(255, 255, 255, 0.72), rgba(255, 248, 239, 0.9), rgba(255, 255, 255, 0.72));
  color: #9a5d11;
  content: "Refreshing metadata...";
  display: flex;
  font-size: 12px;
  font-weight: 900;
  inset: 52px 0 0;
  justify-content: center;
  letter-spacing: 0.02em;
  pointer-events: none;
  position: absolute;
  text-transform: uppercase;
}

.binder-docs {
  border-top: 1px solid var(--line);
  display: grid;
}

.binder-file-tabs {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 10px 14px;
  background: #f8fafc;
  border-bottom: 1px solid var(--line);
}

.binder-file-tabs button {
  background: #eef2f7;
  border: 1px solid transparent;
  border-radius: 999px;
  color: var(--text);
  cursor: pointer;
  font-size: 13px;
  font-weight: 750;
  line-height: 1;
  min-height: 30px;
  padding: 0 12px;
}

.binder-file-tabs button:hover,
.binder-file-tabs button.active {
  background: #dbe3ee;
  border-color: #94a3b8;
}

.binder-preview {
  display: block;
  background: #202020;
  padding: 10px;
}

.binder-preview iframe {
  width: 100%;
  height: min(78vh, 920px);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.binder-simple-view {
  align-items: center;
  background: #ffffff;
  border: 1px solid #cfd6e1;
  border-radius: 8px;
  box-shadow: var(--shadow);
  color: var(--muted);
  display: flex;
  justify-content: center;
  min-height: 180px;
  padding: 32px;
}

.metadata-sections {
  border-top: 1px solid var(--line);
  display: grid;
  grid-template-columns: 1.15fr 1.2fr 0.85fr 1fr;
}

.metadata-section {
  border-right: 1px solid var(--line);
  padding: 14px;
}

.metadata-section:last-child {
  border-right: 0;
}

.metadata-section h3 {
  color: var(--accent-dark);
  font-size: 13px;
  letter-spacing: 0;
  margin: 0 0 10px;
  text-transform: uppercase;
}

.metadata-list {
  display: grid;
  gap: 8px;
}

.metadata-item {
  align-items: baseline;
  display: grid;
  gap: 12px;
  grid-template-columns: 96px minmax(0, 1fr);
}

.metadata-item span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.metadata-item strong {
  overflow-wrap: anywhere;
}

.metadata-item strong.metadata-missing {
  color: var(--muted);
  font-style: italic;
  font-weight: 700;
}

.status {
  min-height: 20px;
  color: var(--muted);
}

.status.error {
  color: var(--danger);
}

.status.success {
  color: var(--success);
}

.notice {
  border: 1px solid var(--line);
  border-radius: 10px;
  margin: 0 0 14px;
  padding: 10px 12px;
  width: max-content;
  max-width: 100%;
}

.notice.success {
  background: rgba(52, 211, 153, 0.12);
  border-color: rgba(52, 211, 153, 0.35);
  color: #047857;
}

.notice.error {
  background: rgba(251, 113, 133, 0.12);
  border-color: rgba(251, 113, 133, 0.35);
  color: #be123c;
}

.notice code {
  color: var(--text);
}

.empty {
  border: 1px dashed var(--line-strong);
  border-radius: 10px;
  color: var(--muted);
  padding: 22px;
  text-align: center;
}

@media (max-width: 860px) {
  .span-4,
  .span-8,
  .span-12 {
    grid-column: span 12;
  }

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

@media (max-width: 640px) {
  .loader-screen {
    background:
      radial-gradient(circle at 50% 42%, rgba(221, 162, 89, 0.24), transparent 15rem),
      linear-gradient(145deg, #f8fafc 0%, #eef2f7 44%, #f7efe4 100%);
    padding: 24px;
  }

  .loader-screen img {
    width: min(86vw, 420px);
  }

  .binder-page {
    padding: 14px 10px 28px;
  }

  .binder-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .binder-header h1 {
    font-size: 24px;
  }

  .binder-group {
    border-radius: 10px;
  }

  .binder-doc {
    align-items: flex-start;
    justify-content: center;
    gap: 3px;
    min-height: 56px;
    padding: 9px 12px;
  }

  .binder-preview {
    padding: 7px;
  }

  .binder-preview iframe {
    height: 76vh;
  }

  .metadata-sections {
    grid-template-columns: 1fr;
  }

  .metadata-section {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .metadata-section:last-child {
    border-bottom: 0;
  }

  .metadata-item {
    grid-template-columns: 90px minmax(0, 1fr);
  }
}
