@import url("https://fonts.googleapis.com/css2?family=IBM+Plex+Mono:wght@400;500&family=IBM+Plex+Sans:wght@400;500;600&display=swap");

:root {
  --ink: #1c1915;
  --muted: #6f675d;
  --paper: #fbf8f3;
  --bg: #ebe4d8;
  --line: #ddd4c6;
  --keep: #176341;
  --keep-bg: #e4f2ea;
  --drop: #8d2e1b;
  --drop-bg: #f8e7e1;
  --focus: #9a4b12;
  color-scheme: light;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: "IBM Plex Sans", "Avenir Next", "Segoe UI", sans-serif;
  font-size: 15px;
}

button, input, select { font: inherit; color: inherit; }

header {
  display: flex;
  flex-wrap: wrap;
  gap: 22px 28px;
  align-items: flex-end;
  justify-content: flex-end;
  padding: 22px 28px 18px;
  background: #6e655b;
  color: #f6f1e7;
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-right: auto;
}
.mark {
  width: 72px;
  height: 72px;
  flex: 0 0 auto;
  display: block;
}

.eyebrow {
  margin: 0;
  color: #c9bfb0;
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

h1 {
  margin: 2px 0 4px;
  font-size: 32px;
  font-weight: 500;
  letter-spacing: -0.04em;
  line-height: 1;
}

.author {
  display: grid;
  gap: 6px;
  font-size: 12px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #c9bfb0;
}

input, select {
  height: 36px;
  padding: 0 10px;
  border: 1px solid transparent;
  border-radius: 6px;
  background: #f6f1e7;
  color: var(--ink);
}

header input { background: #2a261f; color: #f6f1e7; border-color: #4a4338; }
.import input { display: none; }
.import.busy { opacity: 0.7; pointer-events: none; }

.modal[hidden] { display: none !important; }
.modal {
  position: fixed;
  inset: 0;
  z-index: 25;
  display: grid;
  place-items: center;
  padding: 24px 16px;
  background: rgba(28, 25, 21, 0.45);
}
.modal-card {
  width: min(420px, 100%);
  display: grid;
  gap: 12px;
  padding: 28px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 16px;
}
.modal-card h2 { margin: 0; font-size: 28px; font-weight: 500; letter-spacing: -0.03em; }
.modal-card .hint { margin: 0; }
.modal-card label { display: grid; gap: 6px; color: var(--muted); font-size: 13px; }
.modal-card select,
.modal-card input { background: #fff; border: 1px solid var(--line); }
.modal-actions { display: flex; gap: 8px; }
.modal-actions button {
  flex: 1;
  height: 44px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  cursor: pointer;
  font-weight: 500;
}
.modal-actions button[type="submit"] { border: 0; background: var(--ink); color: #f6f1e7; }

.loader[hidden] { display: none !important; }
.loader {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  background: rgba(28, 25, 21, 0.45);
}
.loader-card {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 260px;
  padding: 16px 18px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--paper);
  box-shadow: 0 16px 40px rgba(28, 25, 21, 0.18);
}
.loader-card strong { display: block; font-size: 15px; }
.loader-card p { margin: 3px 0 0; color: var(--muted); font-size: 13px; }
.spinner {
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
  border: 2px solid var(--line);
  border-top-color: var(--ink);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
header button, .export, .help-link {
  height: 36px;
  padding: 0 14px;
  border: 0;
  border-radius: 6px;
  background: #f6f1e7;
  color: var(--ink);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
}

.who { display: flex; align-items: center; gap: 10px; color: #f6f1e7; }
.who-card { position: relative; }
.who-initials {
  width: 36px;
  height: 36px;
  padding: 0;
  display: grid;
  place-items: center;
  border: 1px solid rgba(246, 241, 231, 0.45);
  border-radius: 50%;
  background: transparent;
  color: #f6f1e7;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.04em;
  cursor: pointer;
}
.who-profile {
  position: absolute;
  right: 0;
  top: 44px;
  z-index: 5;
  width: 260px;
  display: grid;
  gap: 8px;
  padding: 12px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--ink);
}
.who-profile[hidden] { display: none; }
.who-profile label { display: grid; gap: 4px; font-size: 12px; color: var(--muted); text-transform: none; letter-spacing: 0; }
.who-profile input {
  width: 100%;
  background: #f3eee6;
  border: 1px solid var(--line);
  color: var(--ink);
  text-transform: none;
  letter-spacing: 0;
}
#logout {
  height: 36px;
  padding: 0 12px;
  border: 1px solid rgba(246, 241, 231, 0.45);
  border-radius: 6px;
  background: transparent;
  color: #f6f1e7;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

body.locked .cutoff,
body.locked .who,
body.locked .export,
body.locked .tabs,
body.locked #view-domains,
body.locked #view-logs,
body.locked #view-staff { display: none; }
.tabs button[hidden] { display: none; }
.staff-note { margin: 0; color: var(--muted); max-width: 720px; }
.staff-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.staff-actions input, .staff-actions select { background: var(--paper); }
.staff-actions input { width: 160px; }
.staff-actions select { height: 32px; border: 1px solid var(--line); border-radius: 8px; }

.login {
  display: grid;
  place-items: center;
  min-height: calc(100vh - 140px);
  padding: 24px 16px 48px;
}
.login[hidden] { display: none; }
.login-card {
  width: min(420px, 100%);
  display: grid;
  gap: 12px;
  padding: 28px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 16px;
}
.login h2 { margin: 0; font-size: 28px; font-weight: 500; letter-spacing: -0.03em; }
.login .hint { margin: 0; color: var(--muted); }
.mm-login {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 44px;
  border-radius: 8px;
  background: var(--ink);
  color: #f6f1e7;
  text-decoration: none;
}
.login-card[hidden] { display: none; }
.login-alt,
.login-card button[type="submit"] {
  height: 44px;
  border-radius: 8px;
  cursor: pointer;
}
.login-alt {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
}
.login-back {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 44px;
  border: 1px solid var(--ink);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}
.login-card label { display: grid; gap: 6px; color: var(--muted); font-size: 13px; }
.login-card input { background: #fff; border: 1px solid var(--line); }
.login-card button[type="submit"] {
  border: 0;
  background: var(--ink);
  color: #f6f1e7;
}
.login-error { margin: 0; color: var(--drop); }

.counters {
  margin: 0 28px 28px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 16px 4px;
}

.counters summary { cursor: pointer; font-weight: 600; display: flex; align-items: center; gap: 8px; }

.stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  padding: 14px 0 0;
}

.people { padding: 6px 0 14px; }
.people-note { margin: 0 0 10px; color: var(--muted); font-size: 13px; line-height: 1.45; }
.people h2 {
  margin: 18px 0 0;
  font-size: 15px;
  font-weight: 600;
}
.people-fold {
  margin-top: 8px;
  border: 1px solid var(--line);
  border-radius: 10px;
}
.people-fold summary {
  cursor: pointer;
  padding: 10px 12px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}
.people-scroll { max-height: 280px; overflow: auto; border-top: 1px solid var(--line); }
.people table { width: max-content; min-width: 100%; font-size: 13px; font-variant-numeric: tabular-nums; }
.people th, .people td { text-align: right; white-space: nowrap; background: var(--paper); padding: 7px 6px; font-size: 12px; }
.people th:first-child, .people td:first-child { text-align: left; position: sticky; left: 0; z-index: 1; }
.people thead th { position: sticky; top: 0; z-index: 2; background: #f7f3ec; }
.people thead th:first-child { z-index: 3; }
.people tbody th { top: auto; }
.people td.zero { color: var(--muted); }

.ico {
  width: 16px;
  height: 16px;
  flex: 0 0 auto;
}

.card {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px 16px 12px;
  min-height: 148px;
}

.card h2 {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 0;
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.card .big {
  margin: 8px 0 0;
  font-size: 28px;
  line-height: 1;
  letter-spacing: -0.04em;
  font-variant-numeric: tabular-nums;
}

.card .sub { margin: 6px 0 10px; color: var(--muted); font-size: 13px; }

.card dl { margin: 0; display: grid; gap: 4px; }
.card dl div { display: flex; justify-content: space-between; gap: 12px; font-size: 13px; }
.card dt { color: var(--muted); }
.card dd { margin: 0; font-variant-numeric: tabular-nums; }
.card.keep { box-shadow: inset 3px 0 0 var(--keep); }
.card.drop { box-shadow: inset 3px 0 0 var(--drop); }
.card.wait { box-shadow: inset 3px 0 0 var(--muted); }

.tabs { display: flex; gap: 8px; padding: 16px 28px 0; }
.tabs button, .filters button, .pager button, thead button, .actions button, .staff-actions button, .text-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--line);
  background: transparent;
  border-radius: 999px;
  padding: 6px 12px;
  cursor: pointer;
}
.tabs button.on, .filters button.on { background: var(--ink); color: #f6f1e7; border-color: var(--ink); }

.toolbar {
  display: grid;
  grid-template-columns: minmax(340px, 1fr) minmax(380px, 460px);
  gap: 14px;
  align-items: center;
  padding: 12px 28px 4px;
}
.toolbar-main {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  min-width: 0;
}

.toolbar input[type="search"] { width: min(360px, 100%); background: var(--paper); border-color: var(--line); }
.search { position: relative; display: flex; align-items: center; }
.search .ico { position: absolute; left: 10px; color: var(--muted); pointer-events: none; }
.search input { padding-left: 32px; }
.range { margin: 0; color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; }
.cutoff {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
  color: var(--muted);
  font-size: 12px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  white-space: nowrap;
}
.cutoff input {
  width: 148px;
  background: #fff;
  border-color: var(--line);
  color: var(--ink);
  color-scheme: light;
  text-transform: none;
  letter-spacing: 0;
}
.cutoff-period {
  color: var(--ink);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0;
  text-transform: none;
}
.toolbar .download {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: auto;
  padding: 6px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--paper);
  color: var(--ink);
  text-decoration: none;
}

.desk {
  display: grid;
  grid-template-columns: minmax(340px, 1fr) minmax(380px, 460px);
  gap: 14px;
  align-items: start;
  padding: 0 28px 16px;
}

.queue .table-wrap { max-height: calc(100vh - 230px); }

.table-wrap, .inspector {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 12px;
}

.table-wrap { overflow: auto; }

table { width: 100%; border-collapse: collapse; }
th, td { padding: 9px 12px; text-align: left; vertical-align: middle; }
th { position: sticky; top: 0; background: #f7f3ec; border-bottom: 1px solid var(--line); font-weight: 500; }
thead button { border: 0; padding: 0; border-radius: 0; color: var(--muted); letter-spacing: 0.04em; text-transform: uppercase; font-size: 12px; }
.queue thead th.plain { color: var(--muted); letter-spacing: 0.04em; text-transform: uppercase; font-size: 12px; font-weight: 500; }
thead button.on { color: var(--ink); }
td { border-top: 1px solid #eee6da; }
tbody tr { cursor: pointer; }
tbody tr:hover { background: #f7f3ec; }
tbody tr.selected { background: #f3e7d4; }
.domain, .domain-btn { font-family: "IBM Plex Mono", ui-monospace, monospace; font-size: 13px; }
.domain-btn { display: inline-flex; align-items: center; gap: 6px; border: 0; background: none; padding: 0; cursor: pointer; text-align: left; }
.domain-btn .ico { width: 14px; height: 14px; color: var(--muted); }
.num { text-align: right; font-variant-numeric: tabular-nums; }
th:nth-child(2), td:nth-child(2) { text-align: right; }

.pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-width: 84px;
  justify-content: center;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
}
.pill .ico { width: 13px; height: 13px; }
.pill.keep { background: var(--keep-bg); color: var(--keep); }
.pill.drop { background: var(--drop-bg); color: var(--drop); }
.pill.wait { background: #f3eee6; color: var(--muted); }

.pager { display: flex; gap: 8px; align-items: center; padding: 10px 12px 12px; color: var(--muted); font-size: 13px; }
.pager button:disabled { opacity: 0.4; cursor: default; }

.inspector { padding: 20px; position: sticky; top: 12px; }
.domain-copy {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  width: 100%;
  margin: 4px 0 14px;
  padding: 0;
  border: 0;
  background: transparent;
  text-align: left;
  font-size: 26px;
  line-height: 1.25;
  word-break: break-all;
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  cursor: pointer;
}
.domain-copy .ico { margin-top: 7px; color: var(--muted); }
.domain-copy:hover span { text-decoration: underline; text-underline-offset: 3px; }
.domain-copy:hover .ico { color: var(--ink); }
.rkn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  height: 48px;
  border: 0;
  border-radius: 10px;
  background: #9a3412;
  color: #fff;
  font-weight: 600;
  cursor: pointer;
}
.hint { margin: 8px 0 16px; color: var(--muted); font-size: 13px; line-height: 1.45; }
.field-label { display: block; margin-bottom: 6px; font-size: 12px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }
.date-row input { height: 48px; font-family: "IBM Plex Mono", ui-monospace, monospace; font-size: 20px; }
.stamp { display: flex; align-items: center; gap: 10px; margin: 16px 0 8px; padding: 16px; border-radius: 12px; font-size: 28px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; }
.stamp .ico { width: 22px; height: 22px; }
.stamp.drop { background: var(--drop-bg); color: var(--drop); }
.stamp.keep { background: var(--keep-bg); color: var(--keep); }
.stamp.wait { background: #f3eee6; color: var(--muted); }
.muted, .inspector .meta { color: var(--muted); }
.trace {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 4px 12px;
  margin: 14px 0;
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 13px;
}
.trace span { color: var(--muted); }
.date-row { display: flex; gap: 8px; }
.date-row input { flex: 1; background: #fff; border: 1px solid var(--line); }
.date-row button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 48px;
  padding: 0 16px;
  border: 0;
  border-radius: 8px;
  background: var(--ink);
  color: #f6f1e7;
  cursor: pointer;
}
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.actions button.primary { background: var(--ink); color: #f6f1e7; border-color: var(--ink); }
.history { margin: 16px 0 0; padding: 0; list-style: none; }
.history li { padding: 8px 0; border-top: 1px solid var(--line); font-size: 13px; }
.text-btn { margin-top: 12px; }

#view-logs { padding-bottom: 28px; }
#view-logs .table-wrap { margin: 0 28px; max-height: calc(100vh - 220px); }

.toast {
  position: fixed;
  left: 50%;
  bottom: 18px;
  z-index: 40;
  transform: translateX(-50%);
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--ink);
  color: #f6f1e7;
  padding: 10px 14px;
  border-radius: 999px;
  font-size: 14px;
}
.toast[hidden] { display: none !important; }

:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

.guide {
  width: min(820px, calc(100% - 32px));
  margin: 28px auto 64px;
}
.guide-card {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 22px 24px 8px;
  margin: 0 0 16px;
}
.guide h2 { margin: 0 0 12px; font-size: 22px; font-weight: 600; letter-spacing: -0.03em; }
.guide h3 { margin: 18px 0 8px; font-size: 16px; }
.guide p, .guide li { line-height: 1.55; }
.guide a { color: var(--focus); }
.guide ol, .guide ul { margin: 8px 0 16px; padding-left: 22px; }
.guide li + li { margin-top: 6px; }
.guide table { width: 100%; border-collapse: collapse; margin: 8px 0 16px; font-size: 14px; }
.guide th, .guide td { text-align: left; vertical-align: top; padding: 8px 10px; border-bottom: 1px solid var(--line); }
.guide th { font-size: 12px; letter-spacing: 0.04em; text-transform: uppercase; color: var(--muted); }
.guide code { font-family: "IBM Plex Mono", ui-monospace, monospace; font-size: 0.92em; }
.toc { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 16px; }
.toc a {
  display: inline-block;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: var(--ink);
  text-decoration: none;
}
.note {
  margin: 0 0 16px;
  padding: 12px 14px;
  border-radius: 10px;
  background: #f3eee6;
}

@media (max-width: 980px) {
  .stats, .desk, .toolbar { grid-template-columns: 1fr; }
  .inspector { order: -1; position: static; }
  .queue .table-wrap { max-height: 360px; }
  header, .counters, .tabs, .toolbar { padding-left: 16px; padding-right: 16px; }
  .desk, #view-logs .table-wrap, .counters { margin-left: 16px; margin-right: 16px; }
  .desk { padding-left: 0; padding-right: 0; }
}
