/* ═══════════════════════════════════════════════════════════════════════════
   Tunda Island Office — operations dashboard.

   Extends the app's design language rather than inventing a second identity:
   same periwinkle accent, same card rule (opaque cards in the page; glass only
   for things that float over content). The ground is a shade deeper than the
   app so the back office reads as its own room.

   Layout is a persistent left rail against a fluid content region — a wide
   window should give you more information, not more margin.
   ═══════════════════════════════════════════════════════════════════════════ */

:root {
  /* Ground + surfaces — blue-biased neutrals, never grey. */
  --ink:          #101B31;
  --bg:           #16233D;
  --surface:      #1E2E4B;
  --surface-var:  #26395C;
  --surface-hi:   #2E4470;

  --peri:         #C7D4EE;
  --peri-dim:     #9FB1D6;
  --muted:        #8496B5;
  --faint:        #5C6E8C;

  /* Semantic set, deliberately distinct from the periwinkle accent so state
     never reads as branding. */
  --good:         #5FB894;
  --warn:         #E8A94E;
  --crit:         #E5766B;

  --hairline:        rgba(255, 255, 255, 0.07);
  --hairline-strong: rgba(255, 255, 255, 0.14);

  --shadow-card: 0 3px 8px -2px rgba(0, 0, 0, 0.22);
  --shadow-lift: 0 12px 32px -12px rgba(0, 0, 0, 0.5);

  --r-sm: 8px;  --r-md: 12px;  --r-lg: 16px;  --r-card: 20px;  --r-pill: 999px;

  --rail: 236px;
  --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, monospace;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  background: var(--bg);
  color: #fff;
  font-family: "Plus Jakarta Sans", system-ui, sans-serif;
  font-weight: 500;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

.hidden { display: none !important; }

/* Digits that sit in columns must line up. */
.num, .stat-value, .opp-count, .result-box { font-variant-numeric: tabular-nums; }

/* ── Auth gate ──────────────────────────────────────────────────────────── */

.gate {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 32px 20px;
  /* The island horizon: a slow warm glow under a deep sea. Ambient only. */
  background:
    radial-gradient(120% 80% at 50% 120%, rgba(199, 212, 238, 0.10), transparent 60%),
    radial-gradient(90% 60% at 20% -10%, rgba(95, 184, 148, 0.07), transparent 55%),
    var(--ink);
}

.glass-card {
  width: min(420px, 100%);
  padding: 40px 34px;
  border-radius: var(--r-card);
  background: rgba(30, 46, 75, 0.72);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--hairline-strong);
  box-shadow: var(--shadow-lift);
}

.wordmark {
  font-size: 25px;
  font-weight: 800;
  letter-spacing: -0.9px;
  background: linear-gradient(135deg, #DCE6FA, #8AA0CC);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.wordmark span { font-weight: 600; }
.wordmark.small { font-size: 17px; letter-spacing: -0.5px; }

.tagline {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.55;
  margin: 10px 0 26px;
}

.field-label {
  display: block;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.11em;
  text-transform: uppercase;
  color: var(--faint);
  margin: 16px 0 7px;
}

input, select, textarea {
  width: 100%;
  padding: 12px 14px;
  border-radius: var(--r-md);
  border: 1px solid var(--hairline-strong);
  background: rgba(255, 255, 255, 0.045);
  color: #fff;
  font-family: inherit;
  font-size: 14.5px;
  font-weight: 500;
  transition: border-color 0.15s, background 0.15s;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--peri-dim);
  background: rgba(255, 255, 255, 0.07);
}
input::placeholder, textarea::placeholder { color: var(--faint); }
textarea { resize: vertical; line-height: 1.5; }
select option { background: var(--surface); color: #fff; }

/* Keyboard focus must always be visible. */
:focus-visible { outline: 2px solid var(--peri); outline-offset: 2px; }

.cta {
  width: 100%;
  margin-top: 22px;
  padding: 13px;
  border: 0;
  border-radius: var(--r-pill);
  background: linear-gradient(135deg, #DCE6FA, #B4C6E8);
  color: var(--ink);
  font-family: inherit;
  font-size: 14.5px;
  font-weight: 800;
  cursor: pointer;
  transition: transform 0.12s, filter 0.15s;
}
.cta:hover:not(:disabled) { filter: brightness(1.06); }
.cta:active:not(:disabled) { transform: translateY(1px); }
.cta:disabled { opacity: 0.4; cursor: not-allowed; }
.cta.small { width: auto; margin: 0; padding: 9px 16px; font-size: 13px; }
.cta.danger { background: linear-gradient(135deg, #F0968C, #DC6055); color: #2B0E0B; }

.ghost-btn {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--hairline-strong);
  color: #fff;
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  padding: 9px 15px;
  border-radius: var(--r-pill);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
  white-space: nowrap;
}
.ghost-btn:hover { background: rgba(255, 255, 255, 0.1); border-color: var(--peri-dim); }

.error {
  color: var(--crit);
  font-size: 13px;
  margin-top: 12px;
  line-height: 1.45;
}
.notice {
  margin-top: 18px;
  padding: 12px 14px;
  background: rgba(255, 255, 255, 0.035);
  border-left: 2px solid var(--peri-dim);
  border-radius: 0 var(--r-sm) var(--r-sm) 0;
  font-size: 12.5px;
  line-height: 1.55;
  color: var(--muted);
}
.notice strong { color: #fff; font-weight: 700; }

/* ── Shell: left rail + fluid content ───────────────────────────────────── */

.portal { display: grid; grid-template-columns: var(--rail) 1fr; min-height: 100vh; }

.rail {
  background: var(--ink);
  border-right: 1px solid var(--hairline);
  padding: 26px 18px;
  display: flex;
  flex-direction: column;
  gap: 26px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.rail-nav { display: flex; flex-direction: column; gap: 3px; }

.tab {
  display: flex;
  align-items: center;
  gap: 11px;
  width: 100%;
  background: transparent;
  border: 0;
  border-radius: var(--r-md);
  color: var(--muted);
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  padding: 11px 13px;
  cursor: pointer;
  text-align: left;
  transition: background 0.14s, color 0.14s;
}
.tab:hover { color: #fff; background: rgba(255, 255, 255, 0.045); }
.tab.active { background: var(--surface-var); color: #fff; font-weight: 700; }
.tab .dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: currentColor; opacity: 0.45; flex: none;
}
.tab.active .dot { background: var(--peri); opacity: 1; }
.tab .badge {
  margin-left: auto;
  background: var(--crit);
  color: #2B0E0B;
  font-size: 11px;
  font-weight: 800;
  padding: 1px 7px;
  border-radius: var(--r-pill);
}

.rail-foot { margin-top: auto; display: flex; flex-direction: column; gap: 10px; }
.rail-who { font-size: 12px; color: var(--faint); line-height: 1.4; word-break: break-all; }

.content { padding: 30px 34px 60px; max-width: 1500px; }

.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  flex-wrap: wrap;
  margin-bottom: 22px;
}
.page-title { font-size: 24px; font-weight: 800; letter-spacing: -0.6px; }
.page-sub { color: var(--muted); font-size: 13.5px; margin-top: 4px; line-height: 1.5; }

.section {
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.13em;
  text-transform: uppercase;
  color: var(--faint);
  margin: 30px 0 12px;
}
.section:first-child { margin-top: 0; }

.card {
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: var(--r-card);
  padding: 22px;
  box-shadow: var(--shadow-card);
}
.muted { color: var(--muted); }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; }

/* ── KPI band ──
   Not an equal-weight grid: numbers that demand action get size and semantic
   colour, inert ones stay quiet. Hierarchy is the information design. */

.kpi-band {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(158px, 1fr));
  gap: 12px;
}

.stat {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: var(--r-lg);
  padding: 17px 18px;
  box-shadow: var(--shadow-card);
  overflow: hidden;
}
/* Severity stripe — state readable before the number is. */
.stat::before {
  content: "";
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 3px;
  background: transparent;
}
.stat.good::before { background: var(--good); }
.stat.warn::before { background: var(--warn); }
.stat.bad::before  { background: var(--crit); }

.stat-value {
  font-family: var(--mono);
  font-size: 27px;
  font-weight: 700;
  letter-spacing: -1px;
  line-height: 1.05;
}
.stat.good .stat-value { color: var(--good); }
.stat.warn .stat-value { color: var(--warn); }
.stat.bad  .stat-value { color: var(--crit); }

.stat-label {
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  margin-top: 7px;
}
.stat-note { font-size: 11.5px; color: var(--faint); margin-top: 5px; line-height: 1.4; }

/* An unverifiable figure must LOOK unverifiable. */
.stat.unverified { border-style: dashed; border-color: rgba(232, 169, 78, 0.42); }
.stat.unverified .stat-note { color: var(--warn); }

/* Meter — proportion read at a glance, no chart library. */
.meter { height: 4px; border-radius: 2px; background: rgba(255,255,255,0.09); margin-top: 11px; overflow: hidden; }
.meter > i { display: block; height: 100%; border-radius: 2px; background: var(--peri); }
.meter.good > i { background: var(--good); }
.meter.warn > i { background: var(--warn); }

/* ── Opportunity rows ── */

.opp {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 15px 0;
  border-bottom: 1px solid var(--hairline);
}
.opp:first-of-type { padding-top: 4px; }
.opp:last-child { border-bottom: 0; padding-bottom: 0; }
.opp-count { font-family: var(--mono); font-weight: 700; font-size: 19px; letter-spacing: -0.5px; }
.opp-what { font-size: 14.5px; }
.opp-text { font-size: 12.5px; color: var(--muted); margin-top: 3px; line-height: 1.45; }

/* ── Moderation queue ── */

.report {
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-left: 3px solid var(--warn);
  border-radius: var(--r-lg);
  padding: 18px 20px;
  margin-bottom: 12px;
  box-shadow: var(--shadow-card);
}
.report-head { display: flex; justify-content: space-between; gap: 14px; flex-wrap: wrap; align-items: baseline; }
.chip {
  display: inline-block;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 3px 9px;
  border-radius: var(--r-pill);
  background: rgba(232, 169, 78, 0.16);
  color: var(--warn);
  border: 1px solid rgba(232, 169, 78, 0.3);
}
.report-who { font-size: 15px; font-weight: 700; margin-top: 9px; }
.report-meta { font-size: 12.5px; color: var(--muted); margin-top: 3px; }
.report-detail {
  margin: 12px 0 0;
  font-size: 13.5px;
  line-height: 1.6;
  padding: 11px 13px;
  background: rgba(0, 0, 0, 0.2);
  border-radius: var(--r-md);
  color: var(--peri-dim);
}
.report-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 15px; }

.empty {
  padding: 44px 20px;
  text-align: center;
  color: var(--muted);
  font-size: 14px;
}
.empty .big { font-size: 30px; display: block; margin-bottom: 10px; opacity: 0.55; }

/* ── Tool rows ── */

.tool-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 22px;
  padding: 18px 0;
  border-bottom: 1px solid var(--hairline);
  flex-wrap: wrap;
}
.tool-row:first-of-type { padding-top: 2px; }
.tool-row:last-child { border-bottom: 0; padding-bottom: 2px; }
.tool-name { font-weight: 700; font-size: 14.5px; margin-bottom: 4px; }
.tool-row .muted { font-size: 12.5px; max-width: 52ch; line-height: 1.5; }
.tool-row code {
  font-family: var(--mono);
  font-size: 12px;
  background: rgba(255,255,255,0.07);
  padding: 1px 5px;
  border-radius: 4px;
}
.btn-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.btn-row input { width: 220px; padding: 9px 12px; font-size: 13px; }

.two-col { display: grid; grid-template-columns: repeat(auto-fit, minmax(330px, 1fr)); gap: 16px; align-items: start; }

/* ── Result box ── */

.result-box {
  margin-top: 16px;
  padding: 14px 16px;
  background: rgba(0, 0, 0, 0.26);
  border: 1px solid var(--hairline);
  border-left: 3px solid var(--peri-dim);
  border-radius: var(--r-md);
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 340px;
  overflow: auto;
  color: var(--peri-dim);
}
.result-box.err { border-left-color: var(--crit); color: #FFB8B0; }
.result-box.ok  { border-left-color: var(--good); }

.foot { margin-top: 40px; font-size: 11.5px; color: var(--faint); }

/* ── Motion ── */

.tab-panel { animation: rise 0.2s ease both; }
@keyframes rise { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    transition-duration: 0.001ms !important;
  }
}

/* ── Narrow ── */

@media (max-width: 860px) {
  .portal { grid-template-columns: 1fr; }
  .rail {
    position: static;
    height: auto;
    flex-direction: row;
    align-items: center;
    gap: 14px;
    overflow-x: auto;
    padding: 14px 16px;
  }
  .rail-nav { flex-direction: row; }
  .rail-foot { margin-top: 0; flex-direction: row; align-items: center; }
  .rail-who { display: none; }
  .content { padding: 22px 18px 50px; }
  .tool-row { flex-direction: column; align-items: flex-start; }
  .btn-row input { width: 100%; }
}

/* ── People search ──────────────────────────────────────────────────────── */

.search-row { display: flex; gap: 10px; align-items: center; }
.search-row input { flex: 1; padding: 13px 16px; font-size: 15px; }

.banner {
  padding: 12px 16px;
  margin-bottom: 14px;
  border-radius: var(--r-md);
  background: rgba(199, 212, 238, 0.09);
  border: 1px solid rgba(199, 212, 238, 0.22);
  font-size: 13.5px;
  line-height: 1.5;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
.banner strong { font-weight: 800; }
.banner em { color: var(--peri); font-style: normal; font-weight: 700; }
.banner .ghost-btn { margin-left: auto; padding: 5px 12px; font-size: 12px; }

.person {
  display: flex;
  gap: 15px;
  align-items: flex-start;
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: var(--r-lg);
  padding: 15px 17px;
  margin-bottom: 10px;
  box-shadow: var(--shadow-card);
}

.avatar {
  width: 46px; height: 46px;
  border-radius: 13px;
  object-fit: cover;
  flex: none;
  background: var(--surface-var);
}
.avatar.placeholder {
  display: grid;
  place-items: center;
  font-weight: 800;
  font-size: 18px;
  color: var(--peri-dim);
  border: 1px solid var(--hairline-strong);
}

.person-main { flex: 1; min-width: 0; }
.person-name { font-size: 15.5px; font-weight: 700; }
.person-meta { font-size: 12.5px; color: var(--muted); margin-top: 3px; line-height: 1.45; }
.person-meta.faint { color: var(--faint); }
.person-meta .uid { font-family: var(--mono); font-size: 11.5px; }

.tags { display: flex; gap: 5px; flex-wrap: wrap; margin-top: 7px; }
.tag {
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  padding: 2px 8px;
  border-radius: var(--r-pill);
  background: rgba(255, 255, 255, 0.07);
  color: var(--muted);
  border: 1px solid var(--hairline);
}
.tag.good { background: rgba(95,184,148,0.14); color: var(--good); border-color: rgba(95,184,148,0.3); }
.tag.warn { background: rgba(232,169,78,0.14); color: var(--warn); border-color: rgba(232,169,78,0.3); }
.tag.bad  { background: rgba(229,118,107,0.14); color: var(--crit); border-color: rgba(229,118,107,0.3); }

.person-actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; max-width: 300px; }
.person-actions .ghost-btn { padding: 6px 12px; font-size: 12px; }

@media (max-width: 860px) {
  .person { flex-wrap: wrap; }
  .person-actions { max-width: none; width: 100%; justify-content: flex-start; }
  .search-row { flex-direction: column; align-items: stretch; }
}

/* uid chips inside the banner — the identity check that a name alone can't give */
.banner .uid {
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--peri-dim);
  background: rgba(0, 0, 0, 0.25);
  padding: 2px 7px;
  border-radius: 5px;
  margin-left: 6px;
  white-space: nowrap;
}
.banner .muted { font-size: 12.5px; }
.banner > div { flex: 1; line-height: 1.7; }

/* A tappable tile must LOOK tappable — otherwise it's decor that moves. */
.stat.tappable {
  cursor: pointer;
  font-family: inherit;
  text-align: left;
  width: 100%;
  color: inherit;
  transition: border-color 0.15s, transform 0.12s, background 0.15s;
}
.stat.tappable:hover {
  border-color: var(--peri-dim);
  background: var(--surface-var);
}
.stat.tappable:active { transform: translateY(1px); }
.stat-go {
  position: absolute;
  top: 14px; right: 14px;
  font-size: 14px;
  color: var(--faint);
  transition: color 0.15s, transform 0.15s;
}
.stat.tappable:hover .stat-go { color: var(--peri); transform: translateX(2px); }

/* ── Message templates ──────────────────────────────────────────────────── */

.templates { display: flex; flex-direction: column; gap: 14px; margin-top: 8px; }
.tmpl-group { display: flex; flex-wrap: wrap; gap: 6px; }
.tmpl-head {
  width: 100%;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--faint);
  margin-bottom: 2px;
}
.tmpl {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--hairline-strong);
  border-radius: var(--r-pill);
  color: #fff;
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 600;
  padding: 7px 13px;
  cursor: pointer;
  transition: background 0.14s, border-color 0.14s;
}
.tmpl:hover { background: rgba(255, 255, 255, 0.1); border-color: var(--peri-dim); }
.tmpl.active {
  background: rgba(199, 212, 238, 0.16);
  border-color: var(--peri);
  color: var(--peri);
}
.tmpl .tag { font-size: 9.5px; padding: 1px 6px; }

/* Right column of the two-col layout: stack its cards with a gap rather than
   margins, so a hidden result box contributes no space and both columns start
   level at the top. */
.col-stack { display: flex; flex-direction: column; gap: 16px; }
.col-stack > .result-box { margin-top: 0; }
