:root {
  --bg: #f3f2ed;
  --surface: #fbfaf7;
  --surface-2: #ebe9e2;
  --text: #1a1a17;
  --muted: #6a6860;
  --border: #d5d2c8;
  --strong: #1a1a17;
  --accent: #0e5a46;
  --accent-text: #ffffff;
  --ok: #0e5a46;
  --ok-bg: #dcebe4;
  --sale: #8a4b00;
  --sale-bg: #f4e5cf;
  --danger: #a32a1f;
  --danger-bg: #f6dfdb;
  --radius: 2px;
  --mono: ui-monospace, "Cascadia Mono", "SF Mono", Consolas, monospace;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141412;
    --surface: #1b1b18;
    --surface-2: #25251f;
    --text: #e9e7df;
    --muted: #9b988d;
    --border: #34332d;
    --strong: #e9e7df;
    --accent: #6cc4a3;
    --accent-text: #0d1a15;
    --ok: #6cc4a3;
    --ok-bg: #1b2e27;
    --sale: #e0a75a;
    --sale-bg: #34281a;
    --danger: #ef7d70;
    --danger-bg: #3a1e1b;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
}

h1, h2, h3 { margin: 0; line-height: 1.25; }
h2 { font-size: 0.8rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); margin-bottom: 12px; }
a { color: var(--accent); }
.mono { font-family: var(--mono); font-size: 0.9em; }
.upper { text-transform: uppercase; }
.muted { color: var(--muted); }
[hidden] { display: none !important; }

/* antraštė */
.topbar {
  display: flex; flex-wrap: wrap; gap: 12px; align-items: center; justify-content: space-between;
  padding: 14px 24px; background: var(--surface); border-bottom: 2px solid var(--strong);
}
.brand h1 { font-family: var(--mono); font-size: 1.15rem; letter-spacing: 0.04em; text-transform: uppercase; }
.tagline { margin: 2px 0 0; color: var(--muted); font-size: 0.82rem; }
.wallet { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.pill { font-size: 0.8rem; color: var(--muted); padding: 4px 8px; border: 1px solid var(--border); border-radius: var(--radius); }
.account { display: flex; gap: 8px; align-items: center; font-size: 0.85rem; }
.role {
  font-size: 0.7rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em;
  padding: 3px 7px; border-radius: var(--radius); background: var(--accent); color: var(--accent-text);
}

/* pranešimų juosta */
.banner {
  margin: 16px 24px 0; padding: 10px 14px; border-radius: var(--radius);
  display: flex; gap: 12px; align-items: center; flex-wrap: wrap;
  border: 1px solid var(--border); border-left-width: 3px; background: var(--surface);
}
.banner.info { border-left-color: var(--muted); }
.banner.warn { border-left-color: var(--sale); background: var(--sale-bg); }
.banner.error { border-left-color: var(--danger); background: var(--danger-bg); color: var(--danger); }

/* skirtukai */
.tabs { display: flex; gap: 0; margin: 16px 24px 0; box-shadow: inset 0 -1px var(--border); overflow-x: auto; overflow-y: hidden; }
.tabs button {
  border: 0; border-bottom: 2px solid transparent; background: none;
  padding: 10px 14px; cursor: pointer; font: inherit; color: var(--muted); white-space: nowrap;
}
.tabs button:hover { color: var(--text); }
.tabs button.active { color: var(--text); font-weight: 600; border-bottom-color: var(--accent); }

main { padding: 20px 24px 48px; max-width: 1200px; }

/* mygtukai ir formos */
.btn {
  font: inherit; font-size: 0.9rem; font-weight: 600; padding: 7px 14px; border-radius: var(--radius); cursor: pointer;
  border: 1px solid var(--strong); background: transparent; color: var(--text);
}
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.btn.primary:hover { filter: brightness(1.1); }
.btn.danger { color: var(--danger); border-color: var(--danger); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
body.busy .btn { pointer-events: none; opacity: 0.6; }

label { display: flex; flex-direction: column; gap: 4px; font-size: 0.8rem; color: var(--muted); margin-bottom: 12px; flex: 1; }
label.check { flex-direction: row; align-items: center; gap: 6px; margin: 0; flex: 0 0 auto; color: var(--text); font-size: 0.88rem; }
input, select, textarea {
  font: inherit; color: var(--text); background: var(--surface); padding: 7px 9px;
  border: 1px solid var(--border); border-radius: var(--radius); width: 100%;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
label.check input { width: auto; accent-color: var(--accent); }
.row { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; }
.row > label { min-width: 130px; }
.row .btn { margin-bottom: 12px; }
.hint { margin: -6px 0 12px; font-size: 0.8rem; color: var(--muted); }

.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; }
.panel.narrow { max-width: 480px; }
.panel h2:not(:first-child) { margin-top: 20px; }
.split { display: grid; grid-template-columns: minmax(280px, 360px) 1fr; gap: 24px; align-items: start; }
.split > * { min-width: 0; }
.toolbar { display: flex; gap: 16px; align-items: center; flex-wrap: wrap; margin-bottom: 14px; }
.toolbar input[type=search] { max-width: 300px; background: var(--surface); }

/* automobilių lentelė */
.table-wrap { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow-x: auto; }
table.cars { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
.cars th {
  text-align: left; font-size: 0.72rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em;
  color: var(--muted); padding: 10px 12px; border-bottom: 1px solid var(--strong); white-space: nowrap;
}
.cars td { padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: top; }
.cars tbody tr:last-child td { border-bottom: 0; }
.cars tbody tr { cursor: pointer; }
.cars tbody tr:hover, .cars tbody tr:focus-visible { background: var(--surface-2); outline: none; }
.cars tr.inactive { color: var(--muted); }
.cars tr.inactive .car-name { text-decoration: line-through; }
.cars .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.car-name { display: block; font-weight: 600; }
.sub { display: block; color: var(--muted); font-size: 0.78rem; }
.price { font-family: var(--mono); font-size: 0.82rem; white-space: nowrap; }

.tag {
  display: inline-block; font-size: 0.68rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em;
  padding: 2px 6px; border-radius: var(--radius); border: 1px solid var(--border); color: var(--muted); white-space: nowrap;
}
.tag.sale { color: var(--sale); background: var(--sale-bg); border-color: transparent; }
.tag.ok { color: var(--ok); background: var(--ok-bg); border-color: transparent; }
.tag.muted { color: var(--muted); background: var(--surface-2); border-color: transparent; }

.empty { padding: 28px; text-align: center; color: var(--muted); background: var(--surface); border: 1px dashed var(--border); border-radius: var(--radius); }
.table-wrap .empty { border: 0; }
.list { list-style: none; padding: 0; margin: 0 0 16px; font-size: 0.88rem; }
.list li { padding: 7px 0; border-bottom: 1px solid var(--border); overflow-wrap: anywhere; }

/* automobilio kortelė */
dialog {
  width: min(780px, calc(100vw - 32px)); max-height: calc(100vh - 48px); border: 1px solid var(--strong);
  border-radius: var(--radius); padding: 24px; background: var(--surface); color: var(--text);
}
dialog::backdrop { background: rgba(12, 12, 10, 0.6); }
.close { position: absolute; top: 10px; right: 12px; border: 0; background: none; font-size: 22px; line-height: 1; cursor: pointer; color: var(--muted); }
.close:hover { color: var(--text); }
.dlg-head { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; margin-bottom: 16px; padding: 0 30px 12px 0; border-bottom: 2px solid var(--strong); }
.dlg-head h2 { margin: 0; font-size: 1.3rem; text-transform: none; letter-spacing: 0; color: var(--text); }
.facts { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 0; margin: 0 0 20px; border: 1px solid var(--border); border-radius: var(--radius); }
.facts > div { padding: 8px 12px; border-right: 1px solid var(--border); border-bottom: 1px solid var(--border); margin: 0 -1px -1px 0; }
.facts dt { font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); }
.facts dd { margin: 2px 0 0; font-weight: 600; overflow-wrap: anywhere; }
.actions { border: 1px solid var(--border); border-left: 3px solid var(--accent); border-radius: var(--radius); padding: 14px; margin-bottom: 20px; }
.actions h3 { font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); margin-bottom: 12px; }
.actions .hint { margin: 8px 0 0; }
.actions .btn-row { display: flex; gap: 10px; flex-wrap: wrap; }
.cols { display: grid; grid-template-columns: 2fr 1fr; gap: 24px; }
.deploy { max-width: 640px; }
.deploy .btn-row { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 8px; }
.deploy .hint { margin: 10px 0 0; }

.timeline { list-style: none; margin: 0; padding: 0 0 0 14px; border-left: 1px solid var(--strong); }
.timeline li { position: relative; padding: 0 0 14px 12px; }
.timeline li::before {
  content: ""; position: absolute; left: -19px; top: 6px; width: 9px; height: 9px;
  background: var(--surface); border: 1px solid var(--strong);
}
.timeline li.svc::before { background: var(--accent); border-color: var(--accent); }
.timeline .when { font-family: var(--mono); font-size: 0.78rem; color: var(--muted); }
.timeline .what { font-weight: 600; }
.owners { margin: 0; padding-left: 22px; font-size: 0.9rem; }
.owners li { padding: 3px 0; }

/* pranešimai */
#toasts { position: fixed; right: 16px; bottom: 16px; display: flex; flex-direction: column; gap: 8px; z-index: 50; max-width: min(380px, calc(100vw - 32px)); }
.toast {
  padding: 10px 14px; border-radius: var(--radius); background: var(--surface); font-size: 0.88rem;
  border: 1px solid var(--border); border-left: 3px solid var(--muted); box-shadow: 0 2px 10px rgba(0, 0, 0, 0.12);
}
.toast.success { border-left-color: var(--ok); }
.toast.error { border-left-color: var(--danger); color: var(--danger); }
.toast.pending { border-left-color: var(--accent); }

@media (max-width: 900px) {
  .split { grid-template-columns: 1fr; }
}

@media (max-width: 760px) {
  .topbar, main { padding-left: 16px; padding-right: 16px; }
  .tabs, .banner { margin-left: 16px; margin-right: 16px; }
  .cols { grid-template-columns: 1fr; }
  .cars .opt { display: none; }
  .cars th, .cars td { padding: 9px 6px; }
  .cars .sub { overflow-wrap: anywhere; }
}
