/* ==========================================================================
   "Ledger" design system — shared by landing/, academy/ and admin/
   See DESIGN.md. Every colour comes from a token, so light/dark just works.
   ========================================================================== */
@import url("https://fonts.googleapis.com/css2?family=Geist:wght@400;500;600;700&family=Geist+Mono:wght@400;500;600&family=Instrument+Serif:ital@0;1&display=swap");

:root, [data-theme="light"] {
  color-scheme: light;
  --bg: #f6f4ef;
  --bg-2: #efece5;
  --surface: #ffffff;
  --surface-2: #f9f8f4;
  --surface-3: #ece9e2;
  --border: rgba(28, 25, 20, 0.09);
  --border-2: rgba(28, 25, 20, 0.16);
  --text: #17150f;
  --muted: #5f5b52;
  --dim: #8e897e;

  --brand: #17150f;          /* primary button */
  --brand-hover: #2e2b23;
  --brand-ink: #f6f4ef;
  --accent: #ee5a1e;         /* signal orange — use sparingly */
  --accent-text: #c2410c;
  --up: #0e8a5f;
  --down: #d93a2b;
  --warn: #a8701a;
  --info: #2b59c3;

  --header: rgba(246, 244, 239, 0.78);
  --overlay: rgba(23, 21, 15, 0.42);
  --shadow-sm: 0 1px 2px rgba(28, 25, 20, 0.05);
  --shadow: 0 1px 2px rgba(28, 25, 20, 0.04), 0 8px 24px -12px rgba(28, 25, 20, 0.12);
  --shadow-lg: 0 2px 4px rgba(28, 25, 20, 0.04), 0 30px 60px -24px rgba(28, 25, 20, 0.25);
}

[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0c0c0a;
  --bg-2: #080807;
  --surface: #151512;
  --surface-2: #1b1b17;
  --surface-3: #26261f;
  --border: rgba(255, 250, 235, 0.08);
  --border-2: rgba(255, 250, 235, 0.15);
  --text: #eeebe3;
  --muted: #a29d90;
  --dim: #6e6a60;

  --brand: #eeebe3;
  --brand-hover: #ffffff;
  --brand-ink: #0c0c0a;
  --accent: #ff6b2c;
  --accent-text: #ff8a55;
  --up: #2fc38a;
  --down: #ff5a4e;
  --warn: #e9b04f;
  --info: #7ba2ff;

  --header: rgba(12, 12, 10, 0.75);
  --overlay: rgba(0, 0, 0, 0.62);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow: 0 1px 0 rgba(255, 250, 235, 0.03) inset, 0 12px 30px -14px rgba(0, 0, 0, 0.7);
  --shadow-lg: 0 1px 0 rgba(255, 250, 235, 0.04) inset, 0 40px 80px -30px rgba(0, 0, 0, 0.85);
}

:root {
  --accent-soft: color-mix(in srgb, var(--accent) 11%, transparent);
  --up-soft: color-mix(in srgb, var(--up) 12%, transparent);
  --down-soft: color-mix(in srgb, var(--down) 11%, transparent);
  --warn-soft: color-mix(in srgb, var(--warn) 13%, transparent);
  --info-soft: color-mix(in srgb, var(--info) 11%, transparent);

  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 16px;
  --radius-xl: 22px;

  --font: "Geist", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --serif: "Instrument Serif", "Times New Roman", ui-serif, Georgia, serif;
  --mono: "Geist Mono", ui-monospace, "SF Mono", Menlo, monospace;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font-family: var(--font); font-size: 15px; line-height: 1.55;
  -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale;
  transition: background-color .3s, color .3s;
}
img, video, svg { display: block; max-width: 100%; }
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; cursor: pointer; border: 0; background: none; }
input, textarea, select { font: inherit; color: inherit; }
::selection { background: color-mix(in srgb, var(--accent) 28%, transparent); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
h1, h2, h3, h4 { margin: 0; letter-spacing: -0.02em; line-height: 1.15; font-weight: 600; }
p { margin: 0; }
.serif { font-family: var(--serif); font-weight: 400; letter-spacing: -0.01em; }
.serif-i { font-family: var(--serif); font-style: italic; font-weight: 400; }
.display { font-family: var(--serif); font-weight: 400; letter-spacing: -0.025em; line-height: 1.02; }
.mono { font-family: var(--mono); font-feature-settings: "tnum"; }
.muted { color: var(--muted); }
.dim { color: var(--dim); }
.accent { color: var(--accent-text); }
.up { color: var(--up); }
.down { color: var(--down); }
.small { font-size: 14px; }
.tiny { font-size: 12px; }
.label-mono { font-family: var(--mono); font-size: 11.5px; letter-spacing: .08em; text-transform: uppercase; color: var(--dim); }

* { scrollbar-width: thin; scrollbar-color: var(--surface-3) transparent; }

/* ---------- Icons ---------- */
.i { width: 18px; height: 18px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.i-sm { width: 15px; height: 15px; }
.i-lg { width: 22px; height: 22px; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 40px; padding: 0 16px; border-radius: 10px;
  font-weight: 500; font-size: 14px; white-space: nowrap; letter-spacing: -0.005em;
  border: 1px solid var(--border-2); background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm);
  transition: transform .15s var(--ease), background .2s, border-color .2s, box-shadow .2s, color .2s, opacity .2s;
}
.btn:hover { background: var(--surface-2); border-color: color-mix(in srgb, var(--text) 25%, transparent); }
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .5; pointer-events: none; }
.btn-primary { background: var(--brand); color: var(--brand-ink); border-color: transparent; }
.btn-primary:hover { background: var(--brand-hover); border-color: transparent; box-shadow: var(--shadow); }
.btn-accent { background: var(--accent); color: #fff; border-color: transparent; }
.btn-accent:hover { background: color-mix(in srgb, var(--accent) 88%, #000); border-color: transparent; }
.btn-ghost { background: transparent; border-color: transparent; color: var(--muted); box-shadow: none; }
.btn-ghost:hover { background: color-mix(in srgb, var(--text) 6%, transparent); color: var(--text); border-color: transparent; }
.btn-danger { background: var(--down-soft); color: var(--down); border-color: color-mix(in srgb, var(--down) 25%, transparent); box-shadow: none; }
.btn-danger:hover { background: color-mix(in srgb, var(--down) 18%, transparent); border-color: color-mix(in srgb, var(--down) 40%, transparent); }
.btn-sm { height: 32px; padding: 0 12px; font-size: 13px; border-radius: 8px; }
.btn-lg { height: 50px; padding: 0 24px; font-size: 15px; border-radius: 12px; }
.btn-icon { width: 38px; padding: 0; }
.btn-icon.btn-sm { width: 32px; }
.btn-block { width: 100%; }
.btn .arrow { transition: transform .2s var(--ease); }
.btn:hover .arrow { transform: translateX(3px); }

/* ---------- Forms ---------- */
.field { display: grid; gap: 7px; }
.field > span, .label { font-size: 13px; font-weight: 500; color: var(--muted); }
.input, .textarea, .select {
  width: 100%; height: 42px; padding: 0 14px; border-radius: 10px;
  background: var(--surface); border: 1px solid var(--border-2); color: var(--text);
  outline: none; transition: border-color .2s, box-shadow .2s, background .2s;
}
.textarea { height: auto; min-height: 96px; padding: 12px 14px; resize: vertical; line-height: 1.5; }
.select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='none' stroke='%238e897e' stroke-width='2' stroke-linecap='round' viewBox='0 0 24 24'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; padding-right: 36px; }
.input:focus, .textarea:focus, .select:focus { border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.input:disabled { background: var(--bg-2); color: var(--muted); }
.input::placeholder, .textarea::placeholder { color: var(--dim); }
.input-icon { position: relative; }
.input-icon .i { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); color: var(--dim); pointer-events: none; }
.input-icon .input { padding-left: 40px; }
.hint { font-size: 12.5px; color: var(--dim); }

.switch { position: relative; width: 40px; height: 23px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; position: absolute; }
.switch i { position: absolute; inset: 0; border-radius: 99px; background: var(--surface-3); border: 1px solid var(--border-2); transition: .2s; cursor: pointer; }
.switch i::after { content: ""; position: absolute; top: 2px; left: 2px; width: 17px; height: 17px; border-radius: 50%; background: var(--surface); box-shadow: var(--shadow-sm); transition: .25s var(--ease); }
.switch input:checked + i { background: var(--up); border-color: transparent; }
.switch input:checked + i::after { transform: translateX(17px); background: #fff; }
.switch input:focus-visible + i { outline: 2px solid var(--accent); outline-offset: 2px; }

.check { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; user-select: none; }
.check input { appearance: none; width: 18px; height: 18px; border-radius: 6px; border: 1.5px solid var(--border-2); background: var(--surface); display: grid; place-items: center; margin: 0; cursor: pointer; transition: .15s; }
.check input:checked { background: var(--brand); border-color: var(--brand); }
.check input:checked::after { content: ""; width: 9px; height: 5px; border: 2px solid var(--brand-ink); border-top: 0; border-right: 0; transform: rotate(-45deg) translate(1px, -1px); }

/* ---------- Surfaces ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow); }
.card-pad { padding: 22px; }
.divider { height: 1px; background: var(--border); border: 0; margin: 0; }

.badge { display: inline-flex; align-items: center; gap: 6px; height: 24px; padding: 0 9px; border-radius: 99px; font-size: 12px; font-weight: 500; background: var(--bg-2); color: var(--muted); border: 1px solid var(--border); white-space: nowrap; }
.badge-green { background: var(--up-soft); color: var(--up); border-color: color-mix(in srgb, var(--up) 22%, transparent); }
.badge-red { background: var(--down-soft); color: var(--down); border-color: color-mix(in srgb, var(--down) 22%, transparent); }
.badge-amber { background: var(--warn-soft); color: var(--warn); border-color: color-mix(in srgb, var(--warn) 22%, transparent); }
.badge-blue { background: var(--info-soft); color: var(--info); border-color: color-mix(in srgb, var(--info) 22%, transparent); }
.badge-accent { background: var(--accent-soft); color: var(--accent-text); border-color: color-mix(in srgb, var(--accent) 25%, transparent); }
.badge-solid { background: var(--brand); color: var(--brand-ink); border-color: transparent; }
.dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }

.avatar { width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; font-weight: 600; font-size: 13px; color: #fff; flex: none; background: var(--brand); }
.avatar-sm { width: 28px; height: 28px; font-size: 11px; }
.avatar-lg { width: 52px; height: 52px; font-size: 18px; }

.progress { height: 6px; border-radius: 99px; background: var(--surface-3); overflow: hidden; }
.progress > i { display: block; height: 100%; border-radius: inherit; background: var(--accent); transition: width .6s var(--ease); }

/* ---------- Table ---------- */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th { text-align: left; font-family: var(--mono); font-weight: 500; font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--dim); padding: 12px 16px; border-bottom: 1px solid var(--border); white-space: nowrap; background: var(--surface-2); }
.table td { padding: 14px 16px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr { transition: background .15s; }
.table tbody tr:hover { background: var(--surface-2); }

/* ---------- Modal ---------- */
.modal-backdrop { position: fixed; inset: 0; z-index: 100; background: var(--overlay); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); display: grid; place-items: center; padding: 16px; animation: fade .2s ease; }
.modal { width: min(560px, 100%); max-height: calc(100dvh - 32px); overflow: auto; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-xl); box-shadow: var(--shadow-lg); animation: pop .3s var(--ease); }
.modal-lg { width: min(760px, 100%); }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 20px 22px 0; }
.modal-head h3 { font-size: 18px; }
.modal-body { padding: 20px 22px; display: grid; gap: 16px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 16px 22px; flex-wrap: wrap; border-top: 1px solid var(--border); background: var(--surface-2); }
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { opacity: 0; transform: translateY(10px) scale(.985); } }

/* ---------- Toast ---------- */
.toasts { position: fixed; z-index: 200; bottom: 20px; right: 20px; left: 20px; display: grid; justify-items: end; gap: 8px; pointer-events: none; }
.toast { pointer-events: auto; display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-radius: 12px; background: var(--brand); color: var(--brand-ink); box-shadow: var(--shadow-lg); font-size: 14px; animation: pop .3s var(--ease); max-width: 420px; }
.toast .i { color: var(--up); }
[data-theme="light"] .toast .i { color: #4ade9a; }
.toast.err .i { color: var(--down); }

/* ---------- Misc ---------- */
.row { display: flex; align-items: center; gap: 12px; }
.between { justify-content: space-between; }
.wrap { flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.stack { display: grid; gap: 16px; }
.empty { text-align: center; padding: 56px 20px; color: var(--muted); }
.empty .i { width: 40px; height: 40px; margin: 0 auto 14px; color: var(--dim); stroke-width: 1.3; }
.empty h4 { color: var(--text); margin-bottom: 6px; font-size: 16px; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.logo { display: inline-flex; align-items: center; gap: 10px; font-family: var(--serif); font-size: 24px; letter-spacing: -0.02em; line-height: 1; }
.logo-mark { width: 28px; height: 28px; display: grid; place-items: center; color: currentColor; flex: none; }
.logo-mark svg { width: 100%; height: 100%; fill: currentColor; }
.logo-full { display: inline-flex; color: currentColor; }
.logo-full svg { height: 26px; width: auto; display: block; fill: currentColor; }

.theme-btn .i-moon { display: none; }
[data-theme="dark"] .theme-btn .i-sun { display: none; }
[data-theme="dark"] .theme-btn .i-moon { display: block; }

.cover { position: relative; overflow: hidden; background: var(--surface-3); }
.cover img { width: 100%; height: 100%; object-fit: cover; }
.cover-art { position: absolute; inset: 0; width: 100%; height: 100%; }

/* Auth screens (academy + admin) */
.auth { min-height: 100dvh; display: grid; grid-template-columns: 1fr 1fr; }
.auth-side { position: relative; overflow: hidden; background: #17150f; color: #f6f4ef; padding: 40px; display: flex; flex-direction: column; justify-content: space-between; }
[data-theme="dark"] .auth-side { background: var(--surface); border-right: 1px solid var(--border); }
.auth-side .logo-mark { color: #f6f4ef; }
.auth-side blockquote em { color: #ff8a55; }
.auth-side blockquote { margin: 0; font-family: var(--serif); font-size: clamp(28px, 3vw, 40px); line-height: 1.12; letter-spacing: -0.02em; max-width: 520px; }
.auth-side .chart { position: absolute; left: 0; right: 0; top: 20%; height: 42%; width: 100%; opacity: .9; pointer-events: none; }
.auth-main { display: grid; place-items: center; padding: 32px 20px; position: relative; }
.auth-card { width: min(380px, 100%); }
.auth-card h1 { font-family: var(--serif); font-weight: 400; font-size: 40px; letter-spacing: -0.02em; margin-bottom: 6px; }
.auth-card form { display: grid; gap: 14px; margin-top: 28px; }
.auth-demo { margin-top: 18px; padding: 12px 14px; border-radius: 12px; background: var(--surface); border: 1px dashed var(--border-2); font-size: 13px; color: var(--muted); }
.auth-demo b { color: var(--text); font-family: var(--mono); font-weight: 500; }
.auth-top { position: absolute; top: 20px; right: 20px; }
.form-error { color: var(--down); font-size: 13px; }

@media (max-width: 860px) {
  .auth { grid-template-columns: 1fr; }
  .auth-side { display: none; }
}
@media (max-width: 640px) {
  .toasts { justify-items: stretch; }
  .card-pad { padding: 18px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
