/* ==========================================================================
   AI Tawin Hub — shared visual layer
   Nordic Calm · Primer structure · glass surfaces · restrained motion
   ========================================================================== */

/* --------------------------------------------------------------- fonts */
@font-face {
  font-family: 'Anuphan';
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url('./fonts/anuphan-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA,
    U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191,
    U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'Anuphan';
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url('./fonts/anuphan-thai.woff2') format('woff2');
  unicode-range: U+02D7, U+0303, U+0331, U+0E01-0E5B, U+200C-200D, U+25CC;
}
@font-face {
  font-family: 'Geist';
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url('./fonts/geist-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA,
    U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191,
    U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'Geist Mono';
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url('./fonts/geistmono-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA,
    U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191,
    U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

/* --------------------------------------------------------------- tokens */
:root,
:root[data-theme='light'] {
  color-scheme: light;

  --font-sans: 'Geist', 'Anuphan', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-mono: 'Geist Mono', 'Anuphan', ui-monospace, SFMono-Regular, Consolas, monospace;

  --canvas: #eef3f9;
  --canvas-2: #e6edf5;
  --glass: rgba(255, 255, 255, 0.56);
  --glass-strong: rgba(255, 255, 255, 0.86);
  --glass-soft: rgba(255, 255, 255, 0.40);
  --field: rgba(255, 255, 255, 0.70);
  --glass-bar: rgba(250, 252, 255, 0.82);
  --card-sheen: rgba(255, 255, 255, 0.62);
  --inset-hi: rgba(255, 255, 255, 0.7);

  --line: rgba(35, 58, 82, 0.14);
  --line-soft: rgba(35, 58, 82, 0.08);
  --line-strong: rgba(35, 58, 82, 0.28);

  --fg: #16202b;
  --fg-2: #33414f;
  --muted: #5b6b7e;
  --inverse: #f7fbff;

  --accent: #1f6feb;
  --accent-2: #0b5bc4;
  --accent-3: #0a4ea8;
  --btn-a: #1f6feb;
  --btn-b: #0b57c2;
  --btn-fg: #ffffff;
  --accent-soft: rgba(31, 111, 235, 0.09);
  --accent-line: rgba(31, 111, 235, 0.28);

  --ok: #1a7f37;
  --ok-soft: rgba(26, 127, 55, 0.10);
  --ok-line: rgba(26, 127, 37, 0.28);
  --warn: #9a6700;
  --warn-soft: rgba(154, 103, 0, 0.10);
  --warn-line: rgba(154, 103, 0, 0.30);
  --bad: #cf222e;
  --bad-soft: rgba(207, 34, 46, 0.09);
  --bad-line: rgba(207, 34, 46, 0.30);

  --ring: rgba(31, 111, 235, 0.24);
  --shadow-sm: 0 1px 2px rgba(20, 32, 44, 0.06);
  --shadow: 0 22px 50px -30px rgba(20, 32, 44, 0.38), 0 2px 8px rgba(20, 32, 44, 0.05);
  --shadow-lg: 0 50px 110px -55px rgba(20, 32, 44, 0.50), 0 10px 30px rgba(20, 32, 44, 0.06);

  --glow-1: rgba(52, 132, 220, 0.42);
  --glow-2: rgba(58, 158, 138, 0.34);
  --glow-3: rgba(104, 128, 186, 0.26);
  --grid-line: rgba(22, 32, 43, 0.07);
  --noise-opacity: 0.028;

  --r-xs: 6px;
  --r-sm: 9px;
  --rad: 13px;
  --r-lg: 18px;
  --r-xl: 24px;
  --r-2xl: 26px;
  --r-full: 999px;

  --ease: cubic-bezier(0.22, 0.68, 0.22, 1);
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-spring: cubic-bezier(0.34, 1.35, 0.64, 1);
  --t-1: 120ms;
  --t-2: 200ms;
  --t-3: 320ms;
  --t-4: 520ms;
}

:root[data-theme='dark'] {
  color-scheme: dark;

  --canvas: #070c12;
  --canvas-2: #0b131c;
  --glass: rgba(20, 30, 42, 0.60);
  --glass-strong: rgba(23, 34, 47, 0.88);
  --glass-soft: rgba(18, 27, 38, 0.42);
  --field: rgba(11, 18, 26, 0.62);
  --glass-bar: rgba(9, 15, 22, 0.80);
  --card-sheen: rgba(120, 170, 220, 0.10);
  --inset-hi: rgba(255, 255, 255, 0.06);

  --line: rgba(148, 178, 205, 0.14);
  --line-soft: rgba(148, 177, 205, 0.09);
  --line-strong: rgba(160, 190, 216, 0.28);

  --fg: #e7eef6;
  --fg-2: #c3d0dd;
  --muted: #8fa3b8;
  --inverse: #0b1118;

  --accent: #58a6ff;
  --accent-2: #3f8ff0;
  --accent-3: #2d6fc9;
  --btn-a: #2472e8;
  --btn-b: #1555b8;
  --btn-fg: #ffffff;
  --accent-soft: rgba(88, 166, 255, 0.12);
  --accent-line: rgba(88, 166, 255, 0.30);

  --ok: #3fb950;
  --ok-soft: rgba(63, 185, 80, 0.13);
  --ok-line: rgba(63, 185, 80, 0.32);
  --warn: #e3b341;
  --warn-soft: rgba(227, 179, 65, 0.13);
  --warn-line: rgba(227, 179, 65, 0.32);
  --bad: #ff6b62;
  --bad-soft: rgba(255, 107, 98, 0.13);
  --bad-line: rgba(255, 107, 98, 0.32);

  --ring: rgba(88, 166, 255, 0.28);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.30);
  --shadow: 0 24px 60px -35px rgba(0, 0, 0, 0.90), 0 2px 10px rgba(0, 0, 0, 0.25);
  --shadow-lg: 0 60px 130px -60px rgba(0, 0, 0, 0.95), 0 12px 36px rgba(0, 0, 0, 0.28);

  --glow-1: rgba(38, 118, 196, 0.62);
  --glow-2: rgba(34, 148, 126, 0.46);
  --glow-3: rgba(68, 92, 176, 0.40);
  --grid-line: rgba(160, 190, 216, 0.06);
  --noise-opacity: 0.04;
}

/* --------------------------------------------------------------- reset */
*,
*::before,
*::after {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  min-height: 100%;
  background: var(--canvas);
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  min-height: 100%;
  margin: 0;
  background: transparent;
  color: var(--fg);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.62;
  letter-spacing: -0.003em;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

h1,
h2,
h3,
h4,
p,
ol,
ul {
  margin: 0;
}

h1,
h2,
h3,
h4 {
  font-weight: 600;
  line-height: 1.24;
  letter-spacing: -0.022em;
  text-wrap: balance;
}

a {
  color: var(--accent);
  text-decoration: none;
  transition: color var(--t-2) var(--ease);
}

a:hover {
  color: var(--accent-2);
}

img,
svg {
  display: block;
  max-width: 100%;
}

button {
  font: inherit;
  color: inherit;
}

::selection {
  background: var(--accent-soft);
  color: var(--fg);
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: var(--r-xs);
}

/* ------------------------------------------------------------ backdrop */
.backdrop {
  position: fixed;
  inset: 0;
  z-index: -3;
  pointer-events: none;
  overflow: hidden;
  background: linear-gradient(180deg, var(--canvas-2) 0%, var(--canvas) 46%, var(--canvas) 100%);
}

.backdrop::before {
  content: '';
  position: absolute;
  inset: -25vmax;
  background:
    radial-gradient(38vmax 30vmax at 10% 4%, var(--glow-1), transparent 62%),
    radial-gradient(44vmax 32vmax at 92% -4%, var(--glow-2), transparent 64%),
    radial-gradient(42vmax 36vmax at 68% 100%, var(--glow-3), transparent 62%);
  filter: blur(24px) saturate(118%);
  animation: aurora-drift 30s var(--ease) infinite alternate;
  will-change: transform;
}

.backdrop::after {
  content: '';
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(to right, var(--grid-line) 1px, transparent 1px),
    linear-gradient(to bottom, var(--grid-line) 1px, transparent 1px);
  background-size: 76px 76px;
  mask-image: radial-gradient(125% 90% at 50% -10%, #000 12%, transparent 78%);
  -webkit-mask-image: radial-gradient(125% 90% at 50% -10%, #000 12%, transparent 78%);
  opacity: 0.75;
}

.noise {
  position: fixed;
  inset: 0;
  z-index: -2;
  pointer-events: none;
  opacity: var(--noise-opacity);
  mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.82' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='180' height='180' filter='url(%23n)' opacity='.55'/%3E%3C/svg%3E");
  background-size: 180px 180px;
}

/* ------------------------------------------------------------- surfaces */
.glass {
  background: var(--glass);
  -webkit-backdrop-filter: blur(20px) saturate(150%);
  backdrop-filter: blur(20px) saturate(150%);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.card {
  position: relative;
  padding: 18px;
  border-radius: var(--r-lg);
  border: 1px solid var(--line);
  background:
    radial-gradient(340px circle at var(--mx, 50%) var(--my, 0%), var(--accent-soft), transparent 64%),
    linear-gradient(158deg, var(--card-sheen) 0%, transparent 46%),
    var(--glass);
  -webkit-backdrop-filter: blur(18px) saturate(145%);
  backdrop-filter: blur(18px) saturate(145%);
  box-shadow: var(--shadow), inset 0 1px 0 var(--inset-hi);
  transition:
    border-color var(--t-3) var(--ease),
    box-shadow var(--t-3) var(--ease),
    transform var(--t-3) var(--ease);
  isolation: isolate;
}

.card::before {
  content: '';
  position: absolute;
  inset: 0 14% auto 14%;
  height: 1px;
  border-radius: var(--r-full);
  background: linear-gradient(90deg, transparent, var(--line-strong), transparent);
  opacity: 0.55;
  pointer-events: none;
}

.card:hover {
  border-color: var(--line-strong);
  box-shadow: var(--shadow-lg);
}

.card > * {
  position: relative;
  z-index: 1;
}

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 24px;
  margin-bottom: 16px;
}

.card h3,
.card-head h3 {
  font-size: 14px;
  font-weight: 600;
  letter-spacing: -0.012em;
  color: var(--fg);
}

/* --------------------------------------------------------------- layout */
.row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.row.end {
  justify-content: flex-end;
}

.row.between {
  justify-content: space-between;
}

.grow {
  flex: 1 1 auto;
  min-width: 0;
}

.grid {
  display: grid;
  gap: 16px;
}

.g2 {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.g3 {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.g4 {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.g5 {
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
}

.a2 {
  grid-template-columns: minmax(330px, 390px) minmax(0, 1fr);
  align-items: start;
}

@media (max-width: 1180px) {
  .a2 {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 980px) {
  .g4 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .g3 {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 720px) {
  .g2 {
    grid-template-columns: 1fr;
  }
  .g4 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
  }
  .stat .v {
    font-size: 23px;
  }
  .stat .k {
    letter-spacing: 0.08em;
  }
}

@media (max-width: 380px) {
  .g4 {
    grid-template-columns: 1fr;
  }
}

/* --------------------------------------------------------------- brand */
.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  min-width: 0;
}

.brand-mark {
  position: relative;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  width: 34px;
  height: 34px;
  overflow: hidden;
  border-radius: 11px;
  color: var(--btn-fg);
  background: linear-gradient(150deg, var(--accent) 0%, var(--accent-2) 54%, var(--accent-3) 100%);
  box-shadow:
    0 10px 24px -12px var(--accent-line),
    inset 0 1px 0 rgba(255, 255, 255, 0.35);
}

.brand-mark::after {
  content: '';
  position: absolute;
  inset: -40% -60%;
  background: linear-gradient(115deg, transparent 40%, rgba(255, 255, 255, 0.5) 50%, transparent 60%);
  transform: translateX(-70%);
  transition: transform 900ms var(--ease-out);
}

.brand:hover .brand-mark::after {
  transform: translateX(70%);
}

.brand-mark svg {
  position: relative;
  z-index: 1;
  width: 19px;
  height: 19px;
}

.brand-name {
  display: block;
  min-width: 0;
  overflow: hidden;
  color: var(--fg);
  font-size: 14.5px;
  font-weight: 600;
  letter-spacing: -0.015em;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.brand-sub {
  display: block;
  margin-top: 1px;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 9.5px;
  font-weight: 500;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

/* ------------------------------------------------------------- buttons */
.btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 34px;
  padding: 7px 13px;
  overflow: hidden;
  isolation: isolate;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: var(--glass-strong);
  color: var(--fg);
  font-size: 12.5px;
  font-weight: 500;
  line-height: 1;
  white-space: nowrap;
  cursor: pointer;
  transition:
    transform var(--t-1) var(--ease),
    border-color var(--t-2) var(--ease),
    background-color var(--t-2) var(--ease),
    box-shadow var(--t-2) var(--ease),
    color var(--t-2) var(--ease);
}

.btn svg {
  flex: 0 0 auto;
  width: 15px;
  height: 15px;
  opacity: 0.78;
}

.btn:hover {
  border-color: var(--line-strong);
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}

.btn:active {
  transform: translateY(0) scale(0.982);
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.btn.primary {
  border-color: transparent;
  background: linear-gradient(180deg, var(--btn-a), var(--btn-b));
  color: var(--btn-fg);
  font-weight: 600;
  box-shadow:
    0 12px 26px -14px var(--accent-line),
    inset 0 1px 0 rgba(255, 255, 255, 0.22);
}

.btn.primary:hover {
  filter: brightness(1.06) saturate(1.05);
  box-shadow:
    0 16px 34px -14px var(--accent-line),
    inset 0 1px 0 rgba(255, 255, 255, 0.25);
}

.btn.primary svg {
  opacity: 0.95;
}

.btn.ghost {
  border-color: transparent;
  background: transparent;
  color: var(--fg-2);
}

.btn.ghost:hover {
  border-color: var(--line);
  background: var(--accent-soft);
  color: var(--fg);
}

.btn.danger {
  border-color: var(--bad-line);
  background: var(--bad-soft);
  color: var(--bad);
}

.btn.danger:hover {
  border-color: var(--bad);
}

.btn.sm {
  min-height: 28px;
  padding: 5px 10px;
  border-radius: var(--r-xs);
  font-size: 11.5px;
}

.btn.wide {
  width: 100%;
}

.btn.is-busy {
  color: transparent !important;
  pointer-events: none;
}

.btn.is-busy::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 13px;
  height: 13px;
  margin: -6.5px 0 0 -6.5px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  color: var(--fg);
  animation: spin 700ms linear infinite;
}

.btn.primary.is-busy::after {
  color: var(--btn-fg);
}

.icon-btn {
  position: relative;
  display: inline-grid;
  place-items: center;
  width: 34px;
  height: 34px;
  padding: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: var(--glass-soft);
  color: var(--fg-2);
  cursor: pointer;
  transition:
    background-color var(--t-2) var(--ease),
    border-color var(--t-2) var(--ease),
    color var(--t-2) var(--ease),
    transform var(--t-1) var(--ease);
}

.icon-btn svg {
  width: 16px;
  height: 16px;
}

.icon-btn:hover {
  border-color: var(--accent-line);
  background: var(--accent-soft);
  color: var(--accent);
  transform: translateY(-1px);
}

.icon-btn:active {
  transform: scale(0.94);
}

.ripple {
  position: absolute;
  z-index: -1;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.22;
  transform: translate(-50%, -50%) scale(0);
  animation: ripple 620ms var(--ease-out) forwards;
  pointer-events: none;
}

/* -------------------------------------------------------------- fields */
.field {
  display: block;
  margin-bottom: 13px;
}

.field > span,
.field > label {
  display: block;
  margin: 0 0 6px 1px;
  color: var(--fg-2);
  font-size: 11.5px;
  font-weight: 500;
  letter-spacing: 0.015em;
  transition: color var(--t-2) var(--ease);
}

.field:focus-within > span,
.field:focus-within > label {
  color: var(--accent);
}

input,
select,
textarea {
  width: 100%;
  min-height: 36px;
  padding: 8px 11px;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: var(--field);
  color: var(--fg);
  font-family: inherit;
  font-size: 13px;
  line-height: 1.45;
  appearance: none;
  transition:
    border-color var(--t-2) var(--ease),
    box-shadow var(--t-2) var(--ease),
    background-color var(--t-2) var(--ease);
}

input::placeholder,
textarea::placeholder {
  color: var(--muted);
  opacity: 0.72;
}

input:hover,
select:hover,
textarea:hover {
  border-color: var(--line-strong);
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--accent);
  background: var(--glass-strong);
  box-shadow: 0 0 0 3px var(--ring);
}

textarea {
  min-height: 78px;
  resize: vertical;
  line-height: 1.6;
}

select {
  padding-right: 32px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.6 6 6.4l5-4.8' fill='none' stroke='%236b7d91' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 11px center;
  cursor: pointer;
}

input[type='checkbox'],
input[type='radio'] {
  width: 15px;
  height: 15px;
  min-height: 0;
  padding: 0;
  accent-color: var(--accent);
  cursor: pointer;
}

input[type='number'] {
  font-variant-numeric: tabular-nums;
}

/* ---------------------------------------------------------------- misc */
.mono {
  font-family: var(--font-mono);
  font-size: 11.5px;
  letter-spacing: -0.01em;
  font-variant-ligatures: none;
}

.muted {
  color: var(--muted);
}

.hint {
  color: var(--muted);
  font-size: 11.5px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: fixed;
  top: -80px;
  left: 16px;
  z-index: 200;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: var(--glass-strong);
  box-shadow: var(--shadow);
  transition: top var(--t-2) var(--ease);
}

.skip-link:focus {
  top: 14px;
}

.ellipsis {
  max-width: 280px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.nowrap {
  white-space: nowrap;
}

/* ---------------------------------------------------------------- tags */
.tag {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  max-width: 100%;
  padding: 2px 8px;
  border: 1px solid var(--line);
  border-radius: var(--r-full);
  background: var(--glass-soft);
  color: var(--muted);
  font-size: 10.5px;
  font-weight: 500;
  line-height: 1.7;
  letter-spacing: 0.01em;
  white-space: nowrap;
}

.tag .dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: currentColor;
  box-shadow: 0 0 8px currentColor;
}

.tag.ok {
  border-color: var(--ok-line);
  background: var(--ok-soft);
  color: var(--ok);
}

.tag.draft,
.tag.warn {
  border-color: var(--warn-line);
  background: var(--warn-soft);
  color: var(--warn);
}

.tag.off,
.tag.bad {
  border-color: var(--bad-line);
  background: var(--bad-soft);
  color: var(--bad);
}

.tag.accent {
  border-color: var(--accent-line);
  background: var(--accent-soft);
  color: var(--accent);
}

/* ---------------------------------------------------------------- bars */
.bar {
  position: relative;
  height: 6px;
  min-width: 90px;
  overflow: hidden;
  border: 1px solid var(--line-soft);
  border-radius: var(--r-full);
  background: var(--field);
}

.bar > i {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent-2), var(--accent));
  box-shadow: 0 0 12px -2px var(--accent-line);
  transition: width 900ms var(--ease-out);
}

.bar > i.warn {
  background: linear-gradient(90deg, var(--warn), #d8a53a);
}

.bar > i.full {
  background: linear-gradient(90deg, var(--bad), #ff8a80);
}

.kpi-line {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin-top: 5px;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 10px;
  font-variant-numeric: tabular-nums;
}

/* -------------------------------------------------------------- keybox */
.keybox {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  padding: 5px 5px 5px 12px;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: var(--field);
  transition: border-color var(--t-2) var(--ease), background-color var(--t-2) var(--ease);
}

.keybox:hover {
  border-color: var(--line-strong);
}

.keybox code {
  flex: 1;
  min-width: 0;
  overflow: auto;
  color: var(--fg-2);
  font-family: var(--font-mono);
  font-size: 11.5px;
  white-space: nowrap;
  scrollbar-width: none;
}

.keybox code::-webkit-scrollbar {
  display: none;
}

.keybox .btn {
  flex: 0 0 auto;
}

pre.code {
  max-height: 320px;
  margin: 0;
  padding: 13px 14px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: var(--field);
  color: var(--fg-2);
  font-family: var(--font-mono);
  font-size: 11.5px;
  line-height: 1.72;
  white-space: pre-wrap;
  word-break: break-word;
}

/* -------------------------------------------------------------- tables */
.scroll {
  width: 100%;
  overflow: auto;
  border-radius: var(--r-sm);
  scrollbar-width: thin;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.5px;
}

th,
td {
  padding: 9px 10px;
  text-align: left;
  vertical-align: middle;
  border-bottom: 1px solid var(--line-soft);
}

th {
  position: sticky;
  top: 0;
  z-index: 2;
  padding-top: 7px;
  padding-bottom: 7px;
  background: var(--glass-strong);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  color: var(--muted);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  white-space: nowrap;
}

td {
  color: var(--fg-2);
}

tbody tr {
  transition: background-color var(--t-1) var(--ease);
}

tbody tr:hover td {
  background: var(--accent-soft);
}

tbody tr:last-child td {
  border-bottom: 0;
}

td button {
  white-space: nowrap;
}

td .row {
  flex-wrap: nowrap;
  gap: 5px;
}

.empty {
  padding: 26px 10px;
  color: var(--muted);
  font-size: 12px;
  text-align: center;
}

.empty::before {
  content: '';
  display: block;
  width: 22px;
  height: 22px;
  margin: 0 auto 8px;
  border: 1px dashed var(--line-strong);
  border-radius: 7px;
  opacity: 0.8;
}

/* ------------------------------------------------------------ skeletons */
.skeleton {
  position: relative;
  overflow: hidden;
  border-radius: var(--r-xs);
  background: var(--field);
}

.skeleton::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent, var(--glass-strong), transparent);
  transform: translateX(-100%);
  animation: shimmer 1.5s var(--ease) infinite;
}

.sk-card {
  min-height: 96px;
}

.sk-line {
  height: 9px;
  margin-bottom: 10px;
  border-radius: 4px;
  background: var(--line-soft);
}

.sk-line.short {
  width: 42%;
}

.sk-value {
  width: 58%;
  height: 24px;
  border-radius: 6px;
  background: var(--line-soft);
}

/* --------------------------------------------------------------- stats */
.stat {
  overflow: hidden;
}

.stat .k {
  display: flex;
  align-items: center;
  gap: 7px;
  overflow: hidden;
  color: var(--muted);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.11em;
  text-overflow: ellipsis;
  text-transform: uppercase;
  white-space: nowrap;
}

.stat .k svg {
  flex: 0 0 auto;
  width: 14px;
  height: 14px;
  color: var(--accent);
  opacity: 0.85;
}

.stat .v {
  margin-top: 10px;
  color: var(--fg);
  font-size: 28px;
  font-weight: 600;
  line-height: 1.1;
  letter-spacing: -0.035em;
  font-variant-numeric: tabular-nums;
}

.stat .v.sm {
  font-size: 17px;
  letter-spacing: -0.02em;
}

.stat::after {
  content: '';
  position: absolute;
  right: -30px;
  bottom: -46px;
  z-index: 0;
  width: 120px;
  height: 90px;
  border-radius: 50%;
  background: radial-gradient(closest-side, var(--accent-soft), transparent 78%);
  opacity: 0.85;
  transition: transform var(--t-4) var(--ease-out);
}

.stat:hover {
  transform: translateY(-2px);
}

.stat:hover::after {
  transform: scale(1.35);
}

/* --------------------------------------------------------------- charts */
.chart {
  display: flex;
  align-items: flex-end;
  gap: 7px;
  height: 190px;
  padding-top: 18px;
}

.chart .col {
  position: relative;
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  gap: 4px;
  min-width: 0;
  height: 100%;
}

.chart .col b {
  min-height: 12px;
  overflow: hidden;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 9px;
  font-weight: 400;
  text-align: center;
  text-overflow: ellipsis;
  white-space: nowrap;
  opacity: 0;
  animation: fade-in 420ms var(--ease) forwards;
  animation-delay: calc(var(--i, 0) * 32ms + 280ms);
}

.chart .col i {
  display: block;
  width: 100%;
  min-height: 2px;
  border-radius: 4px 4px 2px 2px;
  background: linear-gradient(180deg, var(--accent), var(--accent-3));
  box-shadow: 0 0 20px -8px var(--accent-line);
  transform-origin: bottom center;
  animation: bar-grow 760ms var(--ease-out) both;
  animation-delay: calc(var(--i, 0) * 32ms);
  transition: filter var(--t-2) var(--ease);
}

.chart .col:hover i {
  filter: brightness(1.15);
}

.chart .col span {
  overflow: hidden;
  padding-top: 2px;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 9px;
  text-align: center;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* --------------------------------------------------------------- reveal */
.reveal {
  opacity: 0;
  animation: rise 560ms var(--ease-out) forwards;
  animation-delay: calc(var(--i, 0) * 45ms);
}

/* ---------------------------------------------------------------- toast */
.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 130;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.toast-item {
  position: relative;
  display: flex;
  align-items: flex-start;
  gap: 9px;
  min-width: 220px;
  max-width: min(390px, calc(100vw - 32px));
  padding: 11px 14px 12px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: var(--glass-strong);
  -webkit-backdrop-filter: blur(22px) saturate(155%);
  backdrop-filter: blur(28px) saturate(160%);
  box-shadow: var(--shadow-lg);
  color: var(--fg);
  font-size: 12.5px;
  line-height: 1.5;
  cursor: pointer;
  pointer-events: auto;
  animation: toast-in 420ms var(--ease-spring) both;
}

.toast-item::after {
  content: '';
  position: absolute;
  left: 0;
  bottom: 0;
  width: 100%;
  height: 2px;
  background: linear-gradient(90deg, var(--accent), var(--accent-3));
  transform-origin: left;
  animation: toast-life 3800ms linear forwards;
}

.toast-item.warn::after {
  background: linear-gradient(90deg, var(--warn), #d5a63c);
  animation-duration: 6000ms;
}

.toast-item.err {
  border-color: var(--bad-line);
}

.toast-item.err::after {
  background: linear-gradient(90deg, var(--bad), #f08b84);
  animation-duration: 6500ms;
}

.toast-item.out {
  animation: toast-out 260ms var(--ease) both;
}

.toast-dot {
  flex: 0 0 auto;
  width: 6px;
  height: 6px;
  margin-top: 6px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 10px var(--accent);
}

.toast-item.warn .toast-dot {
  background: var(--warn);
  box-shadow: 0 0 10px var(--warn);
}

.toast-item.err .toast-dot {
  background: var(--bad);
  box-shadow: 0 0 10px var(--bad);
}

.toast-text {
  flex: 1;
  min-width: 0;
  word-break: break-word;
}

/* ---------------------------------------------------------------- modal */
.overlay {
  position: fixed;
  inset: 0;
  z-index: 120;
  display: grid;
  place-items: center;
  padding: 22px;
  overflow: auto;
  background: rgba(10, 16, 22, 0.34);
  -webkit-backdrop-filter: blur(12px) saturate(115%);
  backdrop-filter: blur(12px) saturate(115%);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--t-3) var(--ease);
}

.overlay.open {
  opacity: 1;
  pointer-events: auto;
}

.dialog {
  width: 100%;
  max-width: 560px;
  max-height: calc(100dvh - 40px);
  padding: 22px;
  overflow: auto;
  border: 1px solid var(--line-strong);
  border-radius: var(--r-xl);
  background: var(--glass-strong);
  -webkit-backdrop-filter: blur(30px) saturate(160%);
  backdrop-filter: blur(30px) saturate(160%);
  box-shadow: var(--shadow-lg);
  transform: translateY(16px) scale(0.975);
  transition: transform var(--t-4) var(--ease-spring);
}

.overlay.open .dialog {
  transform: none;
}

.dialog h3 {
  margin-bottom: 16px;
  font-size: 17px;
}

.dialog .row {
  margin-top: 6px;
}

/* ---------------------------------------------------------------- auth */
.auth {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 100dvh;
  padding: 28px;
  overflow: hidden;
}

.auth-art {
  position: fixed;
  top: 50%;
  left: clamp(16px, 7vw, 120px);
  z-index: -1;
  color: transparent;
  font-family: 'Geist', sans-serif;
  font-size: clamp(88px, 14vw, 230px);
  font-weight: 600;
  line-height: 0.78;
  letter-spacing: -0.07em;
  text-transform: uppercase;
  -webkit-text-stroke: 1px var(--line-strong);
  opacity: 0.34;
  transform: translateY(-50%);
  animation: art-float 18s var(--ease) infinite alternate;
  pointer-events: none;
  user-select: none;
}

.auth-card {
  position: relative;
  width: 100%;
  max-width: 408px;
  padding: 30px 30px 28px;
  border: 1px solid var(--line-strong);
  border-radius: var(--r-2xl);
  background: var(--glass-strong);
  -webkit-backdrop-filter: blur(30px) saturate(160%);
  backdrop-filter: blur(30px) saturate(160%);
  box-shadow: var(--shadow-lg);
  animation: auth-in 700ms var(--ease-out) both;
}

.auth-card::before {
  content: '';
  position: absolute;
  inset: 0 18% auto 18%;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--line-strong), transparent);
}

.auth-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 26px;
}

.auth-card h1 {
  margin-bottom: 22px;
  font-size: 26px;
  letter-spacing: -0.03em;
}

.auth-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 18px;
  color: var(--muted);
  font-size: 11px;
}

.auth-theme {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 10;
}

/* ----------------------------------------------------------- theme icons */
:root[data-theme='light'] .icon-sun,
:root[data-theme='dark'] .icon-moon {
  display: none;
}

/* -------------------------------------------------------------- spinner */
.spinner {
  width: 14px;
  height: 14px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: spin 700ms linear infinite;
}

.dot {
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 10px var(--accent);
}

.dot.live {
  animation: pulse-dot 2.4s var(--ease) infinite;
}

/* ------------------------------------------------- custom select / combo */
.sel {
  position: relative;
  display: inline-block;
  width: 100%;
  min-width: 0;
  vertical-align: middle;
}

.sel-native {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  min-height: 0 !important;
  padding: 0 !important;
  border: 0 !important;
  opacity: 0 !important;
  pointer-events: none !important;
}

.sel-btn {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
  min-height: 36px;
  padding: 8px 11px;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: var(--field);
  color: var(--fg);
  font-family: inherit;
  font-size: 13px;
  line-height: 1.45;
  text-align: left;
  cursor: pointer;
  transition:
    border-color var(--t-2) var(--ease),
    box-shadow var(--t-2) var(--ease),
    background-color var(--t-2) var(--ease);
}

.sel-btn:hover {
  border-color: var(--line-strong);
  background: var(--glass-strong);
}

.sel-btn:focus-visible,
.sel-btn[aria-expanded='true'] {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.sel-btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.sel-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sel-chevron {
  flex: none;
  width: 7px;
  height: 7px;
  margin-top: -3px;
  border-right: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor;
  opacity: 0.55;
  transform: rotate(45deg);
  transition: transform var(--t-2) var(--ease), margin var(--t-2) var(--ease);
}

.sel-btn[aria-expanded='true'] .sel-chevron {
  margin-top: 3px;
  transform: rotate(-135deg);
}

body > .sel-menu,
body > .combo-menu {
  position: fixed;
  z-index: 260;
  padding: 5px;
  overflow: auto;
  max-height: 280px;
  border: 1px solid var(--line-strong);
  border-radius: var(--r-md);
  background: var(--glass-strong);
  -webkit-backdrop-filter: blur(26px) saturate(160%);
  backdrop-filter: blur(26px) saturate(160%);
  box-shadow: var(--shadow-lg);
  animation: rise 160ms var(--ease-out) both;
}

.sel-opt,
.combo-opt {
  display: block;
  width: 100%;
  padding: 8px 10px;
  border: 0;
  border-radius: var(--r-sm);
  background: transparent;
  color: var(--fg);
  font-family: inherit;
  font-size: 13px;
  line-height: 1.45;
  text-align: left;
  cursor: pointer;
}

.sel-opt:hover,
.sel-opt:focus-visible,
.combo-opt:hover,
.combo-opt:focus-visible {
  outline: none;
  background: var(--accent-soft);
}

.sel-opt.selected {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
}

.sel.is-disabled {
  opacity: 0.6;
}

.row > .sel,
.page-actions > .sel,
.card-head .sel,
.chat-tools .sel {
  width: auto;
  min-width: 158px;
}

/* datalist-style combobox */
.combo {
  position: relative;
  display: block;
  width: 100%;
}

.combo > input {
  padding-right: 34px;
}

.combo-btn {
  position: absolute;
  top: 50%;
  right: 8px;
  width: 18px;
  height: 18px;
  padding: 0;
  border: 0;
  border-radius: var(--r-xs);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transform: translateY(-50%);
}

.combo-btn::before {
  content: '';
  display: block;
  width: 7px;
  height: 7px;
  margin: 3px auto 0;
  border-right: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor;
  opacity: 0.7;
  transform: rotate(45deg);
}

.combo-btn:hover {
  color: var(--accent);
}

/* ------------------------------------------------------------- keyframes */
@keyframes aurora-drift {
  0% {
    transform: translate3d(-2%, -1%, 0) scale(1);
  }
  50% {
    transform: translate3d(1.6%, 1.2%, 0) scale(1.06);
  }
  100% {
    transform: translate3d(2.4%, -1.6%, 0) scale(1.02);
  }
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(12px) scale(0.995);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

@keyframes fade-in {
  to {
    opacity: 1;
  }
}

@keyframes auth-in {
  from {
    opacity: 0;
    filter: blur(6px);
    transform: translateY(18px) scale(0.985);
  }
  to {
    opacity: 1;
    filter: none;
    transform: none;
  }
}

@keyframes art-float {
  from {
    transform: translateY(-50%) rotate(-2deg);
  }
  to {
    transform: translateY(calc(-50% + 18px)) rotate(0deg);
  }
}

@keyframes bar-grow {
  from {
    opacity: 0.4;
    transform: scaleY(0.02);
  }
  to {
    opacity: 1;
    transform: scaleY(1);
  }
}

@keyframes shimmer {
  to {
    transform: translateX(100%);
  }
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@keyframes ripple {
  to {
    opacity: 0;
    transform: translate(-50%, -50%) scale(30);
  }
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(14px) scale(0.96);
  }
}

@keyframes toast-out {
  to {
    opacity: 0;
    transform: translateX(12px) scale(0.97);
  }
}

@keyframes toast-life {
  from {
    transform: scaleX(1);
  }
  to {
    transform: scaleX(0);
  }
}

@keyframes pulse-dot {
  0%,
  100% {
    box-shadow: 0 0 0 0 var(--accent-line);
  }
  50% {
    box-shadow: 0 0 0 5px transparent;
  }
}

@keyframes blink {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.2;
  }
}

/* ---------------------------------------------------------- view trans */
html.theme-vt::view-transition-old(root),
html.theme-vt::view-transition-new(root) {
  animation: none;
}

::view-transition-old(root) {
  animation: vt-out 160ms var(--ease) both;
}

::view-transition-new(root) {
  animation: vt-in 260ms var(--ease-out) both;
}

@keyframes vt-out {
  to {
    opacity: 0;
    transform: translateY(-4px);
  }
}

@keyframes vt-in {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
}

/* ------------------------------------------------------ reduced motion */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
  .backdrop::before,
  .auth-art {
    animation: none !important;
  }
  .reveal {
    opacity: 1;
  }
}

/* ------------------------------------------------------------ responsive */
@media (max-width: 520px) {
  .auth {
    padding: 18px;
  }
  .auth-art {
    display: none;
  }
  .auth-card {
    padding: 24px 20px;
  }
  .toast {
    right: 12px;
    bottom: 12px;
    left: 12px;
  }
  .toast-item {
    max-width: 100%;
  }
}
