/* ═══════════════════════════════════════════════════════════
   Struktura — Design System
   Direction: refined industrial / operational craft
   ═══════════════════════════════════════════════════════════ */

:root {
  /* Surfaces */
  --bg: #e8ecf0;
  --surface: #ffffff;
  --surface-2: #f5f7f9;
  --ink: #0f1419;
  --ink-soft: #3a4450;
  --muted: #6b7582;
  --line: rgba(15, 20, 25, 0.08);
  --line-strong: rgba(15, 20, 25, 0.14);

  /* Brand — mineral teal + warm metal accent */
  --brand: #1a454c;
  --brand-mid: #246068;
  --brand-soft: rgba(26, 69, 76, 0.08);
  --accent: #c17f3a;
  --accent-soft: rgba(193, 127, 58, 0.12);

  /* Sidebar */
  --sidebar: #0e1419;
  --sidebar-elevated: #151d25;
  --sidebar-text: rgba(255, 255, 255, 0.55);
  --sidebar-text-hover: rgba(255, 255, 255, 0.92);
  --sidebar-active: #ffffff;
  --sidebar-width: 260px;

  /* Semantic */
  --ok: #1f8a65;
  --ok-soft: rgba(31, 138, 101, 0.12);
  --warn: #c17f3a;
  --warn-soft: rgba(193, 127, 58, 0.14);
  --danger: #c4453a;
  --danger-soft: rgba(196, 69, 58, 0.12);
  --info: #2a6f8a;
  --info-soft: rgba(42, 111, 138, 0.12);

  /* Type */
  --font: "Outfit", "Segoe UI", system-ui, sans-serif;
  --font-data: "IBM Plex Sans", "Segoe UI", system-ui, sans-serif;
  --fw-strong: 600;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(15, 20, 25, 0.04), 0 8px 24px rgba(15, 20, 25, 0.04);
  --shadow-lg: 0 12px 40px rgba(15, 20, 25, 0.10);
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

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

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  font-family: var(--font-data);
  font-size: 0.9375rem;
  line-height: 1.55;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

h1, h2, h3, h4, h5, h6,
.page-title,
.sidebar-brand,
.kpi-value,
.brand-mark {
  font-family: var(--font);
  letter-spacing: -0.02em;
}

a {
  color: var(--brand-mid);
  text-decoration: none;
  transition: color 0.2s var(--ease);
}
a:hover {
  color: var(--brand);
}

/* ─── App shell ─────────────────────────────────────────── */

.app-shell {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: var(--sidebar-width);
  flex-shrink: 0;
  background:
    radial-gradient(ellipse 120% 80% at 0% 0%, rgba(36, 96, 104, 0.35), transparent 55%),
    radial-gradient(ellipse 80% 50% at 100% 100%, rgba(193, 127, 58, 0.12), transparent 50%),
    var(--sidebar);
  color: var(--sidebar-text);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  z-index: 100;
  border-right: 1px solid rgba(255, 255, 255, 0.04);
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1.15rem 1.2rem 1rem;
  color: #fff !important;
  text-decoration: none !important;
}

.brand-logo {
  width: auto;
  max-width: 128px;
  max-height: 68px;
  height: auto;
  display: block;
  object-fit: contain;
}

.mobile-brand-logo {
  height: 26px;
  width: auto;
  max-width: 130px;
  object-fit: contain;
}

.brand-mark {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: linear-gradient(145deg, var(--brand-mid), var(--brand));
  display: grid;
  place-items: center;
  font-size: 0.85rem;
  font-weight: 700;
  color: #fff;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.15);
  letter-spacing: 0;
}

.brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.15;
}

.brand-text strong {
  font-size: 1.05rem;
  font-weight: 600;
}

.brand-text span {
  font-size: 0.7rem;
  font-weight: 500;
  color: rgba(255,255,255,0.4);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  font-family: var(--font-data);
}

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 0.5rem 0.75rem 1.5rem;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.15) transparent;
}

.nav-group {
  margin-bottom: 1.25rem;
}

.nav-group-label {
  display: block;
  padding: 0.35rem 0.75rem 0.5rem;
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.28);
  font-family: var(--font-data);
}

.sidebar .nav-link {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.55rem 0.75rem;
  margin-bottom: 2px;
  border-radius: var(--radius-sm);
  color: var(--sidebar-text) !important;
  font-size: 0.875rem;
  font-weight: 500;
  transition: background 0.2s var(--ease), color 0.2s var(--ease), transform 0.2s var(--ease);
  position: relative;
}

.sidebar .nav-link i {
  width: 1.15rem;
  text-align: center;
  font-size: 0.9rem;
  opacity: 0.75;
}

.sidebar .nav-link:hover {
  color: var(--sidebar-text-hover) !important;
  background: rgba(255, 255, 255, 0.06);
}

.sidebar .nav-link.active {
  color: var(--sidebar-active) !important;
  background: rgba(255, 255, 255, 0.1);
}

.sidebar .nav-link.active::before {
  content: "";
  position: absolute;
  left: 0;
  top: 20%;
  bottom: 20%;
  width: 3px;
  border-radius: 0 3px 3px 0;
  background: var(--accent);
}

.sidebar .nav-link.active i {
  opacity: 1;
  color: var(--accent);
}

.sidebar-footer {
  padding: 1rem 0.75rem 1.25rem;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.sidebar-footer .nav-link {
  color: rgba(255, 255, 255, 0.45) !important;
}

.sidebar-footer .nav-link:hover {
  color: #fff !important;
  background: rgba(196, 69, 58, 0.2);
}

/* Main content */
.main-content {
  flex: 1;
  min-width: 0;
  padding: 1.75rem 2rem 3rem;
  animation: contentIn 0.45s var(--ease) both;
}

@keyframes contentIn {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Mobile header */
.mobile-header {
  display: none;
  align-items: center;
  gap: 0.75rem;
  padding: 0.85rem 1rem;
  background: var(--sidebar);
  color: #fff;
  position: sticky;
  top: 0;
  z-index: 90;
}

.mobile-nav-toggle {
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.1);
  color: #fff;
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  display: grid;
  place-items: center;
  cursor: pointer;
}

.mobile-overlay {
  position: fixed;
  inset: 0;
  background: rgba(10, 14, 18, 0.55);
  backdrop-filter: blur(4px);
  z-index: 99;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s var(--ease), visibility 0.3s;
}

.mobile-overlay.show {
  opacity: 1;
  visibility: visible;
}

/* ─── Page chrome ───────────────────────────────────────── */

.page-header {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.75rem;
}

.page-title {
  margin: 0;
  font-size: 1.65rem;
  font-weight: 600;
  color: var(--ink);
  line-height: 1.2;
}

.page-subtitle {
  margin: 0.35rem 0 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.page-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}

/* ─── Cards ─────────────────────────────────────────────── */

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.card.shadow,
.card.shadow-sm {
  box-shadow: var(--shadow) !important;
}

.card-header {
  background: var(--surface) !important;
  border-bottom: 1px solid var(--line) !important;
  padding: 0.95rem 1.15rem !important;
  font-family: var(--font);
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--ink);
}

.card-header h6,
.card-header .text-primary {
  color: var(--ink) !important;
  font-family: var(--font);
  font-weight: 600;
  font-size: 0.95rem;
  margin: 0;
}

.card-body {
  padding: 1.15rem !important;
}

/* Legacy SB-Admin left borders → clean top accent */
.border-left-primary,
.border-left-success,
.border-left-info,
.border-left-warning,
.border-left-danger {
  border: 1px solid var(--line) !important;
  border-top: 3px solid var(--brand) !important;
  border-left: 1px solid var(--line) !important;
}

.border-left-success { border-top-color: var(--ok) !important; }
.border-left-info { border-top-color: var(--info) !important; }
.border-left-warning { border-top-color: var(--warn) !important; }
.border-left-danger { border-top-color: var(--danger) !important; }

/* ─── KPI tiles ─────────────────────────────────────────── */

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.kpi-tile {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.15rem 1.25rem;
  box-shadow: var(--shadow);
  position: relative;
  overflow: hidden;
  transition: transform 0.25s var(--ease), box-shadow 0.25s var(--ease);
}

.kpi-tile:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

.kpi-tile::after {
  content: "";
  position: absolute;
  inset: auto -20% -40% auto;
  width: 120px;
  height: 120px;
  border-radius: 50%;
  background: var(--brand-soft);
  pointer-events: none;
}

.kpi-tile[data-tone="ok"]::after { background: var(--ok-soft); }
.kpi-tile[data-tone="warn"]::after { background: var(--warn-soft); }
.kpi-tile[data-tone="info"]::after { background: var(--info-soft); }
.kpi-tile[data-tone="danger"]::after { background: var(--danger-soft); }

.kpi-label {
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 0.5rem;
  position: relative;
  z-index: 1;
}

.kpi-value {
  font-size: 1.45rem;
  font-weight: 600;
  color: var(--ink);
  line-height: 1.2;
  font-variant-numeric: tabular-nums;
  position: relative;
  z-index: 1;
}

.kpi-meta {
  margin-top: 0.45rem;
  font-size: 0.8rem;
  color: var(--muted);
  position: relative;
  z-index: 1;
}

.kpi-icon {
  position: absolute;
  top: 1rem;
  right: 1rem;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  background: var(--brand-soft);
  color: var(--brand);
  z-index: 1;
  font-size: 0.9rem;
}

.kpi-tile[data-tone="ok"] .kpi-icon { background: var(--ok-soft); color: var(--ok); }
.kpi-tile[data-tone="warn"] .kpi-icon { background: var(--warn-soft); color: var(--warn); }
.kpi-tile[data-tone="info"] .kpi-icon { background: var(--info-soft); color: var(--info); }

/* ─── Buttons ───────────────────────────────────────────── */

.btn {
  font-family: var(--font);
  font-weight: 560;
  border-radius: var(--radius-sm);
  padding: 0.5rem 1rem;
  transition: transform 0.2s var(--ease), box-shadow 0.2s var(--ease), background 0.2s, border-color 0.2s;
}

.btn:hover {
  transform: translateY(-1px);
}

.btn-primary {
  --bs-btn-bg: var(--brand);
  --bs-btn-border-color: var(--brand);
  --bs-btn-hover-bg: var(--brand-mid);
  --bs-btn-hover-border-color: var(--brand-mid);
  --bs-btn-active-bg: var(--brand);
  --bs-btn-active-border-color: var(--brand);
  background: var(--brand);
  border-color: var(--brand);
}

.btn-primary:hover,
.btn-primary:focus {
  background: var(--brand-mid);
  border-color: var(--brand-mid);
}

.btn-accent {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.btn-accent:hover {
  background: #a86c2f;
  border-color: #a86c2f;
  color: #fff;
}

.btn-outline-primary {
  --bs-btn-color: var(--brand);
  --bs-btn-border-color: var(--line-strong);
  --bs-btn-hover-bg: var(--brand-soft);
  --bs-btn-hover-border-color: var(--brand);
  --bs-btn-hover-color: var(--brand);
  color: var(--brand);
  border-color: var(--line-strong);
}

.btn-success {
  --bs-btn-bg: var(--ok);
  --bs-btn-border-color: var(--ok);
  --bs-btn-hover-bg: #187555;
  --bs-btn-hover-border-color: #187555;
}

.btn-danger {
  --bs-btn-bg: var(--danger);
  --bs-btn-border-color: var(--danger);
}

.btn-warning {
  --bs-btn-bg: var(--accent);
  --bs-btn-border-color: var(--accent);
  --bs-btn-color: #fff;
  --bs-btn-hover-color: #fff;
  color: #fff;
}

.btn-info {
  --bs-btn-bg: var(--info);
  --bs-btn-border-color: var(--info);
  --bs-btn-color: #fff;
  color: #fff;
}

.btn-secondary {
  --bs-btn-bg: #4a5560;
  --bs-btn-border-color: #4a5560;
}

.btn-ghost {
  background: transparent;
  border: 1px solid var(--line-strong);
  color: var(--ink-soft);
}

.btn-ghost:hover {
  background: var(--surface-2);
  color: var(--ink);
}

.btn-block {
  display: block;
  width: 100%;
}

.quick-actions {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.65rem;
}

.quick-action {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.9rem 1rem;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  color: var(--ink) !important;
  font-weight: 550;
  font-size: 0.875rem;
  transition: background 0.2s var(--ease), border-color 0.2s, transform 0.2s var(--ease);
}

.quick-action:hover {
  background: var(--brand-soft);
  border-color: rgba(26, 69, 76, 0.2);
  transform: translateY(-1px);
  color: var(--brand) !important;
}

.quick-action i {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: var(--surface);
  color: var(--brand);
  font-size: 0.85rem;
  box-shadow: 0 1px 2px rgba(0,0,0,0.04);
}

/* ─── Tables ────────────────────────────────────────────── */

.table {
  --bs-table-bg: transparent;
  margin-bottom: 0;
  font-size: 0.875rem;
  font-variant-numeric: tabular-nums;
}

.table thead th {
  background: var(--surface-2);
  border-bottom: 1px solid var(--line-strong) !important;
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  padding: 0.75rem 1rem;
  white-space: nowrap;
}

.table td {
  padding: 0.8rem 1rem;
  vertical-align: middle;
  border-color: var(--line) !important;
  color: var(--ink-soft);
}

.table-hover tbody tr:hover {
  background: var(--brand-soft);
}

.table-bordered {
  border-color: var(--line);
}

.table-bordered > :not(caption) > * > * {
  border-color: var(--line);
}

.table-striped > tbody > tr:nth-of-type(odd) > * {
  --bs-table-bg-type: var(--surface-2);
}

/* ─── Forms ─────────────────────────────────────────────── */

.form-control,
.form-select {
  border-radius: var(--radius-sm);
  border-color: var(--line-strong);
  padding: 0.55rem 0.85rem;
  font-size: 0.9rem;
  color: var(--ink);
  background: var(--surface);
  transition: border-color 0.2s, box-shadow 0.2s;
}

.form-control:focus,
.form-select:focus {
  border-color: var(--brand-mid);
  box-shadow: 0 0 0 3px var(--brand-soft);
}

.form-label {
  font-weight: 560;
  color: var(--ink-soft);
  font-size: 0.85rem;
  margin-bottom: 0.35rem;
}

/* ─── Badges ────────────────────────────────────────────── */

.badge {
  font-family: var(--font-data);
  font-weight: 560;
  letter-spacing: 0.02em;
  padding: 0.4em 0.65em;
  border-radius: 6px;
}

.bg-primary { background-color: var(--brand) !important; }
.bg-success { background-color: var(--ok) !important; }
.bg-warning { background-color: var(--warn) !important; color: #fff !important; }
.bg-danger { background-color: var(--danger) !important; }
.bg-info { background-color: var(--info) !important; }

.text-primary { color: var(--brand-mid) !important; }
.text-success { color: var(--ok) !important; }
.text-warning { color: var(--warn) !important; }
.text-danger { color: var(--danger) !important; }
.text-info { color: var(--info) !important; }
.text-gray-800 { color: var(--ink) !important; }
.text-gray-300 { color: #c5cad3 !important; }
.text-xs {
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.05em;
}

/* ─── Alerts ────────────────────────────────────────────── */

.alert {
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  box-shadow: none;
}

.alert-success { background: var(--ok-soft); border-color: transparent; color: var(--ok); }
.alert-danger { background: var(--danger-soft); border-color: transparent; color: var(--danger); }
.alert-warning { background: var(--warn-soft); border-color: transparent; color: #8a5620; }
.alert-info { background: var(--info-soft); border-color: transparent; color: var(--info); }

/* ─── Section panels ────────────────────────────────────── */

.panel-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.25rem;
  margin-bottom: 1.25rem;
}

.section-gap {
  margin-bottom: 1.25rem;
}

.empty-state {
  text-align: center;
  padding: 2rem 1rem;
  color: var(--muted);
}

.empty-state i {
  font-size: 1.75rem;
  margin-bottom: 0.75rem;
  opacity: 0.45;
}

.live-dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--ok);
  margin-right: 0.4rem;
  animation: pulseDot 1.8s ease infinite;
}

.live-dot.is-offline {
  background: var(--danger);
  animation: none;
}

@keyframes pulseDot {
  0%, 100% { opacity: 1; box-shadow: 0 0 0 0 rgba(31, 138, 101, 0.45); }
  50% { opacity: 0.7; box-shadow: 0 0 0 6px rgba(31, 138, 101, 0); }
}

.live-toast-host {
  position: fixed;
  top: 1rem;
  right: 1rem;
  z-index: 1080;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  max-width: min(360px, calc(100vw - 2rem));
  pointer-events: none;
}

.live-toast {
  pointer-events: auto;
  display: flex;
  align-items: flex-start;
  gap: 0.65rem;
  padding: 0.75rem 0.9rem;
  border-radius: var(--radius-sm);
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-lg);
  font-size: 0.875rem;
  color: var(--ink);
  animation: contentIn 0.35s var(--ease) both;
}

.live-toast i { margin-top: 0.15rem; color: var(--brand-mid); }
.live-toast--warn i { color: var(--warn); }
.live-toast--ok i { color: var(--ok); }
.live-toast--info i { color: var(--info); }

.live-toast-close {
  margin-left: auto;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
  padding: 0 0.15rem;
}

.live-flash { animation: liveFlash 0.7s ease; }
@keyframes liveFlash {
  0% { background: rgba(36, 96, 104, 0.18); }
  100% { background: transparent; }
}
[data-live-kpi] { transition: background 0.3s ease; border-radius: 4px; }

/* Legacy helpers kept for old templates */
.font-weight-bold { font-weight: 600 !important; }

.table .btn-group .btn {
  padding: 0.35rem 0.55rem;
}

.progress {
  height: 8px;
  border-radius: 999px;
  background: var(--surface-2);
}

.progress-bar {
  border-radius: 999px;
}

.form-check-input:checked {
  background-color: var(--brand);
  border-color: var(--brand);
}

.modal-content {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
}

.modal-header {
  border-bottom-color: var(--line);
  font-family: var(--font);
}

.modal-footer {
  border-top-color: var(--line);
}

/* ─── Motion / micro-interactions ───────────────────────── */

@media (prefers-reduced-motion: no-preference) {
  .main-content > .page-header,
  .main-content > .card,
  .main-content > .kpi-grid,
  .main-content > .panel-grid,
  .main-content > .struktura-tabs {
    animation: riseIn 0.45s var(--ease) both;
  }

  .main-content > .card:nth-child(2),
  .main-content > .kpi-grid { animation-delay: 0.04s; }
  .main-content > .card:nth-child(3),
  .main-content > .panel-grid { animation-delay: 0.08s; }
  .main-content > .card:nth-child(4) { animation-delay: 0.12s; }
  .main-content > .card:nth-child(5) { animation-delay: 0.16s; }

  .kpi-grid .kpi-tile {
    animation: riseIn 0.4s var(--ease) both;
  }
  .kpi-grid .kpi-tile:nth-child(1) { animation-delay: 0.05s; }
  .kpi-grid .kpi-tile:nth-child(2) { animation-delay: 0.09s; }
  .kpi-grid .kpi-tile:nth-child(3) { animation-delay: 0.13s; }
  .kpi-grid .kpi-tile:nth-child(4) { animation-delay: 0.17s; }

  .mobile-list .mobile-item {
    animation: riseIn 0.35s var(--ease) both;
  }
  .mobile-list .mobile-item:nth-child(1) { animation-delay: 0.03s; }
  .mobile-list .mobile-item:nth-child(2) { animation-delay: 0.06s; }
  .mobile-list .mobile-item:nth-child(3) { animation-delay: 0.09s; }
  .mobile-list .mobile-item:nth-child(4) { animation-delay: 0.12s; }
  .mobile-list .mobile-item:nth-child(5) { animation-delay: 0.15s; }
  .mobile-list .mobile-item:nth-child(6) { animation-delay: 0.18s; }
  .mobile-list .mobile-item:nth-child(7) { animation-delay: 0.21s; }
  .mobile-list .mobile-item:nth-child(8) { animation-delay: 0.24s; }

  .sidebar .nav-link {
    transition: background 0.2s var(--ease), color 0.2s var(--ease), transform 0.2s var(--ease), padding-left 0.2s var(--ease);
  }
  .sidebar .nav-link:hover {
    padding-left: 0.95rem;
  }
  .sidebar .nav-link.active::before {
    animation: accentIn 0.35s var(--ease) both;
  }

  .struktura-tabs .nav-link {
    transition: background 0.25s var(--ease), color 0.25s var(--ease), transform 0.2s var(--ease);
  }
  .struktura-tabs .nav-link:active {
    transform: scale(0.97);
  }

  .btn {
    transition: transform 0.2s var(--ease), box-shadow 0.2s var(--ease), background 0.2s, border-color 0.2s, color 0.2s;
  }

  .table tbody tr {
    transition: background 0.18s var(--ease);
  }

  .alert {
    animation: riseIn 0.35s var(--ease) both;
  }
}

@keyframes riseIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes accentIn {
  from {
    opacity: 0;
    transform: scaleY(0.4);
  }
  to {
    opacity: 1;
    transform: scaleY(1);
  }
}

.stock-status-ok { color: var(--ok); }
.stock-status-low { color: var(--warn); }
.stock-status-out { color: var(--danger); }

/* ─── Mobile list cards ─────────────────────────────────── */

.data-desktop {
  display: block;
}

.data-mobile {
  display: none;
}

.mobile-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  padding: 0.85rem;
}

.mobile-item {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1rem 1.05rem;
  box-shadow: var(--shadow);
  transition: transform 0.2s var(--ease), box-shadow 0.2s var(--ease);
}

.mobile-item:active {
  transform: scale(0.99);
}

.mobile-item-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.65rem;
}

.mobile-item-title {
  font-family: var(--font);
  font-weight: 600;
  font-size: 0.98rem;
  color: var(--ink);
  line-height: 1.25;
  margin: 0;
}

.mobile-item-meta {
  font-size: 0.8rem;
  color: var(--muted);
  margin-top: 0.2rem;
}

.mobile-item-rows {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.55rem 0.75rem;
  margin-bottom: 0.85rem;
}

.mobile-item-rows .full {
  grid-column: 1 / -1;
}

.mobile-kv-label {
  display: block;
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 0.15rem;
}

.mobile-kv-value {
  font-size: 0.88rem;
  color: var(--ink-soft);
  font-variant-numeric: tabular-nums;
}

.mobile-item-actions {
  display: flex;
  gap: 0.45rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--line);
}

.mobile-item-actions .btn {
  flex: 1;
}

.row-actions {
  display: inline-flex;
  gap: 0.3rem;
}

.row-actions .btn {
  padding: 0.35rem 0.55rem;
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--ink-soft);
}

.row-actions .btn:hover {
  background: var(--brand-soft);
  color: var(--brand);
  border-color: transparent;
}

.row-actions .btn-danger-soft:hover,
.row-actions .btn.text-danger:hover {
  background: var(--danger-soft);
  color: var(--danger) !important;
}

/* Filter collapse on small screens */
.filter-card .card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  user-select: none;
}

.filter-toggle {
  border: none;
  background: transparent;
  color: var(--muted);
  padding: 0.25rem;
}

/* Project detail tabs */
.struktura-tabs {
  display: flex;
  gap: 0.35rem;
  padding: 0.35rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  margin-bottom: 1.25rem;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.struktura-tabs .nav-link {
  border: none !important;
  border-radius: var(--radius-sm) !important;
  color: var(--muted) !important;
  font-family: var(--font);
  font-weight: 560;
  font-size: 0.875rem;
  padding: 0.6rem 1rem !important;
  white-space: nowrap;
  background: transparent !important;
}

.struktura-tabs .nav-link:hover {
  color: var(--ink) !important;
  background: var(--surface-2) !important;
}

.struktura-tabs .nav-link.active {
  color: #fff !important;
  background: var(--brand) !important;
}

.detail-meta {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1rem;
}

.detail-meta-item label {
  display: block;
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 0.25rem;
}

.detail-meta-item strong {
  font-family: var(--font);
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}

/* Stacked line-item forms (receiving / giving / orders) */
.line-form-table th,
.line-form-table td {
  vertical-align: middle;
}

@media (max-width: 768px) {
  .line-form-table thead {
    display: none;
  }

  .line-form-table,
  .line-form-table tbody,
  .line-form-table tr,
  .line-form-table td {
    display: block;
    width: 100%;
  }

  .line-form-table tr {
    background: var(--surface-2);
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    padding: 0.85rem;
    margin-bottom: 0.75rem;
  }

  .line-form-table td {
    border: none !important;
    padding: 0.35rem 0 !important;
  }

  .line-form-table td::before {
    content: attr(data-label);
    display: block;
    font-size: 0.65rem;
    font-weight: 600;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: var(--muted);
    margin-bottom: 0.2rem;
  }

  .line-form-table tfoot tr {
    background: transparent;
    border: none;
    padding: 0.5rem 0;
  }

  .line-form-table tfoot td::before {
    display: none;
  }
}

/* ─── Responsive ────────────────────────────────────────── */

@media (max-width: 1200px) {
  .kpi-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .kpi-grid[style*="repeat(5"] {
    grid-template-columns: repeat(2, 1fr) !important;
  }
}

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

@media (max-width: 768px) {
  .mobile-header {
    display: flex;
  }

  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    transform: translateX(-105%);
    transition: transform 0.35s var(--ease);
    box-shadow: var(--shadow-lg);
  }

  .sidebar.show {
    transform: translateX(0);
  }

  .main-content {
    padding: 1rem 1rem 2.5rem;
  }

  .page-title {
    font-size: 1.35rem;
  }

  .kpi-grid {
    grid-template-columns: 1fr;
  }

  .quick-actions {
    grid-template-columns: 1fr;
  }

  .form-control,
  .form-select {
    font-size: 16px; /* iOS zoom prevent */
  }

  .data-desktop {
    display: none !important;
  }

  .data-mobile {
    display: block !important;
  }

  .detail-meta {
    grid-template-columns: 1fr;
  }

  .filter-card .collapse:not(.show) {
    display: none;
  }

  .table th,
  .table td {
    white-space: nowrap;
  }
}

@media (max-width: 576px) {
  .page-header {
    flex-direction: column;
  }

  .page-actions {
    width: 100%;
  }

  .page-actions .btn {
    flex: 1;
  }
}

@media print {
  .sidebar,
  .mobile-header,
  .mobile-overlay,
  .page-actions,
  .btn {
    display: none !important;
  }

  .main-content {
    padding: 0 !important;
  }

  .card {
    box-shadow: none !important;
    break-inside: avoid;
  }
}

/* Pagination */
.pagination-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  padding: 0.85rem 1rem;
  border-top: 1px solid var(--line);
  background: color-mix(in srgb, var(--surface) 92%, var(--bg));
}

.pagination-meta {
  font-size: 0.85rem;
  color: var(--muted);
}

.pagination-bar .pagination {
  gap: 0.2rem;
}

.pagination-bar .page-link {
  border-radius: var(--radius-sm);
  border-color: var(--line);
  color: var(--text);
  background: var(--surface);
  min-width: 2.1rem;
  text-align: center;
  padding: 0.35rem 0.55rem;
}

.pagination-bar .page-item.active .page-link {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
}

.pagination-bar .page-item.disabled .page-link {
  opacity: 0.45;
}
