/* Mata Langit - Baintelkam Polri
   Design system: "Real-Time Monitoring" pattern, Government/Public Service
   palette adapted to dark, institutional gold accent, dense dashboard spacing. */

/* ---------- fonts (self-hosted: no third-party requests) ---------- */
@font-face {
  font-family: 'EB Garamond';
  src: url('fonts/ebgaramond-var.woff2') format('woff2-variations');
  font-weight: 400 700;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'Lato';
  src: url('fonts/lato-400.woff2') format('woff2');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'Lato';
  src: url('fonts/lato-700.woff2') format('woff2');
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

/* ---------- tokens ---------- */
:root {
  /* surfaces: navy-black, three elevation steps */
  --bg:          #070B14;
  --bg-grad:     radial-gradient(1200px 600px at 50% -10%, #0F1B31 0%, #070B14 62%);
  --panel:       #0E1728;
  --panel-2:     #131F35;
  --line:        #1E2C46;
  --line-strong: #2B3C5C;

  /* text: all pairs verified >= 4.5:1 against --bg */
  --text:        #E6EDF7;
  --text-dim:    #9FB2CD;
  --text-faint:  #7C90B0;

  /* institutional accents */
  --gold:        #C9A227;
  --gold-bright: #E3C158;
  --gold-dim:    rgba(201, 162, 39, 0.14);
  --blue:        #38BDF8;
  --live:        #34D399;
  --live-dim:    rgba(52, 211, 153, 0.13);
  --warn:        #FBBF24;
  --danger:      #F87171;
  --danger-dim:  rgba(248, 113, 113, 0.12);

  /* dense dashboard scale */
  --s1: 4px;  --s2: 8px;  --s3: 12px; --s4: 16px;
  --s5: 24px; --s6: 32px; --s7: 48px;

  --r-sm: 4px; --r-md: 8px; --r-lg: 12px;

  --font-display: 'EB Garamond', 'Iowan Old Style', Georgia, serif;
  --font-ui: 'Lato', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, 'SF Mono', Menlo, Consolas, monospace;

  --shadow: 0 1px 2px rgba(0,0,0,.4), 0 8px 24px rgba(0,0,0,.28);
  --t-fast: 150ms cubic-bezier(.4,0,.2,1);
  --t-base: 220ms cubic-bezier(.4,0,.2,1);
}

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

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  background-image: var(--bg-grad);
  background-attachment: fixed;
  color: var(--text);
  font-family: var(--font-ui);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

/* Visible focus for keyboard users on every interactive element. */
:focus-visible {
  outline: 2px solid var(--gold-bright);
  outline-offset: 2px;
  border-radius: var(--r-sm);
}

a { color: var(--blue); }

.shell { max-width: 1440px; margin: 0 auto; padding: 0 var(--s5); }

/* ---------- header ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  background: rgba(7, 11, 20, .88);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
  box-shadow: 0 1px 0 rgba(201, 162, 39, .18);
}
.topbar-in {
  max-width: 1440px;
  margin: 0 auto;
  padding: var(--s3) var(--s5);
  display: flex;
  align-items: center;
  gap: var(--s4);
}
.brand { display: flex; align-items: center; gap: var(--s3); text-decoration: none; color: inherit; min-width: 0; }
/* The emblem is a shield, taller than it is wide: constrain the height and let
   the width follow, with no circular crop or plate behind it. */
.brand-logo {
  height: 44px; width: auto; flex: none;
  object-fit: contain;
  display: block;
  filter: drop-shadow(0 1px 3px rgba(0, 0, 0, .55));
}
.brand-fallback {
  width: 46px; height: 46px; flex: none;
  display: grid; place-items: center;
  border-radius: 50%;
  border: 1.5px solid var(--gold);
  background: var(--gold-dim);
  color: var(--gold-bright);
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 17px;
  letter-spacing: .02em;
}
.brand-text { min-width: 0; }
.brand-name {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 21px;
  line-height: 1.1;
  letter-spacing: .06em;
  color: var(--text);
  white-space: nowrap;
}
.brand-sub {
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: .18em;
  color: var(--gold);
  text-transform: uppercase;
  margin-top: 2px;
  white-space: nowrap;
}
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: var(--s4); }

.sysstat {
  display: inline-flex; align-items: center; gap: var(--s2);
  padding: var(--s2) var(--s3);
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--text-dim);
  white-space: nowrap;
}
.sysstat.ok { color: var(--live); border-color: rgba(52,211,153,.35); background: var(--live-dim); }
.sysstat.bad { color: var(--danger); border-color: rgba(248,113,113,.35); background: var(--danger-dim); }

.clock {
  font-family: var(--font-mono);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  color: var(--text-dim);
  white-space: nowrap;
}
.clock b { color: var(--text); font-weight: 700; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s2);
  min-height: 40px;
  padding: 0 var(--s4);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-md);
  background: var(--panel-2);
  color: var(--text);
  font-family: inherit; font-size: 13px; font-weight: 700;
  letter-spacing: .04em;
  text-decoration: none;
  cursor: pointer;
  transition: background var(--t-fast), border-color var(--t-fast), color var(--t-fast);
}
.btn:hover { background: #1A2842; border-color: var(--gold); color: var(--gold-bright); }
.btn-gold {
  background: var(--gold); border-color: var(--gold); color: #1A1205;
}
.btn-gold:hover { background: var(--gold-bright); border-color: var(--gold-bright); color: #1A1205; }
.btn-block { width: 100%; min-height: 46px; font-size: 14px; }

/* ---------- section heads ---------- */
.sec {
  display: flex; align-items: baseline; gap: var(--s3);
  margin: var(--s6) 0 var(--s4);
}
.sec h2 {
  margin: 0;
  font-size: 12px; font-weight: 700;
  letter-spacing: .16em; text-transform: uppercase;
  color: var(--text-faint);
}
.sec .rule { flex: 1; height: 1px; background: var(--line); }
.sec .count {
  font-family: var(--font-mono); font-size: 12px;
  color: var(--gold); font-variant-numeric: tabular-nums;
}

/* ---------- metric strip ---------- */
.metrics {
  display: grid; gap: var(--s3);
  grid-template-columns: repeat(4, 1fr);
  margin-top: var(--s5);
}
.metric {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: var(--s4);
  position: relative;
  overflow: hidden;
}
.metric::before {
  content: ''; position: absolute; inset: 0 auto 0 0; width: 2px; background: var(--gold);
  opacity: .55;
}
.metric-label {
  font-size: 10.5px; font-weight: 700; letter-spacing: .14em;
  text-transform: uppercase; color: var(--text-faint);
}
.metric-value {
  margin-top: var(--s2);
  font-family: var(--font-mono);
  font-size: 26px; font-weight: 700; line-height: 1.1;
  font-variant-numeric: tabular-nums;
  color: var(--text);
}
.metric-value .unit { font-size: 13px; color: var(--text-faint); margin-left: 3px; font-weight: 400; }

/* ---------- stream grid ---------- */
.grid {
  display: grid; gap: var(--s4);
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
}
.card {
  display: block;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  overflow: hidden;
  text-decoration: none;
  color: inherit;
  transition: border-color var(--t-base), transform var(--t-base), box-shadow var(--t-base);
}
.card:hover {
  border-color: var(--gold);
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}
.card-stage {
  position: relative;
  aspect-ratio: 16 / 9;
  background: #04070D;
  border-bottom: 1px solid var(--line);
  overflow: hidden;
}
.card-stage video { width: 100%; height: 100%; object-fit: cover; display: block; }
.card-stage .scan {
  position: absolute; inset: 0;
  background-image:
    linear-gradient(rgba(255,255,255,.028) 1px, transparent 1px);
  background-size: 100% 3px;
  pointer-events: none;
}
.badge-live {
  position: absolute; top: var(--s3); left: var(--s3);
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px var(--s2);
  background: rgba(7,11,20,.82);
  border: 1px solid rgba(52,211,153,.5);
  border-radius: var(--r-sm);
  font-size: 10.5px; font-weight: 700; letter-spacing: .14em;
  color: var(--live);
}
.dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.dot.pulse { animation: pulse 2s ease-in-out infinite; }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: .3; } }

.card-body { padding: var(--s3) var(--s4) var(--s4); }
.card-name {
  font-family: var(--font-display);
  font-size: 19px; font-weight: 600; letter-spacing: .02em;
  word-break: break-all;
}
.card-meta {
  margin-top: var(--s2);
  display: flex; flex-wrap: wrap; gap: var(--s1) var(--s4);
  font-family: var(--font-mono); font-size: 12px;
  color: var(--text-faint); font-variant-numeric: tabular-nums;
}
.card-meta b { color: var(--text-dim); font-weight: 400; }

/* ---------- panels ---------- */
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: var(--s5);
}
.panel h3 {
  margin: 0 0 var(--s4);
  font-size: 12px; font-weight: 700; letter-spacing: .14em;
  text-transform: uppercase; color: var(--text-faint);
}
.kv { margin: 0; display: grid; grid-template-columns: 140px 1fr; gap: var(--s3) var(--s4); }
.kv dt { font-size: 12px; letter-spacing: .06em; text-transform: uppercase; color: var(--text-faint); }
.kv dd { margin: 0; min-width: 0; }
code, .mono {
  font-family: var(--font-mono); font-size: 12.5px;
  background: #060A12; border: 1px solid var(--line);
  border-radius: var(--r-sm); padding: 3px 7px;
  color: var(--gold-bright);
  word-break: break-all;
}

.empty {
  border: 1px dashed var(--line-strong);
  border-radius: var(--r-lg);
  padding: var(--s7) var(--s5);
  text-align: center;
  color: var(--text-faint);
  background: rgba(14,23,40,.5);
}
.empty svg { color: var(--line-strong); margin-bottom: var(--s3); }
.empty p { margin: 0; font-size: 14px; }

/* ---------- footer ---------- */
.foot {
  margin-top: var(--s7);
  border-top: 1px solid var(--line);
  padding: var(--s4) 0 var(--s6);
  display: flex; flex-wrap: wrap; gap: var(--s3) var(--s5);
  align-items: center;
  font-size: 12px; color: var(--text-faint);
}
.foot .sep { margin-left: auto; }

/* ---------- player ---------- */
.player-head {
  display: flex; align-items: center; gap: var(--s4);
  flex-wrap: wrap;
  margin: var(--s5) 0 var(--s4);
}
.player-title { font-family: var(--font-display); font-size: 28px; font-weight: 700; letter-spacing: .02em; margin: 0; word-break: break-all; }
.player-layout { display: grid; gap: var(--s4); grid-template-columns: minmax(0,1fr) 340px; align-items: start; }
.stage {
  position: relative;
  aspect-ratio: 16 / 9;
  background: #04070D;
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  overflow: hidden;
}
.stage video { width: 100%; height: 100%; display: block; background: #04070D; }
.stage-overlay {
  position: absolute; inset: 0;
  display: grid; place-content: center; justify-items: center; gap: var(--s3);
  text-align: center; padding: var(--s5);
  background: rgba(4,7,13,.9);
  color: var(--text-dim);
}
.stage-overlay[hidden] { display: none; }
.spinner {
  width: 26px; height: 26px; border-radius: 50%;
  border: 2px solid var(--line-strong); border-top-color: var(--gold);
  animation: spin 900ms linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- login ---------- */
.login-wrap {
  min-height: 100vh;
  display: grid; place-items: center;
  padding: var(--s5);
}
.login-card {
  width: 100%; max-width: 400px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-top: 2px solid var(--gold);
  border-radius: var(--r-lg);
  padding: var(--s6) var(--s5) var(--s5);
  box-shadow: var(--shadow);
}
.login-brand { text-align: center; margin-bottom: var(--s6); }
.login-brand .brand-logo {
  height: 92px; width: auto; margin: 0 auto var(--s4);
}
.login-brand .brand-fallback {
  width: 72px; height: 72px; margin: 0 auto var(--s4); font-size: 24px;
}
.login-brand .brand-name { font-size: 27px; }
.login-brand .brand-sub { font-size: 11px; }
.field { margin-bottom: var(--s4); }
.field label {
  display: block; margin-bottom: 6px;
  font-size: 11px; font-weight: 700; letter-spacing: .12em;
  text-transform: uppercase; color: var(--text-faint);
}
.field input {
  width: 100%;
  min-height: 46px;
  padding: 0 var(--s3);
  background: #060A12;
  border: 1px solid var(--line-strong);
  border-radius: var(--r-md);
  color: var(--text);
  font-family: inherit; font-size: 15px;
  transition: border-color var(--t-fast);
}
.field input:focus { border-color: var(--gold); outline: none; box-shadow: 0 0 0 3px var(--gold-dim); }
.alert {
  display: flex; align-items: flex-start; gap: var(--s2);
  padding: var(--s3);
  margin-bottom: var(--s4);
  border: 1px solid rgba(248,113,113,.4);
  background: var(--danger-dim);
  border-radius: var(--r-md);
  color: #FCA5A5;
  font-size: 13px;
}
.alert[hidden] { display: none; }
.login-foot {
  margin-top: var(--s5); padding-top: var(--s4);
  border-top: 1px solid var(--line);
  text-align: center; font-size: 11.5px; color: var(--text-faint);
  letter-spacing: .04em;
}

/* ---------- responsive ---------- */
@media (max-width: 1100px) {
  .player-layout { grid-template-columns: 1fr; }
}
@media (max-width: 820px) {
  .metrics { grid-template-columns: repeat(2, 1fr); }
  .brand-name { font-size: 18px; }
  .clock { display: none; }
}
@media (max-width: 560px) {
  .shell, .topbar-in { padding-left: var(--s4); padding-right: var(--s4); }
  .grid { grid-template-columns: 1fr; }
  .kv { grid-template-columns: 1fr; gap: var(--s1) 0; }
  .player-title { font-size: 22px; }
  .metric-value { font-size: 21px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
  }
}

/* ---------- management table ---------- */
.toolbar { display: flex; flex-wrap: wrap; gap: var(--s3); align-items: flex-end; }
.toolbar .field { margin: 0; flex: 1 1 180px; }
.nav-tabs { display: flex; gap: var(--s2); }
.nav-tabs a {
  padding: var(--s2) var(--s4);
  border: 1px solid transparent;
  border-radius: var(--r-md);
  color: var(--text-dim);
  text-decoration: none;
  font-size: 13px; font-weight: 700; letter-spacing: .04em;
  transition: color var(--t-fast), background var(--t-fast), border-color var(--t-fast);
}
.nav-tabs a:hover { color: var(--gold-bright); }
.nav-tabs a[aria-current="page"] {
  color: var(--gold-bright);
  background: var(--gold-dim);
  border-color: rgba(201,162,39,.35);
}

.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: 14px; }
table.data th, table.data td {
  padding: var(--s3) var(--s4);
  text-align: left;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}
table.data th {
  font-size: 10.5px; font-weight: 700; letter-spacing: .14em;
  text-transform: uppercase; color: var(--text-faint);
  border-bottom-color: var(--line-strong);
  white-space: nowrap;
}
table.data tbody tr:last-child td { border-bottom: none; }
table.data tbody tr:hover { background: rgba(255,255,255,.022); }
table.data td.name { font-family: var(--font-display); font-size: 17px; font-weight: 600; }
table.data td.actions { text-align: right; white-space: nowrap; }
table.data td.actions .btn { min-height: 34px; padding: 0 var(--s3); font-size: 12px; margin-left: var(--s2); }

.pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 2px var(--s2);
  border-radius: 999px;
  font-size: 10.5px; font-weight: 700; letter-spacing: .1em;
  border: 1px solid var(--line-strong);
  color: var(--text-faint);
}
.pill.live { color: var(--live); border-color: rgba(52,211,153,.4); background: var(--live-dim); }

.btn-danger { border-color: rgba(248,113,113,.4); color: #FCA5A5; }
.btn-danger:hover { background: var(--danger-dim); border-color: var(--danger); color: #FECACA; }

.notice {
  border: 1px solid rgba(201,162,39,.4);
  background: var(--gold-dim);
  border-radius: var(--r-md);
  padding: var(--s4);
  margin-bottom: var(--s4);
}
.notice[hidden] { display: none; }
.notice h4 {
  margin: 0 0 var(--s3);
  font-size: 11px; font-weight: 700; letter-spacing: .14em;
  text-transform: uppercase; color: var(--gold-bright);
}
.notice .warn { margin: var(--s3) 0 0; font-size: 12.5px; color: var(--text-dim); }

dialog.modal {
  border: 1px solid var(--line-strong);
  border-radius: var(--r-lg);
  background: var(--panel);
  color: var(--text);
  padding: var(--s5);
  max-width: 420px; width: calc(100% - 32px);
  box-shadow: var(--shadow);
}
dialog.modal::backdrop { background: rgba(4,7,13,.72); }
dialog.modal h3 {
  margin: 0 0 var(--s3);
  font-family: var(--font-display); font-size: 21px; font-weight: 700;
  letter-spacing: .02em; text-transform: none; color: var(--text);
}
dialog.modal p { margin: 0 0 var(--s5); color: var(--text-dim); font-size: 14px; }
dialog.modal .row { display: flex; gap: var(--s3); justify-content: flex-end; }
