:root {
  --ink: #14202b;
  --muted: #64717d;
  --paper: #f5f7f8;
  --surface: #ffffff;
  --navy: #173d5b;
  --navy-2: #225b7f;
  --line: #dce3e8;
  --line-strong: #c4cfd6;
  --amber: #e79a2d;
  --amber-soft: #fff2dc;
  --red: #bd4a45;
  --red-soft: #fbe8e6;
  --green: #2c765c;
  --green-soft: #e5f3ed;
  --blue-soft: #e7f0f6;
  --shadow: 0 16px 50px rgba(29, 47, 61, .1);
  font-family: Arial, Helvetica, sans-serif;
  color: var(--ink);
  background: var(--paper);
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; background: var(--paper); font-size: 16px; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
.app-shell { min-height: 100vh; display: grid; grid-template-columns: 260px minmax(0, 1fr); }
.sidebar { position: sticky; top: 0; height: 100vh; overflow-y: auto; padding: 26px 18px; background: #102b40; color: white; display: flex; flex-direction: column; }
.brand { display: flex; align-items: center; gap: 12px; padding: 0 8px 28px; }
.brand-mark { width: 42px; height: 42px; border-radius: 11px; background: var(--amber); color: #102b40; display: grid; place-items: center; font-weight: 800; letter-spacing: -.03em; }
.brand strong, .brand div > span { display: block; }
.brand strong { max-width: 150px; line-height: 1.15; }
.brand div > span { margin-top: 3px; color: #9fb2c0; font-size: .82rem; }
nav { display: grid; gap: 6px; }
.nav-item { border: 0; width: 100%; min-height: 46px; border-radius: 9px; padding: 0 12px; display: flex; align-items: center; justify-content: space-between; color: #c9d6df; background: transparent; text-align: left; }
.nav-item:hover { background: rgba(255,255,255,.06); color: white; }
.nav-item.active { background: #22506f; color: white; box-shadow: inset 3px 0 var(--amber); }
.nav-count { min-width: 24px; padding: 2px 7px; border-radius: 99px; text-align: center; font-size: .75rem; font-family: inherit; }
.nav-count { color: #172b38; background: var(--amber); font-weight: 700; }
.payment-nav-count { color: #7b2c28; background: #f5c7c3; }
.sidebar-note { margin-top: auto; padding: 14px 10px 2px; border-top: 1px solid rgba(255,255,255,.12); display: flex; gap: 10px; align-items: flex-start; }
.status-dot { flex: 0 0 auto; margin-top: 4px; width: 9px; height: 9px; border-radius: 50%; background: #64c49b; box-shadow: 0 0 0 4px rgba(100,196,155,.13); }
.sidebar-note strong, .sidebar-note small { display: block; }
.sidebar-note strong { font-size: .84rem; }
.sidebar-note small { color: #9fb2c0; margin-top: 4px; line-height: 1.35; }
.sidebar-note > div { min-width: 0; }
#serverStatusText > span { display: block; }
.sync-date { font-variant-numeric: tabular-nums; }
.sync-reviews-link { display: block; padding: 0; margin-top: 6px; border: 0; background: none; color: #b8cfde; font: inherit; font-size: .8rem; text-decoration: underline; text-underline-offset: 3px; cursor: pointer; white-space: nowrap; }
.sync-reviews-link[hidden] { display: none; }
.sync-review-item { padding: 0 0 24px; margin-bottom: 24px; border-bottom: 1px solid var(--line); overflow-wrap: anywhere; }
.sync-review-item h3 { margin-top: 0; }
.sync-review-item dt { color: var(--muted); font-size: .85rem; }
.sync-review-item dd { margin: 3px 0 12px; white-space: pre-wrap; }
main { min-width: 0; padding: 0 32px 48px; }
.topbar { min-height: 110px; display: flex; align-items: center; justify-content: space-between; gap: 24px; }
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 0; font-size: 1.75rem; letter-spacing: -.035em; }
h2 { margin-bottom: 0; font-size: 1.25rem; letter-spacing: -.02em; }
h3 { margin-bottom: 6px; font-size: 1rem; }
.eyebrow { margin-bottom: 5px; color: var(--muted); font-size: .75rem; font-weight: 700; letter-spacing: .09em; text-transform: uppercase; }
.top-actions { display: flex; gap: 10px; }
.month-picker { min-height: 42px; display: flex; align-items: center; gap: 9px; padding-left: 12px; border: 1px solid var(--line-strong); border-radius: 8px; background: var(--surface); color: var(--muted); font-size: .78rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; }
.month-picker select { min-height: 40px; border: 0; border-left: 1px solid var(--line); border-radius: 0 8px 8px 0; }
.month-picker option.empty-month-option { color: #7b858d; background: #edf0f2; }
.button { border: 1px solid transparent; min-height: 42px; padding: 0 16px; border-radius: 8px; font-weight: 700; font-size: .9rem; }
.button.primary { color: white; background: var(--navy); }
.button.primary:hover { background: var(--navy-2); }
.button.secondary { color: var(--ink); background: var(--surface); border-color: var(--line-strong); }
.button:disabled { opacity: .55; cursor: wait; }
.view { display: none; }
.view.active { display: block; }
.month-empty .view { display: none !important; }
.month-empty .sidebar nav { opacity: .35; pointer-events: none; }
.empty-month-state { min-height: calc(100vh - 150px); display: grid; place-items: center; }
.empty-month-card { width: min(680px, 100%); padding: 58px 42px; border: 1px dashed var(--line-strong); border-radius: 16px; background: var(--surface); box-shadow: var(--shadow); text-align: center; }
.empty-month-card h2 { margin-bottom: 10px; font-size: 1.65rem; }
.empty-month-card > p:not(.eyebrow) { margin: 0 auto 28px; max-width: 500px; color: var(--muted); line-height: 1.55; }
.upload-main-button { min-height: 58px; padding: 0 30px; font-size: 1.05rem; }
.metrics { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-bottom: 18px; }
.metric { width: 100%; min-height: 128px; padding: 20px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); color: var(--ink); position: relative; overflow: hidden; text-align: left; }
.clickable-metric:hover { border-color: var(--amber); transform: translateY(-1px); box-shadow: 0 10px 30px rgba(29,47,61,.08); }
.metric::after { content: ""; position: absolute; top: 0; bottom: 0; right: 0; width: 5px; background: var(--line); }
.metric.attention::after { background: var(--amber); }
.metric.money::after { background: var(--green); }
.metric strong { display: block; margin: 14px 0 5px; font-size: 1.7rem; letter-spacing: -.04em; }
.metric span { color: var(--muted); font-size: .86rem; }
.panel { border: 1px solid var(--line); border-radius: 12px; background: var(--surface); overflow: hidden; }
.dashboard-grid { display: grid; grid-template-columns: 1.35fr .65fr; gap: 18px; margin-bottom: 18px; }
.panel-heading { padding: 20px 22px 16px; display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; border-bottom: 1px solid var(--line); }
.text-button { border: 0; padding: 4px 0; background: none; color: var(--navy-2); font-size: .86rem; font-weight: 700; }
.issue-stack { padding: 4px 20px 14px; }
.issue-line { width: 100%; display: grid; grid-template-columns: 38px 1fr auto; gap: 12px; align-items: center; padding: 15px 2px; border: 0; border-bottom: 1px solid var(--line); background: transparent; color: var(--ink); text-align: left; }
.issue-line:hover { color: var(--navy-2); }
.issue-line:last-child { border-bottom: 0; }
.issue-icon { width: 34px; height: 34px; border-radius: 8px; background: var(--amber-soft); color: #9b6112; display: grid; place-items: center; font-weight: 800; }
.issue-line strong, .issue-line small { display: block; }
.issue-line small { margin-top: 3px; color: var(--muted); }
.issue-line b { font-size: 1.2rem; }
.composition { padding: 24px 22px; }
.composition-bar { display: flex; height: 14px; border-radius: 99px; overflow: hidden; background: var(--line); margin-bottom: 24px; }
.composition-bar span:nth-child(1) { background: var(--navy-2); }
.composition-bar span:nth-child(2) { background: var(--amber); }
.composition-bar span:nth-child(3) { background: #8e9ba5; }
.composition-legend { display: grid; gap: 14px; }
.legend-row { display: grid; grid-template-columns: 12px 1fr auto; gap: 9px; align-items: center; }
.legend-row i { width: 10px; height: 10px; border-radius: 3px; }
.legend-row:nth-child(1) i { background: var(--navy-2); }
.legend-row:nth-child(2) i { background: var(--amber); }
.legend-row:nth-child(3) i { background: #8e9ba5; }
.legend-row span { color: var(--muted); }
.recent-panel { margin-bottom: 18px; }
.table-wrap { overflow: auto; }
.table-wrap.tall { max-height: calc(100vh - 230px); }
table { width: 100%; border-collapse: collapse; white-space: nowrap; }
th { position: sticky; top: 0; z-index: 1; padding: 11px 14px; color: #61717e; background: #eef2f4; border-bottom: 1px solid var(--line-strong); text-align: left; font-size: .75rem; letter-spacing: .04em; text-transform: uppercase; }
td { padding: 12px 14px; border-bottom: 1px solid var(--line); font-size: .88rem; }
.cell-note { display: block; max-width: 330px; margin-top: 4px; overflow: hidden; color: var(--muted); font-weight: 400; text-overflow: ellipsis; }
tbody tr:hover { background: #f7fafb; }
tbody tr.clickable { cursor: pointer; }
.status { display: inline-flex; min-height: 25px; align-items: center; border-radius: 99px; padding: 2px 9px; font-size: .76rem; font-weight: 700; }
.status.calculated { color: var(--green); background: var(--green-soft); }
.status.review { color: #8d5a0e; background: var(--amber-soft); }
.status.not_payable, .status.missing_driver { color: #6e7780; background: #ebeff2; }
.money { font-variant-numeric: tabular-nums; font-weight: 700; }
.toolbar { min-height: 58px; display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-bottom: 14px; }
.segmented { display: inline-flex; padding: 4px; border: 1px solid var(--line-strong); border-radius: 10px; background: var(--surface); }
.segmented button { border: 0; min-height: 38px; padding: 0 14px; border-radius: 7px; color: var(--muted); background: transparent; font-size: .86rem; font-weight: 700; }
.segmented button.active { color: white; background: var(--navy); }
.segmented span { margin-left: 5px; opacity: .75; }
.search { min-height: 43px; min-width: 320px; padding: 0 12px; border: 1px solid var(--line-strong); border-radius: 9px; background: var(--surface); display: flex; align-items: center; gap: 8px; }
.search span { color: var(--muted); font-size: 1.2rem; }
.search input { width: 100%; border: 0; outline: none; background: transparent; }
.search.wide { flex: 1; max-width: 580px; }
select { min-height: 43px; padding: 0 36px 0 12px; border: 1px solid var(--line-strong); border-radius: 9px; color: var(--ink); background: var(--surface); }
.driver-toolbar { justify-content: flex-start; }
.payment-toolbar { justify-content: flex-start; }
.payment-summary { margin-left: auto; display: grid; grid-template-columns: auto auto auto auto; gap: 6px 10px; align-items: baseline; color: var(--muted); font-size: .82rem; }
.payment-summary strong { color: var(--ink); font-size: 1rem; }
.payment-panel table { table-layout: fixed; }
.payment-panel th:nth-child(1) { width: 42%; }
.payment-panel th:nth-child(2) { width: 18%; }
.payment-panel th:nth-child(3) { width: 20%; }
.payment-panel th:nth-child(4) { width: 20%; }
.payment-toggle { min-width: 128px; min-height: 36px; border: 1px solid; border-radius: 8px; font-weight: 700; transition: background .15s ease, color .15s ease, border-color .15s ease; }
.payment-toggle.unpaid { color: #963d38; border-color: #dfa09c; background: var(--red-soft); }
.payment-toggle.unpaid:hover { background: #f5d4d1; }
.payment-toggle.paid { color: #216249; border-color: #8fc7ae; background: var(--green-soft); }
.payment-toggle.paid:hover { background: #d4ecdf; }
.sort-button { width: 100%; padding: 0; border: 0; color: inherit; background: transparent; display: inline-flex; align-items: center; gap: 5px; font: inherit; font-weight: inherit; letter-spacing: inherit; text-align: left; text-transform: inherit; cursor: pointer; }
.sort-button::after { content: "↕"; opacity: .35; font-size: .78rem; }
.sort-button.active[data-direction="asc"]::after { content: "↑"; opacity: 1; }
.sort-button.active[data-direction="desc"]::after { content: "↓"; opacity: 1; }
.sort-button:hover { color: var(--navy); }
.driver-panel .table-wrap { overflow-x: hidden; }
.driver-panel table { table-layout: fixed; white-space: normal; }
.driver-panel th, .driver-panel td { padding: 10px 7px; overflow-wrap: anywhere; font-size: .78rem; }
.driver-panel th { font-size: .68rem; }
.driver-panel th[data-column="driver"] { width: 18%; }
.driver-panel td[data-column="driver"] { font-size: .83rem; }
.column-hidden { display: none; }
.column-options { display: grid; grid-template-columns: 1fr 1fr; gap: 2px 18px; }
.column-options .check-field { min-height: 38px; margin-top: 0; color: var(--ink); }
.review-layout { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 18px; align-items: start; }
.queue-panel { min-height: 520px; }
.review-queue { display: grid; }
.review-card { width: 100%; padding: 17px 20px; border: 0; border-bottom: 1px solid var(--line); background: var(--surface); color: var(--ink); display: grid; grid-template-columns: 100px minmax(180px, .8fr) minmax(220px, 1.2fr) 140px 34px; gap: 14px; align-items: center; text-align: left; }
.review-card:hover { background: #f7fafb; }
.review-card .date { color: var(--muted); font-size: .82rem; }
.review-card strong, .review-card small { display: block; overflow: hidden; text-overflow: ellipsis; }
.review-card small { margin-top: 4px; color: var(--muted); }
.review-card .review-source { color: #8d5a0e; white-space: normal; }
.review-card .source-note { max-height: 2.8em; color: #536b7a; white-space: normal; }
.review-card.data-issue-card { border-left: 4px solid var(--red); background: #fff8f7; }
.invalid-phone { color: var(--red) !important; font-weight: 800; }
.review-card .next { width: 30px; height: 30px; display: grid; place-items: center; border-radius: 7px; background: var(--amber-soft); color: #905b0f; }
.help-panel { position: sticky; top: 18px; padding: 22px; border-radius: 12px; color: white; background: #173d5b; box-shadow: var(--shadow); }
.help-panel .eyebrow { color: #9fb7c8; }
.help-panel > p:not(.eyebrow) { margin-top: 14px; color: #c3d2dc; line-height: 1.55; }
.help-rule { height: 1px; margin: 22px 0; background: rgba(255,255,255,.14); }
.help-panel dl { margin: 0; }
.help-panel dl div { padding: 10px 0; display: flex; justify-content: space-between; gap: 18px; border-bottom: 1px solid rgba(255,255,255,.1); }
.help-panel dt { font-weight: 700; }
.help-panel dd { margin: 0; color: #aebfca; text-align: right; }
.quality-intro { margin-bottom: 18px; padding: 22px 24px; border-left: 5px solid var(--navy); background: var(--blue-soft); display: grid; grid-template-columns: .5fr 1fr; gap: 40px; align-items: center; }
.quality-intro p:last-child { margin: 0; color: #3d5362; line-height: 1.6; }
.quality-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 18px; }
.quality-card { min-height: 145px; padding: 20px; border: 1px solid var(--line); border-radius: 11px; background: var(--surface); }
.quality-card .check-icon { width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; font-weight: 800; }
.quality-card.pass .check-icon { color: var(--green); background: var(--green-soft); }
.quality-card.warn .check-icon { color: #8d5a0e; background: var(--amber-soft); }
.quality-card.fail .check-icon { color: var(--red); background: var(--red-soft); }
.quality-card strong { display: block; margin: 20px 0 6px; }
.quality-card small { color: var(--muted); line-height: 1.4; }
.quality-explanation { padding: 24px; }
.explanation-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 28px; margin-top: 24px; }
.explanation-grid article { padding-top: 15px; border-top: 2px solid var(--line); }
.explanation-grid article > span { color: var(--amber); font-size: .8rem; font-weight: 800; }
.explanation-grid h3 { margin-top: 12px; }
.explanation-grid p { margin: 0; color: var(--muted); line-height: 1.55; }
.empty { padding: 50px 24px; color: var(--muted); text-align: center; }
dialog { border: 0; padding: 0; background: transparent; }
dialog::backdrop { background: rgba(12, 29, 41, .58); backdrop-filter: blur(2px); }
.detail-dialog { width: min(760px, calc(100vw - 30px)); max-height: calc(100vh - 30px); }
.wide-dialog { width: min(1080px, calc(100vw - 30px)); }
.compact-dialog { width: min(460px, calc(100vw - 30px)); }
.dialog-shell { max-height: calc(100vh - 30px); border-radius: 14px; background: var(--surface); box-shadow: 0 24px 80px rgba(0,0,0,.24); display: flex; flex-direction: column; overflow: hidden; }
.dialog-shell > header, .dialog-shell > footer { flex: 0 0 auto; padding: 18px 22px; display: flex; align-items: center; justify-content: space-between; gap: 20px; border-bottom: 1px solid var(--line); }
.dialog-shell > footer { border-top: 1px solid var(--line); border-bottom: 0; justify-content: flex-end; }
.icon-button { width: 38px; height: 38px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); color: var(--muted); font-size: 1.35rem; }
.dialog-body { overflow: auto; padding: 22px; }
.trip-facts, .driver-summary { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-bottom: 18px; }
.fact { min-height: 74px; padding: 12px; border-radius: 8px; background: #f1f4f6; }
.fact span, .route-block > span, .field > span { display: block; margin-bottom: 6px; color: var(--muted); font-size: .75rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; }
.fact strong { font-size: .9rem; }
.driver-rate-fact.overridden { background: #fff1cc; box-shadow: inset 0 0 0 1px #d8aa43; }
.inline-edit-button, .inline-reset-button { display: block; margin-top: 8px; padding: 0; border: 0; background: transparent; color: var(--navy-2); font: inherit; font-size: .78rem; font-weight: 700; text-align: left; cursor: pointer; }
.driver-rate-editor { margin-top: 8px; }
.driver-rate-editor input { width: 100%; min-height: 38px; padding: 7px 9px; border: 1px solid #c6b38e; border-radius: 7px; background: white; }
.driver-rate-editor small { display: block; margin-top: 6px; color: var(--muted); }
.rate-edit-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.rate-edit-grid > [hidden] { display: none; }
.rate-edit-wide { grid-column: 1 / -1; }
.edit-column { width: 52px; min-width: 52px; max-width: 52px; padding-left: 8px; padding-right: 8px; text-align: center; }
.route-edit-icon { width: 32px; height: 32px; display: inline-grid; place-items: center; padding: 0; border: 1px solid var(--line-strong); border-radius: 7px; color: var(--navy); background: var(--surface); font-size: 1rem; line-height: 1; }
.route-edit-icon:hover { border-color: var(--navy-2); background: var(--blue-soft); }
.route-block { margin-bottom: 18px; padding: 14px; border-left: 3px solid var(--line-strong); background: #fafbfc; }
.route-block p { margin: 0; max-height: 120px; overflow: auto; line-height: 1.55; font-size: .88rem; white-space: pre-wrap; }
.decision-card { padding: 20px; border: 1px solid #e9c88f; border-radius: 10px; background: var(--amber-soft); }
.decision-card > div:first-child > p:last-child { margin-bottom: 18px; color: #6d5732; }
.decision-fields { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; margin-bottom: 14px; }
.field { display: block; }
.field input, .field select, .field textarea { width: 100%; min-height: 43px; padding: 9px 11px; border: 1px solid #c6b38e; border-radius: 7px; outline: none; background: white; }
.field textarea { resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--navy-2); box-shadow: 0 0 0 3px rgba(34,91,127,.13); }
.field-row { display: flex; gap: 12px; align-items: end; }
.field-row .grow { flex: 1; }
.contact-card { margin-bottom: 18px; padding: 18px 20px; border: 1px solid var(--line); border-radius: 10px; background: #f7f9fa; }
.contact-card .field-row { margin: 14px 0 12px; }
.contact-card .name-fields { align-items: stretch; }
.contact-card .name-fields .field { flex: 1 1 0; min-width: 0; }
#contractDecision .field-row { margin-bottom: 18px; }
.check-field { margin-top: 14px; display: flex; align-items: center; gap: 9px; color: #59492f; font-size: .9rem; }
.driver-trips { max-height: 380px; margin-top: 18px; border: 1px solid var(--line); border-radius: 9px; }
.driver-trips .route-cell { min-width: 240px; max-width: 440px; white-space: normal; overflow-wrap: anywhere; }
.hidden { display: none !important; }
.toast { position: fixed; inset: auto 24px 24px auto; z-index: 100; max-width: 460px; margin: 0; padding: 13px 16px; border: 0; border-radius: 9px; color: white; background: #19384f; box-shadow: var(--shadow); opacity: 0; transform: translateY(10px); pointer-events: none; transition: .18s ease; }
.toast::backdrop { background: transparent; backdrop-filter: none; }
.toast.show { opacity: 1; transform: none; }
.toast.error { background: var(--red); }

@media (max-width: 1100px) {
  .metrics, .quality-grid { grid-template-columns: repeat(2, 1fr); }
  .dashboard-grid, .review-layout { grid-template-columns: 1fr; }
  .help-panel { position: static; }
  .review-card { grid-template-columns: 90px minmax(160px, .8fr) minmax(200px, 1.2fr) 30px; }
  .review-card .review-amount { display: none; }
}

@media (max-width: 760px) {
  .app-shell { grid-template-columns: 1fr; }
  .rate-edit-grid { grid-template-columns: 1fr; }
  .rate-edit-wide { grid-column: auto; }
  .sidebar { position: static; width: 100%; height: auto; padding: 12px; }
  .brand { padding: 4px 4px 12px; }
  nav { grid-template-columns: repeat(5, 1fr); }
  .nav-item { min-height: 42px; justify-content: center; font-size: .8rem; }
  .nav-count { display: none; }
  .sidebar-note { display: none; }
  main { padding: 0 14px 30px; }
  .topbar { min-height: 92px; align-items: flex-start; padding-top: 18px; }
  .top-actions { flex-direction: column-reverse; }
  .month-picker { padding-left: 8px; }
  .top-actions .button { min-height: 36px; padding: 0 10px; }
  .metrics, .quality-grid, .explanation-grid { grid-template-columns: 1fr; }
  .metric { min-height: 105px; }
  .toolbar { align-items: stretch; flex-direction: column; }
  .segmented { overflow-x: auto; }
  .search { min-width: 0; width: 100%; }
  .driver-toolbar select { width: 100%; }
  .payment-summary { width: 100%; margin-left: 0; }
  .review-card { grid-template-columns: 80px 1fr 30px; }
  .review-card .customer-block, .review-card .review-amount { display: none; }
  .quality-intro { grid-template-columns: 1fr; gap: 12px; }
  .trip-facts, .driver-summary, .decision-fields { grid-template-columns: repeat(2, 1fr); }
  .field-row { align-items: stretch; flex-direction: column; }
  .column-options { grid-template-columns: 1fr; }
}
.signed-out .app-shell { display: none; }
#loginScreen { display: none; position: fixed; inset: 0; background: #edf1f6; align-items: center; justify-content: center; z-index: 3000; }
.signed-out #loginScreen { display: flex; }
#loginForm { background: white; border-radius: 14px; padding: 32px; width: min(420px, 95vw); box-shadow: 0 12px 40px #15223b22; }
#loginForm label, #accountDialog label { display: grid; gap: 6px; margin: 14px 0; }
#loginForm input, #accountDialog input { padding: 10px; border: 1px solid #b8c2d2; border-radius: 6px; }
#loginError, #accountError { color: #b42318; }
#loginError:empty, #loginStatus:empty { display: none; }
#loginError:not(:empty) { padding: 12px; border: 1px solid #efb4ae; border-radius: 7px; background: #fff0ef; line-height: 1.45; }
#loginStatus { color: #526573; font-size: .9rem; }
#loginForm button:disabled { opacity: .65; cursor: wait; }
#accountDialog { padding: 24px; width: min(440px, 95vw); }
.account-menu { position: relative; margin: -8px 0 18px; z-index: 1200; }
.account-menu > button { background: none; color: inherit; border: 0; padding: 8px; font: inherit; cursor: pointer; }
.account-dropdown { display: none; position: absolute; top: 100%; left: 0; min-width: 210px; padding: 8px; border-radius: 8px; background: white; box-shadow: 0 8px 24px #14243c33; color: #17243b; }
.account-menu:hover .account-dropdown, .account-menu:focus-within .account-dropdown { display: grid; }
.account-dropdown button { background: white; text-align: left; border: 0; padding: 12px; cursor: pointer; }
.account-dropdown button:hover { background: #eef2f7; }
.driver-pdf { display: inline-block; margin-left: 8px; padding: 3px 6px; border: 1px solid #cbd8e2; border-radius: 4px; color: #19445b; background: #f5f9fc; text-decoration: none; white-space: nowrap; font-size: 12px; }
.driver-pdf:hover { background: #e3eff7; }
.data-error-row td { background: #faeeee; }
.data-error-row:hover td { background: #f5e2e1; }
.data-problem-note { background: #faeeee; color: #7b3935; padding: 12px; border-radius: 7px; margin: 12px 0; }
.data-problem-note.no-data-issues { background: #f1f4f6; color: #526573; }
.data-fix-link { display: block; border: 0; background: none; color: inherit; text-align: left; padding: 8px 0; cursor: pointer; }
.request-edit-fields { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 14px; }
.request-edit-fields textarea, .request-edit-fields input, .request-edit-fields select { width: 100%; min-height: 40px; padding: 8px; border: 1px solid #cad5dd; border-radius: 6px; background: white; font: inherit; }
.request-edit-fields textarea { resize: vertical; }
.request-edit-fields .request-field-problem textarea, .request-edit-fields .request-field-problem input, .request-edit-fields .request-field-problem select { border-color: #d58a84; background: #fff0ef; box-shadow: 0 0 0 2px #c94c4430; }
.request-edit-fields .request-field-problem > span { color: #963d38; }
.grid-pagination { display: flex; gap: 15px; align-items: center; margin-top: 14px; }
#requestsGrid td, #vehiclesGrid td, #routesGrid td, #contractsGrid td { white-space: normal; overflow-wrap: anywhere; }
th { white-space: normal; overflow-wrap: anywhere; }
#requestsGrid td { vertical-align: top; }
#requestsGrid .registry-cell { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 3; overflow: hidden; line-height: 1.4; max-height: 4.2em; }
.driver-toolbar { display: flex; align-items: center; flex-wrap: wrap; gap: 16px; margin: 22px 0; }
.driver-toolbar .button { display: inline-flex; align-items: center; justify-content: center; text-decoration: none; min-height: 43px; }
.dialog-shell > footer { display: flex; align-items: center; justify-content: flex-end; gap: 16px; padding: 16px 22px; border-top: 1px solid var(--line); }
.column-resizer { position: absolute; top: 0; right: 0; bottom: 0; width: 9px; cursor: col-resize; touch-action: none; z-index: 4; border-right: 2px solid transparent; }
.column-resizer:hover { border-color: #849eb0; background: #93b1c533; }
.resizing-columns { cursor: col-resize; user-select: none; }
.nav-payments { margin-top: 24px; }
.muted { color: #647786; line-height: 1.5; }
#requestEditError { color: #a32222; }
.editor-sections > * { margin: 0; }
.editor-sections > * + * { margin-top: 18px; }
#vehicleEditIssue:empty { display: none; }
#vehicleEditIssue { color: #a32222; line-height: 1.45; }
.vehicle-affected { border-top: 1px solid var(--line); padding-top: 18px; }
.vehicle-affected p { margin: 0 0 10px; }
#vehicleRequestLinks .data-fix-link { width: 100%; padding: 12px 0; border-bottom: 1px solid var(--line); line-height: 1.4; }
#vehicleRequestLinks .data-fix-link:hover { color: var(--navy-2); text-decoration: underline; }
#vehicleRequestLinks small { display: block; margin-top: 4px; color: var(--muted); }
#requestEditNotice p { margin: 0; line-height: 1.5; }
#requestEditNotice .button { margin-top: 12px; }
@media (max-width: 700px) { .request-edit-fields { grid-template-columns: 1fr; } }

/* Viewport-fitted tables: no horizontal scrolling or word fragmentation. */
.topbar { min-height: 82px; gap: 16px; }
.driver-toolbar { margin: 6px 0 8px; gap: 12px; }
.table-wrap { overflow-x: hidden; }
.table-tools { display: flex; justify-content: flex-end; margin: 4px 0 6px; }
.table-tools .button { min-height: 32px; padding: 5px 12px; }
.toolbar-columns { margin-left: auto; }
.request-days { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0 8px; }
.request-day { min-width: 48px; background: #eef2f4; color: #172b3a; border: 1px solid #172b3a25; border-radius: 7px; padding: 6px 9px; font: inherit; cursor: pointer; display: inline-flex; align-items: baseline; justify-content: center; gap: 5px; }
.request-day strong { font-size: .9rem; }
.request-day small { color: inherit; font-size: .65rem; opacity: .72; }
.request-day.weekend { background: #eadfdf; color: #703f3c; }
.request-day.holiday { background: #c96b65; color: white; }
.request-day.active { outline: 2px solid #102b40; outline-offset: 2px; box-shadow: inset 0 -3px #fff8; font-weight: 700; }
.request-day:focus-visible { outline: 3px solid #e7a72b; outline-offset: 2px; }
.request-day-note { margin: 0 0 9px; color: var(--muted); font-size: .8rem; }
.fit-hidden { display: none !important; }
.fitted-table th { width: auto !important; white-space: normal; word-break: normal; overflow-wrap: normal; hyphens: none; padding: 9px 10px; letter-spacing: 0; }
.fitted-table .sort-button { white-space: normal; overflow-wrap: normal; word-break: normal; }
.fitted-table td { height: 56px; padding: 7px 10px; vertical-align: middle !important; overflow: hidden; }
.fitted-table .compact-cell { max-height: 40px; line-height: 20px; overflow: hidden; overflow-wrap: normal; word-break: normal; }
.fitted-table .registry-cell, #requestsGrid .registry-cell { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; max-height: 40px; line-height: 20px; overflow: hidden; overflow-wrap: normal; word-break: normal; }
.fitted-table td .cell-note { display: none; }
.fitted-table .payment-toggle { min-width: 0; max-width: 100%; white-space: normal; }
.fitted-table .route-cell { min-width: 0; max-width: none; }
#tableDetailBody { margin: 0; }
#tableDetailBody > div { padding: 10px 0; border-bottom: 1px solid var(--line); }
#tableDetailBody dt { color: var(--muted); font-size: .8rem; margin-bottom: 5px; }
#tableDetailBody dd { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.dialog-shell h2 { overflow-wrap: anywhere; }
.tariff-toolbar { min-height: 48px; display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-bottom: 8px; }
.tariff-toolbar-actions { display: flex; align-items: center; gap: 8px; }
.compact-help-button { width: 36px; min-height: 36px; padding: 0; border-radius: 50%; font-size: 1rem; }
.tariff-columns-button { min-height: 36px; padding: 0 12px; }
.tariff-context { margin: 0 0 12px; font-size: .85rem; }
.tariff-pane[hidden] { display: none; }
.tariff-pane .table-wrap.tall { max-height: calc(100vh - 245px); }
#routesGrid .edit-column .compact-cell { display: flex; justify-content: center; }
.table-tools + .table-wrap.tall { max-height: calc(100vh - 220px); }
@media(max-width:700px) { .topbar { padding: 10px 0; } .tariff-toolbar { align-items: stretch; } .tariff-tabs { min-width: 0; } .tariff-tabs button { flex: 1; padding: 0 10px; } }

/* Loading and production status */
.brand { justify-content: center; }
.brand-mark { flex: 0 0 42px; display: grid; place-items: center; }
.route-bundles { margin-top: 22px; }
.route-bundles p { font-size: .88rem; line-height: 1.6; }
.view-loading { display: flex; align-items: center; gap: 9px; padding: 12px 0; color: var(--muted); font-size: .88rem; }
.mini-spinner { display: inline-block; width: 15px; height: 15px; border: 2px solid #b9c9d5; border-top-color: #22506f; border-radius: 50%; animation: loading-spin .8s linear infinite; }
@keyframes loading-spin { to { transform: rotate(360deg); } }
.view[aria-busy="true"] .table-wrap { opacity: .45; pointer-events: none; }
.server-error .status-dot { background: #ec8989; box-shadow: 0 0 0 4px #ec898922; }
.server-error strong { color: #ffb5b5; }
.server-syncing .status-dot { background: transparent; border: 2px solid #8296a5; border-top-color: #fff; width: 12px; height: 12px; animation: loading-spin .8s linear infinite; box-shadow: none; }
.sync-running main .view, .sync-running .month-picker { opacity: .65; pointer-events: none; }
.request-days { display: block; overflow-x: auto; padding: 3px; }
.request-day-row { display: flex; flex-wrap: nowrap; gap: 6px; margin-bottom: 8px; width: max-content; }
.request-day { flex: 0 0 auto; }
.request-day.day-has-errors { border-color: #c66a6a; }
.request-day.day-no-errors { border-color: #65a984; }
.request-day.active { outline-width: 1px; outline-offset: 1px; }
@media (prefers-reduced-motion: reduce) { .mini-spinner, .server-syncing .status-dot { animation: none; } }
