/* The admin page, in the r1 system (the app's docs/DESIGN.md), on system fonts because the
   bundled Geist and Source Serif do not ship with this service. Served under a CSP of
   style-src 'self', so every rule lives here and nothing on the page carries a style attribute.

   One accent, spent once per view: the primary button of the view (Open, or a confirm step's
   button), links, the active tab's line and the selected row's tint. Hairlines at rest, the one
   shadow on the floating detail panel. No weight above 480 where the face has one; system faces
   step at 400 and 500, so 500 stands in for 480. */

:root {
  --ground: #F6F6F8;
  --surface: #FFFFFF;
  --raise: #FFFFFF;
  --ink: #1B1D29;
  --text: #343746;
  --text-2: #5B5E6D;
  --text-3: #686B7A;
  --line: rgba(88, 94, 128, .14);
  --line-2: rgba(88, 94, 128, .24);
  --line-control: #8C8E9C;
  --hover: rgba(88, 94, 128, .06);
  --pressed: rgba(88, 94, 128, .10);
  --action: #2D4FCB;
  --action-hover: #2745B5;
  --action-ink: #FFFFFF;
  --link: #2846B8;
  --tint: rgba(45, 79, 203, .10);
  --good: #1F6B43;
  --warn: #9A4A00;
  --shadow-float: 0 0 0 1px rgba(88, 94, 128, .10), 0 2px 4px rgba(20, 22, 40, .04), 0 8px 24px rgba(20, 22, 40, .08), 0 24px 48px rgba(20, 22, 40, .06);
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  --serif: ui-serif, "New York", "Iowan Old Style", Georgia, serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --ground: #111219;
    --surface: #1A1B24;
    --raise: #22232E;
    --ink: #F2F3F7;
    --text: #D5D7E0;
    --text-2: #A3A6B4;
    --text-3: #9295A5;
    --line: rgba(160, 166, 200, .13);
    --line-2: rgba(160, 166, 200, .24);
    --line-control: #6B6D7B;
    --hover: rgba(160, 166, 200, .07);
    --pressed: rgba(160, 166, 200, .12);
    --action: #4A6BE0;
    --action-hover: #5877E6;
    --link: #8FA6F6;
    --tint: rgba(110, 140, 250, .16);
    --good: #5CC992;
    --warn: #F0A35A;
    --shadow-float: 0 0 0 1px rgba(160, 166, 200, .14), 0 8px 24px rgba(0, 0, 0, .35), 0 24px 48px rgba(0, 0, 0, .30);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--ground);
  color: var(--text);
  font: 400 15px/24px var(--sans);
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
}

[hidden] { display: none !important; }

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

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

/* ---------------------------------------------------------------- chrome */

.progress {
  position: fixed;
  inset: 0 0 auto 0;
  height: 2px;
  overflow: hidden;
  z-index: 30;
}
.progress::after {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 30%;
  background: var(--text-2);
  animation: sweep 1.1s cubic-bezier(.2, 0, 0, 1) infinite;
}
@keyframes sweep { from { transform: translateX(-100%); } to { transform: translateX(340%); } }
@media (prefers-reduced-motion: reduce) { .progress::after { animation: none; width: 100%; opacity: .5; } }

.top {
  display: flex;
  align-items: center;
  gap: 12px;
  height: 48px;
  padding: 0 36px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}
.brand { display: flex; align-items: center; gap: 8px; color: var(--ink); font-weight: 500; font-size: 14px; }
.brand-mark {
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border-radius: 6px;
  background: #1B2A6B;
  color: #FFFFFF;
  font-size: 12px;
  font-weight: 600;
}
.brand-sub { color: var(--text-3); font-weight: 400; }
.top .spacer { flex: 1; }

.page { padding: 28px 36px 64px; }
@media (max-width: 1200px) { .page { padding: 24px; } .top { padding: 0 24px; } }

.title {
  margin: 0;
  font: 400 28px/36px var(--serif);
  letter-spacing: -0.01em;
  color: var(--ink);
}
.meta { margin: 2px 0 0; font-size: 13px; line-height: 20px; color: var(--text-3); }

.tabs { display: flex; gap: 20px; margin-top: 20px; border-bottom: 1px solid var(--line); }
.tab {
  position: relative;
  height: 36px;
  padding: 0;
  border: 0;
  background: none;
  color: var(--text-2);
  font-size: 13px;
  line-height: 20px;
  font-weight: 500;
  cursor: pointer;
}
.tab:hover { color: var(--ink); }
.tab[aria-selected="true"] { color: var(--ink); }
.tab[aria-selected="true"]::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: -1px;
  height: 2px;
  background: var(--action);
}

.toolbar { display: flex; align-items: center; gap: 12px; margin: 16px 0 8px; flex-wrap: wrap; }
.toolbar-end { margin-left: auto; }

.field {
  height: 32px;
  width: 300px;
  padding: 0 10px;
  border: 1px solid var(--line-control);
  border-radius: 8px;
  background: var(--surface);
  font-size: 14px;
  line-height: 20px;
}
.field::placeholder { color: var(--text-3); }
.field:focus-visible { outline-offset: 0; }

.chips { display: flex; gap: 6px; }
.chip {
  height: 30px;
  padding: 0 10px;
  border: 1px solid var(--line-2);
  border-radius: 8px;
  background: transparent;
  color: var(--text-2);
  font-size: 13px;
  line-height: 20px;
  font-weight: 500;
  cursor: pointer;
}
.chip:hover { background: var(--hover); }
.chip[aria-pressed="true"] { background: var(--hover); color: var(--ink); }
.chip .n { color: var(--text-3); margin-left: 4px; }

/* ---------------------------------------------------------------- buttons */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 32px;
  padding: 0 14px;
  border-radius: 999px;
  border: 1px solid var(--line-2);
  background: var(--surface);
  color: var(--ink);
  font-size: 13px;
  line-height: 20px;
  font-weight: 500;
  white-space: nowrap;
  cursor: pointer;
}
.btn:hover { background: var(--hover); }
.btn:active { transform: scale(.99); }
.btn:disabled { color: var(--text-3); background: var(--hover); cursor: default; transform: none; }
.btn-primary { background: var(--action); border-color: transparent; color: var(--action-ink); }
.btn-primary:hover { background: var(--action-hover); }
.btn-ghost { border-color: transparent; background: transparent; color: var(--text-2); }
.btn-ghost:hover { background: var(--hover); color: var(--ink); }
.btn-lg { height: 40px; padding: 0 20px; font-size: 14px; }
.btn-sm { height: 28px; padding: 0 12px; }

/* ---------------------------------------------------------------- the gate */

.gate { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.gate-card {
  width: 100%;
  max-width: 400px;
  padding: 24px;
  border-radius: 12px;
  background: var(--surface);
  box-shadow: 0 0 0 1px var(--line);
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.gate-card .title { font-size: 28px; }
.gate-card p { margin: 0; color: var(--text-2); font-size: 14px; line-height: 20px; }
.gate-card .field { width: 100%; font-family: var(--mono); font-size: 13px; }
.gate-card label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; line-height: 20px; font-weight: 500; color: var(--ink); }
.note { margin: 0; font-size: 13px; line-height: 20px; color: var(--text-2); }
.note.warn { color: var(--warn); font-weight: 500; }

/* ---------------------------------------------------------------- the table */

.table-wrap { background: var(--surface); border-radius: 12px; box-shadow: 0 0 0 1px var(--line); overflow: clip; }
table { width: 100%; border-collapse: collapse; font-size: 14px; line-height: 20px; }
thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  height: 36px;
  padding: 0 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  color: var(--text-3);
  font-size: 12px;
  line-height: 16px;
  letter-spacing: .02em;
  font-weight: 500;
  text-align: left;
  white-space: nowrap;
}
th.num, td.num { text-align: right; }
tbody tr { cursor: pointer; }
tbody tr:hover { background: var(--hover); }
tbody tr[aria-selected="true"] { background: var(--tint); }
tbody tr:focus-visible { outline-offset: -2px; }
td { height: 50px; padding: 8px 16px; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 320px; }
td.email { color: var(--ink); font-weight: 500; }
td.dim { color: var(--text-3); }
/* Not verified: needs attention, so amber words (r1 rule 9), never red. */
td.warn-text { color: var(--warn); }
.num { font-variant-numeric: tabular-nums; white-space: nowrap; }

.status { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; line-height: 20px; font-weight: 500; }
.status::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.status.active { color: var(--good); }
.status.inactive { color: var(--text-3); }

.skeleton { display: block; height: 12px; border-radius: 6px; background: var(--hover); }
.skeleton.w1 { width: 60%; } .skeleton.w2 { width: 40%; } .skeleton.w3 { width: 28%; }

.empty { padding: 40px 16px; }
.empty p { margin: 0; font-size: 15px; line-height: 24px; color: var(--ink); }
.empty p + p { margin-top: 2px; font-size: 14px; line-height: 20px; color: var(--text-2); }

/* ---------------------------------------------------------------- the detail panel */

.panel {
  position: fixed;
  top: 48px;
  right: 0;
  bottom: 0;
  width: 400px;
  z-index: 20;
  display: flex;
  flex-direction: column;
  background: var(--raise);
  box-shadow: var(--shadow-float);
  animation: arrive 150ms cubic-bezier(.16, 1, .3, 1);
}
@keyframes arrive { from { transform: translateX(24px); opacity: 0; } to { transform: none; opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .panel { animation: fade 120ms linear; } @keyframes fade { from { opacity: 0; } } }

.panel-head { display: flex; align-items: flex-start; gap: 12px; padding: 20px 24px 12px; }
.panel-head > div { flex: 1; min-width: 0; }
.panel-meta { margin: 0; font: 500 12px/16px var(--mono); color: var(--text-3); }
.panel-title { margin: 4px 0 0; font: 400 22px/28px var(--serif); color: var(--ink); overflow-wrap: anywhere; }
.icon-btn {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 0;
  background: transparent;
  color: var(--text-2);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
}
.icon-btn:hover { background: var(--hover); color: var(--ink); }

.panel-body { flex: 1; overflow: auto; padding: 0 24px 24px; display: flex; flex-direction: column; gap: 20px; }
.kv { margin: 0; }
.kv div { display: flex; justify-content: space-between; gap: 16px; min-height: 40px; align-items: center; border-bottom: 1px solid var(--line); }
.kv div:last-child { border-bottom: 0; }
.kv dt { color: var(--text-3); font-size: 13px; line-height: 20px; }
.kv dd { margin: 0; color: var(--ink); font-size: 14px; line-height: 20px; text-align: right; overflow-wrap: anywhere; }

.panel-section-label { margin: 0 0 6px; font-size: 12px; line-height: 16px; letter-spacing: .02em; color: var(--text-3); font-weight: 500; }

.confirm { display: flex; flex-direction: column; gap: 12px; padding: 16px; border-radius: 12px; background: var(--ground); }
.confirm-title { margin: 0; font-size: 15px; line-height: 24px; font-weight: 500; color: var(--ink); }
.confirm p { margin: 0; font-size: 14px; line-height: 20px; color: var(--text-2); }
.confirm .row { display: flex; gap: 8px; flex-wrap: wrap; }
.check { display: flex; align-items: flex-start; gap: 8px; font-size: 14px; line-height: 20px; color: var(--text); }
.check input { margin: 3px 0 0; accent-color: var(--action); }

.code {
  margin: 0;
  font: 500 24px/32px var(--mono);
  letter-spacing: .06em;
  color: var(--ink);
  user-select: all;
}

.panel-actions { display: flex; flex-wrap: wrap; gap: 8px; padding: 16px 24px; border-top: 1px solid var(--line); }

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  z-index: 40;
  padding: 10px 16px;
  border-radius: 12px;
  background: var(--raise);
  box-shadow: var(--shadow-float);
  color: var(--ink);
  font-size: 14px;
  line-height: 20px;
}

tbody tr.static { cursor: default; }

/* UniOne access (0.7.0): the Requests view and the access column. */
.tab-count {
  display: inline-block;
  min-width: 18px;
  margin-left: 4px;
  padding: 0 6px;
  border-radius: 9px;
  background: var(--tint);
  color: var(--ink);
  font-size: 12px;
  line-height: 18px;
  text-align: center;
}
td.note-cell { max-width: 360px; color: var(--text-2); }
.ai { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; line-height: 20px; font-weight: 500; }
.ai.requested { color: var(--warn); }
.ai.approved { color: var(--good); }
.ai.declined, .ai.none { color: var(--text-3); font-weight: 400; }
.note-full { margin: 0; padding: 12px 14px; border-radius: 10px; background: var(--ground); font-size: 14px; line-height: 20px; color: var(--text); white-space: pre-wrap; overflow-wrap: anywhere; }
.money-field { display: flex; align-items: center; gap: 8px; font-size: 14px; line-height: 20px; color: var(--text); }
.money-field .field { width: 120px; font-variant-numeric: tabular-nums; }
