/* frogeye app shell + components. Light editorial theme, framed cards. */
* { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  font-family: 'Inter', system-ui, sans-serif;
  background: var(--surface);
  color: var(--ink);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
h1,h2,h3,h4,h5,.display {
  font-family: 'Space Grotesk','Inter',sans-serif;
  font-weight: 700; letter-spacing: -0.02em; line-height: 1.14;
}
a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-dark); }
.muted { color: var(--body); }
.dim { color: var(--muted); }
.mono { font-family: var(--mono); }
::selection { background: var(--accent); color: var(--on-accent); }

.label-sm {
  font-size: .66rem; font-weight: 600; letter-spacing: .14em;
  text-transform: uppercase; color: var(--muted);
}
.kicker {
  font-family: 'Space Grotesk',sans-serif; font-size: .72rem; font-weight: 700;
  letter-spacing: .12em; text-transform: uppercase; color: var(--accent);
}

/* ---------- App grid ---------- */
.app { display: grid; grid-template-columns: 248px 1fr; min-height: 100vh; }
.main { display: flex; flex-direction: column; min-width: 0; }

/* ---------- Sidebar ---------- */
.side { background: var(--side-bg); color: var(--side-fg); display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; }
.side__brand { display: flex; align-items: center; gap: 11px; padding: 20px 20px 18px; border-bottom: 1px solid var(--side-line); }
.side__brand .logo { width: 30px; height: 30px; border-radius: 8px; background: var(--accent); display: grid; place-items: center; flex: none; }
.side__brand .logo svg { width: 18px; height: 18px; }
.side__brand b { font-family: 'Space Grotesk',sans-serif; font-size: 1.02rem; letter-spacing: -0.01em; }
.side__brand small { display: block; color: var(--side-muted); font-size: .64rem; letter-spacing: .12em; text-transform: uppercase; margin-top: 1px; }
.side__nav { padding: 14px 12px; display: flex; flex-direction: column; gap: 2px; overflow-y: auto; }
.side__sec { color: var(--side-muted); font-size: .62rem; letter-spacing: .14em; text-transform: uppercase; padding: 14px 10px 6px; }
.side__nav a { display: flex; align-items: center; gap: 11px; padding: 9px 11px; border-radius: 9px; color: var(--side-fg); font-size: .88rem; font-weight: 500; transition: background .12s,color .12s; }
.side__nav a:hover { background: var(--side-hover); }
.side__nav a.active { background: var(--accent); color: var(--on-accent); }
.side__nav a svg, .side__nav a i { width: 17px; height: 17px; flex: none; }
.side__foot { margin-top: auto; padding: 14px 16px; border-top: 1px solid var(--side-line); font-size: .78rem; }
.side__foot .who { color: var(--side-fg); font-weight: 600; }
.side__foot .role { color: var(--side-muted); font-size: .68rem; text-transform: uppercase; letter-spacing: .1em; }
.side__foot a { color: var(--side-muted); }
.side__foot a:hover { color: var(--accent-on-dark); }

/* ---------- Topbar ---------- */
.topbar { display: flex; align-items: center; gap: 16px; padding: 0 26px; height: 62px; background: var(--page); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20; }
.topbar__title { font-family: 'Space Grotesk',sans-serif; font-weight: 700; font-size: 1.04rem; letter-spacing: -0.01em; }
.topbar__spacer { flex: 1; }
.area-switch { display: flex; align-items: center; gap: 9px; background: var(--off); border: 1px solid var(--line); border-radius: 999px; padding: 7px 13px; }
.area-switch svg { width: 15px; height: 15px; color: var(--accent); }
.area-switch select { border: 0; background: transparent; font-family: 'Inter',sans-serif; font-size: .86rem; font-weight: 600; color: var(--ink); cursor: pointer; outline: none; }
.live-dot { display: inline-flex; align-items: center; gap: 7px; font-size: .72rem; font-weight: 600; color: var(--ok); letter-spacing: .04em; text-transform: uppercase; }
.live-dot i { width: 8px; height: 8px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 0 0 rgba(22,163,74,.5); animation: pulse 1.8s infinite; }
.live-dot.stale { color: var(--idle); } .live-dot.stale i { background: var(--idle); animation: none; }
@keyframes pulse { 0%{box-shadow:0 0 0 0 rgba(22,163,74,.45)} 70%{box-shadow:0 0 0 8px rgba(22,163,74,0)} 100%{box-shadow:0 0 0 0 rgba(22,163,74,0)} }

/* ---------- Content ---------- */
.content { padding: 26px; max-width: 1440px; width: 100%; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 20px; }
.page-head h1 { font-size: 1.5rem; }
.page-head p { color: var(--body); font-size: .9rem; margin-top: 3px; }

/* ---------- Cards / grid ---------- */
.grid { display: grid; gap: 16px; }
.grid.kpis { grid-template-columns: repeat(4, 1fr); }
.grid.cols-2 { grid-template-columns: 2fr 1fr; }
.card { background: var(--page); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card__h { display: flex; align-items: center; justify-content: space-between; padding: 15px 18px; border-bottom: 1px solid var(--line); }
.card__h h3 { font-size: .98rem; }
.card__b { padding: 18px; }

.kpi { background: var(--page); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow); position: relative; overflow: hidden; }
.kpi .k-label { font-size: .68rem; font-weight: 600; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); }
.kpi .k-value { font-family: 'Space Grotesk',sans-serif; font-weight: 700; font-size: 2.3rem; line-height: 1.05; margin-top: 6px; letter-spacing: -0.03em; }
.kpi .k-sub { font-size: .78rem; color: var(--body); margin-top: 4px; }
.kpi.accent { background: linear-gradient(180deg, var(--accent), var(--accent-dark)); color: var(--on-accent); border-color: transparent; }
.kpi.accent .k-label, .kpi.accent .k-sub { color: rgba(255,255,255,.85); }
.kpi .spark { position: absolute; right: 0; bottom: 0; left: 0; height: 34px; opacity: .9; }

/* ---------- Badges / chips ---------- */
.badge { display: inline-flex; align-items: center; gap: 6px; font-size: .68rem; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; padding: 4px 9px; border-radius: 999px; border: 1px solid var(--line-strong); color: var(--dim); background: var(--page); }
.badge.ok { color: var(--ok); background: var(--ok-bg); border-color: transparent; }
.badge.warn { color: var(--warn); background: var(--warn-bg); border-color: transparent; }
.badge.bad { color: var(--bad); background: var(--bad-bg); border-color: transparent; }
.badge.idle { color: var(--dim); background: var(--idle-bg); border-color: transparent; }

/* ---------- Log stream ---------- */
.logstream { font-family: var(--mono); font-size: .76rem; line-height: 1.7; max-height: 340px; overflow-y: auto; }
.logstream .row { display: flex; gap: 12px; padding: 3px 0; border-bottom: 1px dashed var(--line); }
.logstream .t { color: var(--muted); flex: none; }
.logstream .m { color: var(--body); }
.logstream .m b { color: var(--ink); }

/* ---------- Tables ---------- */
table.tbl { width: 100%; border-collapse: collapse; font-size: .86rem; }
table.tbl th { text-align: left; font-size: .66rem; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); font-weight: 600; padding: 10px 12px; border-bottom: 1px solid var(--line); }
table.tbl td { padding: 11px 12px; border-bottom: 1px solid var(--line); }
table.tbl tr:hover td { background: var(--off); }

/* ---------- Buttons / forms ---------- */
.btn { display: inline-flex; align-items: center; gap: 8px; font-family: 'Inter',sans-serif; font-size: .86rem; font-weight: 600; padding: 9px 16px; border-radius: 9px; border: 1px solid var(--line-strong); background: var(--page); color: var(--ink); cursor: pointer; transition: .12s; }
.btn:hover { border-color: var(--ink); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn.primary:hover { background: var(--accent-dark); border-color: var(--accent-dark); }
.btn svg, .btn i { width: 16px; height: 16px; }
.input, select.input { width: 100%; font-family: 'Inter',sans-serif; font-size: .9rem; padding: 11px 13px; border: 1px solid var(--line-strong); border-radius: 9px; background: var(--page); color: var(--ink); outline: none; }
.input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-light); }
.field { margin-bottom: 14px; } .field label { display: block; font-size: .76rem; font-weight: 600; color: var(--dim); margin-bottom: 6px; }

/* ---------- Map / 3d containers ---------- */
.map-wrap, .scene-wrap { width: 100%; height: 460px; border-radius: var(--radius); overflow: hidden; border: 1px solid var(--line); background: var(--off); }

/* ---------- Login ---------- */
.login-wrap { min-height: 100vh; display: grid; grid-template-columns: 1.1fr 1fr; }
.login-aside { background: var(--side-bg); color: var(--on-accent); padding: 56px; display: flex; flex-direction: column; justify-content: space-between; }
.login-aside .brand { display: flex; align-items: center; gap: 12px; }
.login-aside .brand .logo { width: 38px; height: 38px; border-radius: 10px; background: var(--accent); display: grid; place-items: center; }
.login-aside h1 { font-size: 2.1rem; line-height: 1.1; margin-top: 40px; }
.login-aside p { color: var(--on-dark-body); margin-top: 14px; max-width: 36ch; }
.login-aside .meta { color: var(--side-muted); font-size: .76rem; }
.login-form { display: grid; place-items: center; padding: 40px; }
.login-card { width: 100%; max-width: 360px; }
.login-card h2 { font-size: 1.4rem; } .login-card .sub { color: var(--body); font-size: .88rem; margin: 6px 0 26px; }
.alert { padding: 11px 14px; border-radius: 9px; font-size: .84rem; margin-bottom: 16px; }
.alert.err { background: var(--bad-bg); color: var(--bad); }

@media (max-width: 980px) {
  .app { grid-template-columns: 1fr; }
  .side { position: fixed; left: -260px; z-index: 50; transition: left .2s; width: 248px; }
  .side.open { left: 0; }
  .grid.kpis { grid-template-columns: repeat(2,1fr); }
  .grid.cols-2 { grid-template-columns: 1fr; }
  .login-wrap { grid-template-columns: 1fr; } .login-aside { display: none; }
}
.menu-toggle { display: none; background: none; border: 0; cursor: pointer; }
@media (max-width: 980px) { .menu-toggle { display: inline-flex; } }


/* --- panel fullscreen toggle --- */
.fe-toolbar { position: absolute; top: 12px; right: 12px; z-index: 6; display: flex; gap: 6px; }
.fe-fsbtn { display: inline-flex; align-items: center; justify-content: center; width: 34px; height: 34px; padding: 0; border-radius: 9px; border: 1px solid rgba(255,255,255,.18); background: rgba(10,14,22,.55); color: #eaf1ff; cursor: pointer; -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); transition: background .12s, border-color .12s; }
.fe-fsbtn:hover { background: rgba(37,99,235,.9); border-color: transparent; }
.fe-fsbtn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.fe-fsbtn svg { width: 17px; height: 17px; display: block; }
.fe-fsbtn .ic-compress { display: none; }
[data-fe-fs]:fullscreen .fe-fsbtn .ic-expand, [data-fe-fs]:-webkit-full-screen .fe-fsbtn .ic-expand, .fe-maximized .fe-fsbtn .ic-expand { display: none; }
[data-fe-fs]:fullscreen .fe-fsbtn .ic-compress, [data-fe-fs]:-webkit-full-screen .fe-fsbtn .ic-compress, .fe-maximized .fe-fsbtn .ic-compress { display: block; }
[data-fe-fs]:fullscreen, [data-fe-fs]:-webkit-full-screen { width: 100% !important; height: 100% !important; border-radius: 0 !important; border: 0 !important; }
.fe-maximized { position: fixed !important; inset: 0 !important; width: 100vw !important; height: 100vh !important; z-index: 2000 !important; margin: 0 !important; border-radius: 0 !important; border: 0 !important; }


/* ===================================================================
   M1 additions: accessibility + the pieces v1 left unfinished.
   =================================================================== */

/* Visually hidden but announced by screen readers. */
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* The area switcher is a <form> now, not a bare div. */
.area-switch { margin: 0; }

/* Keyboard focus. v1 styled :focus-visible on .fe-fsbtn only, so every other
   control was keyboard-navigable but gave no visible indication of where you
   were -- the browser default outline is suppressed by the custom borders. */
.btn:focus-visible,
.input:focus-visible,
select:focus-visible,
.area-switch select:focus-visible,
.side__nav a:focus-visible,
.logstream:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.side__nav a:focus-visible { outline-color: var(--accent-on-dark); }

/* Small-caps labels were --muted (#999) on white = 2.8:1, below the 4.5:1 WCAG
   AA threshold for text this size. --dim (#666) is 5.7:1. */
.label-sm, .kpi .k-label, table.tbl th, .side__sec { color: var(--dim); }
.kpi.accent .k-label { color: rgba(255,255,255,.9); }

/* Wide tables must scroll inside their own container, never push the page. */
.tbl-wrap { width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }
.tbl-wrap table.tbl { min-width: 620px; }

/* Charts need a bounded box or Chart.js grows without limit on reflow. */
.chart-box { position: relative; height: 260px; }
.chart-box.tall { height: 320px; }

/* Empty and error states. v1 had neither: a failed fetch left a blank card with
   nothing in the console, indistinguishable from "no data yet". */
.state {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 6px; min-height: 140px; text-align: center; padding: 20px;
  color: var(--body); font-size: .86rem;
}
.state i, .state svg { width: 22px; height: 22px; color: var(--muted); }
.state.err { color: var(--bad); }
.state.err i, .state.err svg { color: var(--bad); }
.state b { font-size: .92rem; color: var(--ink); }
.state.err b { color: var(--bad); }

/* Provenance badge: synthetic data must never be mistaken for sensor data. */
.src-badge { font-size: .64rem; letter-spacing: .1em; text-transform: uppercase; font-weight: 700; }
.src-badge.synthetic { color: var(--warn); background: var(--warn-bg); }
.src-badge.hardware  { color: var(--ok);   background: var(--ok-bg); }
.src-badge.mixed     { color: var(--accent); background: var(--accent-light); }

/* Honest-limit note, used where a number needs a caveat attached to it. */
.note {
  font-size: .8rem; color: var(--body); line-height: 1.6;
  border-left: 2px solid var(--line-strong); padding: 2px 0 2px 12px;
}
.note b { color: var(--ink); }

/* Respect a reduced-motion preference: the pulsing live dot, the autorotating
   3D camera and every transition are decorative. */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: .001ms !important; animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
  }
  .live-dot i { animation: none !important; }
}
