/* Polaris admin console. Same navy + champagne-gold palette as the portal,
   tuned for dense tables and forms rather than parent-facing cards. */
:root {
  --navy-dark: #071221;
  --navy: #0C1E36;
  --navy-light: #162E4E;
  --gold: #D4AF37;
  --gold-light: #E9C46A;
  --gold-dark: #A67C1E;
  --paper: #F6F4EE;
  --card: #FFFFFF;
  --ink: #1D2838;
  --muted: #667487;
  --line: #E2E6EC;
  --line-strong: #CBD2DC;
  --row-hover: #FBF7EA;
  --ok: #2E7D32; --ok-bg: #E8F5E9;
  --warn: #B45309; --warn-bg: #FEF3C7;
  --bad: #B3261E; --bad-bg: #FDECEA;
  --info: #1C6FA8; --info-bg: #E6F1FA;
  --radius: 10px;
  --font-serif: 'Cinzel', Georgia, serif;
  --font-sans: 'Inter', system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--paper); color: var(--ink); font: 14px/1.45 var(--font-sans); min-height: 100vh; }
a { color: var(--info); }
[hidden] { display: none !important; }

.topbar {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 20px; background: var(--navy); border-bottom: 2px solid var(--gold);
}
.brand { display: flex; flex-direction: column; text-decoration: none; line-height: 1.1; }
.brand-mark { font: 700 17px var(--font-serif); color: #fff; letter-spacing: 2px; }
.brand-sub { font-size: 10.5px; font-weight: 700; color: var(--gold); letter-spacing: 1.5px; text-transform: uppercase; }
.topbar-right { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.who { color: #C9D3E0; font-size: 12.5px; margin-right: 4px; }

.btn {
  display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line-strong); background: var(--card); color: var(--ink);
  border-radius: 7px; padding: 7px 12px; font: 600 13px var(--font-sans); cursor: pointer; text-decoration: none; white-space: nowrap;
}
.btn:hover { border-color: var(--gold-dark); }
.btn:focus-visible, .icon-btn:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, .nav-link:focus-visible, tr[tabindex]:focus-visible {
  outline: 2px solid var(--gold); outline-offset: 1px;
}
.btn-primary { background: var(--navy); color: #fff; border-color: var(--navy); }
.btn-primary:hover { background: var(--navy-light); }
.btn-gold { background: var(--gold); color: var(--navy-dark); border-color: var(--gold); }
.btn-danger { color: var(--bad); border-color: #EBC4C0; }
.btn-danger:hover { background: var(--bad-bg); border-color: var(--bad); }
.btn-ghost { background: transparent; color: #E6ECF4; border-color: rgba(255,255,255,.22); }
.btn-ghost:hover { border-color: var(--gold); color: #fff; }
.btn-sm { padding: 4px 9px; font-size: 12px; }
.btn[disabled] { opacity: .55; cursor: default; }
.icon-btn { border: 0; background: none; font-size: 26px; line-height: 1; cursor: pointer; color: var(--muted); padding: 0 4px; }

.gate { display: flex; justify-content: center; padding: 64px 16px; }
.gate-card { background: var(--card); border: 1px solid var(--line); border-top: 3px solid var(--gold); border-radius: var(--radius); padding: 28px; width: min(440px, 100%); text-align: center; box-shadow: 0 10px 30px rgba(12,30,54,.06); }
.gate-card h1 { font: 700 20px var(--font-serif); color: var(--navy); margin: 0 0 6px; letter-spacing: 1px; }
#clerk-sign-in { display: flex; justify-content: center; margin-top: 16px; min-height: 60px; }
.error { color: var(--bad); font-size: 13px; }
.muted { color: var(--muted); }

.layout { display: grid; grid-template-columns: 232px minmax(0, 1fr); min-height: calc(100vh - 56px); }
.sidenav { background: var(--navy-dark); padding: 14px 10px 24px; position: sticky; top: 56px; height: calc(100vh - 56px); overflow-y: auto; }
.nav-group { margin: 14px 8px 4px; font-size: 10.5px; font-weight: 700; letter-spacing: 1.3px; text-transform: uppercase; color: var(--gold); }
.nav-link { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 8px 10px; border-radius: 7px; color: #C9D3E0; text-decoration: none; font-weight: 500; }
.nav-link:hover { background: rgba(255,255,255,.06); color: #fff; }
.nav-link.active { background: rgba(212,175,55,.14); color: #fff; box-shadow: inset 3px 0 0 var(--gold); }
.nav-count { font-size: 11px; font-weight: 700; background: rgba(255,255,255,.1); color: #E6ECF4; border-radius: 9px; padding: 1px 7px; }
.nav-count.alert { background: var(--gold); color: var(--navy-dark); }

.content { padding: 22px 28px 60px; min-width: 0; }
.page-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; flex-wrap: wrap; margin-bottom: 14px; }
.page-head h1 { font: 700 21px var(--font-serif); color: var(--navy); margin: 0; letter-spacing: .5px; }
.page-head p { margin: 4px 0 0; color: var(--muted); max-width: 70ch; }
.replaces { display: inline-block; margin-top: 8px; font-size: 12px; color: var(--gold-dark); background: #FBF5E1; border: 1px solid #EEDFAE; border-radius: 6px; padding: 2px 8px; }
.head-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.toolbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 10px; }
.toolbar input[type=search] { flex: 1 1 240px; max-width: 360px; }
.toolbar .summary { margin-left: auto; color: var(--muted); font-size: 12.5px; }
input, select, textarea { font: 14px var(--font-sans); color: var(--ink); background: #fff; border: 1px solid var(--line-strong); border-radius: 7px; padding: 7px 10px; }
textarea { width: 100%; min-height: 90px; resize: vertical; }

.table-wrap { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 11.5px; text-transform: uppercase; letter-spacing: .6px; color: var(--muted); background: #FAFBFC; position: sticky; top: 0; cursor: pointer; user-select: none; white-space: nowrap; }
th .sort { color: var(--gold-dark); }
tbody tr { cursor: pointer; }
tbody tr:hover { background: var(--row-hover); }
tbody tr:last-child td { border-bottom: 0; }
td.num { text-align: right; font-variant-numeric: tabular-nums; }
td.clip { max-width: 360px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.empty { padding: 36px; text-align: center; color: var(--muted); }

.pill { display: inline-block; font-size: 11.5px; font-weight: 600; border-radius: 10px; padding: 1px 8px; white-space: nowrap; }
.pill.ok { background: var(--ok-bg); color: var(--ok); }
.pill.warn { background: var(--warn-bg); color: var(--warn); }
.pill.bad { background: var(--bad-bg); color: var(--bad); }
.pill.info { background: var(--info-bg); color: var(--info); }
.pill.dim { background: #EEF1F4; color: var(--muted); }

.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 14px; margin-bottom: 22px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; text-decoration: none; color: inherit; display: block; }
a.card:hover { border-color: var(--gold); box-shadow: 0 6px 18px rgba(12,30,54,.07); }
.card h3 { margin: 0 0 4px; font-size: 13px; color: var(--muted); font-weight: 600; }
.card .big { font: 700 26px var(--font-sans); color: var(--navy); }
.card .sub { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.card p { margin: 6px 0 0; }
.section-title { font: 700 14px var(--font-serif); color: var(--navy); letter-spacing: .6px; margin: 22px 0 10px; }
.link-list { display: grid; gap: 10px; }
.link-row { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.link-row strong { display: block; }
.link-row span { color: var(--muted); font-size: 12.5px; }

.drawer-backdrop { position: fixed; inset: 0; background: rgba(7,18,33,.35); z-index: 40; }
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(520px, 100vw); background: var(--card); z-index: 50; display: flex; flex-direction: column; box-shadow: -12px 0 40px rgba(7,18,33,.2); border-left: 3px solid var(--gold); }
.drawer-head { display: flex; justify-content: space-between; align-items: center; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.drawer-head h2 { margin: 0; font: 700 16px var(--font-serif); color: var(--navy); letter-spacing: .4px; }
.drawer-body { padding: 18px 20px 28px; overflow-y: auto; flex: 1; }
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 12px; font-weight: 600; color: var(--muted); margin-bottom: 4px; }
.field input:not([type=checkbox]), .field select { width: 100%; }
.field .hint { font-size: 12px; color: var(--muted); margin-top: 4px; }
.field.check label { display: flex; align-items: center; gap: 8px; color: var(--ink); font-size: 14px; font-weight: 500; }
.readonly { background: #FAFBFC; border: 1px solid var(--line); border-radius: 7px; padding: 7px 10px; white-space: pre-wrap; word-break: break-word; min-height: 34px; }
.drawer-actions { display: flex; gap: 8px; justify-content: space-between; margin-top: 20px; flex-wrap: wrap; }
.drawer-actions .right { display: flex; gap: 8px; margin-left: auto; }
.form-error { color: var(--bad); font-size: 13px; margin-top: 10px; }
.meta { font-size: 12px; color: var(--muted); margin-top: 16px; border-top: 1px solid var(--line); padding-top: 10px; }
pre.diff { background: #0E1A33; color: #E6ECF4; font: 12px/1.5 ui-monospace, Menlo, monospace; padding: 10px; border-radius: 7px; overflow-x: auto; white-space: pre-wrap; }

.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--navy); color: #fff; border: 1px solid var(--gold); padding: 10px 16px; border-radius: 8px; z-index: 60; font-weight: 500; box-shadow: 0 8px 24px rgba(0,0,0,.25); }
.toast.bad { background: var(--bad); border-color: var(--bad); }

.drawer.wide { width: min(860px, 100vw); }
.form-section { font: 700 13px var(--font-serif); color: var(--navy); letter-spacing: .6px; margin: 24px 0 4px; padding-top: 14px; border-top: 1px solid var(--line); }
.form-section + .hint { font-size: 12px; color: var(--muted); margin-bottom: 10px; }
.icon-btn.sm { font-size: 16px; width: 28px; height: 30px; border: 1px solid var(--line); border-radius: 6px; background: #fff; flex-shrink: 0; }
.icon-btn.sm:disabled { opacity: .35; cursor: default; }
.row-line { display: flex; gap: 6px; margin-bottom: 6px; align-items: center; }
.row-line input { min-width: 0; }
.q-card { border: 1px solid var(--line); border-left: 3px solid var(--gold); border-radius: 8px; padding: 10px; margin-bottom: 10px; display: grid; gap: 6px; background: #FCFCFB; }
.q-top { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.q-top select { flex: 1 1 200px; }
.q-num { font-weight: 700; color: var(--gold-dark); min-width: 18px; }
.q-req { display: flex; gap: 4px; align-items: center; font-size: 13px; }
.q-card textarea { min-height: 70px; }
.widget-rich .ql-toolbar.ql-snow { border-color: var(--line-strong); border-radius: 7px 7px 0 0; background: #FAFBFC; font-family: var(--font-sans); }
.widget-rich .ql-container.ql-snow { border-color: var(--line-strong); border-radius: 0 0 7px 7px; font: 15px/1.55 var(--font-sans); }
.widget-rich .ql-editor { min-height: 180px; max-height: 55vh; overflow-y: auto; }
.widget-rich .ql-editor h2, .widget-rich .ql-editor h3 { font-family: var(--font-serif); color: var(--navy); }
.import-list { display: grid; gap: 8px; margin: 12px 0; }
.import-item { display: flex; gap: 10px; align-items: flex-start; border: 1px solid var(--line); border-radius: 8px; padding: 10px; cursor: pointer; }
.import-item > span { display: grid; gap: 2px; }
.import-item .muted { font-size: 12.5px; }

@media (max-width: 860px) {
  .layout { grid-template-columns: 1fr; }
  .sidenav { position: static; height: auto; display: flex; gap: 4px; overflow-x: auto; padding: 8px; }
  .nav-group { display: none; }
  .nav-link { white-space: nowrap; }
  .content { padding: 16px; }
  .who { display: none; }
}
