/* Design: minimal / Swiss, dense dashboard, amber primary. Day (light) theme is the default; the "Mode malam" switch
   sets html[data-theme=dark] (see theme.js). Fira Sans for text, Fira Code for numbers so digits line up in tables. */
:root {
  --bg: #f8fafc; --card: #ffffff; --muted-bg: #f1f5f9; --text: #0f172a; --muted: #5b6b82; --line: #e2e8f0;
  --primary: #f59e0b; --on-primary: #0f172a; --link: #b45309; --ring: #d97706;
  --pos: #047857; --neg: #b91c1c; --off: #94a3b8;
  --ok-bg: #ecfdf5; --err-bg: #fef2f2;
  --font: "Fira Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: "Fira Code", ui-monospace, "Cascadia Mono", Consolas, monospace;
  --r: 8px; --ease: 180ms ease-out;
  color-scheme: light;
}
:root[data-theme=dark] {
  --bg: #0f172a; --card: #1a2133; --muted-bg: #222a3d; --text: #f8fafc; --muted: #94a3b8; --line: #2c374d;
  --primary: #f59e0b; --on-primary: #0f172a; --link: #fbbf24; --ring: #f59e0b;
  --pos: #34d399; --neg: #f87171; --off: #64748b;
  --ok-bg: rgba(52, 211, 153, .12); --err-bg: rgba(248, 113, 113, .14);
  color-scheme: dark;
}
body { transition: background-color 600ms ease, color 600ms ease; }

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 16px/1.5 var(--font); }
a { color: var(--link); text-decoration: none; transition: color var(--ease); }
a:hover { text-decoration: underline; text-underline-offset: 3px; }
:focus-visible { outline: 2px solid var(--ring); outline-offset: 2px; border-radius: 4px; }
h1 { font-size: 1.5rem; font-weight: 700; letter-spacing: -.01em; margin: 0; }
h2 { font-size: 1rem; font-weight: 600; margin: 1.75rem 0 .6rem; }
.card h2 { margin-top: 0; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.num, .kpi-value { font-family: var(--mono); font-variant-numeric: tabular-nums; }

/* header */
.top { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: .5rem 1.5rem; flex-wrap: wrap;
  padding: .5rem 16px; background: var(--card); border-bottom: 1px solid var(--line); }
.brand { font-weight: 700; letter-spacing: .08em; color: var(--text); }
.brand:hover { text-decoration: none; }
.top nav { display: flex; gap: .25rem; flex: 1; flex-wrap: wrap; }
.top nav a { color: var(--muted); padding: .55rem .75rem; border-radius: 6px; min-height: 44px; display: inline-flex; align-items: center; }
.top nav a:hover { color: var(--text); background: var(--muted-bg); text-decoration: none; }
.top nav a[aria-current=page] { color: var(--text); background: var(--muted-bg); box-shadow: inset 0 -2px 0 var(--primary); }
.who { color: var(--muted); margin-right: .5rem; font-size: .9rem; }

.wrap { max-width: 1240px; margin: 0 auto; padding: 1.5rem 16px 3rem; }
.center { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: .25rem; }

/* cards & forms */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 1.25rem; margin-bottom: 1rem; }
.login { width: 100%; max-width: 360px; }
.login h1 { margin-bottom: 1rem; }
.narrow { max-width: 440px; margin-top: 1rem; }
label { display: block; margin-bottom: .9rem; font-size: .9rem; font-weight: 500; }
label input:not([type=checkbox]), select { display: block; width: 100%; margin-top: .3rem; padding: .6rem .7rem; min-height: 44px;
  font: inherit; font-weight: 400; color: var(--text); background: var(--bg); border: 1px solid var(--line); border-radius: 6px;
  transition: border-color var(--ease); }
label input:not([type=checkbox]):hover, select:hover { border-color: var(--muted); }
select { cursor: pointer; }
input[type=checkbox] { width: 18px; height: 18px; accent-color: var(--primary); cursor: pointer; }
label.check { display: flex; align-items: center; gap: .5rem; font-weight: 400; cursor: pointer; min-height: 44px; margin: 0; }
fieldset { border: 1px solid var(--line); border-radius: 6px; margin: 0 0 .9rem; padding: .25rem .9rem; }
legend { font-size: .85rem; color: var(--muted); padding: 0 .25rem; }
.inline { display: inline-flex; align-items: center; gap: .4rem; margin: 0; }
.inline input { width: 9.5rem; padding: .4rem .5rem; font: inherit; font-size: .85rem; color: var(--text);
  background: var(--bg); border: 1px solid var(--line); border-radius: 6px; }
.grid-form { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 0 1rem; align-items: end; }
.grid-form .btn { margin-bottom: .9rem; }

.btn { display: inline-flex; align-items: center; justify-content: center; min-height: 44px; padding: .5rem 1.1rem;
  font: inherit; font-weight: 600; cursor: pointer; background: var(--primary); color: var(--on-primary);
  border: 1px solid var(--primary); border-radius: 6px; transition: filter var(--ease), background var(--ease); }
.btn:hover { filter: brightness(1.08); }
.btn:active { filter: brightness(.95); }
.btn.small { min-height: 36px; padding: .3rem .75rem; font-size: .85rem; }
.btn.ghost { background: transparent; color: var(--text); border-color: var(--line); }
.btn.ghost:hover { background: var(--muted-bg); filter: none; }
.btn.danger { background: transparent; color: var(--neg); border-color: var(--neg); }
.btn.danger:hover { background: var(--err-bg); filter: none; }
.login .btn { width: 100%; margin-top: .25rem; }

.alert { padding: .7rem .9rem; border-radius: 6px; margin: 0 0 1rem; border-left: 3px solid; }
.alert.ok { background: var(--ok-bg); border-color: var(--pos); }
.alert.err { background: var(--err-bg); border-color: var(--neg); }
.tag { display: inline-block; padding: .05rem .5rem; border-radius: 999px; font-size: .78rem; background: var(--muted-bg); color: var(--muted); }
.tag.ok { background: var(--ok-bg); color: var(--pos); }

/* home */
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 1rem; margin-top: 1.25rem; }
.tile { display: flex; flex-direction: column; gap: .35rem; color: var(--text); margin: 0;
  transition: border-color var(--ease), transform var(--ease); }
.tile:hover { border-color: var(--primary); text-decoration: none; transform: translateY(-1px); }
.tile span { color: var(--link); font-size: .9rem; }

/* home page: day = plain white, night = a dark sky with twinkling stars (stars.js) behind everything.
   The logo intro (logo.js) plays on an empty screen (body.intro hides the page), then docks into the header slot. */
body.home { background: #ffffff; }
:root[data-theme=dark] body.home { background: linear-gradient(#050816, #0b1026 60%, #0f172a) fixed; }
.night-sky { position: fixed; inset: 0; z-index: 0; width: 100%; height: 100%; display: block; pointer-events: none;
  opacity: 0; transition: opacity 900ms ease; }
:root[data-theme=dark] .night-sky { opacity: 1; }
body.intro { overflow: hidden; }
.home-top { position: fixed; top: 0; left: 0; right: 0; z-index: 40; height: 64px; padding-right: 200px;
  transition: opacity 600ms ease, background-color 600ms ease; }
:root[data-theme=dark] .home-top { background: rgba(15, 23, 42, .72); backdrop-filter: blur(8px); }
.spacer { flex: 1; }
.brand-slot { display: block; height: 40px; flex: none; }
.home-main { position: relative; z-index: 1; padding-top: 96px; transition: opacity 600ms ease; }
body.intro .home-main, body.intro .home-top { opacity: 0; }
.theme-toggle.on-home { position: fixed; top: 10px; right: 16px; z-index: 70; }
/* the original logo, animated piece by piece; fixed so it can fly from the middle into the header */
.brand-logo { position: fixed; z-index: 60; left: 0; top: 0; pointer-events: none; }
.lp { position: absolute; left: 0; top: 0; max-width: none; opacity: 0; transform-origin: 50% 50%; will-change: transform, opacity;
  user-select: none; }
.lp-mascot { filter: drop-shadow(0 10px 18px rgba(15, 23, 42, .28)); }
.lp-text { filter: drop-shadow(0 3px 6px rgba(15, 23, 42, .18)); }
/* night: white wordmark, a soft moonlit glow so the black badge stands out from the dark sky */
:root[data-theme=dark] .lp-text { filter: invert(1) drop-shadow(0 0 10px rgba(0, 0, 0, .25)); }
:root[data-theme=dark] .lp-mascot { filter: drop-shadow(0 0 2px rgba(226, 232, 240, .9)) drop-shadow(0 0 22px rgba(148, 163, 184, .45)); }
.lp { transition: filter 800ms ease; }
.section-title { font-size: 1.5rem; margin: 0 0 .5rem; }

/* day / night switch */
.theme-toggle { display: inline-flex; align-items: center; gap: .55rem; min-height: 44px; padding: .25rem .4rem .25rem .8rem;
  font: inherit; font-size: .85rem; font-weight: 500; color: var(--text); cursor: pointer;
  background: var(--card); border: 1px solid var(--line); border-radius: 999px; transition: background var(--ease), border-color var(--ease); }
.theme-toggle:hover { border-color: var(--muted); }
.theme-toggle.on-hero { position: absolute; top: 16px; right: 16px; z-index: 3; color: #0f172a;
  background: rgba(255, 255, 255, .72); border-color: rgba(255, 255, 255, .9); backdrop-filter: blur(8px); }
:root[data-theme=dark] .theme-toggle.on-hero { color: #f8fafc; background: rgba(15, 23, 42, .6); border-color: rgba(148, 163, 184, .35); }
.tt-track { position: relative; width: 46px; height: 26px; border-radius: 999px; background: #cbd5e1; transition: background 300ms ease; }
.tt-knob { position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; display: grid; place-items: center;
  background: #fff; color: #f59e0b; box-shadow: 0 1px 3px rgba(0, 0, 0, .3); transition: transform 300ms cubic-bezier(.3, 1.4, .5, 1); }
.tt-moon { display: none; }
.tt-state::before { content: "OFF"; font-family: var(--mono); font-size: .75rem; color: var(--muted); }
.theme-toggle[aria-checked=true] .tt-track { background: #f59e0b; }
.theme-toggle[aria-checked=true] .tt-knob { transform: translateX(20px); color: #1e293b; }
.theme-toggle[aria-checked=true] .tt-sun { display: none; }
.theme-toggle[aria-checked=true] .tt-moon { display: block; }
.theme-toggle[aria-checked=true] .tt-state::before { content: "ON"; color: #f59e0b; }
.on-hero .tt-state::before { color: inherit; opacity: .7; }
.theme-toggle[aria-checked=true].on-hero .tt-state::before { color: #fbbf24; opacity: 1; }
@media (max-width: 480px) { .tt-label { display: none; } }
/* only rendered for logged-in users: the public home page shows nothing but the scene */
.member-pill { position: absolute; top: 16px; left: 16px; z-index: 3; display: inline-flex; align-items: center; min-height: 44px;
  padding: 0 1rem; border-radius: 999px; font-size: .85rem; font-weight: 600; color: #0f172a;
  background: rgba(255, 255, 255, .72); border: 1px solid rgba(255, 255, 255, .9); backdrop-filter: blur(8px); }
.member-pill:hover { text-decoration: none; background: rgba(255, 255, 255, .9); }
:root[data-theme=dark] .member-pill { color: #f8fafc; background: rgba(15, 23, 42, .6); border-color: rgba(148, 163, 184, .35); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.empty { text-align: center; padding: 2.5rem 1rem; margin-top: 1.25rem; }
.empty p { margin: .35rem 0 0; }

/* signals */
.live { display: inline-flex; align-items: center; gap: .45rem; font-size: .85rem; color: var(--muted); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--pos); box-shadow: 0 0 0 3px var(--ok-bg); }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: .75rem; margin: 1.25rem 0 .5rem; }
.kpi { display: flex; flex-direction: column; gap: .15rem; padding: .9rem 1rem; background: var(--card);
  border: 1px solid var(--line); border-radius: var(--r); }
.kpi-label { font-size: .8rem; color: var(--muted); }
.kpi-value { font-size: 1.5rem; font-weight: 600; line-height: 1.2; }
.kpi-sub { font-size: .8rem; color: var(--muted); }

.filters { display: flex; gap: .75rem 1.25rem; flex-wrap: wrap; align-items: end; margin: 1rem 0 0; }
.filters label { margin: 0; min-width: 150px; }
.filters label.check { min-width: 0; }

/* tables */
.scroll { overflow: auto; max-height: 70vh; background: var(--card); border: 1px solid var(--line); border-radius: var(--r); }
.card .scroll { border: 0; max-height: none; }
table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th, td { padding: .5rem .75rem; text-align: left; border-bottom: 1px solid var(--line); white-space: nowrap; }
thead th { position: sticky; top: 0; z-index: 1; background: var(--card); font-size: .78rem; font-weight: 600;
  color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
tbody tr { transition: background var(--ease); }
tbody tr:hover { background: var(--muted-bg); }
tbody tr:last-child td { border-bottom: 0; }
td.num, th.num { text-align: right; }
.pos { color: var(--pos); } .neg { color: var(--neg); }
tr.off td { color: var(--off); }
.side { display: inline-block; min-width: 3.6rem; text-align: center; padding: .05rem .4rem; border-radius: 4px;
  font-size: .75rem; font-weight: 600; letter-spacing: .03em; }
.side.long { color: var(--pos); background: var(--ok-bg); }
.side.short { color: var(--neg); background: var(--err-bg); }
.users td { vertical-align: middle; }

@media (max-width: 640px) {
  .who { display: none; }
  h1 { font-size: 1.3rem; }
  .kpi-value { font-size: 1.25rem; }
  .filters label { min-width: 0; flex: 1 1 140px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; }
  .tt-knob { transition: none; }
  .tile:hover { transform: none; }
}
