:root {
  --navy-950: #081a2b;
  --navy-900: #10263f;
  --navy-800: #173856;
  --blue-600: #1769aa;
  --blue-100: #e8f2fb;
  --bg: #f2f5f8;
  --surface: #ffffff;
  --surface-soft: #f8fafc;
  --ink: #132033;
  --muted: #607086;
  --subtle: #8996a7;
  --border: #dce3ea;
  --border-strong: #c8d2dd;
  --red: #c23b34;
  --red-soft: #fbeceb;
  --amber: #d47a12;
  --amber-soft: #fff4df;
  --green: #16835b;
  --green-soft: #e8f6f0;
  --purple: #7357a8;
  --shadow-sm: 0 1px 2px rgba(13, 31, 50, .06), 0 2px 8px rgba(13, 31, 50, .04);
  --shadow-md: 0 12px 32px rgba(13, 31, 50, .12);
  --radius: 14px;
  --header-h: 104px;
}

* { box-sizing: border-box; }
html { min-width: 320px; background: var(--bg); scroll-behavior: smooth; }
body { margin: 0; min-height: 100vh; font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; color: var(--ink); background: var(--bg); line-height: 1.45; -webkit-font-smoothing: antialiased; }
button, input, select { font: inherit; }
button { color: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
a { color: inherit; text-decoration: none; }
h1, h2, h3, h4, p { margin-top: 0; }
h1 { margin-bottom: .45rem; font-size: clamp(1.55rem, 2.3vw, 2.15rem); line-height: 1.12; letter-spacing: -.025em; }
h2 { margin-bottom: .35rem; font-size: 1.12rem; line-height: 1.25; letter-spacing: -.012em; }
h3 { font-size: 1rem; }
small { color: var(--muted); }
.hidden { display: none !important; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; clip: rect(0, 0, 0, 0); white-space: nowrap; overflow: hidden; }
.mobile-only { display: none !important; }

/* Core controls */
.btn, .icon-btn, .primary-nav button, .segmented button, .drawer-tabs button { min-height: 42px; border: 0; border-radius: 9px; background: transparent; cursor: pointer; transition: background .16s ease, border-color .16s ease, color .16s ease, transform .16s ease; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .45rem; padding: .62rem .9rem; border: 1px solid transparent; font-weight: 650; font-size: .88rem; }
.btn:hover, .icon-btn:hover { transform: translateY(-1px); }
.btn--primary { color: #fff; background: var(--blue-600); border-color: var(--blue-600); }
.btn--primary:hover { background: #0f5a94; }
.btn--ghost { color: var(--navy-800); background: #fff; border-color: var(--border-strong); }
.btn--ghost:hover { background: var(--surface-soft); border-color: #9eacbb; }
.btn--header { min-height: 42px; color: #e7eff7; border-color: rgba(255,255,255,.2); background: rgba(255,255,255,.08); }
.btn--header:hover { background: rgba(255,255,255,.14); }
.btn--full { width: 100%; }
.btn--small { min-height: 42px; padding: .45rem .7rem; }
.icon-btn { display: inline-grid; place-items: center; min-width: 42px; padding: 0; font-size: 1.25rem; }
.eyebrow { margin: 0 0 .3rem; color: var(--blue-600); font-size: .7rem; line-height: 1.2; font-weight: 800; letter-spacing: .11em; text-transform: uppercase; }

/* Login */
.login-overlay { position: fixed; inset: 0; z-index: 1000; display: grid; place-items: center; padding: 24px; color: #fff; background: radial-gradient(circle at 12% 15%, #244f73 0, var(--navy-900) 34%, var(--navy-950) 100%); }
.login-shell { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(330px, .75fr); width: min(940px, 100%); overflow: hidden; border: 1px solid rgba(255,255,255,.12); border-radius: 24px; box-shadow: 0 28px 80px rgba(0,0,0,.28); background: rgba(255,255,255,.04); backdrop-filter: blur(12px); }
.login-intro { padding: clamp(36px, 7vw, 72px); }
.login-intro h1 { max-width: 520px; margin-top: 3.5rem; font-size: clamp(2rem, 4vw, 3.55rem); }
.login-intro > p { max-width: 520px; color: #c5d4e1; font-size: 1.05rem; }
.login-facts { display: grid; gap: .65rem; margin: 2rem 0 0; padding: 0; list-style: none; color: #dbe6ef; }
.login-facts li::before { content: "✓"; display: inline-grid; place-items: center; width: 22px; height: 22px; margin-right: .65rem; border-radius: 50%; color: #a6ead0; background: rgba(50, 190, 135, .14); font-weight: 800; }
.login-card { align-self: stretch; padding: clamp(34px, 5vw, 58px); color: var(--ink); background: #fff; }
.login-card h2 { margin-bottom: 1.6rem; font-size: 1.65rem; }
.login-card form { display: grid; gap: .55rem; }
.login-card label { margin-top: .45rem; color: var(--muted); font-size: .8rem; font-weight: 700; }
.login-card input { width: 100%; height: 48px; padding: 0 .8rem; border: 1px solid var(--border-strong); border-radius: 10px; color: var(--ink); background: #fff; outline: none; }
.login-card input:focus { border-color: var(--blue-600); box-shadow: 0 0 0 3px rgba(23,105,170,.13); }
.login-card .btn { margin-top: .8rem; }
.login-error { min-height: 1.3rem; margin-top: .4rem; color: var(--red); font-size: .82rem; }
.brand-lockup { display: inline-flex; align-items: center; gap: .55rem; white-space: nowrap; font-size: 1.08rem; font-weight: 800; letter-spacing: -.015em; }
.brand-lockup--light { color: #fff; }
.brand-mark { display: inline-grid; place-items: center; width: 30px; height: 30px; border-radius: 9px; color: #ffd365; background: rgba(255,255,255,.1); }

/* App shell */
.app-header { position: sticky; top: 0; z-index: 100; color: #fff; background: var(--navy-900); box-shadow: 0 2px 14px rgba(7,24,40,.2); }
.header-main { display: flex; align-items: center; min-height: 60px; max-width: 1520px; margin: 0 auto; padding: 0 28px; gap: 1.2rem; }
.header-main .brand-lockup { margin-right: .6rem; }
.live-badge { display: inline-flex; align-items: center; gap: .45rem; padding: .35rem .55rem; border-radius: 999px; color: #dbe7f1; background: rgba(255,255,255,.07); font-size: .75rem; white-space: nowrap; }
.live-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 3px rgba(46,204,146,.14); }
.live-badge.stale .live-dot { background: var(--amber); }
.header-actions { display: flex; align-items: center; gap: .65rem; margin-left: auto; }
.user-badge { max-width: 160px; overflow: hidden; color: #c8d6e2; font-size: .78rem; text-overflow: ellipsis; white-space: nowrap; }
.header-actions .icon-btn { min-height: 42px; min-width: 42px; color: #dbe7f1; border: 1px solid rgba(255,255,255,.16); }
.filter-count { display: inline-grid; place-items: center; min-width: 20px; height: 20px; padding: 0 5px; border-radius: 999px; color: var(--navy-900); background: #ffd365; font-size: .7rem; }
.primary-nav { display: flex; max-width: 1520px; min-height: 44px; margin: 0 auto; padding: 0 28px; gap: .15rem; overflow-x: auto; scrollbar-width: none; }
.primary-nav::-webkit-scrollbar { display: none; }
.primary-nav button { position: relative; min-height: 44px; padding: 0 .9rem; color: #aebfce; border-radius: 0; font-size: .84rem; font-weight: 650; white-space: nowrap; }
.primary-nav button:hover { color: #fff; background: rgba(255,255,255,.05); }
.primary-nav button.active { color: #fff; }
.primary-nav button.active::after { content: ""; position: absolute; right: .9rem; bottom: 0; left: .9rem; height: 3px; border-radius: 3px 3px 0 0; background: #5cb7ee; }

/* Filter drawer */
.filter-backdrop { position: fixed; inset: 0; z-index: 200; background: rgba(8,26,43,.42); backdrop-filter: blur(2px); }
.filter-panel { position: fixed; top: 0; right: 0; bottom: 0; z-index: 210; display: flex; flex-direction: column; width: min(430px, 100vw); transform: translateX(105%); color: var(--ink); background: #fff; box-shadow: var(--shadow-md); transition: transform .22s ease; }
.filter-panel.open { transform: translateX(0); }
.filter-head { display: flex; align-items: center; justify-content: space-between; min-height: 80px; padding: 20px 24px; border-bottom: 1px solid var(--border); }
.filter-head h2 { margin: 0; font-size: 1.35rem; }
.filter-body { flex: 1; overflow-y: auto; padding: 6px 24px 24px; }
.filter-section { display: grid; gap: .75rem; margin: 0; padding: 22px 0; border: 0; border-bottom: 1px solid var(--border); }
.filter-section legend { padding: 0; color: var(--ink); font-size: .88rem; font-weight: 800; }
.filter-section label { display: grid; gap: .35rem; color: var(--muted); font-size: .76rem; font-weight: 700; }
.filter-section input, .filter-section select, .timeline-toolbar select, .custom-period input { width: 100%; min-height: 42px; padding: .55rem .65rem; border: 1px solid var(--border-strong); border-radius: 9px; color: var(--ink); background: #fff; outline: none; }
.filter-section input:focus, .filter-section select:focus, .timeline-toolbar select:focus { border-color: var(--blue-600); box-shadow: 0 0 0 3px rgba(23,105,170,.12); }
.filter-section select[multiple] { min-height: 112px; }
.form-grid { display: grid; gap: .7rem; }
.form-grid--2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.check-row { display: flex !important; grid-column: 1 / -1; align-items: center; gap: .55rem !important; color: var(--ink) !important; }
.check-row input { width: 18px; min-height: 18px; }
.filter-actions { display: flex; justify-content: space-between; padding: 16px 24px max(16px, env(safe-area-inset-bottom)); border-top: 1px solid var(--border); background: #fff; }

/* Layout */
.main-content { max-width: 1520px; margin: 0 auto; padding: 24px 28px 56px; }
.tab-content { display: none; }
.tab-content.active { display: block; animation: tab-in .18s ease; }
@keyframes tab-in { from { opacity: .65; transform: translateY(2px); } to { opacity: 1; transform: none; } }
.page-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 1.2rem; margin: 4px 0 18px; }
.page-heading > div:first-child { min-width: 0; }
.page-heading p:not(.eyebrow) { max-width: 850px; margin: 0; color: var(--muted); font-size: .9rem; }
.coverage-badge { align-self: center; padding: .65rem .8rem; border: 1px solid var(--border); border-radius: 10px; color: var(--muted); background: rgba(255,255,255,.65); font-size: .78rem; text-align: right; white-space: nowrap; }
.surface { min-width: 0; margin-bottom: 18px; padding: 20px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow-sm); }
.surface-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; margin-bottom: 14px; }
.surface-head h2 { margin-bottom: 0; }
.section-note { max-width: 820px; margin: .35rem 0 0; color: var(--muted); font-size: .82rem; }

/* KPI */
.kpi-row { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-bottom: 18px; }
.kpi-card { position: relative; min-height: 112px; overflow: hidden; padding: 18px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow-sm); }
.kpi-card::before { content: ""; position: absolute; top: 0; bottom: 0; left: 0; width: 4px; background: var(--kpi-color, var(--blue-600)); }
.kpi-value { margin-top: .2rem; font-size: clamp(1.55rem, 2.5vw, 2.2rem); line-height: 1; font-weight: 800; letter-spacing: -.035em; }
.kpi-label { margin-bottom: .55rem; color: var(--muted); font-size: .78rem; font-weight: 700; }
.kpi-detail { margin-top: .65rem; color: var(--subtle); font-size: .72rem; }

/* Timeline */
.timeline-workspace { padding: 0; overflow: hidden; }
.timeline-head { align-items: center; margin: 0; padding: 20px 20px 16px; border-bottom: 1px solid var(--border); }
.timeline-toolbar { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: .55rem; }
.timeline-toolbar select { width: auto; min-width: 120px; min-height: 42px; padding: .45rem .6rem; font-size: .78rem; }
.segmented { display: inline-flex; padding: 3px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface-soft); }
.segmented button { min-height: 42px; padding: .35rem .65rem; border-radius: 7px; color: var(--muted); font-size: .75rem; font-weight: 700; }
.segmented button:hover { color: var(--ink); }
.segmented button.active { color: #fff; background: var(--navy-800); box-shadow: 0 1px 3px rgba(0,0,0,.15); }
.custom-period { display: flex; align-items: center; gap: .5rem; padding: 12px 20px; border-bottom: 1px solid var(--border); background: var(--surface-soft); }
.custom-period input { width: auto; min-height: 42px; }
.chart-caption { display: flex; align-items: baseline; gap: .75rem; padding: 14px 20px 0; }
.chart-caption strong { font-size: .84rem; }
.chart-caption span { color: var(--muted); font-size: .74rem; }
.chart-tools { display: flex; align-items: center; justify-content: flex-end; gap: .45rem; padding: 8px 20px 0; }
.chart-tools > span { margin-right: auto; color: var(--muted); font-size: .72rem; }
.chart-box { width: 100%; }
.chart-box--overview { min-height: 190px; padding: 0 8px; transition: height .12s ease; }
.episode-focus { display: grid; grid-template-columns: 42px minmax(0, 1fr) 42px; align-items: center; gap: 10px; margin: 0 20px; padding: 13px 0 8px; border-top: 1px solid var(--border); }
.episode-focus .icon-btn { color: var(--navy-800); border: 1px solid var(--border); background: var(--surface-soft); }
.episode-summary { min-width: 0; text-align: center; }
.episode-summary strong { display: block; font-size: .95rem; }
.episode-summary span { display: block; margin-top: .2rem; color: var(--muted); font-size: .76rem; }
.chart-box--detail { height: 260px; padding: 0 8px 4px; }
.tl-legend { display: flex; flex-wrap: wrap; gap: 1.1rem; padding: 10px 20px 18px; border-top: 1px solid var(--border); color: var(--muted); font-size: .73rem; }
.lg-item { display: inline-flex; align-items: center; gap: .42rem; }
.lg-swatch { display: inline-block; width: 22px; height: 10px; border-radius: 3px; }
.lg-swatch.power { background: var(--red); }
.lg-swatch.unc { border: 1px dashed #8a98a8; background: rgba(138,152,168,.12); }
.lg-swatch.network { background: repeating-linear-gradient(135deg, #e7a247 0 4px, #fff2dc 4px 8px); }
.lg-swatch.context { background: #77879a; }
.empty-state { margin: 16px 20px; padding: 24px; border: 1px dashed var(--border-strong); border-radius: 10px; color: var(--muted); background: var(--surface-soft); text-align: center; }
.ptl-list { display: none; }
.admin-only-ctl { display: none; }
body.role-admin .admin-only-ctl { display: block; }

.ring-history { margin: 0 20px 20px; padding: 18px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface-soft); }
.ring-history-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; }
.ring-history-head h3 { margin: 0; font-size: 1.05rem; }
.ring-history-head p:not(.eyebrow) { margin: .3rem 0 0; color: var(--muted); font-size: .78rem; }
.ring-history-status { min-height: 1.25rem; margin: .6rem 0; color: var(--muted); font-size: .76rem; }
.ring-history-cy { min-height: 390px; border: 1px solid var(--border); border-radius: 10px; background: #fff; }
.ring-time-slider-label { display: none; margin: .8rem 0; color: var(--muted); font-size: .74rem; }
.ring-time-slider-label input { width: 100%; min-height: 42px; }
.ring-history-legend { display: flex; flex-wrap: wrap; gap: 1rem; padding-top: 10px; color: var(--muted); font-size: .72rem; }
.ring-history-legend span { display: inline-flex; align-items: center; gap: .35rem; }
.ring-dot { width: 12px; height: 12px; border-radius: 50%; background: #8896a5; }
.ring-dot--up { background: var(--green); }
.ring-dot--down { background: var(--red); }
.ring-line { width: 22px; height: 3px; background: #98a4b0; }
.ring-line--down { background: var(--red); }

/* Summary charts and recent events */
.dashboard-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.chart-panel { margin: 0; padding-bottom: 12px; }
.summary-chart { height: 270px; }
.recent-section { margin-top: 18px; }
.recent-list { display: grid; gap: 0; }
.recent-row { display: grid; grid-template-columns: 170px 110px minmax(0, 1fr) 110px 36px; align-items: center; min-height: 58px; gap: 1rem; border-top: 1px solid var(--border); cursor: pointer; }
.recent-row:first-child { border-top: 0; }
.recent-row:hover { background: var(--surface-soft); }
.recent-time { color: var(--muted); font-size: .76rem; font-variant-numeric: tabular-nums; }
.recent-ross { font-weight: 800; }
.recent-context { min-width: 0; overflow: hidden; color: var(--muted); font-size: .78rem; text-overflow: ellipsis; white-space: nowrap; }
.recent-duration { color: var(--ink); font-size: .8rem; font-weight: 750; text-align: right; }
.recent-arrow { color: var(--blue-600); font-size: 1.1rem; }

/* Evidence table */
.evidencija-wrap { overflow: hidden; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow-sm); }
.evidencija-table { width: 100%; border-collapse: collapse; font-size: .78rem; }
.evidencija-table th { padding: .75rem .85rem; color: var(--muted); background: var(--surface-soft); border-bottom: 1px solid var(--border); font-size: .7rem; letter-spacing: .04em; text-align: left; text-transform: uppercase; }
.evidencija-table td { padding: .78rem .85rem; border-bottom: 1px solid var(--border); vertical-align: middle; }
.evidencija-table tbody tr:last-child td { border-bottom: 0; }
.ev-row { cursor: pointer; }
.ev-row:hover { background: #f7fafc; }
.ev-row small { font-size: .66rem; }
.conf-pill, .status-pill { display: inline-flex; align-items: center; min-height: 24px; padding: .16rem .45rem; border-radius: 999px; color: #fff; font-size: .66rem; font-weight: 750; white-space: nowrap; }
.det-btn { min-width: 42px; min-height: 42px; border: 1px solid var(--border); border-radius: 8px; color: var(--blue-600); background: #fff; cursor: pointer; }
.ev-card { margin-bottom: 10px; padding: 16px; border: 1px solid var(--border); border-left: 4px solid var(--red); border-radius: 12px; background: #fff; box-shadow: var(--shadow-sm); cursor: pointer; }
.ev-card-title { margin-bottom: 12px; font-weight: 800; }
.ev-card-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin: 0 0 12px; }
.ev-card-grid div { min-width: 0; }
.ev-card-grid dt { color: var(--muted); font-size: .68rem; }
.ev-card-grid dd { margin: .15rem 0 0; font-size: .78rem; font-weight: 650; }

/* Drawer */
.drawer { position: fixed; inset: 0; z-index: 500; display: grid; grid-template-columns: minmax(0, 1fr) minmax(520px, 680px); }
.drawer-overlay { width: 100%; border: 0; background: rgba(8,26,43,.52); cursor: default; backdrop-filter: blur(2px); }
.drawer-panel { display: flex; flex-direction: column; min-width: 0; overflow: hidden; background: #fff; box-shadow: -20px 0 50px rgba(5,20,34,.2); }
.drawer-header { position: relative; padding: 24px 26px 18px; border-bottom: 1px solid var(--border); }
.drawer-header h2 { max-width: 560px; margin: 0; font-size: 1.35rem; }
.drawer-close { position: absolute; top: 18px; right: 18px; color: var(--muted); background: var(--surface-soft); }
.drawer-meta { display: flex; flex-wrap: wrap; gap: .45rem .8rem; margin-top: .75rem; color: var(--muted); font-size: .75rem; }
.drawer-meta div { display: inline-flex; gap: .25rem; }
.drawer-tabs { display: flex; min-height: 49px; padding: 0 18px; overflow-x: auto; border-bottom: 1px solid var(--border); }
.drawer-tabs button { position: relative; min-height: 49px; padding: 0 .8rem; border-radius: 0; color: var(--muted); font-size: .8rem; font-weight: 700; white-space: nowrap; }
.drawer-tabs button.active { color: var(--blue-600); }
.drawer-tabs button.active::after { content: ""; position: absolute; right: .75rem; bottom: 0; left: .75rem; height: 3px; background: var(--blue-600); }
.dtab { flex: 1; overflow-y: auto; padding: 22px 26px 40px; }
.summary-hero { padding: 18px; border-radius: 12px; color: #fff; background: var(--navy-800); }
.summary-hero strong { display: block; font-size: 1.1rem; }
.summary-hero span { display: block; margin-top: .4rem; color: #cfdeea; font-size: .8rem; }
.summary-metrics { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 10px; margin: 14px 0; }
.summary-metric { padding: 12px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface-soft); }
.summary-metric dt { color: var(--muted); font-size: .68rem; }
.summary-metric dd { margin: .2rem 0 0; font-size: .9rem; font-weight: 750; }
.evidence-callout { padding: 14px; border-left: 4px solid var(--blue-600); border-radius: 8px; color: var(--navy-800); background: var(--blue-100); font-size: .8rem; }
.drawer-period { display: grid; gap: 4px; margin: 6px 0 10px; padding: 10px 12px; border-radius: 9px; }
.drawer-period.power { border-left: 4px solid #c0392b; background: #fff1ef; }
.drawer-period.context { border-left: 4px solid #77879a; background: var(--surface-soft); }
.drawer-period strong, .drawer-period span { display: block; }

/* Incident block, evidence, ring */
.block-diagram { display: grid; gap: .8rem; }
.bd-ross { padding: .7rem; border-radius: 9px; color: #fff; background: var(--navy-800); font-weight: 800; text-align: center; }
.bd-orman { padding: .7rem; border: 1px solid var(--border); border-radius: 10px; }
.bd-orman-label { margin-bottom: .45rem; font-weight: 750; }
.bd-pair { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: .5rem; }
.bd-switch { padding: .65rem .5rem; border-radius: 8px; color: #fff; font-size: .76rem; text-align: center; }
.bd-switch.down { background: var(--red); }
.bd-switch.up { background: var(--green); }
.bd-switch.unknown, .bd-switch.unobservable, .bd-switch.invisible { background: #7f8d9c; }
.bd-legend { display: flex; flex-wrap: wrap; gap: .8rem; margin-top: 10px; font-size: .72rem; color: var(--muted); }
.bd-switch small { display: block; margin-top: .18rem; color: inherit; opacity: .82; }
.bd-note, .evidence-note, .tolerance-note { margin-top: .8rem; padding: .7rem; border-radius: 8px; color: var(--muted); background: var(--surface-soft); font-size: .76rem; }
.ring-cy { min-height: 340px; border: 1px solid var(--border); border-radius: 10px; }
.topo-note { color: var(--muted); font-size: .78rem; }
.evidence-table, .device-tbl, .coll-tbl, .audit-tbl, .user-tbl { width: 100%; border-collapse: collapse; font-size: .74rem; }
.evidence-table th, .device-tbl th, .coll-tbl th, .audit-tbl th, .user-tbl th { padding: .55rem; color: var(--muted); border-bottom: 1px solid var(--border); background: var(--surface-soft); text-align: left; }
.evidence-table td, .device-tbl td, .coll-tbl td, .audit-tbl td, .user-tbl td { padding: .55rem; border-bottom: 1px solid var(--border); }
.dokazi-intro { color: var(--muted); font-size: .8rem; }
.algo-version { color: var(--subtle); font-size: .7rem; }

/* Current state and topology */
.live-state { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 14px; margin-bottom: 18px; }
.ls-ross { padding: 16px; border: 1px solid var(--border); border-left: 4px solid var(--green); border-radius: 12px; background: #fff; box-shadow: var(--shadow-sm); }
.ls-ross.problem { border-left-color: var(--red); }
.ls-ross.ok { border-left-color: var(--green); }
.ls-ross-title { margin-bottom: .7rem; font-weight: 800; }
.ls-ormans { display: grid; gap: .45rem; }
.ls-orman { display: grid; grid-template-columns: 64px minmax(0,1fr) minmax(0,1fr); align-items: center; gap: .4rem; font-size: .72rem; }
.ls-orman-name { font-weight: 750; }
.ls-pill { overflow: hidden; padding: .28rem .4rem; border-radius: 6px; color: #fff; text-overflow: ellipsis; white-space: nowrap; }
.ls-pill.up { background: var(--green); }
.ls-pill.down { background: var(--red); }
.device-details { padding: 0; overflow: hidden; }
.device-details summary { padding: 16px 20px; cursor: pointer; font-weight: 750; }
.device-table { overflow-x: auto; }
.state-up { color: var(--green); font-weight: 750; }
.state-down { color: var(--red); font-weight: 750; }
.topo-box { height: 620px; border: 1px solid var(--border); border-radius: var(--radius); background: #fff; box-shadow: var(--shadow-sm); }
.topo-controls { margin-bottom: 10px; }

/* Admin/report */
.admin-grid { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, .8fr); gap: 18px; }
.collector-info, .policy-editor, .audit-log, .user-list { overflow-x: auto; }
.policy-form { display: grid; gap: .7rem; }
.policy-form label { display: flex; align-items: center; justify-content: space-between; gap: 1rem; color: var(--muted); font-size: .78rem; }
.policy-form input, .policy-form select { min-height: 38px; padding: .4rem .55rem; border: 1px solid var(--border); border-radius: 8px; }
.policy-form button { width: fit-content; min-height: 40px; padding: 0 .8rem; border: 0; border-radius: 8px; color: #fff; background: var(--blue-600); cursor: pointer; }
.export-card { max-width: 900px; }
.export-buttons { display: flex; flex-wrap: wrap; gap: .65rem; margin-bottom: 20px; }
.report-content { padding-top: 18px; border-top: 1px solid var(--border); color: var(--muted); }

/* Responsive */
@media (max-width: 1050px) {
  .kpi-row { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .timeline-head { align-items: flex-start; flex-direction: column; }
  .timeline-toolbar { justify-content: flex-start; }
  .recent-row { grid-template-columns: 145px 90px minmax(0,1fr) 90px 30px; gap: .65rem; }
}

@media (max-width: 760px) {
  :root { --header-h: 60px; }
  .mobile-only { display: inline-grid !important; }
  .login-overlay { padding: 0; }
  .login-shell { display: block; width: 100%; min-height: 100vh; border: 0; border-radius: 0; background: var(--navy-900); }
  .login-intro { padding: 28px 24px 22px; }
  .login-intro h1 { margin-top: 2.3rem; font-size: 2rem; }
  .login-facts { display: none; }
  .login-card { min-height: 55vh; padding: 28px 24px max(32px, env(safe-area-inset-bottom)); border-radius: 24px 24px 0 0; }
  .app-header { position: sticky; }
  .header-main { min-height: 60px; padding: 0 12px; gap: .55rem; }
  .header-main .brand-lockup { font-size: .95rem; }
  .header-main .brand-mark { display: none; }
  .live-badge { padding: .25rem .4rem; }
  #liveBadgeText { display: none; }
  .header-actions { gap: .4rem; }
  .btn--header { min-width: 42px; padding: 0 .55rem; font-size: 0; }
  .btn--header span:first-child { font-size: 1.2rem; }
  .filter-count { font-size: .65rem !important; }
  .user-badge { display: none; }
  .primary-nav { position: fixed; top: 60px; right: 0; left: 0; z-index: 90; display: none; flex-direction: column; min-height: 0; padding: 10px 12px 16px; color: #fff; background: var(--navy-900); box-shadow: 0 12px 24px rgba(8,26,43,.22); }
  .primary-nav.open { display: flex; }
  .primary-nav button { width: 100%; min-height: 48px; padding: 0 14px; border-radius: 9px; text-align: left; }
  .primary-nav button.active { background: rgba(255,255,255,.1); }
  .primary-nav button.active::after { display: none; }
  .main-content { padding: 18px 12px 38px; }
  .page-heading { margin-bottom: 14px; }
  .page-heading .btn { flex: 0 0 auto; }
  .overview-heading { display: block; }
  .coverage-badge { display: inline-block; margin-top: .7rem; text-align: left; }
  .surface { padding: 16px; border-radius: 12px; }
  .kpi-row { grid-template-columns: repeat(2, minmax(0,1fr)); gap: 9px; margin-bottom: 12px; }
  .kpi-card { min-height: 102px; padding: 14px 13px; border-radius: 11px; }
  .kpi-value { font-size: 1.52rem; }
  .kpi-label { font-size: .7rem; }
  .kpi-detail { font-size: .65rem; }
  .timeline-workspace { padding: 0; }
  .timeline-head { padding: 16px 14px 12px; }
  .timeline-head h2 { font-size: 1.03rem; }
  .timeline-toolbar { width: 100%; }
  .timeline-toolbar .tl-period { width: 100%; }
  .timeline-toolbar .segmented button { flex: 1; }
  .timeline-toolbar select { flex: 1; min-width: 0; }
  .chart-caption { display: block; padding: 12px 14px 0; }
  .chart-caption span { display: block; margin-top: .2rem; }
  .chart-tools { align-items: stretch; flex-wrap: wrap; padding: 8px 14px 0; }
  .chart-tools > span { flex-basis: 100%; }
  .chart-box--overview { min-height: 210px; padding: 0; }
  .episode-focus { margin: 0 12px; gap: 6px; }
  .episode-summary strong { font-size: .82rem; }
  .episode-summary span { font-size: .68rem; }
  .chart-box--detail { height: 250px; padding: 0; }
  .tl-legend { padding: 10px 14px 14px; gap: .7rem; }
  .ptl-list { display: grid; gap: 8px; padding: 0 12px 14px; }
  .ring-history { margin: 0 12px 14px; padding: 14px; }
  .ring-history-head { align-items: stretch; flex-direction: column; }
  .ring-time-slider-label { display: grid; gap: .25rem; }
  .ring-history-cy { min-height: 320px; }
  .ptl-mobile-row { display: grid; grid-template-columns: minmax(0,1fr) auto; gap: .35rem .7rem; width: 100%; min-height: 72px; padding: 12px; border: 1px solid var(--border); border-radius: 10px; color: var(--ink); background: var(--surface-soft); text-align: left; cursor: pointer; }
  .ptl-mobile-row span:first-child { display: grid; gap: .15rem; }
  .ptl-mobile-row small { font-size: .66rem; }
  .ptl-mobile-row span:nth-child(2) { grid-column: 1 / -1; color: var(--muted); font-size: .7rem; }
  .ptl-mobile-row b { grid-column: 2; grid-row: 1; align-self: center; color: var(--blue-600); font-size: .72rem; }
  .dashboard-grid { grid-template-columns: 1fr; gap: 12px; }
  .summary-chart { height: 245px; }
  .recent-row { grid-template-columns: 1fr auto; min-height: 70px; padding: 10px 0; gap: .25rem .7rem; }
  .recent-time { grid-column: 1; grid-row: 2; }
  .recent-ross { grid-column: 1; grid-row: 1; }
  .recent-context { display: none; }
  .recent-duration { grid-column: 2; grid-row: 1; }
  .recent-arrow { grid-column: 2; grid-row: 2; text-align: right; }
  .evidencija-wrap { overflow: visible; border: 0; background: transparent; box-shadow: none; }
  .evidencija-table { display: none; }
  .drawer { display: block; }
  .drawer-overlay { display: none; }
  .drawer-panel { position: absolute; inset: 0; width: 100vw; }
  .drawer-header { padding: 18px 18px 14px; }
  .drawer-tabs { padding: 0 8px; }
  .drawer-tabs button { flex: 1; padding: 0 .5rem; }
  .dtab { padding: 18px 16px 32px; }
  .summary-metrics { grid-template-columns: 1fr; }
  .bd-pair { grid-template-columns: 1fr; }
  .ring-cy { min-height: 360px; }
  .live-state { grid-template-columns: 1fr; gap: 10px; }
  .topo-box { height: 72vh; }
  .admin-grid { grid-template-columns: 1fr; }
  .form-grid--2 { grid-template-columns: 1fr; }
  .filter-actions .btn { flex: 1; }
  .ev-card-grid { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 390px) {
  .main-content { padding-right: 9px; padding-left: 9px; }
  .kpi-card { padding: 13px 11px; }
  .kpi-value { font-size: 1.4rem; }
  .segmented button { padding-right: .4rem; padding-left: .4rem; }
}

@media print {
  .app-header, .filter-panel, .filter-backdrop, .timeline-toolbar, .episode-focus .icon-btn, .btn, .drawer { display: none !important; }
  body { background: #fff; }
  .main-content { max-width: none; padding: 0; }
  .tab-content { display: none !important; }
  #tab-izvestaj { display: block !important; }
  .surface { border: 0; box-shadow: none; }
}
