/* MINOX Fleet — mobile-first responsive CSS
   Breakpoints: 430 | 768 | 1024 | 1280 | 1920
   ------------------------------------------------- */
/* Inter font se učitava lokalno preko fonts/inter.css (vidi base.html) */

*, *::before, *::after { box-sizing: border-box; }

/* ===== Custom Properties ===== */
:root {
  /* Brand */
  --navy:        #2e3192;
  --navy-2:      #23255f;
  --navy-3:      #3a3eaa;
  --navy-soft:   #e0e7ff;
  --red:         #dc2626;
  --red-soft:    #fee2e2;

  /* Backgrounds */
  --bg:          #eef0f4;
  --bg-2:        #e6e9ef;
  --panel:       #ffffff;
  --panel-2:     #f5f6ff;

  /* Text */
  --text:        #1f2430;
  --text-2:      #33384a;
  --muted:       #6b7280;
  --border:      #e7e8ee;
  --border-strong:#d9dbe3;

  /* Status */
  --ok:          #15803d;
  --ok-soft:     #dcfce7;
  --warn:        #b45309;
  --warn-soft:   #fef3c7;
  --err:         #b91c1c;
  --err-soft:    #fee2e2;
  --info:        #3730a3;
  --info-soft:   #e0e7ff;

  /* Aliases */
  --accent:      var(--navy);
  --accent-soft: var(--navy-soft);

  /* Shadows */
  --shadow-sm: 0 1px 2px rgba(35,37,95,.05);
  --shadow-md: 0 2px 12px rgba(35,37,95,.08);
  --shadow-lg: 0 8px 24px rgba(35,37,95,.12);

  /* Radii */
  --radius-sm: 4px;
  --radius:    8px;
  --radius-lg: 12px;

  /* Spacing scale (rem) */
  --sp-1: 0.25rem;
  --sp-2: 0.5rem;
  --sp-3: 0.75rem;
  --sp-4: 1rem;
  --sp-5: 1.25rem;
  --sp-6: 1.5rem;

  /* Safe-area insets (iPhone notch / Dynamic Island) */
  --sat: env(safe-area-inset-top,    0px);
  --sab: env(safe-area-inset-bottom, 0px);
  --sal: env(safe-area-inset-left,   0px);
  --sar: env(safe-area-inset-right,  0px);

  /* Sidebar */
  --sidebar-w: 240px;
}

/* ===== Base ===== */
html { -webkit-text-size-adjust: 100%; }
html, body {
  margin: 0; padding: 0;
  background: var(--bg); color: var(--text);
  font: clamp(14px, 1.5vw, 16px)/1.55 'Inter', system-ui, -apple-system, "Segoe UI", sans-serif;
  font-feature-settings: 'cv11','ss01';
  -webkit-font-smoothing: antialiased;
}
img { max-width: 100%; height: auto; display: block; }
a  { color: var(--navy); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ===== Layout — MOBILE FIRST ===== */
.app { display: flex; flex-direction: column; min-height: 100dvh; }

/* Sidebar — hidden off-screen on mobile */
.sidebar {
  position: fixed; top: 0; left: 0;
  width: min(var(--sidebar-w), 85vw);
  height: 100dvh;
  padding: calc(var(--sat) + 0px) 0.75rem calc(var(--sab) + 1rem);
  background: var(--navy-2);
  transform: translateX(-110%);
  transition: transform 240ms cubic-bezier(.4,0,.2,1);
  z-index: 200;
  overflow-y: auto;
  overscroll-behavior: contain;
}
.sidebar.open { transform: translateX(0); box-shadow: 4px 0 32px rgba(0,0,0,.35); }

.sidebar-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,.45);
  z-index: 199;
  backdrop-filter: blur(2px);
}
.sidebar-overlay.open { display: block; }

/* Logo in sidebar */
.logo {
  display: block;
  padding: 0.75rem 0.875rem 1.25rem;
  background: #fff;
  margin: calc(-1 * var(--sat) - 0px) -0.75rem 0.875rem;
}
.logo img { width: 100%; max-width: 160px; height: auto; }

/* Nav */
.cat {
  font-size: 0.625rem; text-transform: uppercase;
  color: #7d80b8; padding: 0.875rem 0.875rem 0.375rem;
  letter-spacing: 1.2px; font-weight: 700;
}
nav { display: flex; flex-direction: column; gap: 1px; }
.nav-item {
  display: flex; align-items: center;
  padding: 0.5rem 0.875rem;
  color: #c5c8e8; border-radius: 6px;
  font-size: 0.8125rem; font-weight: 500;
  transition: background 120ms, color 120ms;
  border-left: 3px solid transparent; margin-left: -3px;
  min-height: 2.5rem;
}
.nav-item:hover { background: rgba(255,255,255,.07); color: #fff; text-decoration: none; }
.nav-ic { width: 1rem; height: 1rem; margin-right: 0.5625rem; vertical-align: -3px; flex-shrink: 0; opacity: .7; }
.nav-item.active .nav-ic, .nav-item:hover .nav-ic { opacity: 1; }
.nav-item.active { background: rgba(255,255,255,.12); color: #fff; border-left-color: #fff; font-weight: 600; }

/* Main */
.main { display: flex; flex-direction: column; min-width: 0; flex: 1; }

/* Topbar */
.topbar {
  display: flex; align-items: center; gap: 0.75rem;
  padding: calc(var(--sat) + 0.75rem) calc(var(--sar) + 1rem) 0.75rem calc(var(--sal) + 1rem);
  border-bottom: 1px solid var(--border);
  background: var(--panel);
  position: sticky; top: 0; z-index: 5;
}
.topbar h1 {
  font-size: clamp(1rem, 3.5vw, 1.25rem);
  margin: 0; font-weight: 700; color: var(--navy);
  letter-spacing: -0.2px; flex: 1; min-width: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.tb-right { display: flex; align-items: center; gap: 0.875rem; flex-shrink: 0; }
.user { color: var(--muted); font-size: 0.8125rem; font-weight: 500;
        display: none; } /* hidden on mobile */

/* Burger */
.burger {
  display: inline-flex; align-items: center; justify-content: center;
  width: 2.25rem; height: 2.25rem; flex-shrink: 0;
  border: 1px solid var(--border); border-radius: 6px;
  background: var(--panel); cursor: pointer;
  font-size: 1.125rem; color: var(--text);
  transition: background 120ms;
}
.burger:hover { background: var(--bg-2); }

/* Content */
.content {
  padding: 0.875rem calc(var(--sar) + 0.875rem) calc(var(--sab) + 1.5rem) calc(var(--sal) + 0.875rem);
  flex: 1;
}

/* ===== Tablet+ (≥768px) ===== */
@media (min-width: 768px) {
  .app { flex-direction: row; }
  .sidebar {
    position: sticky; top: 0;
    transform: translateX(0) !important;
    height: 100dvh;
    flex-shrink: 0;
    padding: 1.125rem 0.75rem;
  }
  .sidebar-overlay { display: none !important; }
  .burger { display: none; }
  .user { display: block; }
  .main { min-width: 0; flex: 1; }
  .topbar { padding: 1rem 1.75rem; }
  .content { padding: 1.5rem 1.75rem; max-width: 1500px; }
}

/* ===== Desktop (≥1280px) ===== */
@media (min-width: 1280px) {
  .content { padding: 1.75rem 2rem; }
}

/* ===== Large desktop (≥1920px) ===== */
@media (min-width: 1920px) {
  :root { --sidebar-w: 280px; }
  .content { max-width: 1800px; padding: 2rem 2.25rem; }
}

/* ===== Cards ===== */
.card {
  background: var(--panel); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 1rem;
  margin-bottom: 1rem; box-shadow: var(--shadow-sm);
}
@media (min-width: 768px) { .card { padding: 1.375rem; } }

.card h2 { margin: 0 0 0.875rem; font-size: clamp(0.9375rem, 2vw, 1rem); font-weight: 700; color: var(--navy); }
.card h3 {
  margin: 0 0 0.75rem;
  font-size: 0.6875rem; font-weight: 700; color: var(--muted);
  text-transform: uppercase; letter-spacing: 1px;
}
.row { display: flex; gap: 1rem; flex-wrap: wrap; }
.row > * { flex: 1; min-width: min(100%, 280px); }

/* Form section titles */
.card > h3, form.card h3 {
  font-size: clamp(0.875rem, 2vw, 0.9375rem); font-weight: 700; color: var(--navy);
  letter-spacing: -0.1px; text-transform: none;
  padding-bottom: 0.625rem; margin-bottom: 1rem;
  border-bottom: 2px solid var(--navy-soft);
}
.card > h3.mt-2, form.card h3.mt-2 { margin-top: 1.75rem; }

/* ===== KPI tiles ===== */
.kpis {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.625rem; margin-bottom: 1rem;
}
@media (min-width: 430px)  { .kpis { grid-template-columns: repeat(3, 1fr); } }
@media (min-width: 768px)  { .kpis { grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 0.875rem; } }
@media (min-width: 1280px) { .kpis { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); } }

.kpi {
  background: var(--panel); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 0.875rem 1rem;
  box-shadow: var(--shadow-sm); transition: box-shadow 120ms;
}
.kpi:hover { box-shadow: var(--shadow-md); }
.kpi .num {
  font-size: clamp(1.375rem, 4vw, 1.875rem);
  font-weight: 700; color: var(--navy); line-height: 1.05;
  letter-spacing: -0.5px; font-variant-numeric: tabular-nums;
}
.kpi .lab {
  font-size: 0.6875rem; color: var(--muted); text-transform: uppercase;
  letter-spacing: 0.8px; margin-top: 0.5rem; font-weight: 600;
}

/* ===== Tables ===== */
.table-wrap {
  overflow-x: auto; border: 1px solid var(--border);
  border-radius: var(--radius-lg); background: var(--panel);
  -webkit-overflow-scrolling: touch;
}
table { width: 100%; border-collapse: collapse; table-layout: auto; }
th, td {
  padding: 0.6875rem 0.875rem; text-align: left;
  font-size: 0.8125rem; border-bottom: 1px solid var(--border);
  max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
th {
  background: var(--panel-2); color: var(--muted); font-weight: 700;
  font-size: 0.65625rem; text-transform: uppercase; letter-spacing: 1px;
}
tbody tr:hover { background: var(--bg-2); }
tbody tr:last-child td { border-bottom: 0; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
td a { color: var(--navy); font-weight: 500; }
td.text-right, td:has(.actions), td:has(.actions-compact) {
  overflow: visible; white-space: nowrap; max-width: none;
}

/* ===== Buttons ===== */
.btn, .btn-small, .btn-primary, .btn-danger {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 0.5625rem 1rem; border-radius: var(--radius);
  cursor: pointer; border: 1px solid var(--border); background: var(--panel);
  color: var(--text); font-size: 0.8125rem; text-decoration: none; font-weight: 600;
  font-family: inherit; transition: all 120ms; white-space: nowrap; gap: 0.375rem;
  min-height: 2.25rem;
}
.btn:hover, .btn-small:hover {
  background: var(--bg-2); border-color: var(--border-strong);
  text-decoration: none; color: var(--navy);
}
.btn-small { padding: 0.375rem 0.75rem; font-size: 0.75rem; min-height: 1.875rem; }
.btn-primary {
  background: var(--navy); border-color: var(--navy); color: #fff;
  box-shadow: 0 1px 2px rgba(26,42,78,.2);
}
.btn-primary:hover { background: var(--navy-2); border-color: var(--navy-2); color: #fff; box-shadow: 0 2px 6px rgba(26,42,78,.3); }
.btn-danger { background: #fff; border-color: #f0c6c6; color: var(--red); }
.btn-danger:hover { background: var(--red-soft); border-color: var(--red); color: var(--red); }

/* ===== Forms ===== */
.form-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.875rem;
}
@media (min-width: 430px) {
  .form-grid { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
}
.form-grid > * { min-width: 0; }
.fld { display: flex; flex-direction: column; gap: 0.375rem; min-width: 0; }
.fld label {
  font-size: 0.6875rem; text-transform: uppercase; color: var(--muted);
  letter-spacing: 0.6px; font-weight: 700;
  display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap;
}
.inline-link { font-size: 0.6875rem; color: var(--navy); text-transform: none; letter-spacing: 0; font-weight: 600; }
.fld input, .fld select, .fld textarea {
  width: 100%; min-width: 0; max-width: 100%;
  padding: 0.625rem 0.75rem; background: #fff;
  border: 1px solid var(--border); border-radius: var(--radius);
  color: var(--text); font: inherit; font-size: 0.875rem; font-weight: 500;
  transition: border-color 120ms, box-shadow 120ms;
  -webkit-appearance: none; appearance: none;
}
.fld textarea { resize: vertical; min-height: 4.375rem; }
.fld input:focus, .fld select:focus, .fld textarea:focus {
  outline: none; border-color: var(--navy);
  box-shadow: 0 0 0 3px rgba(46,49,146,.12);
}
.fld input:disabled, .fld input[readonly] { background: var(--panel-2); color: var(--muted); }

.prefilled-badge {
  background: var(--ok-soft); color: var(--ok); border: 1px solid #b9e3c7;
  border-radius: 10px; padding: 1px 7px; font-size: 9.5px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.4px;
}
.manual-badge {
  background: var(--warn-soft); color: var(--warn); border: 1px solid #ecd9a3;
  border-radius: 10px; padding: 1px 7px; font-size: 9.5px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.4px;
}
.fld .prefilled {
  background: linear-gradient(0deg,rgba(28,138,74,.04),rgba(28,138,74,.04)),#fff;
  border-color: #b9e3c7;
}
.fld .prefilled:focus { border-color: var(--ok); box-shadow: 0 0 0 3px rgba(28,138,74,.15); }

.form-actions {
  display: flex; gap: 0.625rem; justify-content: flex-end; flex-wrap: wrap;
  margin-top: 1.25rem; padding-top: 1rem; border-top: 1px solid var(--border);
}

/* ===== Chips ===== */
.chip {
  display: inline-block; padding: 2px 0.625rem; border-radius: 12px;
  font-size: 0.6875rem; font-weight: 600; line-height: 1.5;
  background: var(--bg-2); color: var(--text-2); border: 1px solid var(--border);
  white-space: nowrap;
}
.chip.ok  { background: var(--ok-soft);   color: var(--ok);   border-color: #b9e3c7; }
.chip.warn{ background: var(--warn-soft); color: var(--warn); border-color: #ecd9a3; }
.chip.err { background: var(--err-soft);  color: var(--err);  border-color: #f0c6c6; }
.chip.muted { color: var(--muted); }

/* ===== Alerts ===== */
.alert {
  padding: 0.75rem 1.125rem; border-radius: var(--radius);
  margin-bottom: 1rem; border: 1px solid;
  font-size: 0.8125rem; font-weight: 500;
}
.alert-success { background: var(--ok-soft);   border-color: #b9e3c7; color: var(--ok); }
.alert-error   { background: var(--err-soft);  border-color: #f0c6c6; color: var(--err); }
.alert-warning { background: var(--warn-soft); border-color: #ecd9a3; color: var(--warn); }
.alert-info    { background: var(--navy-soft); border-color: #c7d0e6; color: var(--navy); }

/* ===== Toolbar ===== */
.toolbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 0.75rem; margin-bottom: 1rem; flex-wrap: wrap;
}
.toolbar .search { flex: 1; min-width: 0; max-width: 100%; position: relative; }
.toolbar .search input {
  width: 100%; padding: 0.625rem 2rem 0.625rem 0.875rem;
  background: var(--panel); border: 1px solid var(--border);
  border-radius: var(--radius); color: var(--text);
  font: inherit; font-size: 0.875rem; font-weight: 500;
  -webkit-appearance: none; appearance: none;
}
.toolbar .search input:focus { outline: none; border-color: var(--navy); box-shadow: 0 0 0 3px rgba(46,49,146,.12); }
@media (min-width: 768px) { .toolbar .search { max-width: 400px; } }

/* ===== Filter chips ===== */
.filter-chips {
  display: inline-flex; background: var(--panel-2);
  border: 1px solid var(--border); border-radius: 999px; padding: 3px;
  flex-wrap: nowrap; overflow-x: auto; max-width: 100%;
}
.chip-link {
  display: inline-block; padding: 6px 14px; border-radius: 999px;
  color: var(--muted); font-size: 0.75rem; font-weight: 600; text-decoration: none;
  transition: background 120ms, color 120ms; white-space: nowrap;
}
.chip-link:hover { color: var(--text); text-decoration: none; }
.chip-link.active { background: var(--navy); color: #fff; }

/* ===== Login ===== */
.login-wrap {
  display: flex; align-items: center; justify-content: center;
  min-height: 100dvh;
  padding: calc(var(--sat) + 1.5rem) calc(var(--sar) + 1rem) calc(var(--sab) + 1.5rem) calc(var(--sal) + 1rem);
  background:
    radial-gradient(at top right, rgba(196,30,58,.05), transparent 60%),
    radial-gradient(at bottom left, rgba(26,42,78,.08), transparent 50%),
    linear-gradient(135deg, var(--bg) 0%, var(--bg-2) 100%);
}
.login-card {
  background: var(--panel); padding: clamp(1.5rem, 6vw, 2.5rem);
  border-radius: var(--radius-lg); border: 1px solid var(--border);
  width: 100%; max-width: 400px;
  box-shadow: var(--shadow-lg);
}
.login-logo { text-align: center; margin-bottom: 1.75rem; }
.login-logo img { max-width: 200px; height: auto; margin: 0 auto; }
.login-card .fld { margin-bottom: 0.875rem; }
.login-card button { width: 100%; padding: 0.75rem; margin-top: 0.75rem; font-size: 0.9375rem; }

/* ===== Detail header ===== */
.det-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  margin-bottom: 1.375rem; gap: 1rem; flex-wrap: wrap;
}
.det-head h2 { margin: 0; font-size: clamp(1rem, 3vw, 1.125rem); color: var(--navy); }
.det-head .meta { color: var(--muted); font-size: 0.8125rem; margin-top: 4px; display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; }

/* ===== Definition list (karton) ===== */
.dl { display: grid; grid-template-columns: 1fr; gap: 0.5rem 1rem; }
@media (min-width: 430px) { .dl { grid-template-columns: 150px 1fr; } }
.dl dt { color: var(--muted); font-size: 0.75rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.4px; }
.dl dd { margin: 0; font-size: 0.84375rem; font-weight: 500; color: var(--text); }

/* ===== Action buttons in tables ===== */
.actions { display: inline-flex; gap: 0.375rem; align-items: center; flex-wrap: wrap; }

/* ===== Hero section ===== */
.hero {
  background: linear-gradient(135deg, #fff 0%, var(--panel-2) 100%);
  border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: clamp(1rem, 3vw, 1.375rem); margin-bottom: 1.125rem;
  box-shadow: var(--shadow-sm);
  display: flex; align-items: center; gap: clamp(0.875rem, 3vw, 1.375rem); flex-wrap: wrap;
}
.hero-emblem {
  width: clamp(56px, 10vw, 88px); height: clamp(56px, 10vw, 88px);
  border-radius: 16px; display: flex; align-items: center; justify-content: center;
  font-size: clamp(1.25rem, 3vw, 2rem); font-weight: 700; color: #fff; flex-shrink: 0;
  background: linear-gradient(135deg, var(--navy) 0%, var(--navy-3) 100%);
  box-shadow: 0 4px 12px rgba(46,49,146,.25);
}
.hero-emblem.kli { background: linear-gradient(135deg, var(--ok) 0%, #1ca055 100%); box-shadow: 0 4px 12px rgba(21,128,61,.25); }
.hero-info { flex: 1; min-width: 0; }
.hero-title {
  font-size: clamp(1.125rem, 4vw, 1.5rem); font-weight: 700;
  color: var(--text); margin: 0 0 6px; letter-spacing: -0.3px;
  overflow-wrap: break-word;
}
.hero-meta { display: flex; align-items: center; gap: 0.625rem; flex-wrap: wrap; color: var(--muted); font-size: 0.8125rem; }
.hero-actions { display: flex; gap: 0.5rem; flex-shrink: 0; flex-wrap: wrap; width: 100%; }
@media (min-width: 768px) { .hero-actions { width: auto; } }
.reg-badge {
  display: inline-block; padding: 5px 12px; border-radius: 8px;
  background: var(--navy); color: #fff;
  font-family: 'JetBrains Mono', Consolas, monospace;
  font-weight: 700; font-size: clamp(0.75rem, 2vw, 0.875rem); letter-spacing: 1px;
}

/* ===== Brze akcije bar ===== */
.actions-bar h3 { margin-bottom: 0.875rem; }
.actions-bar .flex { flex-wrap: wrap; gap: 0.5rem; }

/* ===== Metarow ===== */
.metarow { display: flex; gap: 0.625rem; flex-wrap: wrap; margin-top: 0.75rem; }
.metarow .mtile {
  background: var(--panel); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 0.5rem 0.875rem;
  font-size: 0.75rem; color: var(--muted);
}
.metarow .mtile strong { color: var(--navy); font-size: 1rem; font-weight: 700; margin-right: 4px; }

/* ===== Compact icon buttons ===== */
.actions-compact { display: inline-flex; gap: 4px; align-items: center; }
.btn-ic {
  display: inline-flex; align-items: center; justify-content: center;
  width: 1.75rem; height: 1.75rem; padding: 0;
  border-radius: 6px; border: 1px solid var(--border); background: var(--panel);
  color: var(--text-2); font-size: 0.875rem; line-height: 1; cursor: pointer;
  text-decoration: none; font-family: inherit; transition: all 120ms;
}
.btn-ic:hover { background: var(--bg-2); border-color: var(--border-strong); color: var(--navy); text-decoration: none; }
.btn-ic-danger { color: var(--err); border-color: #f0c6c6; }
.btn-ic-danger:hover { background: var(--err-soft); border-color: var(--err); color: var(--err); }

/* ===== Reg / Klijent ikonice ===== */
td:has(> .ic.voz), .reg-nw { white-space: nowrap; }
.ic {
  display: inline-flex; align-items: center; justify-content: center;
  width: 1.375rem; height: 1.375rem; margin-right: 0.5rem; vertical-align: -5px;
  border-radius: 5px; color: var(--navy); flex-shrink: 0;
}
.ic.voz { background: var(--accent-soft); color: var(--navy); }
.ic.kli { background: var(--ok-soft);     color: var(--ok);   }
.ic.reg { background: #e0f2fe;             color: #0369a1;     }
.ic.kas { background: #f0fdf4;             color: #15803d;     }
.ic.gum { background: #fef3c7;             color: #b45309;     }
.ic.tro { background: #fce7f3;             color: #9d174d;     }
.ic.ste { background: var(--err-soft);     color: var(--err);  }
.ic svg { width: 0.875rem; height: 0.875rem; }

/* ===== Dashboard alarm cards ===== */
.alarm-card .alarm-scroll {
  max-height: 340px; overflow-y: auto; overflow-x: hidden;
  border: 1px solid var(--border); border-radius: var(--radius-lg);
}
.alarm-card .alarm-scroll table { border: 0; table-layout: fixed; width: 100%; }
.alarm-card .alarm-scroll .table-wrap { border: 0; box-shadow: none; overflow: hidden; }
.alarm-card .alarm-scroll thead th {
  position: sticky; top: 0; z-index: 1;
  background: var(--panel-2); box-shadow: 0 1px 0 var(--border);
}
.alarm-card-footer {
  display: flex; justify-content: space-between; align-items: center;
  margin-top: 0.625rem; padding-top: 0.625rem; border-top: 1px solid var(--border);
}
.alarm-card-footer a { font-size: 0.8125rem; font-weight: 600; color: var(--navy); }
.alarm-card-footer .count { color: var(--muted); font-size: 0.75rem; }

/* ===== Form section title (class) ===== */
.form-section-title {
  font-size: clamp(0.875rem, 2vw, 0.9375rem); font-weight: 700; color: var(--navy);
  padding: 1.125rem 0 0.625rem; margin-top: 0.5rem;
  border-bottom: 2px solid var(--navy-soft); margin-bottom: 1rem;
}
.form-section-title:first-child { padding-top: 0; margin-top: 0; }

.req { color: var(--err); margin-left: 3px; font-size: 0.6875rem; }
.field-error { color: var(--err); font-size: 0.6875rem; margin-top: 4px; font-weight: 500; }

/* ===== Card section header ===== */
.card-section-hdr {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 0.75rem; flex-wrap: wrap; gap: 0.5rem;
}

/* ===== Tabs ===== */
.tab-bar {
  display: flex; gap: 4px; margin-bottom: 1.125rem;
  border-bottom: 2px solid var(--border);
  overflow-x: auto; -webkit-overflow-scrolling: touch;
}
.tab-link {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 0.625rem 1.125rem; font-size: 0.8125rem; font-weight: 600;
  color: var(--muted); text-decoration: none; border-radius: 6px 6px 0 0;
  border: 1px solid transparent; border-bottom: none; margin-bottom: -2px;
  transition: color 120ms, background 120ms; white-space: nowrap;
}
.tab-link:hover { color: var(--navy); text-decoration: none; }
.tab-link.active { color: var(--navy); background: var(--panel); border-color: var(--border); border-bottom-color: var(--panel); }
.tab-badge {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 18px; height: 18px; padding: 0 5px;
  border-radius: 9px; font-size: 0.625rem; font-weight: 700;
}
.tab-badge.warn { background: var(--warn-soft); color: var(--warn); }
.tab-badge.err  { background: var(--err-soft);  color: var(--err);  }

/* ===== Row highlight ===== */
.row-warn td { background: var(--warn-soft) !important; }
.row-err  td { background: var(--err-soft)  !important; }

/* ===== Sortable columns ===== */
th.sortable a { color: var(--muted); text-decoration: none; display: flex; align-items: center; gap: 4px; white-space: nowrap; }
th.sortable a:hover { color: var(--navy); }
th.sortable.sort-asc a, th.sortable.sort-desc a { color: var(--navy); }
.sort-arrow { font-size: 0.625rem; opacity: .5; }
th.sortable.sort-asc .sort-arrow, th.sortable.sort-desc .sort-arrow { opacity: 1; color: var(--navy); }

/* ===== Search X button ===== */
.search-clear {
  position: absolute; right: 10px; top: 50%; transform: translateY(-50%);
  background: none; border: none; cursor: pointer; color: var(--err);
  font-size: 1.125rem; line-height: 1; padding: 2px 4px; display: none; z-index: 2;
}
.search-clear.visible { display: block; }
.toolbar .search input[type="text"] { padding-right: 2rem; }

/* ===== Highlight pretrage ===== */
mark.hl { background: #fef08a; color: var(--text); border-radius: 2px; padding: 0 1px; }

/* ===== Cost accordion ===== */
.cost-group { border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: 6px; overflow: hidden; }
.cost-group-hdr {
  display: flex; align-items: center; gap: 0.625rem; width: 100%;
  padding: 0.6875rem 1rem; background: var(--panel-2); border: none;
  cursor: pointer; text-align: left; font: inherit; color: var(--text); transition: background 120ms;
}
.cost-group-hdr:hover { background: var(--bg-2); }
.cost-group-name  { font-weight: 600; font-size: 0.8125rem; color: var(--navy); flex: 1; min-width: 0; }
.cost-group-count { color: var(--muted); font-size: 0.75rem; white-space: nowrap; }
.cost-group-total { font-weight: 700; font-size: 0.8125rem; font-variant-numeric: tabular-nums; margin-left: auto; white-space: nowrap; }
.cost-group-arrow { color: var(--muted); font-size: 0.6875rem; transition: transform 150ms; margin-left: 0.5rem; flex-shrink: 0; }
.cost-group-hdr.open .cost-group-arrow { transform: rotate(90deg); }
.cost-group-body { display: none; }
.cost-group-body.open { display: block; }

.cost-subgroup { border-top: 1px solid var(--border); }
.cost-subgroup-hdr {
  display: flex; align-items: center; gap: 0.625rem; width: 100%;
  padding: 0.5625rem 1rem 0.5625rem 1.75rem; background: none; border: none;
  cursor: pointer; text-align: left; font: inherit; color: var(--text-2);
  font-size: 0.75rem; transition: background 120ms;
}
.cost-subgroup-hdr:hover { background: var(--bg); }
.cost-subgroup-name  { font-weight: 600; flex: 1; min-width: 0; }
.cost-subgroup-total { font-weight: 700; margin-left: auto; font-variant-numeric: tabular-nums; white-space: nowrap; }
.cost-subgroup-arrow { color: var(--muted); font-size: 0.625rem; transition: transform 150ms; margin-left: 0.375rem; flex-shrink: 0; }
.cost-subgroup-hdr.open .cost-subgroup-arrow { transform: rotate(90deg); }
.cost-subgroup-body { display: none; }
.cost-subgroup-body.open { display: block; }
.cost-subgroup-body .table-wrap { border-radius: 0; border-left: 0; border-right: 0; border-bottom: 0; }

/* ===== Pagination ===== */
.pagination {
  display: flex; justify-content: space-between; align-items: center;
  padding: 0.875rem 0 0.25rem; margin-top: 0.5rem;
  gap: 0.75rem; flex-wrap: wrap;
}
.pagination-info { color: var(--muted); font-size: 0.75rem; font-weight: 600; display: flex; align-items: center; gap: 0.875rem; flex-wrap: wrap; }
.pagination-perpage { display: flex; align-items: center; gap: 0.375rem; }
.pagination-perpage a { color: var(--navy); font-weight: 600; }
.pagination-perpage strong { color: var(--text); }
.pagination-controls { display: flex; align-items: center; gap: 0.5rem; }
.pagination-page { color: var(--text-2); font-size: 0.75rem; font-weight: 600; padding: 0 0.375rem; }
.btn-small.disabled { color: var(--muted); cursor: not-allowed; opacity: .5; }

/* ===== Modal ===== */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(15,29,61,.45);
  display: flex; align-items: center; justify-content: center;
  z-index: 1000;
  padding: max(1rem, calc(var(--sat) + 0.5rem)) max(1rem, calc(var(--sar) + 0.5rem)) max(1rem, calc(var(--sab) + 0.5rem)) max(1rem, calc(var(--sal) + 0.5rem));
  animation: fadeIn 120ms ease;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.modal {
  background: var(--panel); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: clamp(1.125rem, 4vw, 1.75rem);
  width: 100%; max-width: 480px;
  max-height: calc(100dvh - 2rem); overflow-y: auto;
  box-shadow: var(--shadow-lg);
  animation: slideUp 160ms ease;
}
@keyframes slideUp { from { transform: translateY(10px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
.modal h3 { margin: 0 0 1rem; font-size: clamp(0.9375rem, 3vw, 1rem); color: var(--navy); font-weight: 700; text-transform: none; }
.action-modal { max-width: 640px; }
.action-modal-grid { margin-bottom: 0; }
.modal .dl { margin-bottom: 1.25rem; }
.modal-actions { display: flex; gap: 0.5rem; justify-content: flex-end; flex-wrap: wrap; }
@media (max-width: 480px) {
  .action-modal-grid { grid-template-columns: 1fr !important; }
  .modal-actions { justify-content: stretch; }
  .modal-actions .btn { flex: 1; text-align: center; }
}

/* ===== Termin row ===== */
.termin-row { cursor: pointer; }
.termin-row:hover { background: var(--navy-soft) !important; }

/* ===== Prefilled badge ===== */
.prefilled-badge {
  background: var(--ok-soft); color: var(--ok); border: 1px solid #b9e3c7;
  border-radius: 10px; padding: 1px 7px; font-size: 9.5px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .4px;
}

/* ===== Utility ===== */
.text-muted   { color: var(--muted); }
.text-right   { text-align: right; }
.mb-0         { margin-bottom: 0; }
.mt-2         { margin-top: 1.125rem; }
.hidden       { display: none; }
.flex         { display: flex; }
.gap          { gap: 0.625rem; }
.wrap         { white-space: normal !important; max-width: none !important; }

/* ===== Mobile card tables (≤600px) ===== */
@media (max-width: 599px) {
  .table-wrap { border: none; border-radius: 0; background: transparent; overflow-x: visible; }
  .table-wrap table { display: block; min-width: 0 !important; }
  .table-wrap table thead { display: none; }
  .table-wrap table tbody { display: block; }
  .table-wrap table tbody tr {
    display: grid; grid-template-columns: 1fr 1fr;
    margin-bottom: 0.75rem;
    border: 1px solid var(--border); border-radius: var(--radius-lg);
    background: var(--panel); box-shadow: var(--shadow-sm); overflow: hidden;
  }
  .table-wrap table tbody tr:last-child { margin-bottom: 0; }
  .table-wrap table td {
    display: flex; flex-direction: column;
    padding: 0.5625rem 0.75rem; border: none;
    border-bottom: 1px solid var(--border);
    border-right: 1px solid var(--border);
    min-height: 3rem; white-space: normal; overflow: visible; max-width: none;
    font-size: 0.8125rem;
  }
  .table-wrap table td:nth-child(even) { border-right: none; }
  .table-wrap table td:last-child {
    grid-column: span 2; border-right: none; min-height: auto;
    flex-direction: row; align-items: center; gap: 0.375rem; flex-wrap: wrap;
    padding: 0.5rem 0.75rem;
  }
  .table-wrap table td[data-label]::before {
    content: attr(data-label);
    font-weight: 700; color: var(--muted);
    font-size: 0.5625rem; text-transform: uppercase; letter-spacing: 0.5px;
    margin-bottom: 4px; display: block; flex-shrink: 0;
  }
  .table-wrap table td.text-right { text-align: left; }
  /* Kalendar na mobilnom */
  .fc { overflow: hidden; }
  #calendar { overflow: hidden; max-width: 100%; }
}

/* ===== Scrollable tables on small tablets (600-767px) ===== */
@media (min-width: 600px) and (max-width: 767px) {
  .table-wrap { overflow-x: auto; }
  table { min-width: 600px; }
}

/* ===== Sortable heading ===== */
.card h3 + .form-grid, .card h3 + table { margin-top: 0; }

/* ===== Print ===== */
@media print {
  .sidebar, .topbar, .toolbar, .burger, .sidebar-overlay,
  .alert, .form-actions, .pagination, .btn, .btn-primary, .btn-danger, .btn-small,
  .hero-actions, .actions, .actions-compact { display: none !important; }
  .app { display: block; }
  .main { display: block; }
  .content { padding: 0; }
  .card { border: 1px solid #ddd !important; box-shadow: none !important; page-break-inside: avoid; }
  body { background: white; font-size: 10pt; }
  h1, h2, h3 { color: black !important; }
  a { color: black !important; text-decoration: none !important; }
  .hero { background: white !important; border: 2px solid #333 !important; }
  table { font-size: 8.5pt; }
}
