/* CarControl – vzhled podle návrhu obrazovek */
:root {
  --bg: #EEF0EC;
  --ink: #17201C;
  --muted: #56615B;
  --line: #DDE1DC;
  --line-soft: #E8EBE6;
  --card: #fff;
  --accent: #0F6B5C;
  --accent-dark: #0A4D42;
  --side: #17201C;
  --side-hover: #24302B;
  --side-on: #2E3D36;
  --side-text: #C9D2CD;
  --side-muted: #9DAAA3;
  --badge: #D9480F;
  --input-line: #CDD3CD;
  --soft: #F4F5F2;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 15px;
  line-height: 1.45;
}
a { color: var(--accent); }
a:hover { color: var(--accent-dark); }
h1 { margin: 0; font-size: 28px; font-weight: 600; line-height: 1.2; }
h2 { margin: 0; font-size: 16px; font-weight: 600; }
.mono { font-family: "IBM Plex Mono", ui-monospace, Consolas, monospace; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* Rozvržení: menu vlevo, na telefonu nahoře */
.layout { display: flex; flex-wrap: wrap; min-height: 100vh; }
.side {
  flex: 1 1 240px; background: var(--side); color: #fff;
  padding: 22px 14px; display: flex; flex-direction: column; gap: 28px;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 0 8px; color: #fff; text-decoration: none; }
.brand-logo { width: 34px; height: 34px; border-radius: 8px; background: var(--accent); display: flex; align-items: center; justify-content: center; }
.brand b { display: block; font-size: 16px; }
.brand small { color: var(--side-muted); font-size: 12px; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 8px;
  color: var(--side-text); text-decoration: none; font-size: 14px; min-height: 44px;
}
.nav a:hover { background: var(--side-hover); color: #fff; }
.nav a.on { background: var(--side-on); color: #fff; font-weight: 500; }
.nav .grow { flex-grow: 1; }
.badge { background: var(--badge); color: #fff; font-size: 11px; font-weight: 600; border-radius: 999px; padding: 1px 7px; }
.side-user { margin-top: auto; display: flex; align-items: center; gap: 10px; padding: 12px 8px 0; border-top: 1px solid var(--side-on); }
.side-user .who { flex-grow: 1; min-width: 0; }
.side-user .who div:first-child { font-size: 14px; overflow: hidden; text-overflow: ellipsis; }
.side-user .who div:last-child { font-size: 12px; color: var(--side-muted); }
.side-user button { background: none; border: 1px solid var(--side-on); color: var(--side-text); border-radius: 8px; min-height: 36px; padding: 0 10px; font: inherit; font-size: 13px; cursor: pointer; }
.side-user button:hover { color: #fff; background: var(--side-hover); }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--side-on); display: flex; align-items: center; justify-content: center; font-size: 13px; font-weight: 600; flex-shrink: 0; }
.avatar.lg { width: 72px; height: 72px; font-size: 24px; background: #DDF0E8; color: #0B5A4C; }
.avatar.md { width: 44px; height: 44px; font-size: 15px; background: #DDF0E8; color: #0B5A4C; }

.main { flex: 999 1 560px; min-width: 0; padding: 28px 32px 48px; display: flex; flex-direction: column; gap: 20px; }
@media (max-width: 640px) { .main { padding: 20px 16px 40px; } }

.page-head { display: flex; flex-wrap: wrap; align-items: center; gap: 16px; }
.page-head .grow { flex-grow: 1; min-width: 220px; }
.page-head .sub { font-size: 14px; color: var(--muted); margin-top: 4px; }
.crumbs { font-size: 14px; color: var(--muted); }

.flash { background: #DDF0E8; color: #0B5A4C; border-radius: 10px; padding: 12px 16px; font-size: 14px; }
.flash.err { background: #FBE4E1; color: #9B1C12; }

/* Karty a mřížky */
.card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; }
.card.pad { padding: 20px; }
.card-head { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; padding: 18px 20px 6px; }
.card-head h2 { flex-grow: 1; }
.card.pad > .card-head { padding: 0 0 10px; }
.row { display: flex; flex-wrap: wrap; gap: 20px; align-items: flex-start; }
.row > * { flex: 1 1 340px; min-width: 0; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 16px; }
.kpi { padding: 18px 20px; text-decoration: none; color: inherit; display: block; }
.kpi .label { font-size: 13px; color: var(--muted); }
.kpi .value { font-size: 30px; font-weight: 600; margin-top: 6px; line-height: 1.15; }
.kpi .note { font-size: 13px; color: var(--muted); margin-top: 4px; }
.kpi.warn { background: #FFF7F2; border-color: #F2C9B3; }
.kpi.warn .label, .kpi.warn .value, .kpi.warn .note { color: #8A3A0C; }

.kv { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 20px; margin: 0; font-size: 14px; }
.kv dt { font-size: 12px; color: var(--muted); margin: 0 0 2px; }
.kv dd { margin: 0; font-weight: 500; overflow-wrap: anywhere; }

/* Tabulky */
.table-wrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-size: 14px; }
th {
  text-align: left; font-weight: 500; color: var(--muted); font-size: 12px; text-transform: uppercase;
  letter-spacing: .04em; padding: 10px 12px; border-bottom: 1px solid var(--line); white-space: nowrap;
}
td { padding: 11px 12px; border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
tbody tr:last-child td { border-bottom: 0; }
td .sub { font-size: 13px; color: var(--muted); }
tr.group td { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; padding: 8px 12px; }
tr.group.overdue td { background: #FBF3F2; color: #9B1C12; }
tr.group.soon td { background: #FDF7EC; color: #7F4505; }
tr.group.ok td { background: var(--soft); color: #46504B; }
.flush td:first-child, .flush th:first-child { padding-left: 0; }
.flush td:last-child, .flush th:last-child { padding-right: 0; }
.empty { padding: 18px 20px; color: var(--muted); font-size: 14px; }

/* Štítky */
.pill { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 500; white-space: nowrap; }
.p-red { background: #FBE4E1; color: #9B1C12; }
.p-amb { background: #FCEFD6; color: #7F4505; }
.p-ok { background: #DDF0E8; color: #0B5A4C; }
.p-gray { background: #E6E9E5; color: #46504B; }

.plate {
  display: inline-flex; align-items: stretch; border: 1.5px solid var(--ink); border-radius: 4px; overflow: hidden;
  font-family: "IBM Plex Mono", ui-monospace, Consolas, monospace; font-weight: 600; font-size: 13px; background: #fff;
  white-space: nowrap; color: var(--ink); text-decoration: none;
}
.plate > span:first-child { background: #1D4FA3; color: #fff; font-size: 9px; padding: 2px 4px; display: flex; align-items: flex-end; }
.plate > span:last-child { padding: 2px 7px; }
.plate.lg { border-width: 2px; border-radius: 5px; }
.plate.lg > span:first-child { font-size: 11px; padding: 3px 6px; }
.plate.lg > span:last-child { font-size: 20px; padding: 4px 12px; }
.vehicle-cell { display: flex; flex-direction: column; gap: 4px; color: inherit; text-decoration: none; align-items: flex-start; }

/* Tlačítka a formuláře */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 0 18px;
  border-radius: 8px; font: inherit; font-size: 14px; font-weight: 500; cursor: pointer; text-decoration: none;
  border: 1px solid var(--input-line); background: #fff; color: var(--ink); white-space: nowrap;
}
.btn:hover { background: var(--soft); color: var(--ink); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-dark); border-color: var(--accent-dark); color: #fff; }
.btn.sm { min-height: 36px; padding: 0 12px; font-size: 13px; }
.btn.danger { color: #9B1C12; }
.btn.link { border: 0; background: none; color: var(--accent); padding: 0 4px; min-height: 32px; text-decoration: underline; }
.btn.link.danger { color: #9B1C12; }
.actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
form.inline { display: inline; }

.grid-form { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; align-items: end; }
.grid-form .span2 { grid-column: span 2; }
@media (max-width: 480px) { .grid-form .span2 { grid-column: auto; } }
.fld { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--muted); }
.fld input, .fld select, .fld textarea, .search input {
  font: inherit; font-size: 14px; color: var(--ink); min-height: 44px; border: 1px solid var(--input-line);
  border-radius: 8px; padding: 0 12px; background: #fff; width: 100%;
}
.fld textarea { padding: 10px 12px; min-height: 88px; resize: vertical; }
.fld input[type=file] { padding: 9px 12px; }
.fld .err { color: #9B1C12; font-size: 12px; }
.fld.has-err input, .fld.has-err select { border-color: #C2382B; }
.check { display: flex; align-items: center; gap: 8px; min-height: 44px; font-size: 14px; color: var(--ink); }
.check input { width: 20px; height: 20px; accent-color: var(--accent); }
.form-section { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); grid-column: 1 / -1; margin-top: 8px; }
.search { display: flex; align-items: center; gap: 8px; background: #fff; border: 1px solid var(--input-line); border-radius: 8px; padding: 0 12px; min-height: 44px; min-width: min(280px, 100%); }
.search input { border: 0; padding: 0; min-height: 40px; outline: 0; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { display: inline-flex; align-items: center; min-height: 36px; padding: 0 14px; border-radius: 999px; font-size: 13px; font-weight: 500; text-decoration: none; background: #E6E9E5; color: #46504B; }
.chip:hover { background: #DADFD9; color: var(--ink); }
.chip.on { background: var(--ink); color: #fff; }

details.drop > summary { list-style: none; cursor: pointer; }
details.drop > summary::-webkit-details-marker { display: none; }
details.drop[open] > summary { margin-bottom: 14px; }
.panel { background: var(--soft); border-radius: 10px; padding: 16px; }
td.acts { white-space: nowrap; text-align: right; width: 1%; }
dialog.modal { text-align: left; white-space: normal; border: 0; border-radius: 14px; padding: 24px; width: min(520px, calc(100vw - 32px)); box-shadow: 0 20px 50px rgba(23, 32, 28, .25); color: var(--ink); }
dialog.modal::backdrop { background: rgba(23, 32, 28, .45); }

.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 16px; }
.login { width: 100%; max-width: 380px; display: flex; flex-direction: column; gap: 16px; padding: 28px; }

/* Telefon: menu jako vodorovný pruh nahoře, ne celá obrazovka */
@media (max-width: 640px) {
  .side { padding: 12px; gap: 10px; }
  .nav { flex-direction: row; overflow-x: auto; gap: 4px; }
  .nav a { white-space: nowrap; flex-shrink: 0; padding: 8px 12px; }
  .nav a .grow { flex-grow: 0; }
  .side-user { margin-top: 0; padding-top: 8px; }
}
