/* VELMA GO — Design system (responsive, accessible, mobile ready) */
:root {
  --bg: #f4f6fa;
  --surface: #fff;
  --border: #e3e8ef;
  --text: #17233b;
  --muted: #66738c;
  --primary: #0f766e;
  --primary-600: #10b981;
  --primary-soft: #d1fae5;
  --ok: #16a34a;
  --warn: #d97706;
  --err: #dc2626;
  --info: #0891b2;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(23,35,59,.08), 0 4px 14px rgba(23,35,59,.06);
  --sidebar-w: 248px;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body { font-family: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif; background: var(--bg); color: var(--text); font-size: 14.5px; line-height: 1.45; }
a { color: var(--primary-600); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.25rem; margin: 0; }
h2 { font-size: 1.35rem; margin: 0 0 .25rem; }
h3 { font-size: 1.05rem; margin: 0; }
.muted { color: var(--muted); }
.small { font-size: .82rem; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .86em; }

/* App shell and desktop navigation */
.app { display: flex; min-height: 100vh; }
.sidebar { width: var(--sidebar-w); flex: 0 0 var(--sidebar-w); background: #101a2e; color: #dfe6f3; display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; height: 100dvh; overflow: hidden; }
.brand { display: flex; flex: 0 0 auto; align-items: center; gap: 10px; padding: 16px; border-bottom: 1px solid rgba(255,255,255,.1); }
.brand-mark { display: inline-flex; flex: 0 0 38px; align-items: center; justify-content: center; width: 38px; height: 38px; border-radius: 10px; background: linear-gradient(145deg,#10b981,#087d66); color: #fff; font-size: 1.1rem; font-weight: 850; }
.brand-lockup { min-width: 0; line-height: 1.1; }
.brand-lockup strong { display: block; white-space: nowrap; font-size: 1.05rem; letter-spacing: .035em; }
.brand-velma { color: #fff; }
.brand-go { color: #6ee7b7; }
.brand-lockup small { display: block; margin-top: 5px; color: #aab8cc; font-size: .58rem; line-height: 1.2; letter-spacing: .055em; white-space: nowrap; }
.brand-login { justify-content: center; padding: 10px 0; border: 0; }
.login-card .brand-mark { background: #10b981; }
.login-card .brand-lockup strong { font-size: 1.35rem; }
.login-card .brand-velma { color: #17233b; }
.login-card .brand-go { color: #0f9b75; }
.login-card .brand-lockup small { color: #52617a; text-align: center; }
.nav { display: block; flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 9px 8px; scrollbar-width: thin; scrollbar-color: #53627a transparent; }
.nav-group { display: block; }
.nav-group-title { display: block; margin: 12px 8px 4px; padding: 4px 9px; color: #aebbd0; font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .085em; line-height: 1.4; }
.nav-link { display: flex; align-items: center; gap: 10px; min-height: 39px; padding: 8px 10px; border-radius: 8px; color: #d6dfec; font-size: .92rem; }
.nav-link:hover { background: rgba(255,255,255,.09); color: #fff; text-decoration: none; }
.nav-link:active { background: rgba(16,185,129,.24); }
.nav-link.active { background: #10b981; color: #062b25; font-weight: 700; }
.line-icon { display: inline-block; flex: 0 0 20px; width: 20px; height: 20px; }
.nav-link .line-icon { flex-basis: 19px; width: 19px; height: 19px; }
.sidebar-footer { display: grid; flex: 0 0 auto; gap: 9px; padding: 12px; border-top: 1px solid rgba(255,255,255,.1); background: #101a2e; }
.sidebar-footer form { min-width: 0; margin: 0; }
.user-chip { display: flex; align-items: center; gap: 9px; min-width: 0; font-size: .88rem; }
.user-chip > span:last-child { min-width: 0; overflow-wrap: anywhere; }
.user-chip small { display: block; color: #aab8cc; }
.avatar { display: inline-flex; flex: 0 0 32px; align-items: center; justify-content: center; width: 32px; height: 32px; border-radius: 50%; background: var(--primary-600); color: #fff; font-size: .72rem; font-weight: 700; }
.sidebar-footer .logout-button { min-height: 42px; border: 1px solid #64748b; background: #26344c; color: #fff; font-weight: 650; }
.sidebar-footer .logout-button:hover { border-color: #94a3b8; background: #334967; color: #fff; }
.sidebar-footer .logout-button:focus-visible { outline: 3px solid #6ee7b7; outline-offset: 2px; }
.sidebar-footer .logout-button:disabled, .sidebar-footer .logout-button[aria-disabled="true"] { border-color: #536176; background: #202b3d; color: #d1d5db; opacity: 1; }
.sidebar-scrim { display: none; }

/* Header */
.main { display: flex; flex: 1; flex-direction: column; min-width: 0; isolation: isolate; }
.topbar { position: sticky; z-index: 30; top: 0; display: flex; align-items: center; gap: 12px; padding: 10px 18px; border-bottom: 1px solid var(--border); background: var(--surface); }
.topbar h1 { flex: 1; }
.mobile-brand { display: none; }
.topbar-title { font-size: 1.12rem; font-weight: 650; }
.topbar-title[aria-hidden="true"] { visibility: hidden; }
.topbar-actions { position: relative; display: flex; align-items: center; gap: 7px; }
.topbar-icon-link { min-width: 42px; min-height: 42px; justify-content: center; border-color: #cbd5e1; background: #fff; color: #17233b; }
.topbar-icon-link:hover { border-color: #94a3b8; background: #e8eef6; color: #0b1220; }
.topbar-icon-link:focus-visible { outline-color: #1d4ed8; }
.notif-btn { position: relative; }
.notif-btn .line-icon { width: 20px; height: 20px; }
.notif-count { position: absolute; top: -3px; right: -3px; display: grid; min-width: 19px; height: 19px; place-items: center; padding: 0 4px; border: 2px solid #fff; border-radius: 999px; background: #dc2626; color: #fff; font-size: .66rem; font-weight: 800; line-height: 1; }
html[dir="rtl"] .notif-count { right: auto; left: -3px; }
.hamburger { display: none; }
.language-picker { display: flex; align-items: center; gap: 4px; }
.language-picker select { width: auto; min-width: 58px; padding: 5px 8px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }

/* Content, headings and cards */
.content { width: 100%; max-width: 1280px; min-width: 0; padding: 18px; }
.content:has(.dashboard-group) { max-width: 1600px; }
.content.wide { max-width: none; }
.page-title { display: none; }
.page-head { display: flex; min-height: 38px; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.page-head:has(.page-title) { display: block; min-height: 0; margin-bottom: 8px; }
.page-head:has(.page-title) .page-title { display: block; margin: 0 0 .25rem; font-size: 1.35rem; }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.dashboard-group-title { margin: 18px 0 8px; font-size: 1rem; }
.dashboard-group + .dashboard-group { margin-top: 22px; }
.card { overflow: hidden; margin-bottom: 16px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 12px 16px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.card-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.card-body { padding: 14px 16px; }
.stats-grid { display: grid; grid-template-columns: repeat(auto-fill,minmax(170px,1fr)); gap: 12px; margin-bottom: 16px; }
.stat-link { color: inherit; text-decoration: none; }
.stat-card { height: 100%; padding: 12px 14px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); }
.stat-value { font-size: 1.45rem; font-weight: 700; }
.stat-label { margin-top: 2px; color: var(--muted); font-size: .82rem; }
.stat-sub { margin-top: 2px; font-size: .78rem; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3,1fr); gap: 16px; }

/* Tables and badges */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .88rem; }
th { padding: 8px 10px; border-bottom: 2px solid var(--border); color: var(--muted); font-size: .78rem; font-weight: 600; letter-spacing: .03em; text-align: left; text-transform: uppercase; white-space: nowrap; }
td { padding: 9px 10px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tbody tr:hover { background: #f8fafd; }
tr.rowlink { cursor: pointer; }
.badge { display: inline-block; padding: 2px 9px; border-radius: 999px; background: var(--badge,#6b7280); color: #fff; font-size: .74rem; font-weight: 600; white-space: nowrap; }
.badge.demo { border: 1px solid #f59e0b; background: #fef3c7; color: #92400e; }

/* Buttons and focus */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 7px 14px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); color: var(--text); cursor: pointer; font-size: .88rem; font-weight: 500; text-decoration: none; }
.btn:hover { background: #f1f4f9; text-decoration: none; }
.btn-primary { border-color: var(--primary-600); background: var(--primary-600); color: #fff; }
.btn-primary:hover { background: var(--primary); }
.btn-danger { border-color: var(--err); background: var(--err); color: #fff; }
.btn-danger:hover { background: #b91c1c; }
.btn-ghost { border-color: transparent; background: transparent; }
.btn-ghost:hover { background: #eef2f8; }
.btn-sm { padding: 3px 9px; font-size: .8rem; }
.btn-block { width: 100%; justify-content: center; }
.btn[disabled] { opacity: .55; cursor: not-allowed; }
a:focus-visible, button:focus-visible, select:focus-visible, input:focus-visible, textarea:focus-visible, [tabindex]:focus-visible { outline: 3px solid #1d4ed8; outline-offset: 2px; border-radius: 4px; }
.sidebar a:focus-visible, .sidebar button:focus-visible { outline-color: #6ee7b7; }

/* Inputs / forms */
form .form-row { display: block; margin-bottom: 12px; }
.form-label { display: block; margin-bottom: 4px; color: #33415c; font-size: .82rem; font-weight: 600; }
input, select, textarea { width: 100%; min-width: 0; max-width: 100%; padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; background: #fff; color: var(--text); font: inherit; }
select { padding-inline: 10px 2.25rem; text-overflow: ellipsis; }
option { max-width: 100%; }
.form-grid > *, .filters > * { min-width: 0; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
.form-grid-3 { display: grid; grid-template-columns: repeat(3,1fr); gap: 0 16px; }
.blacklist-add-form .blacklist-exact-match, .blacklist-add-form .blacklist-form-actions { grid-column: 1 / -1; }
.blacklist-add-form .blacklist-form-actions { display: flex; gap: 8px; margin-bottom: 4px; flex-wrap: wrap; }
.filters { display: flex; align-items: flex-end; gap: 8px; margin-bottom: 12px; flex-wrap: wrap; }
.filters .form-row { width: min(100%,18rem); min-width: 0; margin-bottom: 0; flex: 1 1 12rem; }
.filters .form-row select { width: 100%; min-width: 0; }
.inline-form { display: inline-flex; align-items: center; gap: 6px; }
fieldset { margin: 0 0 14px; padding: 12px 14px; border: 1px solid var(--border); border-radius: var(--radius); }
legend { padding: 0 6px; font-size: .88rem; font-weight: 700; }
input[type="checkbox"] { width: auto; }
textarea { min-height: 70px; resize: vertical; }
.pagination { display: flex; align-items: center; justify-content: center; gap: 10px; margin: 14px 0; }

/* Notices and empty states */
.flash { margin-bottom: 14px; padding: 10px 14px; border-radius: 8px; font-weight: 500; }
.flash.ok { border: 1px solid #86efac; background: #dcfce7; color: #14532d; }
.flash.err { border: 1px solid #fca5a5; background: #fee2e2; color: #7f1d1d; }
.empty { padding: 34px 16px; color: var(--muted); text-align: center; }
.empty-icon { display: grid; width: 38px; height: 38px; place-items: center; margin: 0 auto 10px; border-radius: 10px; background: #edf1f7; color: #52617a; font-size: 1.55rem; font-weight: 600; line-height: 1; }
.banner { display: flex; align-items: flex-start; gap: 10px; margin-bottom: 14px; padding: 12px 14px; border-radius: 8px; font-size: .9rem; }
.banner.warn { border: 1px solid #f59e0b; background: #fef3c7; color: #78350f; }
.banner.info { border: 1px solid #38bdf8; background: #e0f2fe; color: #0c4a6e; }
.banner.err { border: 1px solid #f87171; background: #fee2e2; color: #7f1d1d; }

/* Notifications */
.notif-btn { position: relative; }
.notif-item { display: flex; align-items: flex-start; gap: 10px; padding: 10px 14px; border-bottom: 1px solid var(--border); }
.notif-item.unread { background: #eef5ff; }
.notif-sev { flex: 0 0 10px; width: 10px; height: 10px; margin-top: 5px; border-radius: 50%; }

/* Timelines, photos, signatures and maps */
.timeline { position: relative; padding-left: 22px; }
.timeline::before { position: absolute; top: 4px; bottom: 4px; left: 7px; width: 2px; background: var(--border); content: ""; }
.tl-item { position: relative; padding: 0 0 14px 8px; }
.tl-item::before { position: absolute; top: 5px; left: -19px; width: 12px; height: 12px; border: 2px solid #fff; border-radius: 50%; background: var(--tl-color,var(--primary-600)); box-shadow: 0 0 0 1px var(--border); content: ""; }
.tl-date { color: var(--muted); font-size: .78rem; }
.tl-title { font-weight: 600; }
.photo-grid { display: grid; grid-template-columns: repeat(auto-fill,minmax(130px,1fr)); gap: 10px; }
.photo-thumb { width: 100%; aspect-ratio: 4/3; border: 1px solid var(--border); border-radius: 8px; background: #eef1f6; object-fit: cover; cursor: zoom-in; }
.photo-cell { position: relative; }
.photo-cell .photo-meta { margin-top: 3px; color: var(--muted); font-size: .72rem; }
.lightbox { position: fixed; z-index: 100; inset: 0; display: none; align-items: center; justify-content: center; background: rgba(10,14,22,.82); }
.lightbox.open { display: flex; }
.lightbox img { max-width: 92vw; max-height: 88vh; border-radius: 8px; }
.lightbox-close { position: absolute; top: 12px; right: 16px; border: 0; background: none; color: #fff; font-size: 1.6rem; cursor: pointer; }
.sig-pad { width: 100%; max-width: 480px; height: 160px; border: 1px dashed var(--border); border-radius: 8px; background: #fff; touch-action: none; }
.sig-tools { display: flex; gap: 8px; margin-top: 6px; }
.sig-preview img { max-width: 260px; border: 1px solid var(--border); border-radius: 8px; background: #fff; }
.veh-diagram { position: relative; max-width: 460px; }
.veh-diagram svg { display: block; width: 100%; height: auto; }
.veh-diagram .zone { fill: rgba(37,99,235,.06); stroke: #94a3b8; stroke-width: 1.4; cursor: pointer; }
.veh-diagram .zone:hover { fill: rgba(37,99,235,.18); }
.veh-diagram .zone.selected { fill: rgba(220,38,38,.25); stroke: var(--err); stroke-width: 2.4; }
.gps-layout { display: grid; grid-template-columns: minmax(0,1fr) minmax(300px,380px); align-items: start; gap: 16px; }
.gps-map { position: relative; z-index: 1; height: 540px; border: 1px solid var(--border); border-radius: var(--radius); }
.gps-map-empty { position: absolute; z-index: 1000; inset: 0; display: flex; align-items: center; justify-content: center; padding: 20px; color: var(--muted); text-align: center; pointer-events: none; }
.gps-map-empty strong { color: var(--text); }
.gps-panel { display: grid; gap: 12px; }
.gps-status { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; }
.gps-dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; }
.veh-list { display: grid; max-height: 300px; gap: 6px; overflow-y: auto; }
.veh-item { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 7px 10px; border: 1px solid var(--border); border-radius: 8px; background: #fff; cursor: pointer; }
.veh-item:hover, .veh-item.selected { border-color: var(--primary-600); }
.veh-item.selected { background: var(--primary-soft); }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; font-size: .88rem; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-weight: 500; }
.map-mini { height: 220px; border: 1px solid var(--border); border-radius: 8px; }
.search-results-group { margin-bottom: 18px; }
.contract-sheet { max-width: 800px; margin: 0 auto; padding: 28px; border: 1px solid var(--border); border-radius: var(--radius); background: #fff; font-size: .92rem; }
.contract-sheet h1 { font-size: 1.2rem; letter-spacing: .08em; text-align: center; }
.contract-sheet h2 { margin: 18px 0 6px; padding-bottom: 3px; border-bottom: 1px solid #ccc; font-size: 1rem; }
.contract-sheet table { font-size: .85rem; }
.contract-sheet .sig-row { display: flex; justify-content: space-between; gap: 40px; margin-top: 40px; }
.contract-sheet .sig-box { flex: 1; border-top: 1px solid #333; padding-top: 4px; text-align: center; font-size: .8rem; }

@media print {
  body { background: #fff; }
  .sidebar, .topbar, .no-print, .page-actions, .filters { display: none !important; }
  .content { max-width: none; padding: 0; }
  .card { border: none; box-shadow: none; }
  .contract-sheet { border: none; padding: 0; }
  .main { display: block; }
}
@media (max-width: 1000px) {
  .grid-2, .grid-3, .gps-layout { grid-template-columns: 1fr; }
}
@media (max-width: 900px) {
  body.mobile-menu-open { overflow: hidden; overscroll-behavior: none; }
  .topbar > .mobile-brand { display: flex; flex: 0 0 auto; align-items: center; padding: 0; border: 0; font-size: .9rem; letter-spacing: .02em; }
  .topbar > .mobile-brand .brand-velma { color: var(--text); }
  .topbar > .mobile-brand .brand-go { color: #0f9b75; }
  .topbar > .topbar-title { min-width: 0; }
  .sidebar { position: fixed; z-index: 1000; top: 0; bottom: 0; left: 0; width: min(var(--sidebar-w),86vw); flex-basis: min(var(--sidebar-w),86vw); height: 100vh; height: 100dvh; transform: translateX(-105%); transition: transform .22s ease; }
  html[dir="rtl"] .sidebar { right: 0; left: auto; transform: translateX(105%); }
  .sidebar.open, html[dir="rtl"] .sidebar.open { transform: translateX(0); box-shadow: 0 0 40px rgba(0,0,0,.35); }
  .sidebar-scrim { position: fixed; z-index: 999; inset: 0; display: block; padding: 0; border: 0; background: rgba(9,16,30,.52); opacity: 0; visibility: hidden; transition: opacity .22s ease, visibility .22s ease; }
  .sidebar.open + .sidebar-scrim { opacity: 1; visibility: visible; }
  .hamburger { display: inline-grid; flex: 0 0 42px; width: 42px; height: 42px; place-items: center; border: 0; border-radius: 8px; background: transparent; color: var(--text); cursor: pointer; }
  .hamburger:hover { background: #e8eef6; }
  .hamburger:focus-visible { outline: 3px solid #1d4ed8; outline-offset: 2px; }
  .content { padding: 12px; }
  .topbar { padding: 10px 12px; }
  .sidebar .nav-link { min-height: 42px; }
}
@media (max-width: 700px) {
  .form-grid, .form-grid-3 { grid-template-columns: 1fr; }
  .filters > .form-row { flex: 1 1 100%; width: 100%; }
  .vehicle-filters .vehicle-search { min-width: 0; flex-basis: 100%; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .gps-map { height: 380px; }
}
html[dir="rtl"] .timeline { padding-right: 22px; padding-left: 0; }
html[dir="rtl"] .timeline::before { right: 7px; left: auto; }
html[dir="rtl"] .tl-item { padding-right: 8px; padding-left: 0; }
html[dir="rtl"] .tl-item::before { right: -19px; left: auto; }
@media (max-width: 600px) {
  .brand { padding: 12px; }
  .nav { padding-inline: 8px; }
  .topbar { gap: 6px; padding: 8px; }
  .topbar-actions { flex: 1; min-width: 0; justify-content: flex-end; gap: 3px; }
  .language-picker { min-width: 0; gap: 2px; }
  .language-picker select { width: auto; min-width: 48px; padding: 5px 4px; }
  .language-picker .btn { padding-inline: 7px; }
  .topbar-icon-link { flex: 0 0 40px; width: 40px; min-width: 40px; padding: 6px; }
  .topbar .nav-text { display: none; }
  .topbar > .topbar-title { display: none; }
  .topbar > .mobile-brand { font-size: .82rem; }
  .content { min-width: 0; padding: 12px; }
  .stats-grid { grid-template-columns: repeat(2,minmax(0,1fr)); }
  html[dir="rtl"] th { text-align: right; }
  html[dir="rtl"] .language-picker select { padding-inline: 1.75rem 4px; }
}
@media (max-width: 360px) {
  .topbar { gap: 4px; padding-inline: 6px; }
  .hamburger { flex-basis: 38px; width: 38px; }
  .topbar-actions { gap: 2px; }
  .language-picker { gap: 0; }
  .language-picker select { min-width: 42px; padding-inline: 2px; }
  html[dir="rtl"] .language-picker select { padding-inline: 1.5rem 2px; }
  .language-picker .btn { padding-inline: 2px; font-size: .72rem; white-space: nowrap; }
  .topbar-icon-link { flex-basis: 38px; width: 38px; min-width: 38px; }
}
