:root {
  color-scheme: light;
  --navy: #112f40;
  --navy-2: #1b4658;
  --teal: #168c84;
  --teal-deep: #0f716b;
  --teal-soft: #e7f3f0;
  --gold: #c8a45b;
  --gold-soft: #f1e8d4;
  --ivory: #f7f4ed;
  --navy-soft: #e9f0f2;
  --ink: #20323a;
  --muted: #67777d;
  --line: #d9e0de;
  --surface: #ffffff;
  --surface-2: #f6f4ef;
  --danger: #a13a3a;
  --warning: #8a6218;
  --success: #14786f;
  --shadow: 0 10px 30px rgba(23, 53, 75, 0.08);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--ivory);
  color: var(--ink);
  min-width: 320px;
}

button, input, select, textarea { font: inherit; }
button { cursor: pointer; }

.app-header {
  min-height: 72px;
  padding: 12px max(18px, env(safe-area-inset-right)) 12px max(18px, env(safe-area-inset-left));
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  background: linear-gradient(118deg, #0e2a3a 0%, var(--navy) 52%, #1a4b5b 100%);
  color: #fff;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.15);
}

.brand { display: flex; align-items: center; gap: 12px; }
.brand-home { padding: 0; border: 0; background: transparent; color: inherit; text-align: left; }
.brand-home:focus-visible { outline: 3px solid rgba(255,255,255,.5); outline-offset: 4px; border-radius: 10px; }
.brand img { border-radius: 10px; box-shadow: 0 0 0 2px rgba(200,164,91,.42), 0 4px 12px rgba(0,0,0,.18); }
.brand strong, .brand span { display: block; }
.brand strong { font-size: 17px; }
.brand span { margin-top: 2px; font-size: 12px; opacity: 0.78; }
.header-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.sync-status { align-self: center; padding: 6px 9px; border: 1px solid rgba(255,255,255,.28); border-radius: 999px; color: #d9f3ef; font-size: 11px; }

.button {
  min-height: 40px;
  padding: 9px 14px;
  border: 1px solid transparent;
  border-radius: 9px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  text-decoration: none;
  font-weight: 650;
  transition: background 120ms ease, border 120ms ease, transform 120ms ease;
}
.button:active { transform: translateY(1px); }
.button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 3px solid rgba(21, 154, 145, 0.25);
  outline-offset: 2px;
}
.button-primary { background: var(--teal); color: #fff; box-shadow: 0 4px 12px rgba(15,113,107,.18); }
.button-primary:hover { background: var(--teal-deep); box-shadow: 0 5px 15px rgba(15,113,107,.27); }
.button-secondary { background: var(--surface); color: var(--navy); border-color: var(--line); }
.app-header .button-secondary { background: transparent; color: #fff; border-color: rgba(255,255,255,.32); }
.button-secondary:hover { border-color: var(--teal); }
.button-ghost { background: transparent; color: var(--navy); border-color: transparent; }
.button-danger { background: var(--danger); color: #fff; }
.button-small { min-height: 34px; padding: 6px 10px; font-size: 13px; }
.button[hidden] { display: none; }
.button-dashboard { width: 100%; background: #edf4f6; color: var(--navy); border-color: #c9dbe2; }
.button-dashboard.active { background: var(--navy); color: #fff; border-color: var(--navy); }

.storage-warning {
  padding: 10px 18px;
  background: #fff2cc;
  color: #674b0e;
  border-bottom: 1px solid #e8cf82;
  text-align: center;
}

.app-shell {
  display: grid;
  grid-template-columns: 310px minmax(0, 1fr);
  min-height: calc(100vh - 72px);
  background: linear-gradient(90deg, rgba(233,240,242,.5) 0, rgba(247,244,237,0) 310px);
}

/* Base44-inspired desktop workspace: a contained canvas with a floating
   navigation card and a calm, dashboard-like background. */
@media (min-width: 1060px) {
  body { background: #f1f4f6; }
  .app-shell {
    max-width: 1480px;
    margin: 0 auto;
    padding: 18px;
    gap: 16px;
    background: transparent;
  }
  .case-sidebar {
    min-height: calc(100vh - 108px);
    height: calc(100vh - 108px);
    position: sticky;
    top: 18px;
    border: 1px solid #d8e1e5;
    border-radius: 17px;
    box-shadow: 0 12px 30px rgba(27, 58, 75, .08);
  }
  .workspace { padding: 0; }
}

.case-sidebar {
  padding: 20px 16px;
  background: rgba(255,255,255,.94);
  border-right: 1px solid var(--line);
  box-shadow: inset -1px 0 0 rgba(200,164,91,.14);
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.sidebar-heading { display: flex; align-items: center; justify-content: space-between; }
.sidebar-heading h1 { margin: 0; font-size: 20px; color: var(--navy); }
.sidebar-heading h1::after { content: ""; display: block; width: 34px; height: 2px; margin-top: 7px; background: var(--gold); border-radius: 2px; }
.count-badge {
  min-width: 28px;
  height: 28px;
  padding: 0 8px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--teal-soft);
  color: var(--success);
  font-weight: 700;
}

.field { display: grid; gap: 6px; min-width: 0; }
.field > span, .field > label { color: var(--muted); font-size: 13px; font-weight: 650; }
.field small { color: var(--muted); }
.field input, .field select, .field textarea {
  width: 100%;
  min-height: 42px;
  padding: 9px 11px;
  border: 1px solid #cbd7dd;
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
}
.field textarea { min-height: 90px; resize: vertical; }
.compact-field input { min-height: 40px; }

.case-list { display: grid; gap: 8px; overflow: auto; }
.case-list-empty { color: var(--muted); font-size: 13px; padding: 10px 4px; }
.case-item {
  width: 100%;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  color: var(--ink);
  text-align: left;
}
.case-item:hover { border-color: #9fc9c5; background: #fbfefe; }
.case-item.active { border-color: var(--teal); background: var(--teal-soft); }
.case-item strong, .case-item span { display: block; }
.case-item strong { color: var(--navy); }
.case-item .case-meta { margin-top: 4px; color: var(--muted); font-size: 12px; }
.case-item .case-progress { margin-top: 8px; display: flex; align-items: center; gap: 8px; font-size: 12px; }
.mini-progress { flex: 1; height: 5px; background: #dfe7ea; border-radius: 999px; overflow: hidden; }
.mini-progress span { height: 100%; background: var(--teal); }

.sidebar-tools { margin-top: auto; display: grid; gap: 8px; }
.file-button { width: 100%; }
.privacy-note { margin: 0; color: var(--muted); font-size: 11px; line-height: 1.45; }

.workspace { padding: 24px; min-width: 0; }
.empty-state {
  min-height: 60vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  color: var(--muted);
}
.empty-state h2 { margin: 12px 0 6px; color: var(--navy); }
.empty-state p { max-width: 540px; margin: 0 0 20px; line-height: 1.6; }
.empty-icon {
  width: 64px;
  height: 64px;
  border-radius: 20px;
  display: grid;
  place-items: center;
  background: var(--teal-soft);
  color: var(--teal);
  font-size: 30px;
  font-weight: 800;
}

.case-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}
.case-header h1 { margin: 0; color: var(--navy); font-size: clamp(22px, 3vw, 30px); }
.case-header h1::after { content: ""; display: block; width: 46px; height: 3px; margin-top: 9px; background: var(--gold); border-radius: 3px; }
.case-header p { margin: 5px 0 0; color: var(--muted); }
.case-header-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 9px;
  border-radius: 999px;
  background: var(--teal-soft);
  color: var(--success);
  font-size: 12px;
  font-weight: 700;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}
.summary-card {
  padding: 15px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 13px;
  box-shadow: var(--shadow);
  border-top: 3px solid rgba(200,164,91,.64);
}
.summary-card span { display: block; color: var(--muted); font-size: 12px; }
.summary-card strong { display: block; margin-top: 5px; color: var(--navy); font-size: 21px; }
.summary-card small { display: block; margin-top: 3px; color: var(--muted); }

.progress-track { height: 9px; background: #dfe7ea; border-radius: 999px; overflow: hidden; }
.progress-track span { display: block; height: 100%; background: var(--teal); transition: width 180ms ease; }

.tab-bar {
  display: flex;
  gap: 6px;
  margin-bottom: 16px;
  overflow-x: auto;
  padding: 4px;
  border: 1px solid rgba(200,164,91,.24);
  border-radius: 12px;
  background: rgba(255,255,255,.62);
}
.tab-button {
  white-space: nowrap;
  padding: 9px 13px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: transparent;
  color: var(--navy);
  font-weight: 650;
  transition: background 140ms ease, color 140ms ease, box-shadow 140ms ease;
}
.tab-button:hover { background: var(--navy-soft); }
.tab-button.active { background: var(--navy); color: #fff; border-color: var(--navy); box-shadow: 0 3px 8px rgba(17,47,64,.2); }

.panel {
  padding: 20px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 15px;
  box-shadow: var(--shadow);
  position: relative;
  overflow: hidden;
}
.panel::before { content: ""; position: absolute; inset: 0 0 auto; height: 3px; background: linear-gradient(90deg, var(--gold), rgba(200,164,91,0)); opacity: .72; pointer-events: none; }
.panel + .panel { margin-top: 16px; }
.panel h2 { margin: 0 0 15px; color: var(--navy); font-family: Georgia, "Times New Roman", serif; font-size: 20px; font-weight: 600; letter-spacing: .01em; }
.panel h3 { margin: 22px 0 11px; color: var(--navy); font-size: 16px; }
.panel-note { margin: -6px 0 16px; color: var(--muted); font-size: 13px; line-height: 1.5; }

.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.form-grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.field.full { grid-column: 1 / -1; }

.switch-row {
  min-height: 46px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 9px;
}
.switch-row input { width: 20px; height: 20px; accent-color: var(--teal); }
.switch-row label { font-weight: 650; }
.switch-row small { display: block; margin-top: 2px; color: var(--muted); }

.section-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 10px; }
.section-toolbar-actions { display: flex; align-items: center; justify-content: flex-end; flex-wrap: wrap; gap: 6px; }
.step-navigation { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 14px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 11px; background: rgba(255,255,255,.76); }
.step-navigation > span { color: var(--muted); font-size: 12px; text-align: center; }
.step-navigation strong { color: var(--navy); }
.step-navigation button:disabled { opacity: .5; cursor: not-allowed; }
.section-toolbar h2, .section-toolbar h3 { margin: 0; }

.contact-list, .segment-list { display: grid; gap: 10px; }
.contact-row, .segment-row {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr)) auto;
  gap: 10px;
  align-items: end;
}
.segment-row { grid-template-columns: 1fr 1fr minmax(175px, .8fr) auto auto; }

.workflow-phase + .workflow-phase { margin-top: 20px; }
.phase-heading { display: flex; justify-content: space-between; gap: 12px; align-items: baseline; margin-bottom: 8px; }
.phase-heading h3 { margin: 0; }
.phase-heading span { color: var(--muted); font-size: 12px; }
.task-list { display: grid; gap: 7px; }
.task-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) minmax(160px, 210px);
  gap: 10px;
  align-items: center;
  padding: 10px 11px;
  border-bottom: 1px solid #e7ecef;
}
.task-row:last-child { border-bottom: 0; }
.task-row input[type="checkbox"] { width: 20px; height: 20px; accent-color: var(--teal); }
.task-row.done .task-label { text-decoration: line-through; color: var(--muted); }
.task-row.critical:not(.done) .task-label::after { content: " • απαραίτητο"; color: var(--warning); font-size: 11px; }
.task-note { min-height: 34px !important; padding: 6px 8px !important; font-size: 12px; }

.expense-card-list { display: grid; gap: 8px; margin-top: 10px; }
.expense-card {
  display: grid;
  grid-template-columns: auto minmax(180px, 1fr) minmax(120px, .45fr) minmax(150px, .55fr) auto;
  gap: 12px;
  align-items: center;
  padding: 11px;
  border: 1px solid #d9e3e7;
  border-radius: 10px;
  background: #fbfcfc;
}
.expense-card.paid { border-color: #9accc7; background: #f1faf8; }
.expense-check { display: flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 700; }
.expense-check input { width: 20px; height: 20px; accent-color: var(--teal); }
.expense-name strong, .expense-name span, .expense-budget span, .expense-budget strong { display: block; }
.expense-name strong { color: var(--navy); }
.expense-name span, .expense-budget span { color: var(--muted); font-size: 11px; margin-top: 3px; }
.expense-budget { text-align: right; }
.expense-budget strong { color: var(--navy); margin-top: 3px; }
.expense-actual input, .expense-budget-input input { min-height: 36px !important; }
.saving-badge {
  grid-column: 2 / -1;
  justify-self: start;
  padding: 4px 8px;
  border-radius: 999px;
  background: #e2f4e8;
  color: #21633a;
  font-size: 11px;
  font-weight: 700;
}
.custom-expense-fields { display: grid; grid-template-columns: 1fr minmax(150px, .7fr); gap: 8px; }
.table-saving { display: block; margin-top: 3px; color: var(--success); font-size: 11px; }

.fund-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}
.fund-card {
  min-height: 128px;
  padding: 15px;
  border: 1px solid var(--line);
  border-top: 4px solid var(--navy);
  border-radius: 11px;
  background: #fff;
}
.fund-card span, .fund-card strong, .fund-card small { display: block; }
.fund-card span { color: var(--muted); font-size: 12px; font-weight: 700; }
.fund-card strong { margin-top: 7px; color: var(--navy); font-size: 22px; }
.fund-card small { margin-top: 6px; color: var(--muted); line-height: 1.4; }
.fund-card.vat { border-top-color: #7c5ba7; }
.fund-card.saving { border-top-color: #3b8f56; }
.fund-card.vehicle { border-top-color: #bd7b2a; }
.fund-card.trip { border-top-color: #3679a8; }
.fund-card.wages { border-top-color: #9a587d; }
.fund-card.company { border-top-color: var(--teal); background: var(--teal-soft); }
.fund-card.fixed { border-top-color: #6e6644; background: #faf8ef; }

.dashboard-filter { display: grid; grid-template-columns: minmax(180px, 240px) 1fr; gap: 20px; align-items: end; }
.dashboard-kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.dashboard-kpis > div { padding: 10px 12px; border-left: 3px solid var(--teal); }
.dashboard-kpis span, .dashboard-kpis strong { display: block; }
.dashboard-kpis span { color: var(--muted); font-size: 11px; }
.dashboard-kpis strong { margin-top: 4px; color: var(--navy); font-size: 17px; }
.dashboard-balance { display: flex; flex-wrap: wrap; gap: 14px 24px; margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line); }
.dashboard-balance span { color: var(--muted); }
.dashboard-balance strong { color: var(--navy); }
.fixed-expense-list { display: grid; gap: 9px; }
.fixed-expense-row { display: grid; grid-template-columns: 130px minmax(180px, 1fr) minmax(150px, 220px) auto; gap: 10px; align-items: end; }
.partner-list { display: grid; gap: 10px; }
.partner-row { display: grid; grid-template-columns: minmax(170px, .8fr) minmax(180px, 1fr) minmax(190px, 1fr) minmax(160px, .8fr) minmax(135px, .55fr) minmax(190px, 1fr) auto; gap: 9px; align-items: end; padding: 13px 0; border-bottom: 1px solid var(--line); }
.partner-row:last-child { border-bottom: 0; }
.selected-partner-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin-top: 14px; }
.selected-partner { padding: 12px; border-left: 3px solid var(--gold); background: #f9f7f1; }
.selected-partner span, .selected-partner strong, .selected-partner small { display: block; }
.selected-partner span, .selected-partner small { color: var(--muted); font-size: 12px; }
.selected-partner strong { margin: 4px 0; color: var(--navy); }
.table-scroll { overflow-x: auto; }
.table-case-link { border: 0; padding: 0; background: transparent; color: var(--navy); font-weight: 750; text-align: left; }
.dashboard-table td:first-child small { display: block; margin-top: 3px; color: var(--muted); }

.route-layout { display: grid; grid-template-columns: minmax(330px, .85fr) minmax(420px, 1.25fr); gap: 18px; align-items: stretch; }
.base-route-card { display: flex; flex-wrap: wrap; align-items: baseline; gap: 10px 16px; margin: 14px 0; padding: 12px 14px; border-left: 4px solid var(--teal); background: var(--teal-soft); border-radius: 9px; }
.base-route-card strong { color: var(--navy); }
.base-route-card span { font-weight: 750; color: var(--teal); }
.base-route-card small { width: 100%; color: var(--muted); }
.manual-route-list { display: grid; gap: 12px; }
.manual-route-row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(180px, .34fr); gap: 12px; align-items: end; padding: 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); }
.manual-route-km small { display: block; margin-top: 4px; color: var(--muted); font-size: 11px; line-height: 1.35; }
.catalog-distance { display: grid; align-content: end; min-height: 70px; padding: 10px 12px; border: 1px dashed var(--line); border-radius: 8px; background: #fbfcfb; }
.catalog-distance span { color: var(--muted); font-size: 11px; }
.catalog-distance strong { margin-top: 4px; color: var(--navy); }
.catalog-row { margin: 2px 0 4px; padding: 8px 10px; border: 1px dashed var(--line); border-radius: 9px; background: #fbfcfb; }
.assignment-partner-save { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-top: 14px; padding: 12px 14px; border: 1px solid rgba(21, 154, 145, .24); border-radius: 12px; background: rgba(21, 154, 145, .07); }
.assignment-partner-save span { color: var(--muted); font-size: .88rem; }
.manual-distance-summary { margin-top: 16px; padding: 13px 14px; border-left: 4px solid var(--gold); border-radius: 9px; background: #fffaf0; }
.manual-distance-summary > strong { color: var(--navy); }
.manual-distance-summary small { display: block; margin-top: 10px; color: var(--muted); }
.route-controls { display: grid; gap: 12px; align-content: start; }
.route-stop-list { display: grid; gap: 9px; }
.route-stop-row { display: grid; grid-template-columns: 28px minmax(0, 1fr) auto; gap: 9px; align-items: start; }
.route-order { width: 28px; height: 28px; margin-top: 22px; border-radius: 50%; display: grid; place-items: center; background: var(--navy); color: #fff; font-size: 12px; font-weight: 750; }
.route-stop-main { display: grid; grid-template-columns: minmax(0, 1fr) minmax(155px, .5fr); gap: 8px; }
.compact-route-kind select { min-height: 42px; }
.place-field { position: relative; }
.place-field-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.place-suggestions {
  position: absolute;
  z-index: 1100;
  top: calc(100% - 2px);
  left: 0;
  right: 0;
  display: grid;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #fff;
  box-shadow: 0 12px 30px rgba(23, 53, 75, .18);
  overflow: hidden;
}
.place-suggestions:empty { display: none; }
.place-suggestion { padding: 9px 11px; border: 0; border-bottom: 1px solid #e7ecef; background: #fff; color: var(--ink); text-align: left; }
.place-suggestion:last-child { border-bottom: 0; }
.place-suggestion:hover { background: var(--teal-soft); }
.place-suggestion strong, .place-suggestion span { display: block; }
.place-suggestion span { margin-top: 2px; color: var(--muted); font-size: 11px; }
.place-suggestion.loading { color: var(--muted); cursor: default; }
.preset-row { display: flex; flex-wrap: wrap; gap: 7px; align-items: center; }
.preset-row > span { color: var(--muted); font-size: 12px; }
.route-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.route-online-note, .map-attribution-note { color: var(--muted); font-size: 11px; }
.route-map-wrap { min-height: 430px; position: relative; }
.route-map { height: 100%; min-height: 430px; border-radius: 11px; overflow: hidden; background: var(--navy-soft); border: 1px solid rgba(17,47,64,.18); box-shadow: inset 0 0 0 3px rgba(255,255,255,.28), 0 8px 22px rgba(17,47,64,.12); cursor: crosshair; }
.route-map-fallback { min-height: 430px; padding: 20px; display: grid; place-items: center; text-align: center; color: var(--muted); background: #edf2f4; border-radius: 11px; }
.map-click-hint { position: absolute; z-index: 500; top: 10px; right: 10px; max-width: 220px; padding: 7px 10px; border-radius: 8px; background: rgba(17, 47, 64, .9); color: #fff; font-size: 11px; font-weight: 700; pointer-events: none; }
.map-point-picker { display: grid; gap: 6px; min-width: 190px; }
.map-point-picker strong { color: var(--navy); }
.map-point-picker button { min-height: 32px; padding: 6px 8px; border: 1px solid var(--line); border-radius: 7px; background: #fff; color: var(--navy); text-align: left; cursor: pointer; }
.map-point-picker button:hover { border-color: var(--teal); background: var(--teal-soft); }
.route-results { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; margin-top: 14px; }
.route-results > div { padding: 11px 12px; border: 1px solid var(--line); border-radius: 9px; }
.route-results span, .route-results strong { display: block; }
.route-results span { color: var(--muted); font-size: 11px; }
.route-results strong { margin-top: 4px; color: var(--navy); }
.route-leg-list { margin-top: 10px; padding: 12px 14px; border-left: 4px solid var(--teal); background: #f4faf8; }
.route-leg-list > strong { display: block; margin-bottom: 6px; color: var(--navy); }
.route-leg-list > div { display: flex; justify-content: space-between; gap: 12px; padding: 5px 0; border-top: 1px solid #dfeae7; }
.route-leg-list span { color: var(--muted); }
.route-leg-list strong { color: var(--navy); white-space: nowrap; }
.live-cost-total { color: var(--teal); font-size: 25px; }
.special-trip-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin-top: 14px; }
.special-trip, .special-trip-muted { padding: 14px; border: 1px solid var(--line); border-left: 4px solid var(--gold); border-radius: 10px; background: var(--surface); }
.special-trip > div:first-child strong, .special-trip > div:first-child span, .special-trip-muted strong, .special-trip-muted span { display: block; }
.special-trip > div:first-child strong, .special-trip-muted strong { color: var(--navy); }
.special-trip > div:first-child span, .special-trip-muted span { margin: 4px 0 10px; color: var(--muted); font-size: 12px; }
.special-trip-actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: space-between; margin-top: 8px; }
.special-trip-actions strong { color: var(--navy); }
.crew-cost-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin-top: 14px; }
.crew-cost-row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(150px, .55fr); gap: 10px; align-items: end; padding: 12px; border: 1px solid var(--line); border-radius: 10px; background: #fbfcfb; }

.document-capture { display: grid; grid-template-columns: minmax(230px, 1fr) auto; gap: 12px; align-items: end; }
.document-list { display: grid; gap: 9px; margin-top: 16px; }
.document-row { display: grid; grid-template-columns: minmax(220px, 1fr) auto; gap: 12px; align-items: center; padding: 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); }
.document-row.overdue { border-color: #d59c36; background: #fffaf0; }
.document-row strong, .document-row span, .document-row small { display: block; }
.document-row strong { color: var(--navy); }
.document-row span, .document-row small { margin-top: 3px; color: var(--muted); font-size: 12px; }
.document-row .text-danger { color: var(--danger); font-weight: 700; }
.document-actions { display: flex; flex-wrap: wrap; gap: 6px; justify-content: flex-end; }
.reminder-badge { padding: 6px 10px; border-radius: 999px; background: #fff0d0; color: #765111; font-weight: 700; font-size: 12px; }

.blocker-box {
  margin-bottom: 16px;
  padding: 13px 15px;
  border-left: 4px solid var(--gold);
  background: #fff8e8;
  color: #654d17;
  border-radius: 7px;
}
.blocker-box.ready { border-color: var(--teal); background: var(--teal-soft); color: var(--success); }
.blocker-box strong { display: block; margin-bottom: 4px; }
.blocker-box ul { margin: 6px 0 0; padding-left: 20px; }

.price-banner {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1px;
  margin: 16px 0;
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
  background: var(--line);
}
.price-banner > div { padding: 13px; background: var(--surface); }
.price-banner span { display: block; color: var(--muted); font-size: 12px; }
.price-banner strong { display: block; margin-top: 5px; color: var(--navy); font-size: 19px; }
.price-banner .highlight { background: var(--teal-soft); }
.read-only-cost { min-height: 42px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface-2); }
.read-only-cost span, .read-only-cost strong, .read-only-cost small { display: block; }
.read-only-cost span, .read-only-cost small { color: var(--muted); font-size: 11px; }
.read-only-cost strong { margin-top: 3px; color: var(--navy); font-size: 13px; }
.compact-cost-table { min-width: 640px; }
.compact-cost-table td:nth-child(2), .compact-cost-table td:nth-child(3) { width: 145px; }
.cost-difference { color: var(--teal-deep); font-weight: 750; }
.difference-summary { margin-top: 14px; padding: 12px 14px; border-left: 4px solid var(--gold); border-radius: 8px; background: #fffaf0; color: var(--ink); }
.difference-summary ul { margin: 7px 0 0; padding-left: 20px; }
.difference-summary p { margin: 7px 0 0; color: var(--muted); }

.cost-table { width: 100%; border-collapse: collapse; }
.cost-table th, .cost-table td { padding: 10px 8px; border-bottom: 1px solid var(--line); text-align: left; }
.cost-table th { color: var(--muted); font-size: 12px; }
.cost-table td:last-child, .cost-table th:last-child { text-align: right; }
.cost-table input { width: 110px; min-height: 36px; padding: 6px 8px; border: 1px solid #cbd7dd; border-radius: 7px; text-align: right; }
.cost-table tfoot td { font-weight: 750; color: var(--navy); }
.actual-cost-table { min-width: 760px; }
.actual-cost-table td:first-child { min-width: 260px; }
.actual-cost-table td:nth-child(2), .actual-cost-table td:nth-child(3) { width: 150px; }
.actual-cost-table td:last-child { width: 150px; }
.actual-cost-table .table-money-input { width: 125px; }
.actual-hint { display: block; max-width: 135px; margin-top: 3px; color: var(--muted); font-size: 10px; line-height: 1.25; }
.table-check { display: inline-flex; align-items: center; justify-content: flex-end; gap: 5px; color: var(--muted); font-size: 12px; }
.table-check input { width: 20px; min-height: 20px; accent-color: var(--teal); }
.cost-inline-label { display: grid; gap: 3px; margin: 3px 0; }
.cost-inline-label span { color: var(--muted); font-size: 10px; }
.cost-inline-label input, .cost-inline-label select { width: 100%; min-height: 34px; padding: 5px 7px; border: 1px solid #cbd7dd; border-radius: 7px; background: #fff; color: var(--ink); text-align: left; }
.business-cost-explanation { margin: 14px 0 0; padding: 12px 14px; border-left: 4px solid var(--gold); background: #fbf8f0; color: var(--muted); font-size: 12px; line-height: 1.55; }
.business-cost-explanation strong { color: var(--navy); }
.calculation-columns { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.calculation-block { padding: 15px; border: 1px solid var(--line); border-top: 4px solid var(--gold); border-radius: 10px; }
.calculation-block.actual { border-top-color: var(--teal); }
.calculation-block h3 { margin: 0 0 10px; }
.calculation-block > div { display: flex; justify-content: space-between; gap: 14px; padding: 7px 0; border-bottom: 1px solid #e8eceb; }
.calculation-block > div:last-child { border-bottom: 0; }
.calculation-block span { color: var(--muted); }
.calculation-block strong { color: var(--navy); white-space: nowrap; }
.calculation-block .calculation-subtotal { border-top: 1px solid var(--navy); }
.calculation-block .calculation-total { margin-top: 4px; border-top: 2px solid var(--navy); border-bottom: 0; font-weight: 700; }
.calculation-block .calculation-free { margin-top: 4px; padding: 11px; border: 0; border-radius: 8px; background: var(--teal-soft); font-weight: 800; }
.cash-allocation { display: grid; gap: 5px; margin-top: 13px; padding: 13px 15px; border-left: 4px solid var(--teal); background: #f4faf8; color: var(--muted); }
.cash-allocation strong { color: var(--navy); }

.tax-warning {
  margin-top: 14px;
  padding: 11px 13px;
  border-radius: 8px;
  background: #fff8e8;
  color: #6b531e;
  font-size: 12px;
  line-height: 1.5;
}

.timeline-status {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}
.timeline-item { padding: 12px; border-left: 3px solid var(--line); }
.timeline-item.done { border-color: var(--teal); }
.timeline-item span, .timeline-item strong { display: block; }
.timeline-item span { color: var(--muted); font-size: 12px; }
.timeline-item strong { margin-top: 4px; color: var(--navy); }

.notes-area { min-height: 240px !important; }

.toast {
  position: fixed;
  z-index: 30;
  right: 18px;
  bottom: calc(18px + env(safe-area-inset-bottom));
  max-width: min(360px, calc(100vw - 36px));
  padding: 12px 15px;
  border-radius: 10px;
  background: var(--navy);
  color: #fff;
  box-shadow: 0 12px 30px rgba(0,0,0,.2);
}

.confirm-dialog { max-width: 440px; border: 0; border-radius: 14px; box-shadow: 0 20px 60px rgba(0,0,0,.25); }
.confirm-dialog::backdrop { background: rgba(11,31,45,.55); }
.confirm-dialog h2 { color: var(--navy); }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 20px; }

.hidden { display: none !important; }
.muted { color: var(--muted); }

/* Compact, mobile-first presentation.  The app stays spacious enough for
   route maps and cost tables, while the working column no longer stretches
   across very wide desktop screens. */
@media (min-width: 1200px) {
  .workspace > * {
    width: 100%;
    max-width: 1160px;
    margin-inline: auto;
  }
}

/* Keep long labels and imported partner details from widening the layout. */
.workspace,
.panel,
.tab-panel,
.case-header,
.section-toolbar,
.route-layout,
.expense-card,
.contact-row,
.partner-row {
  min-width: 0;
}
.panel,
.summary-card,
.fund-card,
.calculation-block,
.route-results > div {
  overflow-wrap: anywhere;
}

@media (max-width: 780px) {
  body { font-size: 14px; }
  .app-header {
    min-height: 62px;
    padding: 9px max(10px, env(safe-area-inset-right)) 9px max(10px, env(safe-area-inset-left));
    gap: 8px;
  }
  .brand { gap: 8px; min-width: 0; }
  .brand strong { font-size: 15px; white-space: nowrap; }
  .header-actions { gap: 5px; }
  .header-actions .button { min-height: 36px; padding: 7px 9px; font-size: 12px; }
  .app-shell { min-height: calc(100vh - 62px); }
  .case-sidebar { padding: 10px 10px; }
  .sidebar-heading h1 { font-size: 18px; }
  .case-list { grid-auto-columns: minmax(190px, 72vw); }
  .workspace { padding: 12px 9px calc(16px + env(safe-area-inset-bottom)); }
  .case-header { margin-bottom: 12px; }
  .case-header h1 { font-size: 22px; }
  .case-header p { font-size: 13px; line-height: 1.45; }
  .case-header-actions { gap: 6px; margin-top: 9px; }
  .button { min-height: 38px; padding: 8px 11px; font-size: 13px; }
  .button-small { min-height: 32px; padding: 6px 9px; font-size: 12px; }
  .tab-bar { gap: 4px; margin-bottom: 11px; padding: 3px; }
  .tab-button { padding: 8px 10px; font-size: 12px; }
  .panel { padding: 13px; border-radius: 12px; }
  .panel + .panel { margin-top: 11px; }
  .panel h2 { margin-bottom: 11px; font-size: 18px; }
  .panel h3 { margin: 17px 0 8px; font-size: 15px; }
  .panel-note { margin-bottom: 12px; font-size: 12px; line-height: 1.45; }
  .field { gap: 4px; }
  .field > span, .field > label { font-size: 12px; }
  .field input, .field select, .field textarea { min-height: 40px; padding: 8px 9px; }
  .field textarea { min-height: 78px; }
  .summary-grid { gap: 7px; margin-bottom: 12px; }
  .summary-card { padding: 11px; border-radius: 10px; }
  .summary-card span { font-size: 11px; }
  .summary-card strong { font-size: 17px; }
  .summary-card small { font-size: 11px; }
  .price-banner > div { padding: 10px; }
  .price-banner span { font-size: 11px; }
  .price-banner strong { font-size: 17px; }
  .task-row { gap: 8px; padding: 8px 4px; }
  .task-row input[type="checkbox"] { width: 18px; height: 18px; }
  .task-label { font-size: 13px; line-height: 1.35; }
  .task-note { min-height: 32px !important; font-size: 11px; }
  .route-map-wrap, .route-map, .route-map-fallback { min-height: 300px; }
  .route-map { border-radius: 9px; }
  .route-results { gap: 6px; margin-top: 10px; }
  .route-results > div { padding: 9px 10px; }
  .route-results span { font-size: 10px; }
  .route-results strong { font-size: 13px; }
  .route-leg-list { padding: 10px 11px; }
  .expense-card { gap: 8px; padding: 9px; }
  .expense-name strong, .expense-budget strong { font-size: 13px; }
  .expense-name span, .expense-budget span { font-size: 10px; }
  .expense-check { font-size: 11px; }
  .fund-card { min-height: 108px; padding: 11px; }
  .fund-card strong { font-size: 19px; }
  .fund-card small { font-size: 11px; }
  .calculation-block { padding: 12px; }
  .calculation-block > div { gap: 8px; padding: 6px 0; font-size: 12px; }
  .calculation-block strong { font-size: 13px; }
  .table-scroll { margin-inline: -2px; }
  .cost-table th, .cost-table td { padding: 8px 6px; font-size: 12px; }
  .actual-cost-table { min-width: 680px; }
}

@media (max-width: 420px) {
  .app-header { align-items: center; }
  .brand strong { font-size: 14px; }
  .header-actions .button { padding-inline: 7px; font-size: 11px; }
  .workspace { padding-inline: 7px; }
  .panel { padding: 11px; }
  .case-header h1 { font-size: 20px; }
  .tab-button { padding-inline: 8px; font-size: 11px; }
  .route-map-wrap, .route-map, .route-map-fallback { min-height: 270px; }
  .calculation-block > div { align-items: flex-start; }
  .calculation-block span { max-width: 68%; }
}

@media (max-width: 1050px) {
  .summary-grid, .price-banner { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .form-grid.three { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .contact-row { grid-template-columns: repeat(2, minmax(0, 1fr)) auto; }
  .contact-row .field:nth-child(4) { grid-column: 1 / 3; }
  .segment-row { grid-template-columns: 1fr 1fr; }
  .segment-row > :nth-last-child(-n+2) { justify-self: start; }
  .expense-card { grid-template-columns: auto minmax(180px, 1fr) minmax(120px, .45fr) minmax(150px, .55fr); }
  .expense-card > .button { grid-column: 2; justify-self: start; }
  .saving-badge { grid-column: 2 / -1; }
  .route-layout { grid-template-columns: 1fr; }
  .route-map-wrap, .route-map, .route-map-fallback { min-height: 360px; }
  .dashboard-filter { grid-template-columns: 1fr; }
  .dashboard-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .partner-row { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .partner-row > .button { justify-self: start; }
}

@media (max-width: 780px) {
  .app-header { align-items: flex-start; }
  .brand span { display: none; }
  .sync-status { display: none; }
  .header-actions .button { min-height: 38px; padding: 8px 10px; font-size: 13px; }
  .app-shell { display: block; }
  .case-sidebar { border-right: 0; border-bottom: 1px solid var(--line); padding: 13px 14px; }
  .case-list { grid-auto-flow: column; grid-auto-columns: minmax(230px, 78vw); overflow-x: auto; padding-bottom: 4px; }
  .sidebar-tools, .privacy-note { display: none; }
  .workspace { padding: 16px 12px calc(20px + env(safe-area-inset-bottom)); }
  .case-header { display: block; }
  .case-header-actions { margin-top: 12px; justify-content: flex-start; }
  .panel { padding: 15px; }
  .form-grid, .form-grid.three { grid-template-columns: 1fr; }
  .field.full { grid-column: auto; }
  .task-row { grid-template-columns: auto minmax(0, 1fr); }
  .task-note { grid-column: 2; }
  .contact-row, .segment-row { grid-template-columns: 1fr; }
  .contact-row .field:nth-child(4) { grid-column: auto; }
  .timeline-status { grid-template-columns: 1fr; }
  .fund-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .expense-card { grid-template-columns: auto minmax(0, 1fr); }
  .expense-budget, .expense-budget-input, .expense-actual, .expense-card > .button { grid-column: 2; text-align: left; }
  .saving-badge { grid-column: 2; }
  .custom-expense-fields { grid-template-columns: 1fr; }
  .fixed-expense-row { grid-template-columns: 1fr; }
  .partner-row, .selected-partner-grid { grid-template-columns: 1fr; }
  .route-stop-row { grid-template-columns: 28px minmax(0, 1fr); }
  .route-stop-row > .button { grid-column: 2; justify-self: start; }
  .route-stop-main { grid-template-columns: 1fr; }
  .manual-route-row { grid-template-columns: 1fr; gap: 8px; }
  .route-results { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .route-leg-list > div { display: grid; }
  .special-trip-grid { grid-template-columns: 1fr; }
  .crew-cost-grid, .calculation-columns { grid-template-columns: 1fr; }
  .crew-cost-row { grid-template-columns: 1fr; }
  .document-capture, .document-row { grid-template-columns: 1fr; }
  .document-actions { justify-content: flex-start; }
  .section-toolbar-actions { justify-content: flex-start; }
  .step-navigation { align-items: stretch; flex-direction: column; }
  .step-navigation > span { order: -1; }
  .step-navigation button { width: 100%; }
}

@media (max-width: 480px) {
  .brand strong { font-size: 14px; }
  .brand img { width: 36px; height: 36px; }
  .header-actions { gap: 5px; }
  .header-actions .button { padding: 7px 8px; }
  .summary-grid, .price-banner { grid-template-columns: 1fr; }
  .fund-grid { grid-template-columns: 1fr; }
  .dashboard-kpis, .route-results { grid-template-columns: 1fr; }
  .summary-card strong { font-size: 18px; }
  .section-toolbar { align-items: flex-start; }
  .actual-cost-table th:nth-child(2), .actual-cost-table td:nth-child(2) { display: none; }
}

/* Final mobile overrides (kept after the legacy breakpoints so the compact
   sizing remains effective on phones and small tablets). */
@media (max-width: 780px) {
  body { font-size: 14px; }
  .app-header { min-height: 62px; padding: 9px 10px; gap: 8px; }
  .app-shell { min-height: calc(100vh - 62px); }
  .case-sidebar { padding: 10px; }
  .case-list { grid-auto-columns: minmax(190px, 72vw); }
  .workspace { padding: 12px 9px calc(16px + env(safe-area-inset-bottom)); }
  .panel { padding: 13px; border-radius: 12px; }
  .panel + .panel { margin-top: 11px; }
  .panel h2 { margin-bottom: 11px; font-size: 18px; }
  .panel-note { margin-bottom: 12px; font-size: 12px; line-height: 1.45; }
  .field > span, .field > label { font-size: 12px; }
  .field input, .field select, .field textarea { min-height: 40px; padding: 8px 9px; }
  .button { min-height: 38px; padding: 8px 11px; font-size: 13px; }
  .tab-button { padding: 8px 10px; font-size: 12px; }
  .summary-card { padding: 11px; }
  .summary-card strong { font-size: 17px; }
  .route-map-wrap, .route-map, .route-map-fallback { min-height: 300px; }
  .route-results > div { padding: 9px 10px; }
  .expense-card { gap: 8px; padding: 9px; }
  .fund-card { min-height: 108px; padding: 11px; }
  .fund-card strong { font-size: 19px; }
  .calculation-block { padding: 12px; }
  .calculation-block > div { gap: 8px; padding: 6px 0; font-size: 12px; }
  .table-scroll { margin-inline: -2px; }
  .cost-table th, .cost-table td { padding: 8px 6px; font-size: 12px; }
  .actual-cost-table { min-width: 680px; }
}

@media (max-width: 420px) {
  .workspace { padding-inline: 7px; }
  .panel { padding: 11px; }
  .case-header h1 { font-size: 20px; }
  .header-actions .button { padding-inline: 7px; font-size: 11px; }
  .tab-button { padding-inline: 8px; font-size: 11px; }
  .route-map-wrap, .route-map, .route-map-fallback { min-height: 270px; }
}

.mobile-quick-nav { display: none; }

@media (max-width: 780px) {
  .mobile-quick-nav {
    position: fixed;
    z-index: 20;
    right: 10px;
    bottom: max(10px, env(safe-area-inset-bottom));
    left: 10px;
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 6px;
    padding: 7px;
    border: 1px solid rgba(217, 224, 222, .96);
    border-radius: 16px;
    background: rgba(255, 255, 255, .95);
    box-shadow: 0 12px 30px rgba(23, 53, 75, .18);
    backdrop-filter: blur(14px);
  }
  .mobile-quick-nav button {
    min-width: 0;
    min-height: 54px;
    padding: 6px 3px;
    border: 0;
    border-radius: 11px;
    background: transparent;
    color: var(--navy);
    display: grid;
    place-items: center;
    gap: 2px;
    font-weight: 750;
  }
  .mobile-quick-nav button:hover,
  .mobile-quick-nav button:focus-visible { background: var(--teal-soft); }
  .mobile-quick-nav span { color: var(--teal); font-size: 20px; line-height: 1; }
  .mobile-quick-nav small { overflow: hidden; max-width: 100%; text-overflow: ellipsis; white-space: nowrap; font-size: 10px; }
  body { padding-bottom: 82px; }
}

@media print {
  body { background: #fff; }
  .app-header, .case-sidebar, .tab-bar, .case-header-actions, .button, .toast { display: none !important; }
  .app-shell { display: block; }
  .workspace { padding: 0; }
  .panel, .summary-card { box-shadow: none; break-inside: avoid; }
  .tab-panel { display: block !important; }
  input, select, textarea { border: 0 !important; padding: 0 !important; min-height: auto !important; }
}
