/* OO7 Operations — the OO7 team's admin console */
@font-face { font-family: "Atkinson Next"; src: url("fonts/atkinson-hyperlegible-next-latin-400-normal.woff2") format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Atkinson Next"; src: url("fonts/atkinson-hyperlegible-next-latin-600-normal.woff2") format("woff2"); font-weight: 600; font-display: swap; }
@font-face { font-family: "Atkinson Next"; src: url("fonts/atkinson-hyperlegible-next-latin-700-normal.woff2") format("woff2"); font-weight: 700; font-display: swap; }
@font-face { font-family: "Atkinson Mono"; src: url("fonts/atkinson-hyperlegible-mono-latin-500-normal.woff2") format("woff2"); font-weight: 500; font-display: swap; }

:root {
  --petrol: #0F3443;
  --petrol-2: #174a5d;
  --petrol-ink: #c9d8dc;
  --brass: #C8A24A;
  --fog: #EEF1F0;
  --paper: #FFFFFF;
  --ink: #1E262B;
  --slate: #56636B;
  --rule: #D5DCDC;
  --rule-soft: #E6EBEA;
  --ok: #2E7D57;      --ok-bg: #E4F1EA;
  --warn: #A9681A;    --warn-bg: #F7EBDB;
  --bad: #B8433D;     --bad-bg: #F8E6E4;
  --s-done: #0A77B5;  /* chart: documents done */
  --s-wait: #C27F12;  /* chart: waiting for review */
  --focus: #0A77B5;
  --sans: "Atkinson Next", "Segoe UI", system-ui, -apple-system, "Noto Sans Arabic", Tahoma, sans-serif;
  --mono: "Atkinson Mono", ui-monospace, "Cascadia Mono", Consolas, monospace;
  --r-s: 4px; --r-m: 8px;
  --rail-w: 220px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--fog); color: var(--ink);
  font: 400 15px/1.5 var(--sans);
  -webkit-font-smoothing: antialiased; font-variant-numeric: tabular-nums;
}
a { color: var(--petrol-2); }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
h1, h2, h3 { margin: 0; line-height: 1.2; }
h1 { font-size: 26px; font-weight: 700; letter-spacing: -0.01em; }
h2 { font-size: 18px; font-weight: 700; }
h3 { font-size: 15px; font-weight: 700; }
p { margin: 0 0 0.75em; }
.muted { color: var(--slate); }
.small { font-size: 13px; }
.num { text-align: right; white-space: nowrap; }
.mono { font-family: var(--mono); font-weight: 500; letter-spacing: 0.02em; }
.nowrap { white-space: nowrap; }

/* ---------- the OO7 mark ---------- */
.mark { font-weight: 700; font-size: 20px; letter-spacing: 0.04em; color: var(--brass); }
.mark-sub { font-size: 13px; color: var(--petrol-ink); margin-left: 8px; }

/* ---------- buttons & fields ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 40px; padding: 0 16px; border-radius: var(--r-s);
  border: 1px solid var(--rule); background: var(--paper); color: var(--ink);
  font-weight: 600; cursor: pointer; text-decoration: none; white-space: nowrap;
}
.btn:hover { border-color: #b4c0c1; }
.btn.primary { background: var(--petrol); border-color: var(--petrol); color: #fff; }
.btn.primary:hover { background: var(--petrol-2); }
.btn.danger { color: var(--bad); }
.btn.danger:hover { border-color: var(--bad); }
.btn.small { min-height: 32px; padding: 0 10px; font-size: 13px; }
.btn[disabled] { opacity: .55; cursor: default; }
.link-btn { background: none; border: 0; padding: 0; color: var(--petrol-2); text-decoration: underline; cursor: pointer; font-weight: 600; }

label.field { display: block; margin: 0 0 16px; }
label.field > span { display: block; font-weight: 600; font-size: 14px; margin-bottom: 6px; }
label.field > small { display: block; color: var(--slate); font-size: 13px; margin-top: 4px; }
input[type=text], input[type=email], input[type=password], input[type=search], select, textarea {
  width: 100%; min-height: 42px; padding: 8px 12px; border: 1px solid #b9c4c5; border-radius: var(--r-s);
  background: var(--paper);
}
textarea { min-height: 96px; resize: vertical; line-height: 1.45; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--focus); outline-offset: -1px; border-color: var(--focus); }
.check { display: flex; gap: 10px; align-items: flex-start; margin: 0 0 16px; cursor: pointer; }
.check input { width: 18px; height: 18px; margin: 2px 0 0; accent-color: var(--petrol); }
.check b { display: block; }
.form-error { color: var(--bad); font-weight: 600; margin: 0 0 12px; }
.form-error:empty { display: none; }

/* ---------- sign-in ---------- */
.gate { min-height: 100vh; min-height: 100dvh; background: var(--petrol); display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 24px 16px; }
.gate-card { width: 100%; max-width: 420px; background: var(--paper); border-radius: var(--r-m); padding: 28px 28px 24px; overflow: hidden; }
.gate-card .gate-mark { background: var(--petrol-2); margin: -28px -28px 24px; padding: 18px 28px; }
.gate-card h1 { font-size: 22px; margin-bottom: 6px; }
.gate-card .lead { color: var(--slate); margin-bottom: 20px; }
.gate-card .btn.primary { width: 100%; min-height: 46px; }
.gate-foot { color: var(--petrol-ink); font-size: 13px; margin-top: 16px; text-align: center; }
.steps { list-style: none; margin: 0 0 20px; padding: 0; display: flex; gap: 8px; font-size: 13px; color: var(--slate); }
.steps li { flex: 1; border-top: 3px solid var(--rule); padding-top: 6px; }
.steps li.on { border-color: var(--petrol); color: var(--ink); font-weight: 600; }
.steps li.done { border-color: var(--ok); }
.code-input { font-family: var(--mono); font-size: 28px !important; letter-spacing: 0.35em; text-align: center; min-height: 56px !important; }
.setup-block { border-top: 1px solid var(--rule-soft); padding-top: 18px; margin-top: 4px; }
.setup-block h2 { font-size: 15px; margin-bottom: 8px; }
.qr { display: flex; gap: 16px; align-items: flex-start; margin: 4px 0 14px; }
.qr-img { width: 148px; height: 148px; flex: none; background: #fff; border: 1px solid var(--rule); border-radius: var(--r-s); padding: 4px; }
.qr-img svg { width: 100%; height: 100%; display: block; }
.secret { font-family: var(--mono); font-size: 15px; word-spacing: 0.2em; line-height: 1.7; background: var(--fog); border-radius: var(--r-s); padding: 6px 8px; display: inline-block; user-select: all; }

/* ---------- console layout ---------- */
.app { min-height: 100vh; }
.rail {
  position: fixed; inset: 0 auto 0 0; width: var(--rail-w); background: var(--petrol); color: #fff;
  display: flex; flex-direction: column; padding: 20px 0 16px; z-index: 30;
}
.rail-mark { padding: 0 22px 22px; }
.nav { display: flex; flex-direction: column; }
.nav a, .rail-me {
  display: block; padding: 10px 22px; color: var(--petrol-ink); text-decoration: none; font-weight: 600;
  border-left: 3px solid transparent;
}
.nav a:hover, .rail-me:hover { color: #fff; background: rgba(255,255,255,.04); }
.nav a.on, .rail-me.on { color: #fff; border-left-color: var(--brass); background: rgba(255,255,255,.06); }
.nav a .count { float: right; min-width: 22px; text-align: center; border-radius: 10px; font-size: 12px; padding: 0 6px; background: var(--brass); color: var(--petrol); }
.rail-foot { margin-top: auto; border-top: 1px solid rgba(255,255,255,.1); padding-top: 10px; }
.rail-me small { display: block; font-weight: 400; font-size: 12px; opacity: .8; overflow: hidden; text-overflow: ellipsis; }
.rail-out { background: none; border: 0; color: var(--petrol-ink); padding: 8px 22px; cursor: pointer; text-decoration: underline; font-size: 14px; }
.topbar { display: none; }
.main { margin-left: var(--rail-w); min-height: 100vh; }
.view { max-width: 1180px; padding: 28px 36px 64px; }
.view:focus { outline: none; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.page-head .sub { color: var(--slate); margin-top: 4px; }
.page-tools { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.page-tools input[type=search] { width: 240px; }
section.block { margin: 0 0 36px; }
.block-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }
.surface { background: var(--paper); border: 1px solid var(--rule-soft); border-radius: var(--r-m); }

/* ---------- the status lamps (watchman checks), always on top ---------- */
.lamps {
  position: sticky; top: 0; z-index: 20; background: var(--paper); border-bottom: 1px solid var(--rule);
  display: flex; align-items: center; gap: 18px; padding: 10px 36px; min-height: 52px; flex-wrap: wrap;
}
.lamps-sum { font-weight: 700; display: flex; align-items: center; gap: 8px; white-space: nowrap; }
.lamps-list { display: flex; flex-wrap: wrap; gap: 4px 14px; flex: 1; list-style: none; margin: 0; padding: 0; }
.lamp { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--slate); text-decoration: none; white-space: nowrap; }
.lamp.bad { color: var(--bad); font-weight: 700; }
.lamp.same { color: var(--warn); font-weight: 600; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--ok); flex: none; }
.dot.bad { background: var(--bad); box-shadow: 0 0 0 3px var(--bad-bg); }
.dot.same, .dot.warn { background: var(--warn); }
.dot.none { background: #a9b3b6; }
.lamps-when { font-size: 13px; color: var(--slate); white-space: nowrap; }
.lamps-when.stale { color: var(--warn); font-weight: 600; }
@media (prefers-reduced-motion: no-preference) {
  .dot.bad { animation: pulse 2s ease-in-out infinite; }
  @keyframes pulse { 50% { box-shadow: 0 0 0 6px var(--bad-bg); } }
}

/* ---------- needs-you list ---------- */
.needs { list-style: none; margin: 0; padding: 0; }
.needs li { display: grid; grid-template-columns: 12px 1fr auto; gap: 12px; align-items: center; padding: 14px 18px; border-bottom: 1px solid var(--rule-soft); }
.needs li:last-child { border-bottom: 0; }
.needs .what b { display: block; }
.needs .what span { color: var(--slate); font-size: 14px; }
.calm { padding: 22px 18px; display: flex; gap: 12px; align-items: center; }
.calm b { display: block; }

/* ---------- ledger (this month's numbers) ---------- */
.ledger { display: grid; grid-template-columns: 1fr 1fr; gap: 0 40px; margin: 0; }
.ledger div { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; padding: 11px 0; border-bottom: 1px solid var(--rule); }
.ledger dt { color: var(--slate); }
.ledger dd { margin: 0; font-weight: 700; font-size: 17px; text-align: right; }
.ledger dd small { font-weight: 400; color: var(--slate); font-size: 13px; margin-left: 4px; }

/* ---------- chart ---------- */
.chart-box { padding: 18px 18px 10px; }
.legend { display: flex; gap: 18px; font-size: 13px; color: var(--slate); flex-wrap: wrap; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.sw { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart .axis text { font-size: 11px; fill: var(--slate); }
.chart .grid line { stroke: var(--rule-soft); }
.chart .base { stroke: #9aa6a9; }
.chart .hit { fill: transparent; cursor: default; }
.chart .hit:hover, .chart .hit.on { fill: rgba(15,52,67,.06); }
.seg-toggle { display: inline-flex; border: 1px solid var(--rule); border-radius: var(--r-s); overflow: hidden; }
.seg-toggle button { border: 0; background: var(--paper); padding: 4px 12px; font-size: 13px; cursor: pointer; color: var(--slate); }
.seg-toggle button.on { background: var(--petrol); color: #fff; }
.tip { position: fixed; z-index: 80; pointer-events: none; background: var(--ink); color: #fff; font-size: 13px; padding: 8px 10px; border-radius: var(--r-s); line-height: 1.45; max-width: 240px; }
.tip b { display: block; margin-bottom: 2px; }
.tip i { font-style: normal; display: inline-block; width: 9px; height: 9px; border-radius: 2px; margin-right: 6px; }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; }
table.t { width: 100%; border-collapse: collapse; }
.t th { text-align: left; font-size: 13px; font-weight: 600; color: var(--slate); padding: 10px 14px; border-bottom: 1px solid var(--rule); white-space: nowrap; }
.t td { padding: 12px 14px; border-bottom: 1px solid var(--rule-soft); vertical-align: top; }
.t tr:last-child td { border-bottom: 0; }
.t th.num, .t td.num { text-align: right; }
.t tbody tr.click { cursor: pointer; }
.t tbody tr.click:hover td { background: #f6f8f8; }
.t td .sub { display: block; color: var(--slate); font-size: 13px; }
.t td.actions { text-align: right; white-space: nowrap; }
.t td.actions .btn + .btn { margin-left: 6px; }
.empty { padding: 28px 18px; color: var(--slate); }
.more-row { padding: 14px; text-align: center; }

/* chips */
.chip { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 600; padding: 1px 8px; border-radius: 10px; white-space: nowrap; }
.chip.ok { background: var(--ok-bg); color: var(--ok); }
.chip.warn { background: var(--warn-bg); color: var(--warn); }
.chip.bad { background: var(--bad-bg); color: var(--bad); }
.chip.plain { background: var(--fog); color: var(--slate); }

/* ---------- company panel ---------- */
.panel-wrap { position: fixed; inset: 0; z-index: 50; }
.panel-scrim { position: absolute; inset: 0; background: rgba(15,52,67,.35); }
.panel { position: absolute; top: 0; right: 0; bottom: 0; width: min(640px, 100%); background: var(--fog); display: flex; flex-direction: column; box-shadow: -8px 0 24px rgba(15,52,67,.18); }
@media (prefers-reduced-motion: no-preference) {
  .panel { animation: slidein .18s ease-out; }
  @keyframes slidein { from { transform: translateX(32px); } }
}
.panel-head { background: var(--paper); padding: 20px 24px 0; border-bottom: 1px solid var(--rule); }
.panel-head .row { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; }
.panel-head h2 { font-size: 21px; }
.panel-head .meta { color: var(--slate); font-size: 14px; margin-top: 4px; }
.close-btn { border: 1px solid var(--rule); background: var(--paper); border-radius: var(--r-s); min-width: 40px; min-height: 40px; cursor: pointer; font-size: 14px; font-weight: 600; }
.tabs { display: flex; gap: 2px; margin-top: 16px; overflow-x: auto; }
.tabs button { border: 0; background: none; padding: 10px 14px; font-weight: 600; color: var(--slate); border-bottom: 3px solid transparent; cursor: pointer; white-space: nowrap; }
.tabs button.on { color: var(--ink); border-bottom-color: var(--petrol); }
.panel-body { padding: 22px 24px 40px; overflow-y: auto; flex: 1; }
.panel-body .surface { padding: 18px; }
.panel-body .t td, .panel-body .t th { padding-left: 12px; padding-right: 12px; }
.kv { display: grid; grid-template-columns: 140px 1fr; gap: 8px 16px; margin: 0 0 18px; }
.kv dt { color: var(--slate); }
.kv dd { margin: 0; }
.form-actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

/* ---------- dialogs & toast ---------- */
.modal-wrap { position: fixed; inset: 0; z-index: 70; background: rgba(15,52,67,.45); display: flex; align-items: center; justify-content: center; padding: 16px; }
.modal { background: var(--paper); border-radius: var(--r-m); width: 100%; max-width: 460px; padding: 24px; max-height: 92vh; overflow-y: auto; }
.modal h2 { margin-bottom: 8px; }
.modal .form-actions { margin-top: 20px; justify-content: flex-end; }
.handover { border: 2px dashed var(--brass); border-radius: var(--r-m); padding: 14px 16px; margin: 14px 0; background: #fffbf1; }
.handover dl { display: grid; grid-template-columns: 82px 1fr; gap: 6px 12px; margin: 0; }
.handover dt { color: var(--slate); }
.handover dd { margin: 0; word-break: break-all; }
.handover .pw { font-family: var(--mono); font-size: 22px; letter-spacing: 0.06em; color: var(--ink); }
.warn-note { color: var(--warn); font-weight: 600; font-size: 14px; }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 90; background: var(--ink); color: #fff; padding: 10px 16px; border-radius: var(--r-s); font-weight: 600; max-width: calc(100% - 32px); }
.toast.bad { background: var(--bad); }

/* ---------- health ---------- */
.checks { list-style: none; margin: 0; padding: 0; }
.checks li { display: grid; grid-template-columns: 14px 190px 1fr auto; gap: 12px; align-items: baseline; padding: 12px 18px; border-bottom: 1px solid var(--rule-soft); }
.checks li:last-child { border-bottom: 0; }
.checks li .dot { align-self: center; }
.checks .msg { color: var(--slate); }
.checks li.bad .msg { color: var(--bad); font-weight: 600; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 28px; }

/* ---------- costs hero ---------- */
.cost-hero { display: flex; gap: 40px; flex-wrap: wrap; padding: 20px 22px; align-items: baseline; }
.cost-hero .big { font-size: 40px; font-weight: 700; line-height: 1; letter-spacing: -0.02em; }
.cost-hero .big small { font-size: 18px; font-weight: 600; color: var(--slate); margin-left: 4px; letter-spacing: 0; }
.cost-hero p { margin: 6px 0 0; color: var(--slate); }

/* ---------- activity ---------- */
.act-what { font-weight: 600; }
.act-details { color: var(--slate); font-size: 13px; max-width: 420px; overflow-wrap: anywhere; }

/* ---------- loading ---------- */
.loading { color: var(--slate); padding: 40px 0; }

/* ================= phone & small tablet ================= */
@media (max-width: 900px) {
  .rail { transform: translateX(-100%); transition: transform .2s ease-out; width: 260px; }
  .rail.open { transform: none; }
  .scrim { position: fixed; inset: 0; background: rgba(15,52,67,.4); z-index: 25; }
  .topbar { display: flex; align-items: center; gap: 14px; position: sticky; top: 0; z-index: 22; background: var(--petrol); color: #fff; padding: 10px 16px; min-height: 52px; }
  .menu-btn { background: none; border: 1px solid rgba(255,255,255,.3); color: #fff; border-radius: var(--r-s); padding: 6px 12px; font-weight: 600; cursor: pointer; }
  .topbar-title { font-weight: 600; color: var(--petrol-ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .main { margin-left: 0; }
  .lamps { top: 52px; padding: 8px 16px; gap: 6px 12px; min-height: 0; }
  .lamps-list { display: none; }
  .lamps.open .lamps-list { display: flex; flex-basis: 100%; order: 3; padding: 4px 0 6px; }
  .lamps-sum { cursor: pointer; }
  .view { padding: 20px 16px 56px; }
  h1 { font-size: 23px; }
  .ledger { grid-template-columns: 1fr; }
  .two-col { grid-template-columns: 1fr; }
  .page-tools { width: 100%; }
  .page-tools input[type=search] { flex: 1; width: auto; min-width: 0; }
  .t .hide-s { display: none; }
  .checks li { grid-template-columns: 14px 1fr; }
  .checks li .msg, .checks li .when { grid-column: 2; }
  .needs li { grid-template-columns: 12px 1fr; }
  .needs li .btn { grid-column: 2; justify-self: start; }
  .kv { grid-template-columns: 1fr; gap: 2px; }
  .kv dd { margin-bottom: 10px; }
  .panel-head { padding: 16px 16px 0; }
  .panel-body { padding: 18px 16px 40px; }
  .cost-hero .big { font-size: 34px; }
}
@media (max-width: 560px) {
  .t .hide-xs { display: none; }
  .t td, .t th { padding-left: 10px; padding-right: 10px; }
  .qr { flex-direction: column; }
  .gate-card { padding: 24px 18px 20px; }
  .gate-card .gate-mark { margin: -24px -18px 20px; padding: 16px 18px; }
}
@media print { .rail, .lamps, .topbar { display: none; } .main { margin: 0; } }
