:root {
  color-scheme: light dark;
  --bg: #eef1f2;
  --surface: #ffffff;
  --sunken: #f5f7f8;
  --ink: #1c2a31;
  --muted: #5a6a72;
  --line: #d3dadd;
  --accent: #0f6b5c;
  --accent-ink: #ffffff;
  --accent-soft: #dcefeb;
  --warn: #8a5f00;
  --warn-bg: #fbf1d3;
  --bad: #b3261e;
  --bad-bg: #fbe3e1;
  --ok: #1d6b33;
  --ok-bg: #e0f1e4;
  --plate-bg: #ffffff;
  --plate-ink: #111111;
  --eu: #1b3f94;
  --radius: 10px;
  --font: system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --mono: ui-monospace, 'SF Mono', 'Cascadia Mono', Consolas, monospace;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #13191c;
    --surface: #1b2428;
    --sunken: #162024;
    --ink: #e4ebee;
    --muted: #9aabb3;
    --line: #2c3a40;
    --accent: #3fb59f;
    --accent-ink: #0b1a17;
    --accent-soft: #173a33;
    --warn: #e0b341;
    --warn-bg: #2d2610;
    --bad: #ff8a80;
    --bad-bg: #3a1714;
    --ok: #7fd18f;
    --ok-bg: #15301c;
  }
}
* {
  box-sizing: border-box;
}
html {
  -webkit-text-size-adjust: 100%;
}
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 400 17px/1.5 var(--font);
}
a {
  color: var(--accent);
}
:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}
h1,
h2,
h3 {
  line-height: 1.25;
  margin: 0;
}
h1 {
  font-size: 26px;
}
h2 {
  font-size: 20px;
}
h3 {
  font-size: 17px;
}
p {
  margin: 0;
}
.muted {
  color: var(--muted);
}
.small {
  font-size: 14px;
}
.hidden {
  display: none !important;
}

/* rozvržení */
.top {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}
.top-in {
  max-width: 1040px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 10px 16px;
}
.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--ink);
  font-weight: 700;
  font-size: 18px;
  white-space: nowrap;
}
.logo .mini-plate {
  font: 700 12px/1 var(--mono);
  border: 2px solid #111;
  border-radius: 4px;
  background: #fff;
  color: #111;
  display: inline-flex;
  overflow: hidden;
}
.logo .mini-plate b {
  background: var(--eu);
  color: #fff;
  padding: 4px 3px;
  font-size: 9px;
}
.logo .mini-plate span {
  padding: 3px 5px;
  letter-spacing: 0.05em;
}
.nav {
  display: flex;
  gap: 4px;
  flex: 1;
}
.nav a {
  padding: 8px 12px;
  border-radius: 8px;
  text-decoration: none;
  color: var(--muted);
  font-weight: 600;
  font-size: 15px;
}
.nav a.on {
  background: var(--accent-soft);
  color: var(--accent);
}
.nav a:hover {
  color: var(--ink);
}
.me {
  margin-left: auto;
  text-decoration: none;
  color: var(--ink);
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 15px;
}
.avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--accent);
  color: var(--accent-ink);
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 14px;
}
main {
  max-width: 1040px;
  margin: 0 auto;
  padding: 20px 16px 110px;
  display: grid;
  gap: 18px;
}
main > *,
.card > *,
.grid2 > * {
  min-width: 0;
}
.bottom {
  display: none;
}
@media (max-width: 760px) {
  .nav {
    display: none;
  }
  .me .jm {
    display: none;
  }
  .bottom {
    display: flex;
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 10;
    background: var(--surface);
    border-top: 1px solid var(--line);
    padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
  }
  .bottom a {
    flex: 1;
    display: grid;
    place-items: center;
    gap: 2px;
    padding: 6px 2px;
    text-decoration: none;
    color: var(--muted);
    font-size: 12px;
    font-weight: 600;
    border-radius: 8px;
  }
  .bottom a svg {
    width: 24px;
    height: 24px;
  }
  .bottom a.on {
    color: var(--accent);
    background: var(--accent-soft);
  }
  h1 {
    font-size: 22px;
  }
}

/* karty a seznamy */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  display: grid;
  gap: 14px;
  min-width: 0;
}
@media (max-width: 520px) {
  main {
    padding-left: 10px;
    padding-right: 10px;
  }
  .card {
    padding: 14px;
  }
  .row {
    gap: 10px;
  }
  .plate .n {
    font-size: 15px;
    padding: 6px 7px;
  }
}
.card-head {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: space-between;
}
.grid2 {
  display: grid;
  gap: 18px;
  grid-template-columns: repeat(auto-fit, minmax(min(320px, 100%), 1fr));
  align-items: start;
}
.list {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
}
.row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 4px;
  border-top: 1px solid var(--line);
  text-decoration: none;
  color: inherit;
  min-height: 56px;
}
.row:first-child {
  border-top: 0;
}
a.row:hover {
  background: var(--sunken);
}
.row .grow {
  flex: 1;
  min-width: 0;
}
.row .t {
  font-weight: 600;
}
.row .s {
  color: var(--muted);
  font-size: 14px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.empty {
  color: var(--muted);
  padding: 8px 0;
}
.kv {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 6px 16px;
  font-size: 15px;
}
.kv dt {
  color: var(--muted);
}
.kv dd {
  margin: 0;
  overflow-wrap: anywhere;
}

/* SPZ – česká tabulka */
.plate {
  display: inline-flex;
  align-items: stretch;
  background: var(--plate-bg);
  color: var(--plate-ink);
  border: 2px solid #111;
  border-radius: 6px;
  overflow: hidden;
  flex-shrink: 0;
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.25);
}
.plate .eu {
  background: var(--eu);
  color: #fff;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: 2px 5px;
  font: 700 10px/1 var(--font);
  gap: 2px;
}
.plate .eu::before {
  content: '★';
  color: #ffd400;
  font-size: 9px;
}
.plate .n {
  font: 700 17px/1 var(--mono);
  letter-spacing: 0.08em;
  padding: 7px 10px;
  white-space: nowrap;
}
.plate.big {
  border-width: 3px;
  border-radius: 9px;
}
.plate.big .eu {
  padding: 4px 9px;
  font-size: 13px;
}
.plate.big .n {
  font-size: clamp(26px, 7vw, 40px);
  padding: 8px 18px;
}

/* vyhledávání jako SPZ */
.search {
  display: flex;
  align-items: stretch;
  border: 3px solid #111;
  border-radius: 10px;
  background: #fff;
  overflow: hidden;
}
.search .eu {
  background: var(--eu);
  color: #fff;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: 4px 12px;
  font: 700 14px/1 var(--font);
  gap: 3px;
}
.search .eu::before {
  content: '★';
  color: #ffd400;
  font-size: 12px;
}
.search input {
  flex: 1;
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: #111;
  font: 700 clamp(22px, 6vw, 30px)/1 var(--mono);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 14px 16px;
}
.search input::placeholder {
  color: #9aa5aa;
  letter-spacing: 0.02em;
  text-transform: none;
  font-weight: 500;
  font-family: var(--font);
  font-size: 18px;
}
.search:focus-within {
  box-shadow: 0 0 0 4px var(--accent-soft);
}

/* štítky stavů */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
  background: var(--sunken);
  color: var(--muted);
  border: 1px solid var(--line);
}
.chip.prijata {
  background: var(--sunken);
  color: var(--ink);
}
.chip.v_praci {
  background: var(--accent-soft);
  color: var(--accent);
  border-color: transparent;
}
.chip.ceka_na_dily,
.chip.brzy {
  background: var(--warn-bg);
  color: var(--warn);
  border-color: transparent;
}
.chip.hotova,
.chip.ok {
  background: var(--ok-bg);
  color: var(--ok);
  border-color: transparent;
}
.chip.po_terminu {
  background: var(--bad-bg);
  color: var(--bad);
  border-color: transparent;
}
.dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
  background: var(--line);
}
.dot.po_terminu {
  background: var(--bad);
}
.dot.brzy {
  background: var(--warn);
}
.dot.ok {
  background: var(--ok);
}

/* servisní knížka */
.plan {
  display: grid;
  gap: 2px;
}
.plan .item {
  display: grid;
  grid-template-columns: 14px 1fr auto;
  gap: 4px 12px;
  align-items: center;
  padding: 10px 0;
  border-top: 1px solid var(--line);
}
.plan .item:first-child {
  border-top: 0;
}
.plan .item .s {
  grid-column: 2 / 4;
  color: var(--muted);
  font-size: 14px;
}
.km-odhad {
  display: flex;
  gap: 10px;
  align-items: baseline;
  flex-wrap: wrap;
}
.km-odhad b {
  font: 700 24px/1 var(--mono);
}

/* historie zakázek */
.timeline {
  display: grid;
}
.timeline a {
  display: grid;
  grid-template-columns: 96px 1fr auto;
  gap: 4px 14px;
  padding: 12px 4px;
  border-top: 1px solid var(--line);
  text-decoration: none;
  color: inherit;
}
.timeline a:first-child {
  border-top: 0;
}
.timeline a:hover {
  background: var(--sunken);
}
.timeline .d {
  font-weight: 700;
  font-size: 15px;
}
.timeline .d small {
  display: block;
  font-weight: 400;
  color: var(--muted);
}
.timeline .u {
  color: var(--muted);
  font-size: 14px;
}
@media (max-width: 520px) {
  .timeline a {
    grid-template-columns: 1fr auto;
  }
  .timeline .d {
    grid-column: 1 / 3;
    display: flex;
    gap: 10px;
  }
}

/* formuláře */
form {
  display: grid;
  gap: 14px;
}
.fields {
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
}
label {
  display: grid;
  gap: 6px;
  font-weight: 600;
  font-size: 15px;
}
label .hint {
  font-weight: 400;
  color: var(--muted);
  font-size: 13px;
}
input,
select,
textarea {
  font: inherit;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 11px 12px;
  min-height: 46px;
  width: 100%;
}
textarea {
  min-height: 90px;
  resize: vertical;
}
input:focus,
select:focus,
textarea:focus {
  outline: 0;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
input.vin,
input.spz {
  font-family: var(--mono);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
}
button,
.btn {
  font: 700 16px/1 var(--font);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 48px;
  padding: 0 20px;
  border-radius: 10px;
  border: 1px solid transparent;
  background: var(--accent);
  color: var(--accent-ink);
  cursor: pointer;
  text-decoration: none;
}
button:hover,
.btn:hover {
  filter: brightness(1.08);
}
button:disabled {
  opacity: 0.5;
  cursor: default;
  filter: none;
}
button.sec,
.btn.sec {
  background: var(--surface);
  color: var(--ink);
  border-color: var(--line);
}
button.ghost {
  background: transparent;
  color: var(--accent);
  border-color: transparent;
  padding: 0 10px;
}
button.bad {
  background: var(--surface);
  color: var(--bad);
  border-color: var(--line);
}
button.small,
.btn.small {
  min-height: 38px;
  padding: 0 14px;
  font-size: 14px;
}
.chips {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.chips.scroll {
  flex-wrap: nowrap;
  overflow-x: auto;
  padding-bottom: 4px;
  scrollbar-width: thin;
}
.chips.scroll button {
  flex-shrink: 0;
}
.chips button {
  min-height: 40px;
  padding: 0 14px;
  font-size: 14px;
  font-weight: 600;
  background: var(--sunken);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 999px;
}
.chips button.on {
  background: var(--accent);
  color: var(--accent-ink);
  border-color: var(--accent);
}
.stavy {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 8px;
}
.stavy button {
  background: var(--sunken);
  color: var(--ink);
  border: 2px solid var(--line);
  font-size: 15px;
}
.stavy button.on {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
}

/* návrhy a upozornění */
.tip {
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 12px 14px;
  border-radius: 10px;
  background: var(--warn-bg);
  color: var(--ink);
}
.tip.po_terminu {
  background: var(--bad-bg);
}
.tip .grow {
  flex: 1;
}
.tip .s {
  color: var(--muted);
  font-size: 14px;
}
.secret {
  font: 700 22px/1.2 var(--mono);
  letter-spacing: 0.06em;
  background: var(--sunken);
  border: 2px dashed var(--accent);
  border-radius: 10px;
  padding: 14px;
  text-align: center;
  user-select: all;
}
.ceny {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 6px 16px;
  font-size: 16px;
}
.ceny .tot {
  font-weight: 800;
  font-size: 20px;
  border-top: 1px solid var(--line);
  padding-top: 8px;
}
.stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}
.stat {
  background: var(--sunken);
  border-radius: 10px;
  padding: 12px;
  text-decoration: none;
  color: inherit;
}
.stat b {
  display: block;
  font-size: 28px;
  line-height: 1.1;
}
.stat span {
  color: var(--muted);
  font-size: 14px;
}

/* přihlášení */
.login {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 20px;
}
.login .card {
  width: min(420px, 100%);
  padding: 28px;
}
.login .plate {
  align-self: start;
}

/* hlášky */
.toast {
  position: fixed;
  left: 50%;
  bottom: 90px;
  transform: translateX(-50%);
  background: var(--ink);
  color: var(--bg);
  padding: 12px 18px;
  border-radius: 10px;
  font-weight: 600;
  z-index: 50;
  max-width: calc(100% - 32px);
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.25);
}
.toast.bad {
  background: var(--bad);
  color: #fff;
}
dialog {
  border: 0;
  border-radius: 14px;
  padding: 0;
  background: var(--surface);
  color: var(--ink);
  width: min(520px, calc(100% - 24px));
}
dialog::backdrop {
  background: rgba(10, 16, 18, 0.55);
}
dialog .card {
  border: 0;
}
@media (prefers-reduced-motion: no-preference) {
  .toast {
    animation: up 0.18s ease-out;
  }
  @keyframes up {
    from {
      opacity: 0;
      transform: translate(-50%, 8px);
    }
  }
}
@media print {
  .top,
  .bottom,
  .actions,
  button {
    display: none !important;
  }
  body {
    background: #fff;
    color: #000;
  }
  .card {
    border: 0;
    padding: 0;
  }
}
