/* KSRNR Conservation Intelligence — visual system

   The palette is cut from the IBRIX crystal: clear teal through aqua to mint, over a
   ground of cool light. Warm gold survives from the reserve itself and is spent only on
   the things that want a person's attention.

   Two rules govern everything here:
   · Clarity of line. Every border is visible at a glance. Nothing has to be guessed at.
   · A room people can work in. Conservation work is long and often grim; the interface
     must not add to that. Light by default, luminous after dark, never oppressive.
*/

:root {
  color-scheme: light dark;

  /* ── Crystal, day ── */
  --basalt-900: #eaf4f2;   /* app ground   */
  --basalt-850: #ffffff;   /* card surface */
  --basalt-800: #f3faf9;   /* inset        */
  --basalt-700: #dcecea;   /* track        */
  --basalt-600: #bcd8d3;   /* raised edge  */
  --line: #a9cdc7;         /* a line you can actually see */
  --line-soft: #cde4e0;

  --bone: #08302c;         /* deep teal ink: warmer and kinder than black */
  --mute: #416b66;
  --mute-2: #6f9691;

  --brand: #0d9e86;
  --brand-2: #0f86bd;
  --brand-3: #1fbf88;
  --brand-soft: rgba(13, 158, 134, .12);
  --violet: #6f5ad0;
  --sand: #b07f22;
  --sand-dim: #8e6616;
  --verd: #0d9e86;
  --amber: #c0840e;
  --rust: #c9482c;
  --ink-blue: #0f86bd;

  --canvas-grid: rgba(8, 48, 44, .08);
  --canvas-label: rgba(65, 107, 102, .9);
  --shade: rgba(13, 158, 134, .06);
  --sheen: rgba(13, 158, 134, .11);
  --bar-a: #ffffff; --bar-b: #eef8f6;
  --panel-bg: rgba(255, 255, 255, .94);
  --footer-bg: #ddeeeb;
  --on-sand: #ffffff;
  --head-fg: #1d514b;
  --scroll: #a4c8c2;
  --deep: #08302c;
  --card-top: rgba(255, 255, 255, .95);

  --ok: var(--brand); --warn: var(--amber); --bad: var(--rust);

  --sans: "IBM Plex Sans", system-ui, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, monospace;
  --serif: "Cormorant Garamond", Georgia, serif;

  --r: 4px;
  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 24px; --s6: 32px;
  --sh: 0 1px 0 rgba(255, 255, 255, .9) inset, 0 8px 22px -16px rgba(8, 48, 44, .3);
  --sh-lift: 0 1px 0 rgba(255, 255, 255, .95) inset, 0 18px 40px -22px rgba(8, 48, 44, .36);
}

/* ── Crystal, night: the same stone in deep water, not a black hole ── */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --basalt-900: #061a1f;
    --basalt-850: #0b262c;
    --basalt-800: #0f2f36;
    --basalt-700: #16404a;
    --basalt-600: #225a66;
    --line: #2a6b78;
    --line-soft: #1b4b56;

    --bone: #e8faf7;
    --mute: #9bc0bd;
    --mute-2: #6d9a97;

    --brand: #3ce0bb;
    --brand-2: #4cc3f0;
    --brand-3: #5ef0c0;
    --brand-soft: rgba(60, 224, 187, .14);
    --violet: #a58cf5;
    --sand: #e3b85f;
    --sand-dim: #b8913f;
    --verd: #3ce0bb;
    --amber: #e8bc55;
    --rust: #f07355;
    --ink-blue: #4cc3f0;

    --canvas-grid: rgba(156, 226, 220, .08);
    --canvas-label: rgba(155, 192, 189, .8);
    --shade: rgba(60, 224, 187, .06);
    --sheen: rgba(60, 224, 187, .1);
    --bar-a: #082228; --bar-b: #051a1f;
    --panel-bg: rgba(8, 34, 40, .92);
    --footer-bg: #04151a;
    --on-sand: #05171c;
    --head-fg: #b6dedb;
    --scroll: #1d5460;
    --deep: #041014;
    --card-top: rgba(156, 226, 220, .1);

    --sh: 0 1px 0 rgba(156, 226, 220, .06) inset, 0 14px 34px -20px rgba(0, 0, 0, .85);
    --sh-lift: 0 1px 0 rgba(156, 226, 220, .1) inset, 0 26px 54px -24px rgba(0, 0, 0, .9);
  }
}
:root[data-theme="dark"] {
  --basalt-900: #061a1f;
  --basalt-850: #0b262c;
  --basalt-800: #0f2f36;
  --basalt-700: #16404a;
  --basalt-600: #225a66;
  --line: #2a6b78;
  --line-soft: #1b4b56;

  --bone: #e8faf7;
  --mute: #9bc0bd;
  --mute-2: #6d9a97;

  --brand: #3ce0bb;
  --brand-2: #4cc3f0;
  --brand-3: #5ef0c0;
  --brand-soft: rgba(60, 224, 187, .14);
  --violet: #a58cf5;
  --sand: #e3b85f;
  --sand-dim: #b8913f;
  --verd: #3ce0bb;
  --amber: #e8bc55;
  --rust: #f07355;
  --ink-blue: #4cc3f0;

  --canvas-grid: rgba(156, 226, 220, .07);
  --canvas-label: rgba(155, 192, 189, .75);
  --shade: rgba(60, 224, 187, .05);
  --sheen: rgba(60, 224, 187, .1);
  --bar-a: #082228; --bar-b: #051a1f;
  --panel-bg: rgba(8, 34, 40, .92);
  --footer-bg: #04151a;
  --on-sand: #05171c;
  --head-fg: #b6dedb;
  --scroll: #1d5460;
  --deep: #041014;
  --card-top: rgba(156, 226, 220, .1);

  --sh: 0 1px 0 rgba(156, 226, 220, .06) inset, 0 14px 34px -20px rgba(0, 0, 0, .85);
  --sh-lift: 0 1px 0 rgba(156, 226, 220, .1) inset, 0 26px 54px -24px rgba(0, 0, 0, .9);
}

html[dir="rtl"] { --sans: "IBM Plex Sans Arabic", "IBM Plex Sans", system-ui, sans-serif; }

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  background: var(--basalt-900);
  color: var(--bone);
  font: 400 14px/1.5 var(--sans);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}
::selection { background: rgba(201, 168, 106, .25); }
::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--scroll); border-radius: 9px; border: 2px solid var(--basalt-900); }
::-webkit-scrollbar-thumb:hover { background: var(--mute-2); }

button, input, select { font: inherit; color: inherit; background: none; border: 0; }
button { cursor: pointer; }
a { color: inherit; }

.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.num { font-family: var(--mono); font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.ovl { font: 500 10px/1 var(--sans); letter-spacing: .16em; text-transform: uppercase; color: var(--mute-2); }
html[dir="rtl"] .ovl { letter-spacing: .04em; }
.dim { color: var(--mute); }
.sand { color: var(--sand); }

/* ─────────────── Shell ─────────────── */
#app { height: 100%; display: flex; flex-direction: column; }

.topbar {
  display: flex; align-items: stretch; height: 54px; flex: none; overflow: hidden;
  background: linear-gradient(180deg, var(--bar-a), var(--bar-b));
  border-bottom: 1px solid var(--line);
  position: relative; z-index: 40;
}
.brand { display: flex; align-items: center; gap: 11px; padding: 0 18px; border-inline-end: 1px solid var(--line-soft); }
.brand img { height: 30px; width: auto; filter: drop-shadow(0 2px 6px rgba(47, 143, 116, .35)); }
.brand .bt { line-height: 1.15; }
.brand .bt b { display: block; font: 600 13px/1.15 var(--sans); letter-spacing: .01em; white-space: nowrap; }
.brand .bt span { font: 400 10px/1.4 var(--sans); color: var(--mute-2); letter-spacing: .1em; text-transform: uppercase; }

.nav { display: flex; align-items: stretch; overflow-x: auto; scrollbar-width: none; min-width: 0; }
.nav::-webkit-scrollbar { display: none; }
.nav button {
  position: relative; padding: 0 13px; display: flex; align-items: center; gap: 7px;
  color: var(--mute); font-size: 12.5px; white-space: nowrap;
  border-bottom: 2px solid transparent; transition: color .15s, background .15s;
}
.nav button:hover { color: var(--bone); background: var(--shade); }
.nav button.on { color: var(--bone); border-bottom-color: var(--sand); background: rgba(201, 168, 106, .05); }
.nav svg { width: 15px; height: 15px; opacity: .85; }
.nav .badge {
  font: 500 10px/1 var(--mono); background: var(--rust); color: #fff;
  padding: 2px 4px; border-radius: 2px; min-width: 16px; text-align: center;
}

.topright { margin-inline-start: auto; display: flex; align-items: center; gap: 4px; padding-inline: 10px; border-inline-start: 1px solid var(--line-soft); flex: none; }
@media (max-width: 1740px) { .topright .chip.res { display: none; } }
@media (max-width: 1540px) { .topright .chip span { display: none; } }
@media (max-width: 1400px) { .nav button span { font-size: 12px; } .nav button { padding: 0 10px; } }
@media (max-width: 1280px) { .userbox .un, .userbox .ur { display: none; } }
.chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 5px 9px; border-radius: var(--r);
  border: 1px solid var(--line); background: var(--shade); font-size: 11px; color: var(--mute);
  white-space: nowrap; flex: none;
}
.chip:hover { border-color: var(--basalt-600); color: var(--bone); }
.chip b { color: var(--bone); font-weight: 500; }
.dotp { width: 6px; height: 6px; border-radius: 50%; background: var(--brand); box-shadow: 0 0 0 0 rgba(75, 176, 148, .6); animation: pulse 2.6s infinite; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 var(--brand-soft); } 70% { box-shadow: 0 0 0 7px rgba(0,0,0,0); } 100% { box-shadow: 0 0 0 0 rgba(0,0,0,0); } }

.userbox { display: flex; align-items: center; gap: 9px; padding-inline-start: 10px; }
.avatar { width: 28px; height: 28px; border-radius: 50%; background: linear-gradient(140deg, var(--basalt-700), var(--basalt-800)); border: 1px solid var(--line); display: grid; place-items: center; font: 600 11px var(--mono); color: var(--sand); }
.userbox .un { font-size: 12px; line-height: 1.2; white-space: nowrap; }
.userbox .ur { font-size: 10px; color: var(--mute-2); letter-spacing: .06em; text-transform: uppercase; white-space: nowrap; }

/* ─────────────── Content ─────────────── */
main { flex: 1; min-height: 0; overflow: auto; position: relative; }
.view { padding: var(--s5) var(--s5) var(--s6); max-width: 1780px; margin: 0 auto; }
.view.flush { padding: 0; max-width: none; height: 100%; }

.vh { display: flex; align-items: flex-end; justify-content: space-between; gap: var(--s5); margin-bottom: var(--s4); flex-wrap: wrap; }
.vh h1 { font: 400 33px/1.1 var(--serif); letter-spacing: -.005em; }
html[dir="rtl"] .vh h1 { font-family: var(--sans); font-weight: 600; font-size: 27px; line-height: 1.3; letter-spacing: -.01em; }
.vh p { color: var(--mute); font-size: 13px; line-height: 1.6; margin-top: var(--s2); max-width: 74ch; }

.card {
  position: relative; background: var(--basalt-850);
  border: 1px solid var(--line-soft); border-radius: var(--r); box-shadow: var(--sh);
}
.card::before {
  content: ""; position: absolute; inset-block-start: 0; inset-inline: 1px; height: 1px;
  background: var(--card-top); border-radius: var(--r) var(--r) 0 0; pointer-events: none;
}
.card > header {
  display: flex; align-items: center; justify-content: space-between; gap: var(--s3);
  padding: var(--s3) var(--s4); border-bottom: 1px solid var(--line-soft);
  background: linear-gradient(180deg, var(--shade), transparent);
}
.card > header h2 {
  position: relative; font: 500 11.5px/1 var(--sans); letter-spacing: .11em;
  text-transform: uppercase; color: var(--head-fg); padding-inline-start: 11px;
}
.card > header h2::before {
  content: ""; position: absolute; inset-inline-start: 0; inset-block-start: -1px;
  width: 2px; height: 12px; background: var(--sand); border-radius: 2px; opacity: .85;
}
html[dir="rtl"] .card > header h2 { letter-spacing: 0; font-size: 13px; }
.card .body { padding: var(--s4); }

.grid { display: grid; gap: var(--s3); }
.g4 { grid-template-columns: repeat(4, 1fr); }
.g3 { grid-template-columns: repeat(3, 1fr); }
.g2 { grid-template-columns: repeat(2, 1fr); }
@media (max-width: 1240px) { .g4 { grid-template-columns: repeat(2, 1fr); } .g3, .g2 { grid-template-columns: 1fr; } }

/* Metric tiles */
.kpi { padding: var(--s4) var(--s4) 18px; position: relative; overflow: hidden; }
.kpi .kl { font: 500 10px/1 var(--sans); letter-spacing: .14em; text-transform: uppercase; color: var(--mute-2); }
html[dir="rtl"] .kpi .kl { letter-spacing: 0; font-size: 11px; }
.kpi .kfig { font: 250 42px/1 var(--mono); letter-spacing: -.035em; margin: 14px 0 9px; font-variant-numeric: tabular-nums; white-space: nowrap; color: var(--bone); }
.kpi .kfig small { font-size: 15px; color: var(--mute); letter-spacing: 0; margin-inline-start: 4px; vertical-align: baseline; }
.kpi .ks { font-size: 11.5px; color: var(--mute); display: flex; align-items: center; gap: 6px; }
.kpi .spark { position: absolute; inset-block-end: 0; inset-inline: 0; height: 30px; opacity: .62; pointer-events: none; }

.delta { font: 500 11px var(--mono); padding: 1px 4px; border-radius: 2px; }
.delta.up { color: var(--verd); background: rgba(75, 176, 148, .1); }
.delta.dn { color: var(--rust); background: rgba(194, 96, 63, .1); }

/* Tables */
table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
th {
  text-align: start; font: 500 10px/1 var(--sans); letter-spacing: .1em; text-transform: uppercase;
  color: var(--mute-2); padding: 11px 14px; border-bottom: 1px solid var(--line-soft); white-space: nowrap;
  position: sticky; top: 0; background: var(--basalt-850); z-index: 2;
}
html[dir="rtl"] th { letter-spacing: 0; font-size: 11px; }
td { padding: 11px 14px; border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
tbody tr { transition: background .12s; }
tbody tr:hover { background: var(--shade); }
tbody tr.sel { background: rgba(201, 168, 106, .07); box-shadow: inset 2px 0 0 var(--sand); }
html[dir="rtl"] tbody tr.sel { box-shadow: inset -2px 0 0 var(--sand); }
tr.clk { cursor: pointer; }

.tag { display: inline-flex; align-items: center; gap: 5px; font: 500 10.5px/1 var(--sans); padding: 3px 6px; border-radius: 2px; border: 1px solid; white-space: nowrap; }
.t-ok { color: var(--verd); border-color: rgba(75, 176, 148, .3); background: rgba(75, 176, 148, .08); }
.t-warn { color: var(--amber); border-color: rgba(217, 164, 65, .3); background: rgba(217, 164, 65, .08); }
.t-bad { color: var(--rust); border-color: rgba(194, 96, 63, .32); background: rgba(194, 96, 63, .09); }
.t-mute { color: var(--mute); border-color: var(--line); }
.t-sand { color: var(--sand); border-color: rgba(201, 168, 106, .3); background: rgba(201, 168, 106, .07); }

.dot { width: 6px; height: 6px; border-radius: 50%; flex: none; }
.d-ok { background: var(--verd); } .d-warn { background: var(--amber); } .d-bad { background: var(--rust); }

/* Confidence meter */
.conf { display: flex; align-items: center; gap: 8px; }
.conf .bar { width: 52px; height: 3px; background: var(--basalt-600); border-radius: 2px; overflow: hidden; flex: none; }
.conf .bar i { display: block; height: 100%; border-radius: 2px; }
.conf .v { font: 500 12px var(--mono); font-variant-numeric: tabular-nums; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; gap: 7px; padding: 7px 13px; border-radius: var(--r);
  border: 1px solid var(--line); background: var(--shade); font-size: 12.5px; color: var(--mute);
  transition: .14s;
}
.btn:hover { border-color: var(--basalt-600); background: var(--basalt-700); color: var(--bone); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--sand); border-color: var(--sand); color: var(--on-sand); font-weight: 500; }
.btn.primary:hover { filter: brightness(1.12); }
.btn.ok { color: var(--verd); border-color: rgba(75, 176, 148, .35); }
.btn.ok:hover { background: rgba(75, 176, 148, .12); }
.btn.bad { color: var(--rust); border-color: rgba(194, 96, 63, .35); }
.btn.bad:hover { background: rgba(194, 96, 63, .12); }
.btn.sm { padding: 5px 9px; font-size: 11.5px; }
.btn svg { width: 14px; height: 14px; }
.btn:disabled { opacity: .4; cursor: not-allowed; }

.seg { display: inline-flex; border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; }
.seg button { padding: 5px 11px; font-size: 11.5px; color: var(--mute); border-inline-end: 1px solid var(--line-soft); }
.seg button:last-child { border-inline-end: 0; }
.seg button.on { background: rgba(201, 168, 106, .12); color: var(--sand); }
.seg button:hover:not(.on) { background: var(--shade); color: var(--bone); }

.inp {
  border: 1px solid var(--line); border-radius: var(--r); background: var(--basalt-800);
  padding: 7px 10px; font-size: 12.5px; width: 100%;
}
.inp:focus { outline: 0; border-color: var(--sand-dim); background: var(--basalt-700); }
.inp::placeholder { color: var(--mute-2); }

/* Camera frame with detection overlay */
.frame { position: relative; background: #000; overflow: hidden; border-radius: 2px; }
.frame img { width: 100%; display: block; }
.frame .scan { position: absolute; inset: 0; pointer-events: none; }
.frame.ir img { filter: grayscale(1) brightness(1.12) contrast(1.22); }
.frame.thermal img { filter: grayscale(1) contrast(1.5) brightness(.85); mix-blend-mode: luminosity; }
.frame.thermal { background: linear-gradient(160deg, #1b0b2e, #5c1a4a 45%, #c24a24 75%, #f0c04a); }
.frame.dust img { filter: sepia(.35) contrast(.85) brightness(1.08) saturate(.7); }
.frame.haze img { filter: contrast(.9) brightness(1.06) saturate(.85); }
.frame.glare img { filter: contrast(1.05) brightness(1.1) saturate(1.1); }
.frame .grain {
  position: absolute; inset: 0; pointer-events: none; opacity: .09; mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120'%3E%3Cfilter id='n'%3E%3CfeTurbulence baseFrequency='.9' numOctaves='3'/%3E%3C/filter%3E%3Crect width='120' height='120' filter='url(%23n)'/%3E%3C/svg%3E");
}
.bbox { position: absolute; border: 1.5px solid var(--sand); box-shadow: 0 0 0 1px rgba(0, 0, 0, .45); }
.bbox::after {
  content: attr(data-l); position: absolute; inset-block-start: -19px; inset-inline-start: -1.5px;
  background: var(--sand); color: #14181a; font: 600 10px/1 var(--mono); padding: 4px 5px; white-space: nowrap;
}
.bbox.sec { border-color: var(--rust); }
.bbox.sec::after { background: var(--rust); color: #fff; }
.osd { position: absolute; font: 500 10px/1.5 var(--mono); color: rgba(255, 255, 255, .88); text-shadow: 0 1px 3px #000; letter-spacing: .04em; }
.osd.tl { inset-block-start: 8px; inset-inline-start: 9px; }
.osd.tr { inset-block-start: 8px; inset-inline-end: 9px; text-align: end; }
.osd.bl { inset-block-end: 8px; inset-inline-start: 9px; }
.osd.br { inset-block-end: 8px; inset-inline-end: 9px; text-align: end; }
.rec { display: inline-flex; align-items: center; gap: 5px; }
.rec i { width: 6px; height: 6px; border-radius: 50%; background: #e2513a; animation: blink 1.4s steps(1) infinite; }
@keyframes blink { 50% { opacity: .15; } }

/* Map */
#mapwrap { position: absolute; inset: 0; }
.mapcanvas { width: 100%; height: 100%; display: block; cursor: grab; }
.mapcanvas:active { cursor: grabbing; }
.mapui { position: absolute; pointer-events: none; }
.mapui > * { pointer-events: auto; }
.panel {
  background: var(--panel-bg); backdrop-filter: blur(14px);
  border: 1px solid var(--line); border-radius: var(--r); box-shadow: 0 16px 48px -22px #000;
}
.legendrow { display: flex; align-items: center; gap: 8px; font-size: 11.5px; color: var(--mute); padding: 3px 0; }
.legendrow .sw { width: 14px; height: 10px; border-radius: 1px; flex: none; }

/* Timeline scrubber */
.scrub { height: 46px; position: relative; }
.scrub canvas { width: 100%; height: 100%; display: block; }

/* Detail drawer */
.drawer {
  position: fixed; inset-block: 0; inset-inline-end: 0; width: min(520px, 94vw); z-index: 60;
  background: var(--basalt-850); border-inline-start: 1px solid var(--line);
  box-shadow: -30px 0 70px -30px #000; display: flex; flex-direction: column;
  transform: translateX(100%); transition: transform .28s cubic-bezier(.2, .8, .3, 1);
}
html[dir="rtl"] .drawer { box-shadow: 30px 0 70px -30px #000; transform: translateX(-100%); }
.drawer.open { transform: none; }
.scrim { position: fixed; inset: 0; background: rgba(0, 0, 0, .5); z-index: 55; opacity: 0; pointer-events: none; transition: opacity .28s; }
.scrim.on { opacity: 1; pointer-events: auto; }

.kv { display: grid; grid-template-columns: 138px 1fr; gap: 7px 12px; font-size: 12.5px; }
.kv dt { color: var(--mute-2); font-size: 11.5px; }
.kv dd { color: var(--bone); }

/* Toast */
#toasts { position: fixed; inset-block-end: 18px; inset-inline-start: 18px; z-index: 90; display: flex; flex-direction: column; gap: 8px; }
.toast {
  display: flex; align-items: center; gap: 10px; padding: 10px 14px; font-size: 12.5px;
  background: var(--panel-bg); backdrop-filter: blur(14px); border: 1px solid var(--line); border-inline-start: 2px solid var(--sand);
  border-radius: var(--r); box-shadow: 0 18px 40px -20px #000; animation: slidein .3s cubic-bezier(.2, .8, .3, 1);
}
@keyframes slidein { from { transform: translateY(8px); opacity: 0; } }
.toast.alert { border-inline-start-color: var(--rust); }

/* Login */
.login { height: 100%; display: grid; grid-template-columns: 1.15fr .85fr; }
@media (max-width: 980px) { .login { grid-template-columns: 1fr; } .login .lvis { display: none; } }
.lvis { position: relative; overflow: hidden; background: var(--deep); }
.lvis canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.lvis .cap { position: absolute; inset-block-end: 26px; inset-inline: 30px; z-index: 2; }
.lform { display: flex; flex-direction: column; justify-content: center; padding: 48px clamp(28px, 5vw, 66px); background: var(--basalt-850); border-inline-start: 1px solid var(--line-soft); overflow: auto; }
.field { margin-bottom: 13px; }
.field label { display: block; font: 500 10px/1 var(--sans); letter-spacing: .13em; text-transform: uppercase; color: var(--mute-2); margin-bottom: 6px; }
html[dir="rtl"] .field label { letter-spacing: 0; font-size: 11px; }
.roles { display: grid; gap: 7px; }
.rolebtn { display: flex; align-items: center; gap: 11px; padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--r); text-align: start; transition: .14s; }
.rolebtn:hover { border-color: var(--basalt-600); background: var(--shade); }
.rolebtn.on { border-color: var(--sand-dim); background: rgba(201, 168, 106, .08); }
.rolebtn .rn { font-size: 13px; }
.rolebtn .rd { font-size: 11px; color: var(--mute-2); margin-top: 1px; }

.bars { display: flex; flex-direction: column; gap: 7px; }
.barrow { display: grid; grid-template-columns: 1fr 46px; gap: 10px; align-items: center; font-size: 12.5px; }
.barrow .track { height: 5px; border-radius: 3px; background: var(--basalt-700); overflow: hidden; }
.barrow .track i { display: block; height: 100%; background: linear-gradient(90deg, var(--sand-dim), var(--sand)); border-radius: 3px; transition: width .6s cubic-bezier(.2,.8,.3,1); }
html[dir="rtl"] .barrow .track i { background: linear-gradient(270deg, var(--sand-dim), var(--sand)); }

.note { font-size: 11.5px; color: var(--mute-2); line-height: 1.6; }
.hr { height: 1px; background: var(--line-soft); margin: 14px 0; }

.pill-row { display: flex; gap: 6px; flex-wrap: wrap; }

.matrix { border-collapse: collapse; font: 500 11px var(--mono); }
.matrix td, .matrix th { border: 1px solid var(--line-soft); padding: 6px 8px; text-align: center; }
.matrix th { position: static; background: none; font-size: 10px; }

.sk { display: flex; align-items: center; gap: 4px; font: 500 10.5px var(--mono); color: var(--mute-2); }
kbd { font: 500 10px var(--mono); border: 1px solid var(--line); border-block-end-width: 2px; border-radius: 3px; padding: 1px 4px; color: var(--mute); }

.empty { padding: 46px 20px; text-align: center; color: var(--mute-2); font-size: 12.5px; }

/* ═══════════════ Live wall ═══════════════ */
.wall { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
@media (max-width: 1100px) { .wall { grid-template-columns: repeat(2, 1fr); } }
.tile {
  display: block; width: 100%; padding: 0; text-align: start; overflow: hidden;
  border: 1px solid var(--line-soft); border-radius: var(--r); background: var(--deep);
  transition: border-color .25s, transform .35s cubic-bezier(.2,.8,.3,1), box-shadow .35s;
}
.tile:hover { border-color: var(--sand-dim); transform: translateY(-2px); box-shadow: 0 18px 40px -26px rgba(0,0,0,.5); }
.tile.sel { border-color: var(--sand); box-shadow: 0 0 0 1px var(--sheen), 0 18px 40px -26px rgba(0,0,0,.5); }
.tilecv { aspect-ratio: 16/9; position: relative; background: #000; }
.tilecv canvas { position: absolute; inset: 0; }
.tilebar {
  display: flex; align-items: center; gap: 8px; padding: 6px 9px; font-size: 10.5px;
  border-top: 1px solid var(--line-soft); background: var(--basalt-850); color: var(--bone);
}
.tilebar .dot { margin-inline-start: auto; }

.ptzpad { display: grid; grid-template-columns: repeat(3, 30px); grid-template-rows: repeat(3, 30px); gap: 3px; }
.ptzbtn {
  border: 1px solid var(--line); border-radius: 2px; font-size: 10px; color: var(--mute);
  display: grid; place-items: center; transition: .14s; background: var(--shade);
}
.ptzbtn:hover { border-color: var(--sand-dim); color: var(--sand); background: rgba(201,168,106,.08); }
.ptzbtn:active { transform: scale(.94); }
.ptzpad button:nth-child(1) { grid-area: 1/2; }
.ptzpad button:nth-child(2) { grid-area: 2/1; }
.ptzpad button:nth-child(3) { grid-area: 2/2; }
.ptzpad button:nth-child(4) { grid-area: 2/3; }
.ptzpad button:nth-child(5) { grid-area: 3/2; }

tr.flash { animation: flashrow 1.6s ease-out; }
@keyframes flashrow { 0% { background: rgba(201,168,106,.22); } 100% { background: transparent; } }

/* ═══════════════ Motion ═══════════════ */
@media (prefers-reduced-motion: no-preference) {
  .reveal { animation: rise .58s cubic-bezier(.2,.85,.3,1) both; }
  @keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

  main > .view { animation: viewin .42s cubic-bezier(.2,.85,.3,1) both; }
  @keyframes viewin { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

  .card { transition: border-color .3s, box-shadow .35s, transform .35s cubic-bezier(.2,.8,.3,1); }
  .card:hover { border-color: var(--basalt-600); }

  .kpi::after {
    content: ""; position: absolute; inset: 0; pointer-events: none; opacity: 0;
    background: linear-gradient(105deg, transparent 38%, rgba(201,168,106,.09) 50%, transparent 62%);
    transform: translateX(-55%);
  }
  .kpi:hover::after { opacity: 1; animation: sheen 1.15s cubic-bezier(.35,.1,.25,1); }
  @keyframes sheen { to { transform: translateX(55%); } }

  .btn, .chip, .tag { transition: background .18s, border-color .18s, color .18s, transform .18s; }
  .nav button::after {
    content: ""; position: absolute; inset-block-end: 0; inset-inline: 50%; height: 2px;
    background: var(--sand); transition: inset-inline .28s cubic-bezier(.2,.85,.3,1);
  }
  .nav button.on::after { inset-inline: 0; }
  .nav button.on { border-bottom-color: transparent; }
}
.reveal:nth-child(2) { animation-delay: .05s; }
.reveal:nth-child(3) { animation-delay: .1s; }
.reveal:nth-child(4) { animation-delay: .15s; }

/* Gilded rule used under view headers */
.vh { position: relative; padding-bottom: 14px; }
.vh::after {
  content: ""; position: absolute; inset-block-end: 0; inset-inline: 0; height: 1px;
  background: linear-gradient(90deg, rgba(201,168,106,.55), rgba(201,168,106,.06) 38%, transparent 70%);
}
html[dir="rtl"] .vh::after { background: linear-gradient(270deg, rgba(201,168,106,.55), rgba(201,168,106,.06) 38%, transparent 70%); }

.card.fillcard { display: flex; flex-direction: column; }
.card.fillcard > .body { flex: 1; min-height: 0; display: flex; flex-direction: column; }

.footstrip { flex: none; padding: 5px 16px; border-top: 1px solid var(--line-soft); display: flex; justify-content: space-between; align-items: center; background: var(--footer-bg); }
.nav .badge { color: var(--on-sand); }

.attn { display: block; width: 100%; text-align: start; padding: 9px 10px; border-radius: 3px; border: 1px solid var(--line-soft); margin-bottom: 7px; background: var(--shade); transition: border-color .2s, background .2s, transform .2s; }
.attn:hover { border-color: var(--basalt-600); background: var(--basalt-800); transform: translateX(2px); }
html[dir="rtl"] .attn:hover { transform: translateX(-2px); }
.panel.sector { transition: border-color .22s, transform .22s cubic-bezier(.2,.8,.3,1), box-shadow .22s; }
.panel.sector:hover { border-color: var(--sand-dim); transform: translateY(-1px); box-shadow: 0 10px 26px -18px rgba(0,0,0,.6); }

/* Motion refinements */
@media (prefers-reduced-motion: no-preference) {
  .barrow .track i { transition: width .75s cubic-bezier(.2,.85,.3,1); }
  .card { will-change: auto; }
  .card:hover { box-shadow: 0 1px 0 var(--shade) inset, 0 18px 40px -26px rgba(0,0,0,.55); }
  tbody tr { transition: background .16s, box-shadow .16s; }
  .tag, .badge { transition: background .2s, color .2s, border-color .2s; }
  .conf .bar i { transition: width .6s cubic-bezier(.2,.85,.3,1); }
  .drawer .kv dd, .drawer .kv dt { animation: rise .45s cubic-bezier(.2,.85,.3,1) both; }
  .topbar::after {
    content: ""; position: absolute; inset-block-end: -1px; inset-inline: 0; height: 1px;
    background: linear-gradient(90deg, transparent, var(--sand), transparent);
    opacity: .45; animation: sweep 9s ease-in-out infinite;
  }
  @keyframes sweep {
    0%, 100% { transform: translateX(-30%) scaleX(.35); opacity: .18; }
    50% { transform: translateX(30%) scaleX(.6); opacity: .5; }
  }
  .seg button, .rolebtn, .ptzbtn, .attn { transition: background .18s, border-color .18s, color .18s, transform .18s; }
  .btn:hover svg { transform: translateX(1px); transition: transform .2s; }
  html[dir="rtl"] .btn:hover svg { transform: translateX(-1px); }
}

/* Species links */
.splink {
  display: inline-flex; align-items: center; gap: 7px; padding: 0; font: inherit;
  color: inherit; text-align: start; border-bottom: 1px solid transparent; transition: .16s;
}
.splink:hover { color: var(--sand); border-bottom-color: var(--sand-dim); }
.splink .dot { flex: none; }
.barrow.clk { cursor: pointer; border-radius: 3px; transition: background .16s; }
.barrow.clk:hover { background: var(--shade); }
.barrow.clk:hover .track i { filter: brightness(1.15); }

/* Keyboard focus is part of the design, not an afterthought */
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; border-radius: 2px; }
button:focus:not(:focus-visible) { outline: none; }
