/* ==========================================================================
   Skilloify design system
   Self-contained: no Bootstrap, no icon font, no webfont. One file, one
   request, works offline and behind restrictive CDNs.
   ========================================================================== */

/* --------------------------------------------------------------- 1. Tokens */

:root {
  color-scheme: light;

  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;

  --bg:            #f4f6fb;
  --bg-grad:       radial-gradient(1200px 600px at 80% -10%, #e8ecff 0%, transparent 60%);
  --surface:       #ffffff;
  --surface-2:     #f8f9fc;
  --surface-3:     #eef1f8;
  --border:        #e2e6f0;
  --border-strong: #ccd3e3;

  --text:      #131722;
  --text-soft: #4a5164;
  --muted:     #6b7488;
  --faint:     #939bb0;

  --primary:      #4f46e5;
  --primary-hover:#4338ca;
  --primary-soft: #eef0fe;
  --primary-text: #ffffff;
  --ring:         rgba(79, 70, 229, .32);

  --success:  #0f8a5f;  --success-soft: #e2f6ee;
  --warning:  #a4650a;  --warning-soft: #fdf1dc;
  --danger:   #c92a3d;  --danger-soft:  #fdeaec;
  --info:     #1f6fbf;  --info-soft:    #e6f1fc;
  --neutral:  #5a6376;  --neutral-soft: #eceff5;
  --violet:   #6d3fc4;  --violet-soft:  #f0e9fd;

  --radius-sm: 6px;
  --radius:    10px;
  --radius-lg: 14px;
  --radius-xl: 20px;

  --shadow-sm: 0 1px 2px rgba(16, 22, 40, .06);
  --shadow:    0 1px 3px rgba(16, 22, 40, .07), 0 6px 16px -8px rgba(16, 22, 40, .14);
  --shadow-lg: 0 12px 32px -12px rgba(16, 22, 40, .28), 0 2px 6px rgba(16, 22, 40, .06);

  --sidebar-w: 256px;
  --topbar-h: 62px;

  --code-bg: #f2f4f9;
  --term-bg: #10131c;
  --term-text: #d5dbe8;
}

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

  --bg:            #090b11;
  --bg-grad:       radial-gradient(1100px 560px at 82% -12%, #1b2145 0%, transparent 62%);
  --surface:       #12151e;
  --surface-2:     #171b26;
  --surface-3:     #1d2230;
  --border:        #242a38;
  --border-strong: #333b4d;

  --text:      #e9ecf5;
  --text-soft: #b6bdcd;
  --muted:     #8f98ac;
  --faint:     #6d7488;

  --primary:      #8b8bf7;
  --primary-hover:#a0a0fb;
  --primary-soft: #1e2144;
  --primary-text: #0b0d14;
  --ring:         rgba(139, 139, 247, .38);

  --success:  #4ecfa0;  --success-soft: #10281f;
  --warning:  #e2ac54;  --warning-soft: #2c2113;
  --danger:   #f4808f;  --danger-soft:  #2e151a;
  --info:     #71b6f5;  --info-soft:    #111f2f;
  --neutral:  #98a1b5;  --neutral-soft: #1c212c;
  --violet:   #b191f2;  --violet-soft:  #201a35;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .5);
  --shadow:    0 1px 3px rgba(0, 0, 0, .5), 0 8px 20px -10px rgba(0, 0, 0, .7);
  --shadow-lg: 0 18px 44px -16px rgba(0, 0, 0, .8);

  --code-bg: #1a1f2b;
  --term-bg: #0b0e15;
  --term-text: #ccd3e2;
}

/* --------------------------------------------------------------- 2. Reset */

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

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.55;
  color: var(--text);
  background: var(--bg);
  background-image: var(--bg-grad);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

h1, h2, h3, h4, h5, h6 { margin: 0; font-weight: 650; line-height: 1.25; letter-spacing: -.012em; }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.185rem; }
h3 { font-size: 1.0625rem; }
h4 { font-size: .9375rem; }
p  { margin: 0 0 .75rem; }
p:last-child { margin-bottom: 0; }

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

code, pre, kbd, samp { font-family: var(--font-mono); font-size: .8125em; }
code { background: var(--code-bg); padding: .1em .38em; border-radius: 5px; }
pre { margin: 0; }
img, svg { max-width: 100%; }
hr { border: 0; border-top: 1px solid var(--border); margin: 1.25rem 0; }

:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; border-radius: 4px; }

::selection { background: var(--ring); }

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

[hidden] { display: none !important; }

/* ------------------------------------------------------------- 3. Utility */

.muted     { color: var(--muted); }
.faint     { color: var(--faint); }
.small     { font-size: .8125rem; }
.tiny      { font-size: .75rem; }
.strong    { font-weight: 620; }
.mono      { font-family: var(--font-mono); }
.nowrap    { white-space: nowrap; }
.truncate  { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.text-right{ text-align: right; }
.tnum      { font-variant-numeric: tabular-nums; }
.uppercase { text-transform: uppercase; letter-spacing: .06em; font-size: .6875rem; font-weight: 700; color: var(--faint); }

.row     { display: flex; align-items: center; gap: .625rem; }
.row--between { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.row--wrap { flex-wrap: wrap; }
.col     { display: flex; flex-direction: column; gap: .625rem; }
.grow    { flex: 1 1 auto; min-width: 0; }
.stack > * + * { margin-top: 1rem; }

.mt-0{margin-top:0}.mt-1{margin-top:.5rem}.mt-2{margin-top:1rem}.mt-3{margin-top:1.5rem}
.mb-0{margin-bottom:0}.mb-1{margin-bottom:.5rem}.mb-2{margin-bottom:1rem}.mb-3{margin-bottom:1.5rem}

.grid { display: grid; gap: 1rem; }
.grid--stats { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.grid--2     { grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.grid--cards { grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); }
.grid--split { grid-template-columns: minmax(0, 1.65fr) minmax(0, 1fr); align-items: start; }
@media (max-width: 960px) { .grid--split { grid-template-columns: minmax(0, 1fr); } }

/* --------------------------------------------------------------- 4. Icons */

/* The icon class sits directly on the <svg>, so the sizing must live here.
   A `svg.icon { width: 100% }` rule would out-specify it and blow every icon
   up to its container's width. */
.icon {
  width: 1.125em; height: 1.125em;
  flex: none; display: inline-block; vertical-align: -.18em;
  fill: none; stroke: currentColor;
  stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round;
}
.icon svg { width: 100%; height: 100%; }
.icon--lg { width: 1.4em; height: 1.4em; }

/* -------------------------------------------------------------- 5. Shell */

.app { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w);
  flex: none;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 60;
  overflow-y: auto;
  overscroll-behavior: contain;
  transition: transform .22s cubic-bezier(.4, 0, .2, 1);
}

.sidebar__brand {
  display: flex; align-items: center; gap: .625rem;
  padding: 1rem 1.125rem;
  min-height: var(--topbar-h);
  border-bottom: 1px solid var(--border);
  color: var(--text);
}
.sidebar__brand:hover { text-decoration: none; }
.sidebar__mark {
  width: 32px; height: 32px; flex: none; border-radius: 9px;
  background: linear-gradient(140deg, var(--primary), #8b5cf6);
  color: #fff; display: grid; place-items: center;
  box-shadow: 0 3px 10px -3px var(--ring);
}
.sidebar__mark .icon { width: 18px; height: 18px; }
.sidebar__name { font-weight: 700; letter-spacing: -.02em; font-size: .95rem; line-height: 1.1; }
.sidebar__tag  { font-size: .6875rem; color: var(--faint); line-height: 1.2; }

.nav { padding: .75rem .625rem 1.25rem; display: flex; flex-direction: column; gap: 1px; }
.nav__group {
  padding: 1rem .75rem .375rem;
  font-size: .6875rem; font-weight: 700; letter-spacing: .07em;
  text-transform: uppercase; color: var(--faint);
}
.nav__link {
  display: flex; align-items: center; gap: .625rem;
  padding: .5rem .75rem;
  border-radius: var(--radius-sm);
  color: var(--text-soft);
  font-weight: 520;
  position: relative;
}
.nav__link:hover { background: var(--surface-3); color: var(--text); text-decoration: none; }
.nav__link.is-active { background: var(--primary-soft); color: var(--primary); font-weight: 620; }
.nav__link.is-active::before {
  content: ""; position: absolute; left: -.625rem; top: 20%; bottom: 20%;
  width: 3px; border-radius: 0 3px 3px 0; background: var(--primary);
}
.nav__link .icon { color: currentColor; opacity: .9; }
.nav__count {
  margin-left: auto; font-size: .6875rem; font-weight: 700;
  background: var(--surface-3); color: var(--muted);
  padding: .05rem .4rem; border-radius: 999px; min-width: 1.35em; text-align: center;
}
.nav__link.is-active .nav__count { background: var(--primary); color: var(--primary-text); }

.sidebar__foot { margin-top: auto; padding: .875rem 1.125rem; border-top: 1px solid var(--border); }

.main { flex: 1 1 auto; min-width: 0; margin-left: var(--sidebar-w); display: flex; flex-direction: column; }

.topbar {
  position: sticky; top: 0; z-index: 40;
  min-height: var(--topbar-h);
  display: flex; align-items: center; gap: 1rem;
  padding: .625rem 1.5rem;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: saturate(1.6) blur(10px);
  border-bottom: 1px solid var(--border);
}
.topbar__title { font-size: 1.0625rem; font-weight: 660; letter-spacing: -.015em; }
.topbar__sub { font-size: .8125rem; color: var(--muted); }
.topbar__actions { margin-left: auto; display: flex; align-items: center; gap: .5rem; }

.content { padding: 1.5rem; max-width: 1520px; width: 100%; }
@media (max-width: 640px) { .content { padding: 1rem; } .topbar { padding: .625rem 1rem; } }

/* Scoped so it out-specifies `.btn { display: inline-flex }`, which is
   declared later in this file. */
.topbar .sidebar__toggle { display: none; }
.scrim { display: none; }

@media (max-width: 1024px) {
  .sidebar { transform: translateX(-100%); box-shadow: var(--shadow-lg); }
  .sidebar.is-open { transform: translateX(0); }
  .main { margin-left: 0; }
  .topbar .sidebar__toggle { display: inline-flex; }
  .scrim {
    display: block; position: fixed; inset: 0; z-index: 50;
    background: rgba(8, 10, 18, .5); opacity: 0; pointer-events: none;
    transition: opacity .2s;
  }
  .scrim.is-open { opacity: 1; pointer-events: auto; }
}

/* --------------------------------------------------------------- 6. Cards */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}
.card__head {
  display: flex; align-items: center; gap: 1rem;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
}
.card__head h2, .card__head h3 { margin: 0; }
.card__head .row--between { flex: 1; }
.card__title { font-size: .9375rem; font-weight: 650; }
.card__desc  { font-size: .8125rem; color: var(--muted); margin-top: .1rem; }
.card__body  { padding: 1.25rem; }
.card__body--flush { padding: 0; }
.card__foot  { padding: .875rem 1.25rem; border-top: 1px solid var(--border); background: var(--surface-2); border-radius: 0 0 var(--radius-lg) var(--radius-lg); }

/* ---------------------------------------------------------------- 7. Stat */

.stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.0625rem 1.125rem;
  box-shadow: var(--shadow-sm);
  display: flex; flex-direction: column; gap: .375rem;
  position: relative; overflow: hidden;
}
.stat__label { font-size: .75rem; font-weight: 640; color: var(--muted); letter-spacing: .01em; display: flex; align-items: center; gap: .4rem; }
.stat__value { font-size: 1.75rem; font-weight: 700; letter-spacing: -.03em; line-height: 1.1; font-variant-numeric: tabular-nums; }
.stat__meta  { font-size: .78125rem; color: var(--muted); display: flex; align-items: center; gap: .35rem; }
.stat__spark { position: absolute; right: 0; bottom: 0; left: 0; height: 34px; opacity: .5; pointer-events: none; }
.stat__icon {
  width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center;
  background: var(--primary-soft); color: var(--primary);
}
.stat--success .stat__icon { background: var(--success-soft); color: var(--success); }
.stat--warning .stat__icon { background: var(--warning-soft); color: var(--warning); }
.stat--danger  .stat__icon { background: var(--danger-soft);  color: var(--danger); }
.stat--violet  .stat__icon { background: var(--violet-soft);  color: var(--violet); }

/* -------------------------------------------------------------- 8. Buttons */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  padding: .4375rem .8125rem;
  font: inherit; font-size: .8125rem; font-weight: 600;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  white-space: nowrap;
  transition: background .14s, border-color .14s, color .14s, box-shadow .14s, transform .06s;
}
.btn:hover { background: var(--surface-3); text-decoration: none; }
.btn:active { transform: translateY(.5px); }
.btn[disabled], .btn.is-loading { opacity: .6; pointer-events: none; }

.btn--primary { background: var(--primary); border-color: var(--primary); color: var(--primary-text); box-shadow: 0 1px 2px var(--ring); }
.btn--primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }

.btn--danger  { background: var(--surface); border-color: var(--border-strong); color: var(--danger); }
.btn--danger:hover { background: var(--danger-soft); border-color: var(--danger); }

.btn--ghost   { background: transparent; border-color: transparent; color: var(--text-soft); }
.btn--ghost:hover { background: var(--surface-3); color: var(--text); }

.btn--lg { padding: .625rem 1.125rem; font-size: .875rem; }
.btn--sm { padding: .25rem .5625rem; font-size: .75rem; }
.btn--block { width: 100%; }
.btn--icon { padding: .4375rem; }
.btn--icon.btn--sm { padding: .3125rem; }

.btn.is-loading { position: relative; color: transparent !important; }
.btn.is-loading::after {
  content: ""; position: absolute; inset: 0; margin: auto;
  width: 14px; height: 14px; border-radius: 50%;
  border: 2px solid currentColor; border-top-color: transparent;
  color: var(--text); animation: spin .6s linear infinite;
}
.btn--primary.is-loading::after { color: var(--primary-text); }

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

.btn-group { display: inline-flex; gap: .375rem; flex-wrap: wrap; }

/* -------------------------------------------------------------- 9. Chips */

.segmented { display: inline-flex; flex-wrap: wrap; gap: .375rem; }
.chip {
  display: inline-flex; align-items: center; gap: .375rem;
  padding: .3125rem .625rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-soft);
  font-size: .78125rem; font-weight: 560;
  cursor: pointer;
}
.chip:hover { background: var(--surface-3); color: var(--text); text-decoration: none; border-color: var(--border-strong); }
.chip.is-active { background: var(--primary); border-color: var(--primary); color: var(--primary-text); font-weight: 640; }
.chip__count { font-variant-numeric: tabular-nums; opacity: .72; font-weight: 600; }
.chip.is-active .chip__count { opacity: .85; }

/* ------------------------------------------------------------- 10. Pills */

.pill {
  display: inline-flex; align-items: center; gap: .3125rem;
  padding: .1875rem .5rem;
  border-radius: 999px;
  font-size: .6875rem; font-weight: 680;
  letter-spacing: .025em;
  background: var(--neutral-soft); color: var(--neutral);
  white-space: nowrap;
}
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; flex: none; }
.pill--plain::before { display: none; }

.pill--active, .pill--completed, .pill--success, .pill--enabled, .pill--healthy
                            { background: var(--success-soft); color: var(--success); }
.pill--cooldown, .pill--rate_limited, .pill--retrying, .pill--warning, .pill--degraded
                            { background: var(--warning-soft); color: var(--warning); }
.pill--failed, .pill--invalid, .pill--quota_exceeded, .pill--danger, .pill--error, .pill--critical, .pill--down
                            { background: var(--danger-soft); color: var(--danger); }
.pill--running, .pill--info { background: var(--info-soft); color: var(--info); }
.pill--queued, .pill--waiting_for_provider, .pill--violet
                            { background: var(--violet-soft); color: var(--violet); }
.pill--disabled, .pill--cancelled, .pill--inactive
                            { background: var(--neutral-soft); color: var(--neutral); }

.pill--running::before { animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: .25; } }

.tag {
  display: inline-flex; align-items: center; gap: .3rem;
  padding: .125rem .4375rem; border-radius: var(--radius-sm);
  background: var(--surface-3); color: var(--text-soft);
  font-size: .71875rem; font-weight: 580; border: 1px solid var(--border);
}
.tag--mono { font-family: var(--font-mono); font-size: .6875rem; }

/* ------------------------------------------------------------- 11. Tables */

.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: .8125rem; }
.table th {
  text-align: left; font-weight: 640; font-size: .6875rem;
  text-transform: uppercase; letter-spacing: .055em; color: var(--faint);
  padding: .625rem 1rem; background: var(--surface-2);
  border-bottom: 1px solid var(--border); white-space: nowrap;
  position: sticky; top: 0; z-index: 1;
}
.table td { padding: .6875rem 1rem; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover td { background: var(--surface-2); }
.table__actions { text-align: right; white-space: nowrap; }
.table__num { text-align: right; font-variant-numeric: tabular-nums; }

@media (max-width: 760px) {
  .table--stack thead { display: none; }
  .table--stack, .table--stack tbody, .table--stack tr, .table--stack td { display: block; width: 100%; }
  .table--stack tr { border-bottom: 1px solid var(--border); padding: .625rem .25rem; }
  .table--stack tr:last-child { border-bottom: 0; }
  .table--stack td { border: 0; padding: .25rem 1rem; display: flex; gap: 1rem; align-items: baseline; }
  .table--stack td::before {
    content: attr(data-label); flex: 0 0 40%;
    font-size: .6875rem; text-transform: uppercase; letter-spacing: .05em;
    color: var(--faint); font-weight: 700;
  }
  .table--stack td:empty { display: none; }
  .table--stack .table__actions { justify-content: flex-start; padding-top: .5rem; }
}

/* -------------------------------------------------------------- 12. Forms */

.field { display: flex; flex-direction: column; gap: .3125rem; margin-bottom: 1rem; }
.field:last-child { margin-bottom: 0; }
.label { font-size: .8125rem; font-weight: 600; color: var(--text-soft); }
.label .req { color: var(--danger); }
.hint  { font-size: .75rem; color: var(--muted); }

.input, .select, .textarea {
  width: 100%;
  padding: .5rem .6875rem;
  font: inherit; font-size: .875rem;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  transition: border-color .14s, box-shadow .14s;
}
.input::placeholder, .textarea::placeholder { color: var(--faint); }
.input:focus, .select:focus, .textarea:focus {
  outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--ring);
}
.textarea { resize: vertical; min-height: 84px; line-height: 1.55; }
.textarea--mono { font-family: var(--font-mono); font-size: .8125rem; }

.select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%236b7488' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right .5rem center; background-size: 16px;
  padding-right: 2rem;
}
:root[data-theme="dark"] .select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%238f98ac' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
}

.field.has-error .input, .field.has-error .select, .field.has-error .textarea { border-color: var(--danger); }
.field__error { font-size: .75rem; color: var(--danger); font-weight: 560; }

.input-group { display: flex; }
.input-group .input { border-radius: var(--radius-sm) 0 0 var(--radius-sm); }
.input-group .btn  { border-radius: 0 var(--radius-sm) var(--radius-sm) 0; border-left: 0; }

.search { position: relative; }
.search .icon {
  position: absolute; left: .625rem; top: 50%; transform: translateY(-50%);
  color: var(--faint); pointer-events: none; width: 16px; height: 16px;
}
.search .input { padding-left: 2rem; }

.check { display: flex; align-items: flex-start; gap: .5rem; cursor: pointer; }
.check input { margin: .2rem 0 0; width: 15px; height: 15px; accent-color: var(--primary); flex: none; }
.check__text { font-size: .8125rem; }

.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 0 1rem; }

/* ------------------------------------------------------------- 13. Alerts */

.alert {
  display: flex; gap: .625rem; align-items: flex-start;
  padding: .75rem .875rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface-2);
  font-size: .8125rem;
}
.alert .icon { flex: none; margin-top: .1rem; }
.alert--danger  { background: var(--danger-soft);  border-color: color-mix(in srgb, var(--danger) 32%, transparent);  color: var(--danger); }
.alert--warning { background: var(--warning-soft); border-color: color-mix(in srgb, var(--warning) 32%, transparent); color: var(--warning); }
.alert--success { background: var(--success-soft); border-color: color-mix(in srgb, var(--success) 32%, transparent); color: var(--success); }
.alert--info    { background: var(--info-soft);    border-color: color-mix(in srgb, var(--info) 32%, transparent);    color: var(--info); }
.alert strong { font-weight: 680; }

/* -------------------------------------------------------- 14. Empty state */

.empty {
  padding: 3rem 1.5rem; text-align: center;
  display: flex; flex-direction: column; align-items: center; gap: .625rem;
}
.empty__icon {
  width: 46px; height: 46px; border-radius: 13px; display: grid; place-items: center;
  background: var(--surface-3); color: var(--faint); margin-bottom: .25rem;
}
.empty__icon .icon { width: 22px; height: 22px; }
.empty h3 { font-size: .9375rem; }
.empty p { color: var(--muted); max-width: 44ch; font-size: .8125rem; }

.state-panel {
  max-width: 460px; margin: 0 auto; padding: 2.5rem 2rem; text-align: center;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-xl); box-shadow: var(--shadow-lg);
}
.state-panel__icon {
  width: 52px; height: 52px; margin: 0 auto 1rem; border-radius: 15px;
  display: grid; place-items: center; background: var(--surface-3); color: var(--muted);
}
.state-panel__icon svg { width: 26px; height: 26px; }
.state-panel__icon--danger  { background: var(--danger-soft);  color: var(--danger); }
.state-panel__icon--warning { background: var(--warning-soft); color: var(--warning); }
.state-panel h1 { font-size: 1.25rem; margin-bottom: .5rem; }
.state-panel p  { color: var(--muted); margin-bottom: 1.5rem; }
.err-trace {
  text-align: left; font-size: .6875rem; background: var(--code-bg); color: var(--text-soft);
  padding: .75rem; border-radius: var(--radius-sm); overflow: auto; max-height: 220px; margin-bottom: 1.25rem;
}
.page-centered { display: grid; place-items: center; min-height: 100vh; padding: 1.5rem; }

/* -------------------------------------------------------------- 15. Modal */

.modal {
  position: fixed; inset: 0; z-index: 100;
  display: grid; place-items: center; padding: 1.25rem;
  background: rgba(9, 11, 18, .55);
  backdrop-filter: blur(3px);
  opacity: 0; pointer-events: none; transition: opacity .16s;
}
.modal.is-open { opacity: 1; pointer-events: auto; }
.modal__box {
  width: 100%; max-width: 540px; max-height: calc(100vh - 2.5rem);
  display: flex; flex-direction: column;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); box-shadow: var(--shadow-lg);
  transform: translateY(8px) scale(.985); transition: transform .18s cubic-bezier(.2,.8,.3,1);
}
.modal.is-open .modal__box { transform: none; }
.modal__box--wide { max-width: 720px; }
.modal__head { display: flex; align-items: center; gap: 1rem; padding: 1rem 1.25rem; border-bottom: 1px solid var(--border); }
.modal__head h2 { font-size: .9375rem; }
.modal__body { padding: 1.25rem; overflow-y: auto; }
.modal__foot { padding: .875rem 1.25rem; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: .5rem; background: var(--surface-2); border-radius: 0 0 var(--radius-lg) var(--radius-lg); }

/* ------------------------------------------------------------- 16. Toasts */

.toasts {
  position: fixed; right: 1rem; bottom: 1rem; z-index: 200;
  display: flex; flex-direction: column; gap: .5rem;
  max-width: min(380px, calc(100vw - 2rem));
}
.toast {
  display: flex; gap: .625rem; align-items: flex-start;
  padding: .6875rem .8125rem;
  background: var(--surface); border: 1px solid var(--border);
  border-left: 3px solid var(--neutral);
  border-radius: var(--radius); box-shadow: var(--shadow-lg);
  font-size: .8125rem;
  animation: toast-in .22s cubic-bezier(.2,.8,.3,1);
}
.toast--success { border-left-color: var(--success); }
.toast--error   { border-left-color: var(--danger); }
.toast--warning { border-left-color: var(--warning); }
.toast--info    { border-left-color: var(--info); }
.toast__icon--success { color: var(--success); }
.toast__icon--error   { color: var(--danger); }
.toast__icon--warning { color: var(--warning); }
.toast__icon--info    { color: var(--info); }
.toast__body { flex: 1; min-width: 0; }
.toast__title { font-weight: 640; }
.toast__text  { color: var(--muted); font-size: .78125rem; margin-top: .1rem; word-break: break-word; }
.toast__close { background: none; border: 0; color: var(--faint); cursor: pointer; padding: 0 .125rem; line-height: 1; }
.toast__close:hover { color: var(--text); }
.toast.is-leaving { animation: toast-out .18s forwards; }

@keyframes toast-in  { from { opacity: 0; transform: translateY(10px); } }
@keyframes toast-out { to   { opacity: 0; transform: translateX(14px); } }

/* -------------------------------------------------------------- 17. Menus */

.menu { position: relative; }
.menu__panel {
  position: absolute; right: 0; top: calc(100% + .375rem); z-index: 80;
  min-width: 210px; padding: .3125rem;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow-lg);
}
.menu__item {
  display: flex; align-items: center; gap: .5rem; width: 100%;
  padding: .4375rem .5625rem; border: 0; border-radius: var(--radius-sm);
  background: none; font: inherit; font-size: .8125rem; color: var(--text);
  text-align: left; cursor: pointer;
}
.menu__item:hover { background: var(--surface-3); text-decoration: none; }
.menu__item--danger { color: var(--danger); }
.menu__sep { height: 1px; background: var(--border); margin: .3125rem 0; }
.menu__meta { padding: .5rem .5625rem .375rem; }

.user-btn {
  display: flex; align-items: center; gap: .5rem;
  padding: .25rem .5rem .25rem .25rem;
  border: 1px solid var(--border); border-radius: 999px;
  background: var(--surface); cursor: pointer; font: inherit;
  color: var(--text);
}
.user-btn:hover { background: var(--surface-3); }
.avatar {
  width: 26px; height: 26px; flex: none; border-radius: 50%;
  background: linear-gradient(140deg, var(--primary), #8b5cf6);
  color: #fff; display: grid; place-items: center;
  font-size: .6875rem; font-weight: 700; letter-spacing: .02em;
}
.avatar--lg { width: 36px; height: 36px; font-size: .8125rem; }

/* -------------------------------------------------------- 18. Terminal log */

.term {
  background: var(--term-bg); color: var(--term-text);
  border-radius: var(--radius); padding: .875rem;
  font-family: var(--font-mono); font-size: .71875rem; line-height: 1.65;
  overflow: auto; overscroll-behavior: contain;
  border: 1px solid var(--border);
}
.term__line { display: flex; gap: .5rem; padding: .0625rem 0; }
.term__line + .term__line { border-top: 1px solid rgba(255,255,255,.04); }
.term__time { color: #6b7488; flex: none; }
.term__lvl  { flex: none; font-weight: 700; width: 4.75em; }
.term__lvl--INFO { color: #71b6f5; }
.term__lvl--WARNING { color: #e2ac54; }
.term__lvl--ERROR, .term__lvl--CRITICAL { color: #f4808f; }
.term__msg { color: var(--term-text); word-break: break-word; min-width: 0; }
.term__empty { color: #6b7488; font-style: italic; }

.output {
  background: var(--code-bg); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1rem;
  font-family: var(--font-mono); font-size: .78125rem; line-height: 1.65;
  white-space: pre-wrap; word-break: break-word;
  max-height: 560px; overflow: auto;
}

/* ------------------------------------------------------- 19. Meter / list */

.meter { height: 6px; border-radius: 999px; background: var(--surface-3); overflow: hidden; display: flex; }
.meter__seg { height: 100%; }
.meter__seg--active   { background: var(--success); }
.meter__seg--cooldown { background: var(--warning); }
.meter__seg--dead     { background: var(--neutral); }

.list { display: flex; flex-direction: column; }
.list__row {
  display: flex; align-items: center; gap: .75rem;
  padding: .6875rem 1.25rem; border-bottom: 1px solid var(--border);
  color: var(--text);
}
.list__row:last-child { border-bottom: 0; }
a.list__row:hover { background: var(--surface-2); text-decoration: none; }
.list__main { flex: 1; min-width: 0; }
.list__title { font-weight: 580; font-size: .84375rem; }
.list__sub { font-size: .75rem; color: var(--muted); }

.dl { display: grid; grid-template-columns: minmax(120px, auto) 1fr; gap: .5rem 1rem; font-size: .8125rem; }
.dl dt { color: var(--muted); }
.dl dd { margin: 0; font-weight: 560; word-break: break-word; }

/* ------------------------------------------------------------ 20. Skeleton */

.skeleton {
  background: linear-gradient(90deg, var(--surface-3) 25%, var(--surface-2) 37%, var(--surface-3) 63%);
  background-size: 400% 100%; border-radius: var(--radius-sm);
  animation: shimmer 1.3s ease-in-out infinite; height: 1em;
}
@keyframes shimmer { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }

/* ---------------------------------------------------------------- 21. Auth */

.auth {
  min-height: 100vh; display: grid; grid-template-columns: 1fr; place-items: center;
  padding: 1.5rem;
}
@media (min-width: 900px) { .auth { grid-template-columns: 1.05fr .95fr; } }

.auth__aside {
  display: none; align-self: stretch; border-radius: var(--radius-xl);
  padding: 3rem; color: #eef0ff;
  background:
    radial-gradient(700px 400px at 20% 10%, rgba(139,92,246,.55), transparent 60%),
    radial-gradient(600px 400px at 90% 90%, rgba(56,189,248,.35), transparent 60%),
    linear-gradient(160deg, #221f52 0%, #12142c 100%);
  flex-direction: column; justify-content: center; gap: 1.5rem;
}
@media (min-width: 900px) { .auth__aside { display: flex; } }
.auth__aside h2 { font-size: 1.75rem; color: #fff; letter-spacing: -.03em; }
.auth__aside p { color: #b9bede; max-width: 40ch; }
.auth__points { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: .875rem; }
.auth__points li { display: flex; gap: .625rem; align-items: flex-start; color: #cfd4ec; font-size: .875rem; }
.auth__points .icon { color: #9d8bff; flex: none; margin-top: .15rem; }

.auth__card {
  width: 100%; max-width: 400px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-xl); box-shadow: var(--shadow-lg);
  padding: 2rem;
}
.auth__brand { display: flex; align-items: center; gap: .625rem; margin-bottom: 1.5rem; }

/* ---------------------------------------------------------- 22. Misc bits */

.kv-inline { display: flex; flex-wrap: wrap; gap: .375rem .875rem; font-size: .78125rem; color: var(--muted); }
.kv-inline b { color: var(--text-soft); font-weight: 600; }

.copy-wrap { position: relative; }

.var-chip {
  display: inline-flex; align-items: center;
  padding: .0625rem .375rem; border-radius: 5px;
  background: var(--primary-soft); color: var(--primary);
  font-family: var(--font-mono); font-size: .6875rem; font-weight: 600;
}

.prompt-preview {
  background: var(--code-bg); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: .625rem .75rem;
  font-family: var(--font-mono); font-size: .71875rem; line-height: 1.6;
  color: var(--text-soft);
  max-height: 5.4em; overflow: hidden; position: relative;
}
.prompt-preview::after {
  content: ""; position: absolute; inset: auto 0 0 0; height: 2em;
  background: linear-gradient(transparent, var(--code-bg));
}

.chart-box { position: relative; height: 260px; }
.chart-box--sm { height: 190px; }

/* Shown instead of a Chart.js canvas when the CDN can't be reached. */
.fallback-chart { display: flex; flex-direction: column; gap: .625rem; padding: .5rem 0; }
.fallback-chart__row { display: grid; grid-template-columns: minmax(70px, 22%) 1fr auto; gap: .75rem; align-items: center; }
.fallback-chart__label { font-size: .78125rem; font-weight: 580; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fallback-chart__track { height: 9px; border-radius: 999px; background: var(--surface-3); overflow: hidden; }
.fallback-chart__bar { display: block; height: 100%; border-radius: 999px; background: linear-gradient(90deg, var(--primary), #8b5cf6); }
.fallback-chart__value { font-size: .75rem; color: var(--muted); font-variant-numeric: tabular-nums; }

@media print {
  .sidebar, .topbar__actions, .btn, .toasts { display: none !important; }
  .main { margin-left: 0; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
