/* The look of both backoffices (Owner and AG).
   One shell, one set of parts. The page files (owner.css, ag.css) only add what is theirs alone. */
@font-face {
  font-family: ConsoleIcons;
  src: url("/lobby/assets/icons.woff2") format("woff2");
  font-display: block;
}

:root {
  /* brand */
  --forest: #10382e;
  --forest-deep: #0b2a22;
  --lime: #d9f383;
  /* surfaces and text */
  --paper: #f3f5ef;
  --sheet: #fff;
  --line: #dce4da;
  --ink: #16261f;
  --muted: #5a6b62;
  /* states: every state of a site or a request has one of these four */
  --open: #12704f;      --open-bg: #e3f3ea;
  --wait: #8a5a00;      --wait-bg: #fbf0d9;
  --stop: #a3371f;      --stop-bg: #fbe7e1;
  --off: #55605a;       --off-bg: #eaeeea;
  --rail: 236px;
  --text: "Sukhumvit Set", "Noto Sans Thai", "Leelawadee UI", system-ui, -apple-system, "Segoe UI", Tahoma, sans-serif;
  /* only for identifiers a machine reads: AG codes and username segments */
  --code: ui-monospace, "SF Mono", "Cascadia Mono", Menlo, Consolas, monospace;
  color-scheme: light;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 15px/1.55 var(--text); background: var(--paper); color: var(--ink); }
h1, h2, h3, p, dl, dd, ul, ol { margin: 0; }
ul, ol { padding: 0; list-style: none; }
h1 { font-size: clamp(24px, 2.6vw, 30px); line-height: 1.2; font-weight: 700; letter-spacing: -.01em; }
h2 { font-size: 17px; line-height: 1.3; font-weight: 700; }
h3 { font-size: 15px; line-height: 1.35; font-weight: 700; }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
button, select, summary { cursor: pointer; }
button:disabled { cursor: default; opacity: .55; }
:focus-visible { outline: 3px solid #1c8b67; outline-offset: 2px; border-radius: 4px; }
.ico { font: normal 1em/1 ConsoleIcons; display: inline-block; }
.muted { color: var(--muted); }
.hint { color: var(--muted); font-size: 13.5px; }
/* A link inside a sentence has to look like one. */
.hint a, .empty a { color: var(--open); font-weight: 600; text-decoration: underline; text-underline-offset: 2px; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

/* ---------- brand ---------- */
.brand { display: inline-flex; align-items: center; gap: 12px; color: #fff; }
.brand-mark { transform: skew(-24deg); display: grid; gap: 3px; }
.brand-mark b { display: block; width: 24px; height: 5px; background: var(--lime); }
.brand-mark b:nth-child(2) { width: 18px; margin-left: 4px; }
.brand-mark b:nth-child(3) { margin-left: 2px; }
.brand-name { font: 900 italic 21px/1 Arial, sans-serif; letter-spacing: -.04em; white-space: nowrap; }
.brand-name em { color: var(--lime); font-style: inherit; }
.brand-name small { display: block; margin-top: 6px; color: #b9d3c3; font: 600 10px/1 Arial, sans-serif; letter-spacing: .2em; font-style: normal; }

/* ---------- the gate (signed out) ---------- */
.gate { min-height: 100dvh; display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 6fr); }
.gate-brand { background: var(--forest); color: #dcebe1; padding: clamp(28px, 6vw, 72px); display: flex; flex-direction: column; justify-content: space-between; gap: 40px; }
.gate-brand p { max-width: 30ch; font-size: clamp(20px, 2.4vw, 28px); line-height: 1.35; font-weight: 700; color: #fff; }
.gate-brand .env { align-self: flex-start; }
.gate-form { display: grid; align-content: center; justify-items: center; padding: 32px 20px; }
.gate-card { width: min(380px, 100%); }
.gate-card h1 { font-size: 26px; }
.gate-card .hint { margin-top: 6px; }
.gate-card form { margin-top: 24px; }
.gate-card .button { width: 100%; min-height: 44px; }
.gate-status { margin-top: 14px; min-height: 1.5em; color: var(--stop); font-size: 14px; }

/* ---------- the shell (signed in) ---------- */
.shell { display: grid; grid-template-columns: var(--rail) minmax(0, 1fr); min-height: 100dvh; }
.rail { background: var(--forest); color: #dcebe1; display: flex; flex-direction: column; position: sticky; top: 0; height: 100dvh; padding: 24px 14px 14px; }
.rail .brand { padding: 2px 8px 22px; }
/* The usual focus ring is green on white; on the dark rail it has to be the lime. */
.rail :focus-visible, .topbar :focus-visible, .gate-brand :focus-visible { outline-color: var(--lime); }
.rail-nav { flex: 1; overflow-y: auto; scrollbar-width: thin; scrollbar-color: #3a6555 transparent; display: grid; align-content: start; gap: 2px; }
.rail-nav h2 { margin: 16px 10px 6px; color: #a9c6b5; font-size: 12.5px; font-weight: 600; }
.rail-nav h2:first-child { margin-top: 0; }
.rail-nav a { display: flex; align-items: center; gap: 11px; min-height: 40px; padding: 8px 10px; border-radius: 8px; color: #e3efe7; font-weight: 600; font-size: 14.5px; }
.rail-nav a .ico { width: 18px; text-align: center; opacity: .85; }
.rail-nav a:hover { background: #1c4a3d; }
.rail-nav a[aria-current="page"] { background: var(--lime); color: #12301f; }
.rail-nav a[aria-current="page"] .ico { opacity: 1; }
.badge { margin-left: auto; min-width: 22px; padding: 1px 7px; border-radius: 20px; background: #c2431b; color: #fff; font-size: 12px; font-weight: 800; text-align: center; }
.rail-foot { border-top: 1px solid #2c5647; margin-top: 12px; padding: 12px 8px 2px; display: grid; gap: 10px; font-size: 13.5px; }
.who { display: flex; align-items: center; gap: 10px; min-width: 0; }
.who-initial { flex: 0 0 auto; width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; background: var(--lime); color: #12301f; font-weight: 800; }
.who-text { min-width: 0; }
.who-text strong { display: block; color: #fff; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.who-text span { color: #a9c6b5; font-size: 12.5px; }
.rail-foot .button { background: transparent; border-color: #3a6555; color: #e3efe7; }
.rail-foot .button:hover { background: #1c4a3d; border-color: #4c7a68; }
.env { display: inline-block; justify-self: start; border: 1px solid #4c7a68; border-radius: 30px; padding: 2px 10px; color: #dcebe1; font-size: 12px; white-space: nowrap; }
.env:empty { display: none; }

.work { min-width: 0; display: flex; flex-direction: column; }
.topbar { display: none; }
.content { width: 100%; max-width: 1180px; padding: clamp(22px, 3.2vw, 44px) clamp(16px, 3.4vw, 48px) 96px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 22px; }
.page-head .hint { margin-top: 4px; max-width: 70ch; }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.block { margin-top: 26px; }
.block-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 10px; }
.block-head a { color: var(--open); font-weight: 600; font-size: 14px; }
.block-head a:hover { text-decoration: underline; }

/* ---------- buttons ---------- */
.button { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 38px; padding: 7px 14px; border: 1px solid #cdd9cd; border-radius: 8px; background: var(--sheet); color: var(--ink); font-size: 14px; font-weight: 600; }
.button:hover { background: #eef4ec; border-color: #a9c7b3; }
.button.primary { background: var(--forest); border-color: var(--forest); color: #fff; }
.button.primary:hover { background: #17503f; border-color: #17503f; }
.button.danger { background: var(--stop); border-color: var(--stop); color: #fff; }
.button.danger:hover { background: #8a2c17; border-color: #8a2c17; }
.button.small { min-height: 32px; padding: 4px 11px; font-size: 13.5px; }
.link-button { border: 0; background: none; padding: 4px 2px; color: var(--open); font-weight: 600; font-size: 14px; }
.link-button:hover { text-decoration: underline; }
.link-button.danger { color: var(--stop); }
.icon-button { display: grid; place-items: center; width: 38px; height: 38px; border: 1px solid var(--line); border-radius: 8px; background: var(--sheet); font-size: 18px; line-height: 1; }
.icon-button:hover { background: #eef4ec; }

/* ---------- panels, lists, tables ---------- */
.panel { background: var(--sheet); border: 1px solid var(--line); border-radius: 14px; padding: 18px 20px; min-width: 0; }
.panel.flush { padding: 0; overflow: hidden; }
.empty { padding: 34px 20px; text-align: center; color: var(--muted); }
.empty strong { display: block; color: var(--ink); font-size: 16px; margin-bottom: 4px; }
.empty .button { margin-top: 14px; }

/* A ledger: one thing per row, ruled, read left to right. */
.ledger > li { display: flex; align-items: center; gap: 14px; padding: 14px 20px; border-top: 1px solid var(--line); }
.ledger > li:first-child { border-top: 0; }
.ledger > li.empty { justify-content: center; }
.ledger .grow { flex: 1; min-width: 0; }
.ledger strong { display: block; overflow-wrap: anywhere; }
.ledger small { display: block; color: var(--muted); font-size: 13px; overflow-wrap: anywhere; }
.ledger time { color: var(--muted); font-size: 13px; white-space: nowrap; }
.ledger .row-link { display: flex; align-items: center; gap: 14px; flex: 1; min-width: 0; margin: -14px -20px; padding: 14px 20px; border: 0; background: none; text-align: left; }
.ledger .row-link:hover { background: #f6f9f3; }
.ledger .chevron { color: #9aaba1; }
.ledger .reason { margin-top: 3px; padding-left: 9px; border-left: 2px solid var(--line); }

.table-wrap { overflow: auto; position: relative; }
table { border-collapse: collapse; width: 100%; font-size: 14px; white-space: nowrap; }
th { text-align: left; font-weight: 600; font-size: 13px; color: var(--muted); padding: 11px 16px; border-bottom: 1px solid var(--line); background: #f8faf6; }
td { padding: 12px 16px; border-bottom: 1px solid var(--line); }
tbody tr:last-child td { border-bottom: 0; }
td select { padding: 5px 8px; border: 1px solid var(--line); border-radius: 6px; background: var(--sheet); max-width: 100%; }
td strong, td small { display: block; }
td small { color: var(--muted); font-size: 13px; }
/* Money lines up on the right, digit under digit. */
.num { text-align: right; font-variant-numeric: tabular-nums; }
td.wrap { white-space: normal; min-width: 22ch; max-width: 44ch; overflow-wrap: anywhere; }
caption { caption-side: top; text-align: left; padding: 12px 16px 10px; font-weight: 700; font-size: 14px; }
tfoot th, tfoot td { background: #f8faf6; border-top: 1px solid var(--line); border-bottom: 0; color: var(--ink); font-size: 14px; font-weight: 700; padding: 12px 16px; }
.code { font: 600 13px/1 var(--code); }
/* The one number a section is about. */
.figure { font-size: clamp(26px, 3.4vw, 34px); line-height: 1.15; font-weight: 700; letter-spacing: -.01em; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
/* A figure that is an id, not a number: in the face of codes, and small enough to stand on one line. */
.figure.code { font: 600 clamp(15px, 1.7vw, 18px)/1.4 var(--code); letter-spacing: 0; user-select: all; }

/* A few numbers side by side, each with what it is. */
.figures { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 16px; }
.figures .panel { display: grid; gap: 2px; align-content: start; }
/* Panels that hold a sentence, not a number: fewer to a row, and one that is a line of its own. */
.figures.roomy { grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.figures .panel.across { grid-column: 1 / -1; }
.figures a { color: var(--open); font-weight: 600; font-size: 14px; margin-top: 4px; }
.figures a:hover { text-decoration: underline; }
.below-zero { color: var(--stop); }
/* The period of a report: two days and what to do with them. */
.report-form { display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap; margin: 14px 0; }
.report-form label { display: grid; gap: 6px; font-size: 14px; font-weight: 600; }
.report-form input { min-height: 38px; padding: 7px 10px; border: 1px solid #cdd9cd; border-radius: 8px; background: var(--sheet); font-weight: 400; }
label.check { display: inline-flex; gap: 8px; align-items: center; font-size: 14px; font-weight: 600; min-height: 38px; }
label.check input { width: 18px; height: 18px; accent-color: var(--forest, #17493c); }
@media (max-width: 900px) { .report-form input { min-height: 44px; } label.check { min-height: 44px; } }

.facts { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 9px 18px; font-size: 14px; }
.facts dt { color: var(--muted); }
.facts dd { overflow-wrap: anywhere; }

/* ---------- the identity plate of an AG ----------
   The code people use, and the fixed segment its members' usernames carry at AMB. */
.plate { display: inline-flex; align-items: stretch; border-radius: 7px; overflow: hidden; font: 600 13px/1 var(--code); white-space: nowrap; flex: 0 0 auto; border: 1px solid var(--forest); }
.plate-code { background: var(--forest); color: #fff; padding: 7px 9px; letter-spacing: .01em; }
.plate-segment { background: var(--lime); color: #12301f; padding: 7px 8px; }
.plate-segment.none { background: var(--sheet); color: var(--muted); font-family: var(--text); font-weight: 500; }
.plate.large { font-size: 15px; }
.plate.large .plate-code, .plate.large .plate-segment { padding: 9px 12px; }

/* ---------- state chips ---------- */
.chip { display: inline-flex; align-items: center; gap: 6px; border-radius: 20px; padding: 3px 10px; font-size: 12.5px; font-weight: 700; white-space: nowrap; background: var(--off-bg); color: var(--off); }
.chip::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.chip.is-open { background: var(--open-bg); color: var(--open); }
.chip.is-wait { background: var(--wait-bg); color: var(--wait); }
.chip.is-stop { background: var(--stop-bg); color: var(--stop); }

/* How many sites are in which state, as one bar. */
.statebar { display: flex; height: 14px; border-radius: 8px; overflow: hidden; background: var(--off-bg); }
.statebar i { display: block; min-width: 6px; }
.statebar .is-open { background: var(--open); }
.statebar .is-wait { background: #e0a530; }
.statebar .is-stop { background: var(--stop); }
.statebar-legend { display: flex; flex-wrap: wrap; gap: 6px 22px; margin-top: 12px; font-size: 14px; }
.statebar-legend span { display: inline-flex; align-items: baseline; gap: 7px; }
.statebar-legend b { font-size: 20px; font-variant-numeric: tabular-nums; }
.statebar-legend i { width: 9px; height: 9px; border-radius: 50%; align-self: center; }

/* What needs the person now. */
.todo > li { display: flex; align-items: center; gap: 14px; padding: 13px 20px; border-top: 1px solid var(--line); }
.todo > li:first-child { border-top: 0; }
.todo .ico { flex: 0 0 auto; width: 34px; height: 34px; border-radius: 9px; display: grid; place-items: center; background: var(--wait-bg); color: var(--wait); }
.todo .is-stop .ico, .todo li.is-stop .ico { background: var(--stop-bg); color: var(--stop); }
.todo li.is-done .ico { background: var(--open-bg); color: var(--open); }
.todo .grow { flex: 1; min-width: 0; }
.todo small { display: block; color: var(--muted); font-size: 13px; }

.notice { display: block; padding: 12px 16px; border-radius: 10px; background: var(--wait-bg); border: 1px solid #ecd6a6; color: #6b4600; font-size: 14px; margin-bottom: 16px; }
.notice.is-stop { background: var(--stop-bg); border-color: #efc6ba; color: #7d2915; }
.secret-once { margin-top: 14px; padding: 14px 16px; background: #f1f7e6; border: 1px solid #cfe2b4; border-radius: 10px; display: grid; gap: 6px; }
.secret-once code { font: 700 16px/1.3 var(--code); overflow-wrap: anywhere; user-select: all; }

/* The path of an AG from made to open: it is a sequence, so it is numbered. */
.steps { counter-reset: step; display: grid; }
.steps > li { counter-increment: step; position: relative; padding: 0 0 20px 44px; }
.steps > li::before { content: counter(step); position: absolute; left: 0; top: 0; width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; background: var(--sheet); border: 2px solid #b9c8bd; color: var(--muted); font-weight: 700; font-size: 13px; }
.steps > li::after { content: ""; position: absolute; left: 13px; top: 30px; bottom: 2px; width: 2px; background: #cfdad1; }
.steps > li:last-child { padding-bottom: 0; }
.steps > li:last-child::after { display: none; }
.steps > li.is-done::before { content: "\f00c"; font: normal 13px/1 ConsoleIcons; background: var(--open); border-color: var(--open); color: #fff; }
.steps > li.is-done::after { background: var(--open); }
.steps > li.is-now::before { border-color: var(--forest); color: var(--forest); background: var(--lime); }
.steps h3 { padding-top: 3px; }
.steps p { color: var(--muted); font-size: 14px; margin-top: 2px; }
.steps .step-action { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-top: 10px; }
.steps select { min-height: 38px; padding: 6px 10px; border: 1px solid #cdd9cd; border-radius: 8px; background: var(--sheet); max-width: 100%; }

/* ---------- forms ---------- */
.form { display: grid; gap: 14px; }
.form label, .form .field { display: grid; gap: 6px; font-size: 14px; font-weight: 600; }
.form input, .form select, .form textarea { width: 100%; min-height: 42px; padding: 9px 11px; border: 1px solid #cdd9cd; border-radius: 8px; background: var(--sheet); font-weight: 400; }
.form textarea { resize: vertical; min-height: 84px; }
.form input:focus-visible, .form select:focus-visible, .form textarea:focus-visible { outline-offset: 0; border-color: #1c8b67; }
.form .field-hint { color: var(--muted); font-size: 13px; font-weight: 400; }
.form .two { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.form-error { color: var(--stop); font-size: 14px; }
/* A choice between two ways of working, each with a line that says what it means. */
.choices { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; border: 0; padding: 0; margin: 0; min-width: 0; }
.choices legend { padding: 0; margin-bottom: 6px; font-size: 14px; font-weight: 600; }
.choice { position: relative; display: block; border: 1px solid #cdd9cd; border-radius: 10px; padding: 11px 12px 11px 38px; background: var(--sheet); cursor: pointer; }
.choice input { position: absolute; left: 12px; top: 14px; width: 16px; height: 16px; min-height: 0; padding: 0; accent-color: var(--forest); }
.choice strong { display: block; font-size: 14px; }
.choice span { display: block; color: var(--muted); font-size: 13px; font-weight: 400; margin-top: 2px; }
.choice:has(input:checked) { border-color: var(--forest); background: #f1f7e6; box-shadow: inset 0 0 0 1px var(--forest); }

/* ---------- dialogs ---------- */
dialog { border: 0; border-radius: 16px; padding: 24px; color: var(--ink); background: var(--sheet); width: min(540px, calc(100vw - 24px)); max-height: 90dvh; box-shadow: 0 24px 70px #0b2a2240; }
dialog::backdrop { background: #0b2a2299; }
dialog.wide { width: min(880px, calc(100vw - 24px)); }
.dialog-top { display: flex; gap: 12px; justify-content: space-between; align-items: flex-start; margin-bottom: 16px; }
.dialog-top h2 { font-size: 22px; line-height: 1.25; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; margin-top: 4px; }
.review { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.review div { background: #f3f7ef; border-radius: 9px; padding: 9px 12px; overflow-wrap: anywhere; }
.review dt { font-size: 12.5px; color: var(--muted); }
.review dd { font-weight: 700; margin-top: 2px; }
/* A sheet slides in from the side and keeps the list behind it in view. */
dialog.sheet { margin: 0 0 0 auto; height: 100dvh; max-height: 100dvh; width: min(520px, 100vw); max-width: 100vw; border-radius: 18px 0 0 18px; padding: 0; overflow: hidden; }
dialog.sheet[open] { display: flex; flex-direction: column; animation: sheet-in .18s ease-out; }
@keyframes sheet-in { from { transform: translateX(28px); opacity: 0; } }
.sheet-head { padding: 20px 22px 16px; border-bottom: 1px solid var(--line); display: grid; gap: 12px; }
.sheet-head .dialog-top { margin: 0; }
.sheet-title { min-width: 0; }
.sheet-title h2 { font-size: 21px; overflow-wrap: anywhere; }
.sheet-tags { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.sheet-body { padding: 20px 22px 28px; overflow-y: auto; display: grid; gap: 24px; align-content: start; }
.sheet-status { color: var(--open); font-size: 14px; min-height: 0; }
.sheet-status:empty { display: none; }

/* What happened last, said once at the bottom of the screen. */
.toast { position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%); z-index: 30; max-width: min(560px, calc(100vw - 24px)); padding: 11px 18px; border-radius: 10px; background: var(--forest-deep); color: #fff; font-size: 14.5px; box-shadow: 0 10px 30px #0b2a2240; }
.toast:empty { display: none; }

.pager { display: flex; align-items: center; justify-content: flex-end; gap: 10px; margin-top: 14px; flex-wrap: wrap; font-size: 14px; }
.pager label { margin-right: auto; color: var(--muted); }
.pager select { padding: 5px 8px; border: 1px solid var(--line); border-radius: 6px; background: var(--sheet); }

/* ---------- narrow screens: the rail becomes a drawer ---------- */
@media (max-width: 900px) {
  .gate { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto 1fr; }
  .gate-brand { padding: 22px 20px; gap: 14px; }
  .gate-brand p { font-size: 18px; }
  .shell { grid-template-columns: minmax(0, 1fr); }
  .rail { position: fixed; inset: 0 auto 0 0; width: min(280px, 86vw); z-index: 20; transform: translateX(-102%); visibility: hidden; transition: transform .18s ease-out, visibility .18s; }
  .rail.is-open { transform: none; visibility: visible; box-shadow: 0 0 0 100vmax #0b2a2299; }
  .topbar { display: flex; align-items: center; gap: 12px; position: sticky; top: 0; z-index: 10; background: var(--forest); padding: 10px 14px; }
  .topbar .icon-button { background: transparent; border-color: #3a6555; color: #fff; }
  .topbar .brand-name { font-size: 18px; }
  .topbar .brand-name small { display: none; }
  .content { padding-bottom: 110px; }
  .form .two, .choices, .review { grid-template-columns: minmax(0, 1fr); }
  dialog.sheet { width: 100vw; border-radius: 0; }
  /* Fingers need more room than a pointer. */
  .button { min-height: 44px; }
  .button.small { min-height: 40px; }
  .rail-nav a { min-height: 46px; }
  .icon-button { width: 44px; height: 44px; }
  .ledger > li, .todo > li { padding-inline: 16px; }
  .ledger .row-link { margin-inline: -16px; padding-inline: 16px; }
  th, td { padding-inline: 14px; }
}
@media (prefers-reduced-motion: reduce) {
  dialog.sheet[open] { animation: none; }
  .rail { transition: none; }
}
