/* Jotslate Admin. Colors, radii and type come from shared/brand-tokens.json (ink, chalk, cobalt). */

:root {
  color-scheme: dark;
  --bg: #0D0F12;
  --surface: #16181D;
  --surface-2: #1E2127;
  --sep: #2A2E36;
  --text: #F4F5F7;
  --text-2: #A3A9B4;
  --text-3: #6E7480;
  --accent: #6680FF;
  --accent-fill: #3355FF;
  --on-accent: #FFFFFF;
  --accent-tint: rgba(102, 128, 255, 0.22);
  --good: #3DD68C;
  --warn: #FFB224;
  --bad: #FF6369;
  --good-tint: rgba(61, 214, 140, 0.16);
  --warn-tint: rgba(255, 178, 36, 0.16);
  --bad-tint: rgba(255, 99, 105, 0.16);
  --shadow: 0 1px 0 rgba(255, 255, 255, 0.03) inset;

  --r-chip: 8px;
  --r-control: 12px;
  --r-row: 14px;
  --r-card: 20px;

  --font-ui: "Instrument Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  --font-display: "Instrument Serif", "New York", Georgia, serif;
  --font-mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, monospace;
}

:root[data-theme="light"] {
  color-scheme: light;
  --bg: #F4F5F7;
  --surface: #FFFFFF;
  --surface-2: #ECEEF2;
  --sep: #DCDFE5;
  --text: #0D0F12;
  --text-2: #5F6571;
  --text-3: #8A909C;
  --accent: #2E4BE6;
  --accent-fill: #3355FF;
  --accent-tint: rgba(51, 85, 255, 0.14);
  --good: #0A7F58;
  --warn: #A35F00;
  --bad: #CE2C31;
  --good-tint: rgba(14, 159, 110, 0.14);
  --warn-tint: rgba(199, 119, 0, 0.14);
  --bad-tint: rgba(217, 48, 54, 0.12);
  --shadow: 0 1px 2px rgba(13, 15, 18, 0.04);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-ui);
  font-size: 15px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.boot { padding: 48px 24px; color: var(--text-2); }

/* Layout -------------------------------------------------------------------------------------- */

.shell { display: grid; grid-template-columns: 232px minmax(0, 1fr); min-height: 100vh; }
.sidebar {
  position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column; gap: 4px;
  padding: 24px 16px; border-right: 1px solid var(--sep); background: var(--bg);
}
.brand { display: flex; align-items: baseline; gap: 8px; padding: 0 12px 20px; }
.wordmark { font-family: var(--font-display); font-size: 28px; letter-spacing: -0.4px; line-height: 1; }
.brand .tag { font-size: 11px; font-weight: 600; letter-spacing: 0.8px; text-transform: uppercase; color: var(--text-3); }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a {
  display: flex; justify-content: space-between; align-items: center;
  padding: 9px 12px; border-radius: var(--r-control);
  color: var(--text-2); font-weight: 500;
}
.nav a:hover { background: var(--surface); color: var(--text); text-decoration: none; }
.nav a[aria-current="page"] { background: var(--accent-tint); color: var(--text); }
.nav .count { font-size: 12px; color: var(--text-2); background: var(--surface-2); border-radius: 999px; padding: 1px 8px; }
.sidebar .account { margin-top: auto; padding: 12px; font-size: 13px; color: var(--text-2); display: grid; gap: 8px; }
.sidebar .account .email { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar .account .row { display: flex; gap: 8px; }

main { padding: 32px 40px 64px; max-width: 1240px; width: 100%; }
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 24px; }
h1 { font-family: var(--font-display); font-weight: 400; font-size: 34px; letter-spacing: -0.4px; line-height: 1.1; margin: 0; }
h2 { font-size: 17px; font-weight: 600; margin: 0 0 12px; }
h3 { font-size: 15px; font-weight: 600; margin: 0 0 8px; }
.sub { color: var(--text-2); margin: 6px 0 0; }
.muted { color: var(--text-2); }
.faint { color: var(--text-3); }
.mono { font-family: var(--font-mono); font-size: 13px; }
.eyebrow { font-size: 11px; font-weight: 600; letter-spacing: 0.8px; text-transform: uppercase; color: var(--text-3); }

.card {
  background: var(--surface); border: 1px solid var(--sep); border-radius: var(--r-card);
  padding: 20px; box-shadow: var(--shadow);
}
.stack { display: grid; gap: 20px; grid-template-columns: minmax(0, 1fr); }
.grid-2 { display: grid; gap: 20px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.stack > *, .grid-2 > *, .card { min-width: 0; }
.section-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin-bottom: 12px; }
.section-head h2 { margin: 0; }

/* Controls ------------------------------------------------------------------------------------ */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 36px; padding: 0 14px; border-radius: var(--r-control);
  border: 1px solid var(--sep); background: var(--surface-2); color: var(--text);
  font-weight: 600; font-size: 14px; cursor: pointer; white-space: nowrap;
}
.btn:hover { border-color: var(--text-3); }
.btn:disabled { opacity: 0.5; cursor: default; }
.btn.primary { background: var(--accent-fill); border-color: var(--accent-fill); color: var(--on-accent); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { color: var(--bad); }
.btn.small { min-height: 30px; padding: 0 10px; font-size: 13px; }
.btn.ghost { background: transparent; }

input[type="text"], input[type="email"], input[type="date"], input[type="number"], select, textarea {
  min-height: 36px; padding: 6px 12px; border-radius: var(--r-control);
  border: 1px solid var(--sep); background: var(--surface); color: var(--text);
}
textarea { width: 100%; min-height: 120px; resize: vertical; line-height: 1.5; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); outline: none; }
label.field { display: grid; gap: 6px; font-size: 13px; color: var(--text-2); }

.toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.segmented { display: inline-flex; padding: 3px; border-radius: var(--r-control); background: var(--surface-2); border: 1px solid var(--sep); }
.segmented button {
  border: 0; background: transparent; padding: 5px 12px; border-radius: 9px;
  font-size: 13px; font-weight: 600; color: var(--text-2); cursor: pointer;
}
.segmented button[aria-pressed="true"] { background: var(--surface); color: var(--text); box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2); }

/* Tiles --------------------------------------------------------------------------------------- */

.tiles { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(168px, 1fr)); }
.tile { background: var(--surface); border: 1px solid var(--sep); border-radius: var(--r-row); padding: 14px 16px; }
.tile .value { font-size: 28px; font-weight: 600; letter-spacing: -0.3px; font-variant-numeric: tabular-nums; margin-top: 4px; }
.tile .note { font-size: 12px; color: var(--text-2); margin-top: 2px; }

/* Tables -------------------------------------------------------------------------------------- */

.table-wrap { overflow-x: auto; margin: 0 -4px; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th {
  text-align: left; font-size: 11px; font-weight: 600; letter-spacing: 0.8px; text-transform: uppercase;
  color: var(--text-3); padding: 8px; border-bottom: 1px solid var(--sep); white-space: nowrap;
}
td { padding: 10px 8px; border-bottom: 1px solid var(--sep); vertical-align: top; }
tr:last-child td { border-bottom: 0; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
tbody tr.link { cursor: pointer; }
tbody tr.link:hover td { background: var(--surface-2); }
tr.highlight td { background: var(--accent-tint); }
.clip { max-width: 360px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Chips and status ---------------------------------------------------------------------------- */

.chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 2px 8px; border-radius: var(--r-chip);
  background: var(--surface-2); color: var(--text-2); font-size: 12px; font-weight: 600; white-space: nowrap;
}
.chip .dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.chip.good { background: var(--good-tint); color: var(--good); }
.chip.warn { background: var(--warn-tint); color: var(--warn); }
.chip.bad { background: var(--bad-tint); color: var(--bad); }
.chip.accent { background: var(--accent-tint); color: var(--accent); }
.props { display: flex; flex-wrap: wrap; gap: 4px; }
.props .chip { font-weight: 500; font-family: var(--font-mono); font-size: 11px; }

.callout { border-radius: var(--r-row); padding: 12px 16px; background: var(--surface-2); color: var(--text-2); font-size: 14px; }
.callout.bad { background: var(--bad-tint); color: var(--bad); }
.callout.good { background: var(--good-tint); color: var(--good); }
.empty { padding: 28px 8px; text-align: center; color: var(--text-2); }

/* Charts -------------------------------------------------------------------------------------- */

.chart { position: relative; }
.chart svg { display: block; width: 100%; overflow: visible; }
.chart .grid line { stroke: var(--sep); stroke-width: 1; }
.chart .axis text { fill: var(--text-3); font-size: 11px; font-family: var(--font-ui); }
.chart .bar { fill: var(--accent); }
.chart .hit { fill: transparent; cursor: default; }
.chart .hit:hover + .bar, .chart .bar.active { fill: var(--accent); opacity: 0.75; }
.tooltip {
  position: absolute; pointer-events: none; z-index: 5; transform: translate(-50%, -100%);
  background: var(--surface-2); border: 1px solid var(--sep); border-radius: 10px;
  padding: 6px 10px; font-size: 12px; white-space: nowrap; box-shadow: 0 6px 20px rgba(0, 0, 0, 0.25);
}
.tooltip strong { display: block; font-size: 14px; font-variant-numeric: tabular-nums; }

.funnel { display: grid; gap: 10px; }
.funnel .step { display: grid; grid-template-columns: 170px minmax(0, 1fr) 150px; gap: 12px; align-items: center; }
.funnel .label { font-size: 14px; }
.funnel .track { height: 22px; border-radius: 4px; background: var(--surface-2); overflow: hidden; }
.funnel .fill { height: 100%; background: var(--accent); border-radius: 0 4px 4px 0; min-width: 2px; }
.funnel .figures { text-align: right; font-variant-numeric: tabular-nums; font-size: 14px; }
.funnel .figures span { color: var(--text-2); font-size: 12px; margin-left: 6px; }
.funnel.wide .step { grid-template-columns: 170px minmax(0, 1fr) 240px; }

/* Threads ------------------------------------------------------------------------------------- */

.thread { display: grid; gap: 12px; }
.message { border-radius: var(--r-row); padding: 12px 14px; background: var(--surface-2); max-width: 760px; }
.message.admin { background: var(--accent-tint); margin-left: auto; }
.message .meta { font-size: 12px; color: var(--text-2); margin-bottom: 4px; }
.message .text, .pre { white-space: pre-wrap; overflow-wrap: anywhere; }
.pre { font-family: var(--font-mono); font-size: 13px; background: var(--surface-2); border-radius: var(--r-row); padding: 12px 14px; }
dl.kv { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 6px 16px; margin: 0; font-size: 14px; }
dl.kv dt { color: var(--text-2); }
dl.kv dd { margin: 0; overflow-wrap: anywhere; }

/* Sign in ------------------------------------------------------------------------------------- */

.signin { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.signin .card { width: min(400px, 100%); padding: 28px; display: grid; gap: 16px; }
.signin .wordmark { font-size: 34px; }
.signin form { display: grid; gap: 12px; }
.signin input { width: 100%; }
.code-input { font-family: var(--font-mono); letter-spacing: 6px; font-size: 20px; text-align: center; }

/* Small screens ------------------------------------------------------------------------------- */

@media (max-width: 860px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .sidebar {
    position: sticky; top: 0; z-index: 10; height: auto; flex-direction: row; align-items: center;
    padding: 10px 16px; border-right: 0; border-bottom: 1px solid var(--sep); overflow-x: auto; gap: 8px;
  }
  .brand { padding: 0 8px 0 0; }
  .brand .tag { display: none; }
  .nav { flex-direction: row; }
  .nav a { padding: 7px 10px; white-space: nowrap; }
  .nav .count { display: none; }
  .sidebar .account { margin: 0 0 0 auto; padding: 0; }
  .sidebar .account .email { display: none; }
  main { padding: 20px 16px 48px; }
  .grid-2 { grid-template-columns: minmax(0, 1fr); }
  .page-head .toolbar { width: 100%; }
  .section-head { flex-wrap: wrap; }
  .funnel .step { grid-template-columns: 1fr 110px; }
  .funnel.wide .step { grid-template-columns: 1fr auto; }
  .funnel .track { grid-column: 1 / -1; grid-row: 2; }
  h1 { font-size: 28px; }
}
