:root {
  --surface: #eef2f1;
  --panel: #ffffff;
  --ink: #15231f;
  --muted: #5a6b65;
  --line: #cfd8d4;
  --accent: #0f6b5c;
  --accent-ink: #073f37;
  --accent-soft: #d8ebe6;
  --ok: #065f46;
  --err: #9f1239;
  --text: 0.875rem;
  --text-sm: 0.78rem;
  --space: 0.55rem;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: "Segoe UI", Georgia, serif;
  font-size: var(--text);
  line-height: 1.35;
  color: var(--ink);
  background:
    radial-gradient(circle at top left, rgba(15, 107, 92, 0.1), transparent 42%),
    linear-gradient(180deg, #f4f7f6 0%, #e8efec 100%);
  min-height: 100vh;
}
a { color: var(--accent-ink); text-decoration: none; }
a:hover { text-decoration: underline; }

.shell {
  display: flex;
  width: 100%;
  min-height: 100vh;
}
.sidebar {
  width: 248px;
  flex: 0 0 248px;
  display: flex;
  flex-direction: column;
  align-self: stretch;
  position: sticky;
  top: 0;
  max-height: 100vh;
  padding: 0.85rem 0.65rem;
  border-right: 1px solid var(--line);
  background: var(--panel);
}
.sidebar .nav {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
}
.sidebar-logout-wrap {
  margin-top: 0.85rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--line);
}
.sidebar-logout-name {
  font-size: 0.72rem;
  color: var(--muted);
  margin: 0 0 0.4rem;
  padding: 0 0.15rem;
  word-break: break-word;
}
.sidebar-logout {
  display: flex;
  width: 100%;
  justify-content: center;
  background: #fff;
  border: 1px solid var(--line);
  color: var(--ink);
}
.sidebar-logout:hover {
  background: var(--accent-soft);
  color: var(--accent-ink);
  text-decoration: none;
}
.brand-kicker {
  font-size: 0.65rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--accent);
  font-weight: 700;
}
.brand {
  font-size: 1.25rem;
  margin: 0.1rem 0;
  line-height: 1.2;
  font-weight: 700;
  color: var(--ink);
  text-decoration: none;
}
.brand span { color: var(--accent); font-weight: 700; }
.brand-sub { color: var(--muted); font-size: 0.75rem; margin-bottom: 0.75rem; }
.nav a {
  display: block;
  padding: 0.35rem 0.55rem;
  border-radius: 5px;
  color: var(--ink);
  margin-bottom: 0.12rem;
  text-decoration: none;
  font-size: 0.84rem;
}
.nav a:hover, .nav a.active { background: var(--accent-soft); text-decoration: none; }

.main { flex: 1; min-width: 0; }
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  padding: 0.55rem 1rem;
  border-bottom: 1px solid var(--line);
  background: rgba(255,255,255,0.85);
}
.topbar h1 { margin: 0; font-size: 1.15rem; flex: 1 1 auto; min-width: 8rem; line-height: 1.2; }
.expiry-chip {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem 0.7rem;
  align-items: center;
  padding: 0.28rem 0.55rem;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #fff;
  font-size: 0.8rem;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
}
.expiry-chip:hover { text-decoration: none; border-color: var(--accent); }
.table-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.45rem;
  padding: 0.55rem 0.7rem;
  border-bottom: 1px solid var(--line);
}
.row-expiry-late { background: #fff1f2; }
.row-expiry-soon { background: #fffbeb; }
.content { padding: 0.75rem 1rem 1.25rem; width: 100%; max-width: 1680px; }
h1 { font-size: 1.15rem; margin: 0 0 0.8rem; }

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.7rem 0.8rem;
  box-shadow: 0 1px 0 rgba(28,42,36,0.04);
}
.site-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.55rem 0.65rem;
  margin-bottom: 0.5rem;
  background: #f8fbfa;
  cursor: pointer;
}
.site-card .field { margin-bottom: 0; }
.site-card.is-pick {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-soft);
  background: #fff;
}
.site-card-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.5rem;
  margin-bottom: 0.4rem;
}
.sites-map {
  height: 22rem;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  margin: 0.45rem 0 0.75rem;
  z-index: 1;
}
.site-search-row {
  display: flex;
  gap: 0.4rem;
  align-items: stretch;
}
.site-search-row input { flex: 1; }
.site-search-hits {
  list-style: none;
  margin: 0.35rem 0 0;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  max-height: 9rem;
  overflow: auto;
}
.site-search-hits button {
  display: block;
  width: 100%;
  text-align: left;
  border: 0;
  background: none;
  padding: 0.4rem 0.55rem;
  font: inherit;
  cursor: pointer;
}
.site-search-hits button:hover {
  background: var(--accent-soft);
}
.grid { display: grid; gap: var(--space); }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.veh-form .field { margin-bottom: 0; }
.trip-form { gap: 0.45rem 0.65rem; align-items: end; }
.trip-form .field { margin-bottom: 0; }
.trip-form .trip-span-2 { grid-column: span 2; }
.trip-form .trip-crew-full { grid-column: 1 / -1; }
.trip-form .trip-sofer-row { margin-bottom: 0; }
.trip-form .trip-driver-plus { margin-bottom: 0; }
@media (max-width: 900px) {
  .shell { flex-direction: column; }
  .sidebar {
    width: auto;
    position: static;
    max-height: none;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }
  .sidebar .nav { overflow: visible; }
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  .veh-form .grid-3,
  .veh-form .grid-4,
  .trip-form.grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .trip-form .trip-span-2 { grid-column: span 2; }
}
@media (max-width: 520px) {
  .veh-form .grid-3,
  .veh-form .grid-4,
  .trip-form.grid-3 { grid-template-columns: 1fr; }
  .trip-form .trip-span-2 { grid-column: auto; }
}

.kpi { display: block; transition: border-color .15s; padding: 0.65rem 0.75rem; }
.kpi:hover { border-color: var(--accent); text-decoration: none; }
.kpi .label { font-size: 0.65rem; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); }
.kpi .value { font-size: 1.35rem; margin-top: 0.2rem; line-height: 1.15; font-weight: 700; }
.kpi .hint { font-size: 0.75rem; color: var(--muted); margin-top: 0.2rem; }

.trip-sofer-row {
  display: flex;
  align-items: flex-end;
  gap: 0.35rem;
}
.trip-sofer-row .field { flex: 1; min-width: 0; }
.trip-driver-plus {
  flex: 0 0 2rem;
  width: 2rem;
  min-width: 2rem;
  height: 2rem;
  padding: 0;
  margin-bottom: 0.35rem;
  font-size: 1.15rem;
  line-height: 1;
}
.field { display: flex; flex-direction: column; gap: 0.15rem; font-size: var(--text); margin-bottom: 0.35rem; }
[hidden] { display: none !important; }
.field span { color: var(--muted); font-size: var(--text-sm); line-height: 1.2; }
.field input, .field select, .field textarea,
input, select, textarea {
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 0.32rem 0.5rem;
  font: inherit;
  font-size: 0.875rem;
  background: #fff;
  min-height: 2rem;
  width: 100%;
}
.field input:focus, .field select:focus, .field textarea:focus,
input:focus, select:focus {
  outline: 2px solid var(--accent-soft);
  border-color: var(--accent);
}

.btn, button.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 5px;
  padding: 0.32rem 0.65rem;
  font: inherit;
  cursor: pointer;
  border: 1px solid var(--line);
  text-decoration: none;
  font-size: 0.84rem;
  line-height: 1.2;
  background: #fff;
  color: var(--ink);
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}
.btn:hover,
.btn:focus-visible {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
  text-decoration: none;
}
.btn.btn-primary,
button.btn-primary {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
.btn.btn-primary:hover,
.btn.btn-primary:focus-visible,
button.btn-primary:hover,
button.btn-primary:focus-visible {
  background: #148574;
  border-color: #148574;
  color: #fff;
}
.btn.btn-ghost,
button.btn-ghost { background: transparent; color: var(--muted); border-color: transparent; }
.btn.btn-ghost:hover,
.btn.btn-ghost:focus-visible,
button.btn-ghost:hover,
button.btn-ghost:focus-visible {
  background: transparent;
  color: var(--accent-ink);
  border-color: transparent;
  text-decoration: none;
}

.table { width: 100%; border-collapse: collapse; font-size: 0.84rem; }
.table th, .table td { padding: 0.32rem 0.45rem; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.table th { color: var(--muted); font-weight: 600; font-size: 0.74rem; }
.table .right { text-align: right; }
.expiry-late { color: #b42318; font-weight: 600; }
.expiry-soon { color: #b54708; font-weight: 600; }
.reminders { margin-bottom: 0.75rem; }
.reminders-title {
  font-size: 0.74rem;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 0.35rem;
}
.reminder {
  display: block;
  padding: 0.48rem 0.7rem;
  border-radius: 8px;
  font-size: 0.84rem;
  border: 1px solid;
  margin-bottom: 0.35rem;
  text-decoration: none;
}
.reminder:last-child { margin-bottom: 0; }
.reminder-expired { background: #fff1f2; color: #9f1239; border-color: #fecdd3; }
.reminder-soon { background: #fffbeb; color: #92400e; border-color: #fde68a; }
.reminder:hover { filter: brightness(0.98); }
.push-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem 0.85rem;
  padding: 0.5rem 0.7rem;
  border-radius: 8px;
  margin-bottom: 0.75rem;
  background: #eef6f4;
  border: 1px solid #cfe3de;
  font-size: 0.84rem;
}
.push-hint { margin: 0 0 0.75rem; font-size: 0.8rem; color: var(--muted); }
.push-hint-ok { color: #065f46; }
.push-hint-err { color: #9f1239; }
.table-wrap { padding: 0; overflow: auto; }

.flash { padding: 0.45rem 0.7rem; border-radius: 8px; margin-bottom: 0.65rem; font-size: 0.84rem; }
.flash-ok { background: #ecfdf5; color: #065f46; border: 1px solid #a7f3d0; }
.flash-err { background: #fff1f2; color: #9f1239; border: 1px solid #fecdd3; }
.muted { color: var(--muted); }
.mt { margin-top: 0.65rem; }
.right { text-align: right; }

.dash-period {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 0.55rem 0.85rem;
  margin-bottom: 0.75rem;
}
.dash-period .field { min-width: 9rem; margin-bottom: 0; }
.filter-actions { display: flex; gap: 0.4rem; align-items: center; flex-wrap: wrap; }
.hq-actions .btn,
.hq-actions .btn.btn-primary,
.hq-here-actions .btn {
  background: #fff;
  color: var(--ink);
  border-color: var(--line);
}
.hq-actions .btn:hover,
.hq-actions .btn:focus-visible,
.hq-actions .btn.btn-primary:hover,
.hq-actions .btn.btn-primary:focus-visible,
.hq-here-actions .btn:hover,
.hq-here-actions .btn:focus-visible {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
  text-decoration: none;
}
.hq-here-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}
.choice-btns .btn.is-on,
.hq-actions.choice-btns .btn.is-on {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}
.login-card { width: 100%; max-width: 22rem; }
.login-card .brand { margin-bottom: 0.35rem; }
.phone-hint { background: var(--accent-soft); color: var(--accent-ink); border: 1px solid var(--line); }

.scan-box { display: grid; gap: 0.45rem; }
#photo-input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  overflow: hidden;
}
.scan-preview {
  max-width: 100%;
  max-height: 220px;
  border-radius: 8px;
  border: 1px solid var(--line);
  object-fit: contain;
  background: #fff;
}
.receipt-thumb {
  display: block;
  width: 56px;
  height: 56px;
  object-fit: cover;
  border-radius: 4px;
  border: 1px solid var(--line);
  background: #fff;
  margin-bottom: 0.15rem;
}

.content-driver { max-width: 560px; margin: 0 auto; padding-bottom: 2.5rem; }
.driver-tabs { display: flex; gap: 0.4rem; margin: 0 0 0.8rem; }
.driver-tabs a {
  flex: 1;
  text-align: center;
  text-decoration: none;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0.55rem;
  font-size: 0.88rem;
}
.driver-tabs a.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
.driver-tabs a:hover { text-decoration: none; }

.gps-card { text-align: center; }
.gps-km { font-size: 2.4rem; font-weight: 700; letter-spacing: -0.03em; margin: 0.2rem 0 0.5rem; color: var(--accent-ink); }
.gps-actions { display: grid; gap: 0.5rem; margin-top: 0.7rem; }
.gps-btn { width: 100%; padding: 0.85rem 1rem; font-size: 1.05rem; }
.gps-stop { background: var(--accent-ink); color: #fff; }
.gps-pause { background: #c47a2c; color: #fff; }
.gps-card.gps-paused { border-color: #c47a2c; box-shadow: 0 0 0 2px rgba(196, 122, 44, 0.22); }
.gps-stop:disabled,
.gps-btn:disabled { opacity: 0.45; cursor: not-allowed; }
.gps-card.gps-live {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(15, 107, 92, 0.18);
}
body.gps-on {
  background:
    radial-gradient(circle at top left, rgba(15, 107, 92, 0.16), transparent 42%),
    linear-gradient(180deg, #e7f3ef 0%, #dceae5 100%);
}
.gps-keep-video {
  position: fixed;
  width: 1px;
  height: 1px;
  opacity: 0.01;
  pointer-events: none;
  bottom: 0;
  left: 0;
  z-index: 0;
}

body.is-driver .shell { display: block; }
body.is-driver .top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.55rem 1rem;
  border-bottom: 1px solid var(--line);
  background: rgba(255,255,255,0.92);
  position: sticky;
  top: 0;
  z-index: 5;
}
body.is-driver .top .brand { font-size: 1.1rem; margin: 0; }
body.is-driver .top .nav { display: flex; gap: 0.4rem; align-items: center; flex-wrap: wrap; }
body.is-driver .top .nav a {
  margin: 0;
  padding: 0.35rem 0.65rem;
}
.muted-nav { color: var(--muted); padding: 0.4rem 0.5rem; font-size: 0.82rem; }

.phone-url {
  font-family: ui-monospace, Consolas, monospace;
  font-size: 0.95rem;
  word-break: break-all;
  background: #fff;
  border: 1px dashed var(--line);
  border-radius: 8px;
  padding: 0.45rem 0.55rem;
  margin: 0.35rem 0;
  user-select: all;
}
.check-list { display: flex; flex-wrap: wrap; gap: 0.45rem 0.9rem; margin-top: 0.35rem; }
.check-list label { display: flex; align-items: center; gap: 0.35rem; font-size: 0.95rem; margin-bottom: 0; }
.check-list input { width: auto; min-height: 0; }

.pw-wrap {
  position: relative;
  display: flex;
  align-items: stretch;
}
.pw-wrap input {
  width: 100%;
  padding-right: 2.3rem;
}
.pw-toggle {
  position: absolute;
  right: 0.2rem;
  top: 50%;
  transform: translateY(-50%);
  border: 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  padding: 0.2rem 0.35rem;
  line-height: 0;
  border-radius: 4px;
}
.pw-toggle:hover, .pw-toggle.is-on { color: var(--accent-ink); background: var(--accent-soft); }
.invite-text {
  width: 100%;
  min-height: 9rem;
  font: 0.85rem/1.4 ui-monospace, Consolas, monospace;
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 0.5rem 0.55rem;
  background: #fff;
}
