/* Ursa Note admin panel. Duotone Heat tokens from the site, light and dark. */

:root {
  color-scheme: light dark;
  --bg: #fbfaf9;
  --surface: #ffffff;
  --surface-2: #f5eff6;
  --ink: #323247;
  --text: #5f565f;
  --muted: #7d7080;
  --rule: #ebe1ec;
  --rule-strong: #ddcde0;
  --accent: #894aa9;
  --accent-soft: #fcdee8;
  --accent-ink: #894aa9;
  --button-bg: #894aa9;
  --button-hover: #7b3f99;
  --button-text: #ffffff;
  --halo: rgb(202 124 208 / .28);
  --series: #894aa9;
  --grid: #efe8f0;
  --axis: #8a7f8c;
  --good-bg: #e3f3e8;
  --good: #1f6b3b;
  --warn-bg: #fbf0d9;
  --warn: #855600;
  --bad-bg: #fde9ef;
  --bad: #b4234f;
  --shadow: 0 1px 2px rgb(50 50 71 / .05), 0 8px 24px -12px rgb(117 81 128 / .18);
  --radius: 14px;
  --font: "Atkinson Hyperlegible Next", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, system-ui, sans-serif;
  --display: "Urbanist", "Avenir Next", -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #29293b;
    --surface: #323247;
    --surface-2: #3b3b53;
    --ink: #fafaf9;
    --text: rgb(240 230 248 / .84);
    --muted: #baa9b9;
    --rule: rgb(186 169 185 / .16);
    --rule-strong: rgb(186 169 185 / .3);
    --accent: #dcafdf;
    --accent-soft: rgb(202 124 208 / .2);
    --accent-ink: #f0d4f1;
    --button-bg: #dcafdf;
    --button-hover: #e8c6ea;
    --button-text: #29293b;
    --halo: rgb(220 175 223 / .25);
    --series: #ca7cd0;
    --grid: rgb(186 169 185 / .14);
    --axis: #baa9b9;
    --good-bg: rgb(126 211 155 / .14);
    --good: #a6e6bb;
    --warn-bg: rgb(242 192 96 / .14);
    --warn: #f3d18f;
    --bad-bg: rgb(255 157 181 / .13);
    --bad: #ffb0c3;
    --shadow: 0 1px 2px rgb(0 0 0 / .25), 0 10px 30px -14px rgb(0 0 0 / .5);
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { margin: 0; color: var(--ink); font-family: var(--display); line-height: 1.2; letter-spacing: -.01em; }
h1 { font-size: 28px; font-weight: 700; }
h2 { font-size: 17px; font-weight: 650; }
h3 { font-size: 15px; font-weight: 650; }
p { margin: 0; }
a { color: var(--accent); text-underline-offset: 2px; }
code { font-family: var(--mono); font-size: 12.5px; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.muted { color: var(--muted); }
.hint { font-size: 13px; color: var(--muted); margin-top: 2px; }
.loading { padding: 64px 16px; text-align: center; color: var(--muted); }

/* top bar */
.top {
  position: sticky;
  top: 0;
  z-index: 10;
  background: color-mix(in srgb, var(--bg) 86%, transparent);
  -webkit-backdrop-filter: saturate(1.4) blur(14px);
  backdrop-filter: saturate(1.4) blur(14px);
  border-bottom: 1px solid var(--rule);
}
.top-in { max-width: 1200px; margin: 0 auto; padding: 10px 24px; display: flex; align-items: center; gap: 24px; }
.brand { display: flex; align-items: center; gap: 10px; color: var(--ink); text-decoration: none; font: 700 16px/1 var(--display); white-space: nowrap; }
.brand img { width: 28px; height: 28px; border-radius: 7px; }
.brand small { padding-left: 10px; border-left: 1px solid var(--rule-strong); font: 500 13px/1 var(--font); color: var(--muted); }
.tabs { display: flex; flex: 1; gap: 2px; overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tabs a { padding: 7px 12px; border-radius: 999px; color: var(--muted); font-size: 14px; font-weight: 600; text-decoration: none; white-space: nowrap; }
.tabs a:hover { color: var(--ink); background: var(--surface-2); }
.tabs a[aria-current="page"] { color: var(--accent-ink); background: var(--accent-soft); }
.who { display: flex; align-items: center; gap: 10px; font-size: 13px; color: var(--muted); }
.who-email { max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* page */
main { max-width: 1200px; margin: 0 auto; padding: 32px 24px 96px; }
main[aria-busy="true"] > * { opacity: .6; transition: opacity .2s; }
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 24px; }
.page-head h1 { overflow-wrap: anywhere; }
.page-head p { margin-top: 6px; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; }
.back { display: inline-block; margin-bottom: 12px; font-size: 14px; font-weight: 600; text-decoration: none; }
.section-title { margin: 36px 0 14px; }

/* cards and grids */
.card { min-width: 0; padding: 20px; background: var(--surface); border: 1px solid var(--rule); border-radius: var(--radius); box-shadow: var(--shadow); }
.card > h2 { margin-bottom: 14px; }
.card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.card-head p { margin-top: 4px; font-size: 13px; }
.grid2, .grid3, .charts { display: grid; gap: 16px; margin-top: 16px; }
.grid2 { grid-template-columns: repeat(auto-fit, minmax(min(100%, 380px), 1fr)); align-items: start; }
.grid3 { grid-template-columns: repeat(auto-fit, minmax(min(100%, 260px), 1fr)); align-items: start; }
.charts { grid-template-columns: repeat(auto-fit, minmax(min(100%, 420px), 1fr)); }
.banner { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; margin-bottom: 16px; padding: 12px 16px; background: var(--surface); border: 1px solid var(--rule); border-radius: var(--radius); }
.banner > span:nth-child(2) { flex: 1; min-width: 200px; }
.banner a { font-weight: 600; text-decoration: none; }

/* stat tiles */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 148px), 1fr)); gap: 12px; }
.stat { display: block; padding: 16px 18px; color: inherit; text-decoration: none; background: var(--surface); border: 1px solid var(--rule); border-radius: var(--radius); box-shadow: var(--shadow); }
a.stat:hover { border-color: var(--rule-strong); }
.stat-label { font-size: 13px; font-weight: 600; color: var(--muted); }
.stat-value { margin: 6px 0 4px; font: 700 34px/1.1 var(--display); color: var(--ink); font-variant-numeric: proportional-nums; letter-spacing: -.02em; }
.stat-note { font-size: 12.5px; color: var(--muted); }

/* tags */
.tag { display: inline-flex; align-items: center; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 700; line-height: 1.6; white-space: nowrap; background: var(--surface-2); color: var(--text); }
.tag + .tag { margin-left: 6px; }
.tag.accent { background: var(--accent-soft); color: var(--accent-ink); }
.tag.good { background: var(--good-bg); color: var(--good); }
.tag.warn { background: var(--warn-bg); color: var(--warn); }
.tag.bad { background: var(--bad-bg); color: var(--bad); }

/* facts and bar lists */
.facts { display: grid; grid-template-columns: auto 1fr; gap: 8px 16px; margin: 0; font-size: 14px; }
.facts dt { color: var(--muted); }
.facts dd { min-width: 0; margin: 0; color: var(--ink); text-align: right; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.bars { display: grid; gap: 12px; margin: 0; padding: 0; list-style: none; }
.bars li { display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; font-size: 14px; }
.bar-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ink); }
.bar-value { font-variant-numeric: tabular-nums; }
.bar-track { grid-column: 1 / -1; height: 6px; overflow: hidden; border-radius: 3px; background: var(--surface-2); }
.bar-fill { display: block; height: 100%; min-width: 3px; border-radius: 3px; background: var(--series); }

/* charts */
.chart { position: relative; border-radius: 6px; outline-offset: 6px; }
.chart svg { display: block; overflow: visible; }
.chart svg :not(.hit) { pointer-events: none; }
.chart .hit { fill: transparent; }
.chart .hit.on { fill: var(--surface-2); }
.chart .grid { stroke: var(--grid); }
.chart .base { stroke: var(--rule-strong); }
.chart .bar { fill: var(--series); }
.chart text { fill: var(--axis); font: 11px var(--font); font-variant-numeric: tabular-nums; }
.tip {
  position: absolute;
  z-index: 2;
  padding: 6px 10px;
  border-radius: 8px;
  background: var(--ink);
  color: var(--bg);
  font-size: 12.5px;
  font-weight: 600;
  white-space: nowrap;
  pointer-events: none;
  transform: translate(-50%, calc(-100% - 10px));
  box-shadow: var(--shadow);
}
.chart-table { max-height: 260px; overflow-y: auto; }

/* toolbar, filters and tables */
.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-bottom: 14px; }
.toolbar input[type="search"] { flex: 1 1 220px; width: auto; max-width: 340px; }
.seg { display: inline-flex; flex-wrap: wrap; gap: 2px; padding: 3px; border-radius: 12px; background: var(--surface-2); }
.seg button { min-height: 32px; padding: 4px 12px; border: 0; border-radius: 9px; background: transparent; color: var(--muted); }
.seg button:hover { background: transparent; color: var(--ink); }
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--ink); box-shadow: 0 1px 3px rgb(0 0 0 / .12); }
.count { font-weight: 500; color: var(--muted); font-variant-numeric: tabular-nums; }
.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--rule); border-radius: var(--radius); box-shadow: var(--shadow); }
table { width: 100%; border-collapse: collapse; font-size: 14px; font-variant-numeric: tabular-nums; }
th { padding: 11px 14px; border-bottom: 1px solid var(--rule); color: var(--muted); font-size: 12.5px; font-weight: 600; text-align: left; white-space: nowrap; }
td { padding: 10px 14px; border-bottom: 1px solid var(--rule); vertical-align: middle; }
tbody tr:last-child td { border-bottom: 0; }
th:has(> input), td:has(> input) { width: 1%; padding-right: 0; }
tr.link { cursor: pointer; }
tr.link:hover td { background: var(--surface-2); }
.email { color: var(--ink); font-weight: 600; text-decoration: none; overflow-wrap: anywhere; }
td .email, td time { white-space: nowrap; }
a.email:hover { text-decoration: underline; }
.row-actions { display: flex; justify-content: flex-end; gap: 6px; white-space: nowrap; }
.empty { padding: 40px 20px; text-align: center; color: var(--muted); background: var(--surface); border: 1px dashed var(--rule-strong); border-radius: var(--radius); }
.empty p + p { margin-top: 12px; }
.pager { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 14px; font-size: 13px; color: var(--muted); }
.pager-links { display: flex; gap: 8px; }
.bulk {
  position: sticky;
  bottom: 16px;
  z-index: 5;
  display: flex;
  align-items: center;
  gap: 10px;
  width: fit-content;
  max-width: 100%;
  margin: 14px auto 0;
  padding: 8px 8px 8px 16px;
  border-radius: 999px;
  background: var(--ink);
  color: var(--bg);
  font-size: 14px;
  font-weight: 600;
  box-shadow: 0 10px 30px rgb(0 0 0 / .25);
}
.bulk button:not(.primary) { background: transparent; color: var(--bg); border-color: color-mix(in srgb, var(--bg) 35%, transparent); }

/* controls */
button, .btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 36px;
  padding: 6px 14px;
  border: 1px solid var(--rule-strong);
  border-radius: 10px;
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  transition: background .15s, border-color .15s, transform .1s;
}
button:hover, .btn:hover { background: var(--surface-2); }
button:active:not(:disabled), .btn:active { transform: scale(.98); }
button:disabled { opacity: .5; cursor: default; }
button.small, .btn.small { min-height: 30px; padding: 3px 10px; border-radius: 8px; font-size: 13px; }
button.primary { background: var(--button-bg); border-color: var(--button-bg); color: var(--button-text); }
button.primary:hover:not(:disabled) { background: var(--button-hover); border-color: var(--button-hover); }
button.danger { color: var(--bad); }
button.danger.solid { background: var(--bad); border-color: var(--bad); color: var(--surface); }
button.link { min-height: 0; padding: 0; border: 0; background: none; color: var(--accent); }
button.wide { width: 100%; min-height: 44px; font-size: 15px; }
input, select, textarea {
  width: 100%;
  min-height: 40px;
  padding: 8px 12px;
  border: 1px solid var(--rule-strong);
  border-radius: 10px;
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  font-size: 15px;
}
textarea { min-height: 96px; resize: vertical; line-height: 1.45; }
input[type="checkbox"] { width: 17px; height: 17px; min-height: 0; margin: 0; padding: 0; accent-color: var(--button-bg); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 4px var(--halo); }
input[type="checkbox"]:focus { box-shadow: none; }
input[type="checkbox"]:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.field { display: grid; gap: 6px; font-size: 13px; font-weight: 600; color: var(--ink); }
.check { display: flex; align-items: flex-start; gap: 10px; font-size: 14px; color: var(--text); }
.check input { flex: none; margin-top: 2px; }
.stack { display: grid; gap: 14px; }
.mode { display: grid; justify-items: start; gap: 10px; margin-bottom: 18px; padding-bottom: 18px; border-bottom: 1px solid var(--rule); }
.form-error { color: var(--bad); font-size: 14px; }
.results { display: grid; gap: 8px; margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--rule); font-size: 14px; }
.results ul { margin: 0; padding-left: 18px; }

/* sign in */
.login { display: grid; place-items: center; min-height: 100vh; padding: 24px 16px; }
.login-card { display: grid; gap: 16px; width: min(400px, 100%); padding: 32px 28px; }
.login-card img { width: 48px; height: 48px; border-radius: 12px; }
.login-card form { display: grid; gap: 12px; }
.login-card label { font-size: 13px; font-weight: 600; color: var(--ink); }
.code-input { padding: 12px; font: 600 24px/1 var(--mono); letter-spacing: .35em; text-align: center; }

/* dialog and toast */
dialog {
  width: min(460px, calc(100% - 32px));
  padding: 24px;
  border: 1px solid var(--rule);
  border-radius: 18px;
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 24px 64px rgb(0 0 0 / .3);
}
dialog::backdrop { background: rgb(41 41 59 / .5); }
dialog form { display: grid; gap: 14px; }
dialog p { overflow-wrap: anywhere; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 6px; }
.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  z-index: 30;
  max-width: calc(100% - 32px);
  padding: 10px 16px;
  border-radius: 12px;
  background: var(--ink);
  color: var(--bg);
  font-size: 14px;
  font-weight: 600;
  box-shadow: 0 10px 30px rgb(0 0 0 / .25);
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 12px);
  transition: opacity .2s, transform .25s cubic-bezier(.16, 1, .3, 1);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.error { background: var(--bad); color: var(--surface); }

@media (max-width: 760px) {
  .top-in { flex-wrap: wrap; gap: 10px 16px; padding: 10px 16px 0; }
  .tabs { order: 3; flex-basis: 100%; margin: 0 -16px; padding: 0 12px 8px; }
  .who { margin-left: auto; }
  .who-email { display: none; }
  main { padding: 24px 16px 80px; }
  h1 { font-size: 24px; }
  .stat-value { font-size: 28px; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
