/* Turtuga Interactive App.
   The same visual universe as Headquarters. Official palette, official gold,
   no invented brand colour. This layer is for doing work, so it carries the
   controls Headquarters deliberately does not have. */
:root {
  --bone: #F2F0EB; --bone-2: #EAE7E0; --paper: #FFFFFF;
  --ink: #0C0C0C; --grey: #63625E; --grey-2: #8C8B86;
  --line: #E1DED6; --line-2: #D2CEC4;
  --gold: #C2A762; --gold-ink: #7C6531; --gold-wash: rgba(194,167,98,.10);
  --ok: #2F6B4F; --ok-wash: rgba(47,107,79,.10);
  --warn: #8A6A1F; --warn-wash: rgba(138,106,31,.12);
  --crit: #8C3A2E; --crit-wash: rgba(140,58,46,.10);
  --idle: #6E6C67; --idle-wash: rgba(110,108,103,.10);
  --r: 14px; --r-sm: 9px;
  --shadow: 0 1px 2px rgba(12,12,12,.04), 0 6px 20px rgba(12,12,12,.05);
  --shadow-lg: 0 2px 6px rgba(12,12,12,.06), 0 18px 48px rgba(12,12,12,.10);
  --sans: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Inter, system-ui, sans-serif;
  --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, monospace;
  --side: 232px;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; font: 15px/1.55 var(--sans); color: var(--ink);
  background: var(--bone); -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
.num { font-variant-numeric: tabular-nums; }
:focus-visible { outline: 2px solid var(--gold-ink); outline-offset: 2px; border-radius: 4px; }
h1, h2, h3 { margin: 0; font-weight: 500; letter-spacing: -.015em; }

/* ------------------------------------------------------------------ auth */
.gate { min-height: 100vh; min-height: 100svh; display: grid; place-items: center;
        padding: calc(24px + env(safe-area-inset-top)) 24px calc(24px + env(safe-area-inset-bottom)); }
.gate__box {
  width: 100%; max-width: 380px; background: var(--paper);
  border: 1px solid var(--line); border-radius: var(--r);
  box-shadow: var(--shadow-lg); padding: 34px 30px 26px; text-align: center;
}
.gate__mark { height: 52px; margin-bottom: 20px; }
.gate h1 { font-size: 21px; }
.gate__sub { margin: 8px 0 24px; color: var(--grey); font-size: 13.5px; }
.field { text-align: left; margin-bottom: 14px; }
.field label {
  display: block; font-size: 10.5px; letter-spacing: .1em;
  text-transform: uppercase; color: var(--grey); margin-bottom: 6px;
}
input, textarea, select {
  width: 100%; font: inherit; padding: 10px 12px; color: var(--ink);
  background: var(--paper); border: 1px solid var(--line-2);
  border-radius: var(--r-sm); transition: border-color .15s;
}
input:focus, textarea:focus, select:focus {
  outline: none; border-color: var(--gold-ink);
  box-shadow: 0 0 0 3px rgba(124,101,49,.15);
}
textarea { min-height: 84px; resize: vertical; }

.btn {
  font: inherit; font-size: 14px; cursor: pointer; padding: 10px 18px;
  border-radius: var(--r-sm); border: 1px solid var(--line-2);
  background: var(--paper); color: var(--ink); transition: all .15s;
}
.btn:hover { border-color: var(--gold-ink); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn--primary { background: var(--ink); color: var(--bone); border-color: var(--ink); }
.btn--primary:hover { background: var(--gold-ink); border-color: var(--gold-ink); }
.btn--sm { padding: 6px 12px; font-size: 13px; }
.btn--ghost { border-color: transparent; color: var(--grey); }
.btn--ghost:hover { color: var(--ink); border-color: var(--line-2); }
.btn--full { width: 100%; }
.linkish {
  background: none; border: 0; font: inherit; font-size: 13px; color: var(--gold-ink);
  cursor: pointer; padding: 0; border-bottom: 1px solid var(--line-2);
}

.msg { margin-top: 14px; font-size: 13px; padding: 10px 12px; border-radius: var(--r-sm); }
.msg--err { background: var(--crit-wash); color: var(--crit); }
.msg--ok { background: var(--ok-wash); color: var(--ok); }

/* ----------------------------------------------------------------- shell */
.app { display: grid; grid-template-columns: var(--side) 1fr; min-height: 100vh; min-height: 100svh; }
.side {
  background: var(--paper); border-right: 1px solid var(--line);
  display: flex; flex-direction: column; position: sticky; top: 0;
  height: 100vh; height: 100svh;
}
.side__brand { padding: 20px 18px 16px; border-bottom: 1px solid var(--line); }
.side__brand img { width: 100%; max-width: 172px; height: auto; display: block; }
.side__brand small {
  display: block; margin-top: 7px; font-size: 9.5px; letter-spacing: .16em;
  text-transform: uppercase; color: var(--grey-2);
}
.side__nav { padding: 12px 10px; flex: 1; overflow-y: auto; }
.side__grp {
  font-size: 9.5px; letter-spacing: .13em; text-transform: uppercase;
  color: var(--grey-2); padding: 14px 10px 6px;
}
.side a.nav {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 8px 10px; border-radius: var(--r-sm); font-size: 14px; color: var(--grey);
}
.side a.nav:hover { background: var(--bone); color: var(--ink); }
.side a.nav[aria-current="page"] {
  background: var(--gold-wash); color: var(--ink); font-weight: 500;
  box-shadow: inset 2px 0 0 var(--gold-ink);
}
.badge {
  font: 500 11px/1 var(--mono); padding: 3px 7px; border-radius: 999px;
  background: var(--bone-2); color: var(--grey);
}
.badge--attn { background: var(--crit-wash); color: var(--crit); }
.side__foot { padding: 14px 18px; border-top: 1px solid var(--line); font-size: 12px; color: var(--grey); }
.side__foot b { display: block; color: var(--ink); font-weight: 500; font-size: 13px; }

.main { min-width: 0; display: flex; flex-direction: column; }
.top {
  height: 58px; display: flex; align-items: center; gap: 14px; padding: 0 26px;
  border-bottom: 1px solid var(--line); background: rgba(255,255,255,.86);
  -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px);
  position: sticky; top: 0; z-index: 20;
}
.top__t { font-size: 15px; font-weight: 500; }
.top__spacer { flex: 1; }
.chip {
  display: inline-flex; align-items: center; gap: 7px; font-size: 11.5px;
  padding: 4px 11px; border-radius: 999px; border: 1px solid var(--line);
  background: var(--paper); color: var(--grey);
}
.chip::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--ok); }
.wrap { padding: 26px; max-width: 1180px; width: 100%; }

/* ------------------------------------------------------------- primitives */
.page__h { font-size: 27px; }
.page__sub { margin: 7px 0 0; color: var(--grey); font-size: 14.5px; max-width: 74ch; }
section { margin-top: 34px; }
.head { display: flex; align-items: baseline; gap: 13px; margin-bottom: 14px; }
.head h2 { font-size: 12px; letter-spacing: .1em; text-transform: uppercase; color: var(--grey); font-weight: 400; }
.head__rule { flex: 1; height: 1px; background: var(--line); }
.head__n { font-size: 12px; color: var(--grey-2); }

.grid { display: grid; gap: 14px; }
.g2 { grid-template-columns: repeat(2, 1fr); }
.g3 { grid-template-columns: repeat(3, 1fr); }
.g4 { grid-template-columns: repeat(4, 1fr); }
.card {
  background: var(--paper); border: 1px solid var(--line);
  border-radius: var(--r); padding: 17px 19px; box-shadow: var(--shadow);
}
.card--link { transition: transform .16s, box-shadow .16s, border-color .16s; display: block; }
.card--link:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); border-color: rgba(194,167,98,.45); }
.kpi__l { font-size: 12px; color: var(--grey); }
.kpi__v { font-size: 29px; line-height: 1.1; margin-top: 6px; letter-spacing: -.02em; }
.kpi__v.sm { font-size: 18px; }
.kpi__s { margin-top: 6px; font-size: 12px; color: var(--grey); }

.pill {
  display: inline-flex; align-items: center; font-size: 11px; padding: 3px 9px;
  border-radius: 999px; border: 1px solid transparent; letter-spacing: .02em; white-space: nowrap;
}
.pill--ok { background: var(--ok-wash); color: var(--ok); }
.pill--warn { background: var(--warn-wash); color: var(--warn); }
.pill--crit { background: var(--crit-wash); color: var(--crit); }
.pill--idle { background: var(--idle-wash); color: var(--idle); }
.pill--gold { background: var(--gold-wash); color: var(--gold-ink); }
.mute { color: var(--grey); }
.dim { color: var(--grey-2); }

.row {
  display: grid; grid-template-columns: 4px 1fr auto; gap: 14px; align-items: start;
  background: var(--paper); border: 1px solid var(--line); border-radius: var(--r);
  padding: 15px 17px; box-shadow: var(--shadow);
}
.row__bar { align-self: stretch; border-radius: 3px; background: var(--idle); }
.row--P0 .row__bar { background: var(--crit); }
.row--P1 .row__bar { background: var(--warn); }
.row--P2 .row__bar { background: var(--gold-ink); }
.row--P3 .row__bar { background: var(--idle); }
.row__t { font-size: 15px; font-weight: 500; }
.row__w { margin-top: 5px; font-size: 13.5px; color: var(--grey); max-width: 82ch; }
.row__m { margin-top: 8px; font-size: 12px; color: var(--grey-2); display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }
.row__actions { display: flex; gap: 7px; align-items: center; flex-wrap: wrap; justify-content: flex-end; }

.tblwrap { overflow-x: auto; background: var(--paper); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow); }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th {
  text-align: left; font: 400 10.5px/1 var(--sans); letter-spacing: .1em;
  text-transform: uppercase; color: var(--grey); padding: 13px 15px;
  border-bottom: 1px solid var(--line); white-space: nowrap;
}
td { padding: 12px 15px; border-bottom: 1px solid var(--line); vertical-align: top; }
tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: var(--bone); }
td.num, th.r { white-space: nowrap; }
.r { text-align: right; }

.empty {
  background: var(--paper); border: 1px dashed var(--line-2); border-radius: var(--r);
  padding: 26px; color: var(--grey); font-size: 13.5px; text-align: center;
}
.empty b { display: block; color: var(--ink); font-weight: 500; margin-bottom: 5px; font-size: 15px; }

.help { border-bottom: 1px dotted var(--grey-2); cursor: help; }
#tip {
  position: fixed; z-index: 90; max-width: 330px; background: var(--ink); color: var(--bone);
  padding: 12px 14px; border-radius: 10px; font-size: 12.5px; line-height: 1.5;
  box-shadow: var(--shadow-lg); opacity: 0; pointer-events: none; transition: opacity .12s;
}
#tip.on { opacity: 1; }
#tip h4 { margin: 0 0 5px; font-size: 12.5px; color: var(--gold); }

.modal { position: fixed; inset: 0; z-index: 80; display: none; place-items: center; padding: 24px;
  background: rgba(12,12,12,.42);
  -webkit-backdrop-filter: blur(2px); backdrop-filter: blur(2px); }
.modal.on { display: grid; }
.modal__box { background: var(--paper); border-radius: var(--r); box-shadow: var(--shadow-lg);
  max-width: 470px; width: 100%; padding: 24px; max-height: 86vh; overflow-y: auto; }
.modal__box h3 { font-size: 18px; margin-bottom: 4px; }
.modal__f { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }

.stack { display: flex; flex-direction: column; gap: 11px; }
.inline { display: flex; gap: 9px; align-items: center; flex-wrap: wrap; }
.note { background: var(--paper); border: 1px solid var(--line); border-radius: var(--r-sm); padding: 12px 14px; }
.note__m { font-size: 11.5px; color: var(--grey-2); margin-bottom: 5px; }

.meta { display: grid; grid-template-columns: repeat(4, 1fr); gap: 17px 22px; }
.meta__k { font-size: 10.5px; letter-spacing: .09em; text-transform: uppercase; color: var(--grey); }
.meta__v { margin: 4px 0 0; font-size: 14.5px; }
.meta__v.absent { color: var(--grey-2); }

.spin { display: inline-block; width: 15px; height: 15px; border: 2px solid var(--line-2);
  border-top-color: var(--gold-ink); border-radius: 50%; animation: sp .7s linear infinite; }
@keyframes sp { to { transform: rotate(360deg); } }

/* --------------------------------------------------------------- responsive */
@media (max-width: 1080px) { .g4 { grid-template-columns: repeat(2, 1fr); } .meta { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  .side { padding-top: env(safe-area-inset-top); }
  .wrap { padding-bottom: calc(44px + env(safe-area-inset-bottom)); }
  .side, .main { min-width: 0; }
  .side { position: static; height: auto; flex-direction: row; align-items: center;
          overflow-x: auto; border-right: 0; border-bottom: 1px solid var(--line); }
  .side__brand { border-bottom: 0; border-right: 1px solid var(--line); padding: 11px 14px; flex: none; }
  .side__brand small { display: none; }
  .side__brand img { max-width: 116px; }
  .side__nav { display: flex; gap: 4px; padding: 8px; }
  .side__grp, .side__foot { display: none; }
  .side a.nav { white-space: nowrap; }
}
@media (max-width: 680px) {
  /* iOS Safari zooms the page in whenever a focused field is under 16px.
     Sixteen keeps the sign in screen still when the keyboard opens. */
  input, textarea, select { font-size: 16px; }
  .wrap { padding: 18px 14px 44px; }
  .top { padding: 0 14px; }
  .page__h { font-size: 22px; }
  .g2, .g3, .g4 { grid-template-columns: 1fr; }
  .meta { grid-template-columns: repeat(2, 1fr); }
  .row { grid-template-columns: 4px 1fr; }
  .row__actions { grid-column: 2; justify-content: flex-start; }
}
@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .001ms !important; transition-duration: .001ms !important; }
  .card--link:hover { transform: none; }
}
