:root {
  --font-primary: "Montserrat", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-secondary: "Barlow", system-ui, -apple-system, "Segoe UI", sans-serif;
  --bg: #0f1420;
  --panel: #1a2233;
  --panel-hover: #202b41;
  --border: #2b3550;
  --muted: #9aa4b8;
  --text: #e8ecf4;
  --accent: #3b82f6;
  --accent-hover: #2563eb;
  --accent-soft: rgba(59, 130, 246, 0.12);
  --green: #34d399;
  --red: #f87171;
  --radius: 10px;
  --transition: 0.15s ease;
}

* { box-sizing: border-box; }

.hidden { display: none; }

body {
  margin: 0;
  font-family: var(--font-secondary);
  background: var(--bg);
  color: var(--text);
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  position: relative;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  background:
    linear-gradient(180deg, rgba(15, 20, 32, 0.88), rgba(15, 20, 32, 0.93)),
    url("/img/background/bg.png") center / cover no-repeat fixed;
  z-index: -1;
}

.login-body {
  height: 100vh;
  height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.login-card {
  position: relative;
  background: var(--panel);
  padding: 2.8rem 2.5rem 2.5rem;
  border-radius: 20px;
  width: 340px;
  max-width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  border: 1px solid var(--border);
  box-shadow: 0 30px 70px rgba(0, 0, 0, 0.55);
  overflow: hidden;
}

.login-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--accent), #a78bfa, var(--accent));
}

.login-logo { height: 46px; margin-bottom: 0.4rem; }

.login-card h1 { margin: 0; font-size: 1.3rem; font-family: var(--font-primary); text-align: center; }
.subtitle { margin: 0 0 0.5rem; color: var(--muted); font-size: 0.9rem; text-align: center; }

.login-card label { width: 100%; }

.login-card button[type="submit"] { width: 100%; margin-top: 0.4rem; }

label { display: flex; flex-direction: column; gap: 0.4rem; font-size: 0.9rem; }

input {
  padding: 0.65rem 0.8rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-size: 1rem;
  transition: border-color var(--transition), box-shadow var(--transition);
}

input:hover { border-color: #3a4568; }

input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

button {
  padding: 0.7rem 1.1rem;
  border-radius: var(--radius);
  border: none;
  background: var(--accent);
  color: white;
  font-family: var(--font-primary);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: background var(--transition), transform var(--transition), box-shadow var(--transition);
}

button:hover { background: var(--accent-hover); box-shadow: 0 6px 16px rgba(59, 130, 246, 0.28); }
button:active { transform: translateY(1px); box-shadow: none; }

.error { color: var(--red); min-height: 1.2em; font-size: 0.85rem; margin: 0; }

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.7rem 2rem;
  background: linear-gradient(180deg, var(--panel-hover), var(--panel));
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.25);
  gap: 0.8rem;
  position: sticky;
  top: 0;
  z-index: 10;
}

.topbar::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 2px;
  background: linear-gradient(90deg, var(--accent), transparent 70%);
  opacity: 0.7;
}

.topbar-logo-link {
  display: block;
  border-radius: var(--radius);
  transition: opacity var(--transition), transform var(--transition);
}
.topbar-logo-link:hover { opacity: 0.85; transform: scale(1.03); }
.topbar-logo-link:active { transform: scale(0.98); }

.topbar-logo { height: 44px; display: block; }

.topbar-right { display: flex; align-items: center; gap: 1rem; }

.status {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-size: 0.85rem;
  color: var(--muted);
  background: rgba(15, 20, 32, 0.5);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.4rem 0.9rem 0.4rem 0.7rem;
}

.topbar-divider {
  width: 1px;
  height: 22px;
  background: var(--border);
}

.topbar-right button {
  padding: 0.5rem 1.1rem;
  font-size: 0.85rem;
  font-weight: 500;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
}

.topbar-right button:hover {
  background: var(--border);
  box-shadow: none;
}

.dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--red);
  display: inline-block;
  transition: background var(--transition);
  box-shadow: 0 0 0 3px rgba(248, 113, 113, 0.18);
}
.dot.connected { background: var(--green); box-shadow: 0 0 0 3px rgba(52, 211, 153, 0.18); }

.app-layout {
  display: flex;
  flex: 1;
  align-items: stretch;
  min-height: 0;
}

.sidebar {
  width: 160px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  background: linear-gradient(180deg, var(--panel-hover), var(--panel));
  border-right: 1px solid var(--border);
  box-shadow: 6px 0 24px rgba(0, 0, 0, 0.18);
  padding: 1.5rem 1rem;
  position: relative;
  z-index: 5;
}

.sidebar::after {
  content: "";
  position: absolute;
  top: 0;
  right: -1px;
  bottom: 0;
  width: 2px;
  background: linear-gradient(180deg, var(--accent), transparent 55%);
  opacity: 0.55;
}

.nav-link {
  position: relative;
  color: var(--muted);
  text-decoration: none;
  padding: 0.65rem 0.9rem;
  border-radius: var(--radius);
  font-family: var(--font-primary);
  font-size: 0.9rem;
  font-weight: 500;
  transition: background var(--transition), color var(--transition), transform var(--transition);
}

.nav-link::before {
  content: "";
  position: absolute;
  left: -1rem;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 0;
  border-radius: 0 4px 4px 0;
  background: white;
  transition: height var(--transition);
}

.nav-link:hover { background: var(--bg); color: var(--text); transform: translateX(3px); }

.nav-link.active {
  background: var(--accent);
  color: white;
  box-shadow: 0 6px 16px rgba(59, 130, 246, 0.28);
}

.nav-link.active::before { height: 55%; }

.nav-link-home {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  margin-bottom: 0.5rem;
  background: linear-gradient(135deg, var(--accent), #a78bfa);
  color: white;
  box-shadow: 0 8px 22px rgba(59, 130, 246, 0.38);
}

.nav-link-home::before { display: none; }

.nav-link-home:hover {
  background: linear-gradient(135deg, var(--accent-hover), #9061f9);
  color: white;
  transform: translateX(3px) scale(1.02);
  box-shadow: 0 10px 26px rgba(59, 130, 246, 0.48);
}

.nav-link-home.active {
  box-shadow: 0 10px 28px rgba(59, 130, 246, 0.55);
}

.nav-icon { flex-shrink: 0; }

.sidebar-divider {
  height: 1px;
  background: var(--border);
  margin: 0.5rem 0.3rem;
}

#dividerNalozi { margin-top: auto; }

.content { flex: 1; padding: 2rem; min-width: 0; overflow-y: auto; overflow-x: hidden; position: relative; }

.scroll-top-btn {
  position: fixed;
  right: 1.8rem;
  bottom: 1.8rem;
  width: 44px;
  height: 44px;
  padding: 0;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  line-height: 1;
  opacity: 0;
  pointer-events: none;
  transform: translateY(10px);
  transition: opacity var(--transition), transform var(--transition);
  z-index: 20;
}

.scroll-top-btn.visible {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

.page-title { font-family: var(--font-primary); font-size: 1.3rem; margin: 0 0 1.5rem; }

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

.channels { margin-bottom: 1.5rem; }

.section-title {
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--muted);
  margin: 0 0 0.8rem;
}

.stat-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 1.1rem 1.3rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  transition: transform var(--transition), border-color var(--transition), box-shadow var(--transition);
}

.stat-card:hover {
  transform: translateY(-2px);
  border-color: #3a4568;
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.25);
}

.stat-label { font-size: 0.8rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.03em; }
.stat-value { font-family: var(--font-primary); font-size: 1.5rem; font-weight: 600; }
.stat-value.stat-online { color: var(--green); }
.stat-value.stat-offline { color: var(--red); }

.tabs {
  display: flex;
  gap: 0.4rem;
  margin-bottom: 1rem;
}

.tab {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--border);
  padding: 0.5rem 1.1rem;
  font-family: var(--font-primary);
  font-size: 0.85rem;
  font-weight: 500;
  border-radius: 999px;
}

.tab:hover { background: var(--panel-hover); color: var(--text); box-shadow: none; }

.tab.active {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
  box-shadow: 0 6px 16px rgba(59, 130, 246, 0.28);
}

#subTabs {
  margin-bottom: 1.4rem;
  padding-bottom: 1.2rem;
  border-bottom: 1px solid var(--border);
}

#subTabs .tab {
  padding: 0.6rem 1.4rem;
  font-size: 0.9rem;
  border-radius: var(--radius);
}

.tab-online {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
}

.date-range {
  display: flex;
  align-items: flex-end;
  gap: 0.8rem;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}

.date-range input[type="date"] { min-width: 150px; }

.date-range button { padding: 0.6rem 1.1rem; font-size: 0.85rem; }

.btn-secondary {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
}
.btn-secondary:hover { background: var(--border); box-shadow: none; }

.toolbar {
  margin-bottom: 1rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}

.toolbar #searchInput {
  width: 100%;
  max-width: 320px;
}

.snapshot-note {
  font-size: 0.85rem;
  color: var(--muted);
  font-style: italic;
}
.snapshot-note.hidden { display: none; }

.table-wrap {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  overflow-x: auto;
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.18);
}

table { width: 100%; border-collapse: collapse; }

th, td {
  text-align: left;
  padding: 0.8rem 1rem;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

th {
  color: var(--muted);
  font-weight: 500;
  font-size: 0.85rem;
  text-transform: uppercase;
  position: sticky;
  top: 0;
  background: var(--panel);
}

th[data-sort] { cursor: pointer; user-select: none; transition: color var(--transition); }
th[data-sort]:hover { color: var(--text); }
th.sort-asc::after { content: " ▲"; font-size: 0.7em; }
th.sort-desc::after { content: " ▼"; font-size: 0.7em; }

tbody tr.main-row { cursor: pointer; transition: background 0.15s; }
tbody tr.main-row:hover { background: var(--accent-soft); }

tr.main-row.flash { animation: flash 1s ease-out; }

@keyframes flash {
  from { background: rgba(59, 130, 246, 0.35); }
  to { background: transparent; }
}

.saldo-pos { color: var(--green); }
.saldo-neg { color: var(--red); }

.col-expand { width: 2rem; }

.chevron {
  display: inline-block;
  color: var(--muted);
  transition: transform 0.15s;
}
.chevron.open { transform: rotate(90deg); }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.25rem 0.6rem;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 500;
}

.badge-dot { width: 7px; height: 7px; border-radius: 50%; }

.badge-compact { padding: 0.1rem 0.4rem; font-size: 0.68rem; white-space: nowrap; }

.badge-online { background: rgba(52, 211, 153, 0.12); color: var(--green); }
.badge-online .badge-dot { background: var(--green); }

.badge-offline { background: rgba(248, 113, 113, 0.12); color: var(--red); }
.badge-offline .badge-dot { background: var(--red); }

.badge-betting { background: var(--accent-soft); color: var(--accent); }
.badge-casino { background: rgba(167, 139, 250, 0.14); color: #a78bfa; }

.evona-section { margin-bottom: 1.5rem; }
.evona-section .section-title { margin-bottom: 0.8rem; }

#terminalTable tbody tr[data-terminal-id] { cursor: pointer; transition: background var(--transition); }
#terminalTable tbody tr[data-terminal-id]:hover { background: var(--accent-soft); }

.terminal-online-row { background: rgba(167, 139, 250, 0.06); }
.terminal-online-row .naziv { color: #a78bfa; }

.terminal-divider td { padding: 0; height: 0; border-bottom: 2px solid var(--border); }

#ticketTable tbody tr[data-ticket-id] { cursor: pointer; transition: background var(--transition); }
#ticketTable tbody tr[data-ticket-id]:hover { background: var(--accent-soft); }

#ticketTable th, #ticketTable td { padding: 0.5rem 0.6rem; font-size: 0.78rem; }
#ticketTable th { font-size: 0.68rem; }

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(6, 9, 16, 0.72);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  z-index: 50;
}
.modal-overlay.hidden { display: none; }

.modal {
  position: relative;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 1.8rem;
  width: 100%;
  max-width: 540px;
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.5);
}

.modal .summary { grid-template-columns: repeat(2, 1fr); margin-bottom: 0; }

.modal-wide { max-width: 780px; }

.modal-receipt {
  max-width: 400px;
  background: #fbfaf7;
  color: #1a1a1a;
  padding: 1.7rem 1.5rem 1.4rem;
}
.modal-receipt .modal-close { border-color: #e2ded4; color: #9a9488; }
.modal-receipt .modal-close:hover { background: #efece4; color: #1a1a1a; box-shadow: none; }

.receipt-header { text-align: center; margin-bottom: 1rem; }
.receipt-logo-chip {
  display: inline-block;
  background: linear-gradient(180deg, var(--panel-hover), var(--panel));
  border-radius: 10px;
  padding: 0.6rem 1rem;
  margin-bottom: 0.6rem;
}
.receipt-logo { height: 32px; display: block; }
.receipt-id { font-family: var(--font-secondary); font-size: 0.82rem; letter-spacing: 0.5px; color: #55503f; }

.receipt-bets { border-top: 1px dashed #cfc9ba; }
.receipt-bet { padding: 0.6rem 0; border-bottom: 1px dashed #cfc9ba; }
.receipt-bet-match { font-weight: 700; font-size: 0.86rem; color: #16140f; margin-bottom: 0.2rem; }
.receipt-bet-code { color: #8c8672; font-weight: 700; margin-right: 0.4rem; }
.receipt-bet-row { display: flex; justify-content: space-between; align-items: baseline; gap: 0.6rem; font-size: 0.82rem; }
.receipt-bet-type { color: #7c8c5a; }
.receipt-bet-pick { font-weight: 700; color: #16140f; white-space: nowrap; }
.receipt-bet-pick.won { color: #16a34a; }
.receipt-bet-pick.lost { color: #dc2626; }

.receipt-footer { margin-top: 0.9rem; padding-top: 0.8rem; border-top: 1px solid #26241d; }
.receipt-line { display: flex; justify-content: space-between; font-size: 0.85rem; padding: 0.18rem 0; color: #3a3626; }
.receipt-line.strong { font-weight: 700; color: #16140f; }

.receipt-status-badge {
  padding: 0.18rem 0.6rem;
  border-radius: 999px;
  font-weight: 700;
  font-size: 0.78rem;
}
.receipt-status-badge.won { background: rgba(22, 163, 74, 0.14); color: #16a34a; }
.receipt-status-badge.lost { background: rgba(220, 38, 38, 0.14); color: #dc2626; }
.receipt-status-badge.neutral { background: rgba(58, 54, 38, 0.1); color: #55503f; }

.receipt-date { text-align: center; margin-top: 0.8rem; font-size: 0.78rem; color: #8c8672; }
.receipt-note { text-align: center; font-size: 0.85rem; color: #7c7767; padding: 0.8rem 0; }

.modal-close {
  position: absolute;
  top: 1rem;
  right: 1rem;
  width: 32px;
  height: 32px;
  padding: 0;
  border-radius: 50%;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--muted);
  font-size: 1.1rem;
  line-height: 1;
}
.modal-close:hover { background: var(--border); color: var(--text); box-shadow: none; }

.modal-subtitle { color: var(--muted); font-size: 0.85rem; margin: 0 0 1.4rem; }

.modal .section-title { margin: 1.6rem 0 0.8rem; }

.chart-svg text { font-family: var(--font-secondary); }

.ticket-search {
  display: flex;
  align-items: flex-end;
  gap: 0.8rem;
  margin-bottom: 1.2rem;
  flex-wrap: wrap;
}

.ticket-search input[type="text"] { min-width: 200px; }
.ticket-search input[type="date"] { min-width: 150px; }

.ticket-search select {
  padding: 0.6rem 0.7rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-size: 1rem;
}

.badge-neutral { background: rgba(154, 164, 184, 0.14); color: var(--muted); }

.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  margin-top: 1.2rem;
}

.pagination button {
  padding: 0.5rem 1rem;
  font-size: 0.85rem;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
}
.pagination button:hover { background: var(--border); box-shadow: none; }
.pagination button:disabled { opacity: 0.4; cursor: not-allowed; }
.pagination button:disabled:hover { background: transparent; }

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

#terminalTable th,
#terminalTable td {
  padding: 0.6rem 0.7rem;
  font-size: 0.85rem;
}

#terminalTable th:last-child,
#terminalTable td:last-child {
  position: sticky;
  right: 0;
  background: var(--panel);
  box-shadow: -8px 0 12px -6px rgba(0, 0, 0, 0.35);
}

.detail-row td { padding: 0; border-bottom: 1px solid var(--border); }
.detail-row.hidden { display: none; }

.detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 0.9rem;
  padding: 1rem 1.5rem 1.2rem 3rem;
  background: rgba(15, 20, 32, 0.5);
  white-space: normal;
}

.detail-item { display: flex; flex-direction: column; gap: 0.25rem; }
.detail-label { font-size: 0.72rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.02em; }
.detail-value { font-size: 0.95rem; font-weight: 500; }

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

.hero-total {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 0.5rem;
  background: linear-gradient(180deg, var(--panel-hover), var(--panel));
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 2.2rem 1.5rem;
  margin-bottom: 1.8rem;
  box-shadow: 0 20px 45px rgba(0, 0, 0, 0.3);
}

.hero-value { font-size: 2.6rem; }

.hero-eur { color: var(--muted); font-size: 1.05rem; }

.source-card {
  text-decoration: none;
  color: inherit;
  position: relative;
}

.source-card-empty { opacity: 0.6; }
.source-card-empty:hover { opacity: 0.85; }

.source-note {
  font-size: 0.75rem;
  color: var(--muted);
  font-style: italic;
}

.placeholder-page {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 0.5rem;
  min-height: 50vh;
  color: var(--muted);
}

.placeholder-page h2 {
  font-family: var(--font-primary);
  color: var(--text);
  font-size: 1.2rem;
  margin: 0;
}

@media (max-width: 720px) {
  .summary { grid-template-columns: repeat(2, 1fr); }
  .content { padding: 1rem; }

  .topbar { padding: 0.6rem 1rem; }
  .topbar-logo { height: 34px; }

  .app-layout { flex-direction: column; }
  .sidebar {
    width: 100%;
    flex-direction: row;
    align-items: center;
    border-right: none;
    border-bottom: 1px solid var(--border);
    box-shadow: 0 6px 24px rgba(0, 0, 0, 0.18);
    padding: 0.8rem 1rem;
  }
  .sidebar::after {
    top: auto;
    right: 0;
    left: 0;
    bottom: -1px;
    width: auto;
    height: 2px;
    background: linear-gradient(90deg, var(--accent), transparent 55%);
  }
  .nav-link::before { display: none; }
  .sidebar-divider { width: 1px; height: 22px; margin: 0 0.4rem; }
  #dividerNalozi { margin-top: 0; margin-left: auto; }

  .topbar { flex-wrap: wrap; row-gap: 0.5rem; }
  .modal { padding: 1.4rem; }
  .modal .summary { grid-template-columns: repeat(2, 1fr); gap: 0.7rem; }
  .pagination { flex-wrap: wrap; }
}

@media (max-width: 480px) {
  .page-title { font-size: 1.15rem; margin-bottom: 1.1rem; }

  .topbar { padding: 0.5rem 0.8rem; gap: 0.5rem; }
  .topbar-logo { height: 28px; }
  .status span:not(.dot) { display: none; }
  .status { padding: 0.4rem; gap: 0; }
  .topbar-right { gap: 0.6rem; }
  .topbar-right button { padding: 0.45rem 0.7rem; font-size: 0.8rem; }

  .sidebar { padding: 0.6rem 0.7rem; gap: 0.1rem; }
  .nav-link { padding: 0.5rem 0.6rem; font-size: 0.82rem; }

  .login-card { padding: 2rem 1.4rem 1.6rem; gap: 0.8rem; }

  .summary { grid-template-columns: repeat(2, 1fr); gap: 0.7rem; }
  .stat-card { padding: 0.85rem 1rem; }
  .stat-value { font-size: 1.25rem; }

  .tabs { gap: 0.3rem; }
  .tab { padding: 0.45rem 0.85rem; font-size: 0.8rem; }
  #subTabs .tab { padding: 0.5rem 1rem; }

  .date-range, .ticket-search { gap: 0.6rem; }
  .date-range input[type="date"] { min-width: 130px; }
  .ticket-search input[type="text"] { min-width: 140px; }
  .ticket-search input[type="date"] { min-width: 130px; }

  th, td { padding: 0.6rem 0.7rem; font-size: 0.85rem; }
  #terminalTable th, #terminalTable td { padding: 0.5rem 0.6rem; font-size: 0.8rem; }

  .modal { padding: 1.1rem; border-radius: 12px; }
  .modal .summary { grid-template-columns: 1fr 1fr; }
  .modal-overlay { padding: 0.8rem; }

  .pagination { gap: 0.6rem; }
  .pagination span { width: 100%; text-align: center; order: -1; }

  .scroll-top-btn { right: 1rem; bottom: 1rem; width: 40px; height: 40px; }
}

/* Mobilni prikaz tabela kao kartica — svaki red postaje kartica sa
   "Oznaka: vrednost" parovima umesto horizontalnog skrolovanja. Oznake
   dolaze iz data-label atributa koje public/js/mobile-tables.js automatski
   upisuje na svaku <td> na osnovu naslova kolone iz <thead>. */
@media (max-width: 640px) {
  .table-wrap { overflow-x: visible; box-shadow: none; background: transparent; border: none; }

  .table-wrap table thead { display: none; }

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

  .table-wrap table tr {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 0.7rem;
    padding: 0.2rem 0.9rem;
  }

  .table-wrap table tr.terminal-online-row { background: rgba(167, 139, 250, 0.06); }

  .table-wrap table tr.terminal-divider { background: none; border: none; margin: 0.4rem 0; padding: 0; }
  .table-wrap table tr.terminal-divider td { padding: 0; height: 2px; border-bottom: 2px solid var(--border); }

  .table-wrap table tr.detail-row { background: transparent; border: none; padding: 0; margin: -0.5rem 0 0.7rem; }
  .table-wrap table tr.detail-row td { display: block; text-align: left; padding: 0; border-bottom: none; }
  .table-wrap table tr.detail-row td::before { content: none; }

  .table-wrap table td {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.8rem;
    padding: 0.55rem 0;
    border-bottom: 1px solid var(--border);
    text-align: right;
    white-space: normal;
    font-size: 0.85rem;
  }
  .table-wrap table td:last-child { border-bottom: none; }

  .table-wrap table td::before {
    content: attr(data-label);
    font-weight: 600;
    color: var(--muted);
    text-align: left;
    flex-shrink: 0;
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.3px;
  }
  .table-wrap table td:not([data-label])::before { content: none; }

  .table-wrap table td.col-expand { display: none; }

  .table-wrap table td.empty-state {
    justify-content: center;
    border-bottom: none;
    padding: 1rem 0;
  }
  .table-wrap table td.empty-state::before { content: none; }

  .table-wrap table td.naziv { font-weight: 700; }
}
