@import url('https://fonts.googleapis.com/css2?family=Inter+Tight:wght@500;600;700&display=swap');

/* ==========================================================================
   RUX Console — tokens + primitives  (v5)

   Deep graphite planes lit by a single ember accent. Structure comes from
   hairlines and one surface step, never from stacked shadows. A fixed ember
   bloom sits behind the page so dark chrome still reads as warm metal rather
   than a flat void. The accent marks active state, primary action and focus —
   nowhere else.

   Legacy token names (--purple-*, --bg-900, --radius-*) stay aliased so the
   landing and auth sheets keep resolving against this palette.
   ========================================================================== */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  /* ---- surfaces — six steps, warm graphite ---- */
  --bg-0: #070709;
  --bg-1: #0b0b0f;
  --bg-2: #101015;
  --bg-3: #16161c;
  --bg-4: #1e1e25;
  --bg-5: #272730;

  /* legacy ramp names */
  --bg-900: var(--bg-0);
  --bg-800: var(--bg-1);
  --bg-700: var(--bg-2);
  --bg-600: var(--bg-3);
  --bg-500: var(--bg-4);

  /* ---- hairlines ---- */
  --line-1: rgba(255, 255, 255, 0.052);
  --line-2: rgba(255, 255, 255, 0.095);
  --line-3: rgba(255, 255, 255, 0.175);
  --border: var(--line-1);
  --border-hover: var(--line-3);

  /* top highlight on raised planes — 1px light catching the edge */
  --edge: rgba(255, 255, 255, 0.055);

  /* ---- ink ---- */
  --ink-1: #f2f2f6;
  --ink-2: #a2a2ae;
  --ink-3: #6e6e7b;
  --ink-4: #4a4a55;
  --text-primary: var(--ink-1);
  --text-secondary: var(--ink-2);
  --text-muted: var(--ink-3);

  /* ---- signal accent — ember ---- */
  --brand: #ff6a1a;
  --brand-2: #ff8f4d;
  --brand-3: #ffbb8a;
  --brand-deep: #e85806;
  --brand-veil: rgba(255, 106, 26, 0.10);
  --brand-line: rgba(255, 106, 26, 0.30);
  --brand-glow: rgba(255, 106, 26, 0.17);
  --brand-ink: #1a0800;

  /* legacy purple names resolve to the accent */
  --purple-500: var(--brand);
  --purple-400: var(--brand-2);
  --purple-300: var(--brand-3);
  --purple-600: var(--brand-deep);

  --blue-400: #6fa6ff;
  --blue-500: #3d7dff;
  --green-400: #45d98d;
  --green-500: #22b96b;
  --red-400: #ff6b63;
  --red-500: #ee4b41;
  --yellow-400: #ffc247;
  --indigo-400: #a3b0ff;

  --ok-veil: rgba(69, 217, 141, 0.11);
  --warn-veil: rgba(255, 194, 71, 0.11);
  --err-veil: rgba(255, 107, 99, 0.11);
  --info-veil: rgba(111, 166, 255, 0.11);

  /* ---- radii ---- */
  --r-sm: 7px;
  --r-md: 10px;
  --r-lg: 14px;
  --r-xl: 18px;
  --radius-sm: var(--r-sm);
  --radius-md: var(--r-md);
  --radius-lg: var(--r-lg);
  --radius-xl: var(--r-xl);

  --ease: cubic-bezier(0.22, 0.72, 0.28, 1);

  /* ---- shadows — flat by default; only floating layers lift ---- */
  --sh-1: 0 1px 2px rgba(0, 0, 0, 0.5);
  --sh-2: 0 14px 32px -18px rgba(0, 0, 0, 0.85);
  --sh-3: 0 38px 80px -34px rgba(0, 0, 0, 0.92);
  --shadow-sm: var(--sh-1);
  --shadow-md: var(--sh-2);
  --shadow-lg: var(--sh-3);
  --shadow-purple: var(--sh-2);

  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-display: 'Inter Tight', 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;

  --z-nav: 100;
  --z-pop: 400;
  --z-drawer: 800;
  --z-modal: 1000;
  --z-toast: 1200;
}

html { font-size: 15px; scroll-behavior: smooth; }

body {
  font-family: var(--font-sans);
  color: var(--ink-1);
  line-height: 1.6;
  font-size: 0.9rem;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  min-height: 100vh;
  background-color: var(--bg-0);
  background-image:
    radial-gradient(1080px 540px at 20% -14%, rgba(255, 106, 26, 0.055), transparent 62%),
    radial-gradient(760px 420px at 94% 2%, rgba(111, 166, 255, 0.026), transparent 60%);
  background-attachment: fixed;
}

a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }
button { font: inherit; color: inherit; cursor: pointer; border: none; background: none; }
input, select, textarea { font: inherit; color: inherit; }

h1, h2, h3, h4 {
  font-family: var(--font-display);
  font-weight: 600;
  line-height: 1.2;
  letter-spacing: -0.024em;
}

::selection { background: rgba(255, 106, 26, 0.3); }

:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
  border-radius: 6px;
}

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.085);
  border: 3px solid transparent;
  background-clip: content-box;
  border-radius: 9px;
}
::-webkit-scrollbar-thumb:hover { background: rgba(255, 255, 255, 0.16); background-clip: content-box; }

/* ===== TEXT HELPERS ===== */
.gradient-text { color: var(--brand-2); }.text-green { color: var(--green-400); }
.text-red { color: var(--red-400); }
.text-muted { color: var(--ink-3); }.mono { font-family: var(--font-mono); font-size: 0.88em; letter-spacing: -0.01em; }
.num { font-variant-numeric: tabular-nums; font-feature-settings: 'tnum' 1; }

/* ===== BUTTONS ===== */
.btn,
.btn-primary,
.btn-ghost,
.btn-danger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 8px 15px;
  border-radius: var(--r-md);
  font-size: 0.865rem;
  font-weight: 550;
  letter-spacing: -0.006em;
  white-space: nowrap;
  border: 1px solid transparent;
  transition: background 0.12s var(--ease), border-color 0.12s var(--ease),
              color 0.12s var(--ease), transform 0.08s var(--ease);
}
.btn[disabled], .btn-primary[disabled], .btn-ghost[disabled] { opacity: 0.4; pointer-events: none; }

.btn-primary {
  background: var(--brand);
  color: var(--brand-ink);
  font-weight: 600;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.22), 0 6px 18px -10px rgba(255, 106, 26, 0.7);
}
.btn-primary:hover { background: var(--brand-2); }
.btn-primary:active { background: var(--brand-deep); transform: translateY(1px); }

.btn-ghost {
  background: var(--bg-3);
  border-color: var(--line-2);
  color: var(--ink-1);
  box-shadow: inset 0 1px 0 var(--edge);
}
.btn-ghost:hover { background: var(--bg-4); border-color: var(--line-3); }

.btn-danger {
  background: var(--err-veil);
  border-color: rgba(255, 107, 99, 0.26);
  color: var(--red-400);
}
.btn-danger:hover { background: rgba(255, 107, 99, 0.17); border-color: rgba(255, 107, 99, 0.42); }.btn-lg { padding: 11px 20px; font-size: 0.92rem; }
.btn-sm { padding: 5px 11px; font-size: 0.8rem; border-radius: var(--r-sm); }
.btn-full { width: 100%; }

/* ===== TAGS ===== */
.tag {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 8px;
  border-radius: 6px;
  font-size: 0.735rem;
  font-weight: 550;
  letter-spacing: 0.002em;
  border: 1px solid transparent;
  white-space: nowrap;
}
.tag-green { background: var(--ok-veil); color: var(--green-400); }
.tag-red { background: var(--err-veil); color: var(--red-400); }
.tag-yellow { background: var(--warn-veil); color: var(--yellow-400); }
.tag-blue { background: var(--info-veil); color: var(--blue-400); }
.tag-accent, .tag-purple { background: var(--brand-veil); color: var(--brand-3); }
.tag-grey { background: rgba(255, 255, 255, 0.055); color: var(--ink-2); }

.status-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
}
.status-dot.green { background: var(--green-400); box-shadow: 0 0 0 3px rgba(69, 217, 141, 0.14); }
.status-dot.red { background: var(--red-400); box-shadow: 0 0 0 3px rgba(255, 107, 99, 0.14); }
.status-dot.yellow { background: var(--yellow-400); box-shadow: 0 0 0 3px rgba(255, 194, 71, 0.14); }
.status-dot.grey { background: var(--ink-3); }

/* ===== FORM CONTROLS ===== */
.form-group { margin-bottom: 16px; }
.form-group > label,
.form-label {
  display: block;
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--ink-2);
  margin-bottom: 7px;
  letter-spacing: -0.005em;
}
.form-group input,
.form-group select,
.form-group textarea,
.input {
  width: 100%;
  padding: 9px 12px;
  background: var(--bg-1);
  border: 1px solid var(--line-2);
  border-radius: var(--r-md);
  color: var(--ink-1);
  font-size: 0.885rem;
  transition: border-color 0.12s var(--ease), box-shadow 0.12s var(--ease), background 0.12s var(--ease);
}
.form-group textarea { resize: vertical; min-height: 96px; line-height: 1.65; }
.form-group input:hover, .form-group select:hover, .form-group textarea:hover { border-color: var(--line-3); }
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus,
.input:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-glow);
}
.form-group input::placeholder, .form-group textarea::placeholder { color: var(--ink-3); }
.form-group select { appearance: none; padding-right: 32px; cursor: pointer;
  background-image: linear-gradient(45deg, transparent 50%, var(--ink-3) 50%),
                    linear-gradient(135deg, var(--ink-3) 50%, transparent 50%);
  background-position: calc(100% - 16px) 54%, calc(100% - 11px) 54%;
  background-size: 4px 4px, 4px 4px;
  background-repeat: no-repeat;
}

.form-hint { font-size: 0.775rem; color: var(--ink-3); margin-top: 6px; line-height: 1.55; }
.form-error { font-size: 0.81rem; color: var(--red-400); min-height: 18px; margin-bottom: 12px; }
.form-label-row { display: flex; align-items: center; justify-content: space-between; margin-bottom: 7px; }
.form-label-row label { margin-bottom: 0; }
.form-check { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.form-check input[type=checkbox] { width: 15px; height: 15px; accent-color: var(--brand); }
.form-check label { font-size: 0.865rem; color: var(--ink-2); cursor: pointer; }

.input-password-wrap { position: relative; }
.input-password-wrap input { padding-right: 40px; }
.toggle-pw {
  position: absolute; right: 9px; top: 50%;
  transform: translateY(-50%);
  color: var(--ink-3);
  padding: 4px;
  border-radius: var(--r-sm);
  transition: color 0.12s var(--ease);
}
.toggle-pw:hover { color: var(--ink-1); }

/* ===== SWITCH ===== */
.toggle-switch { position: relative; display: inline-block; width: 38px; height: 22px; flex-shrink: 0; }
.toggle-switch input { opacity: 0; width: 0; height: 0; position: absolute; }
.toggle-slider {
  position: absolute; inset: 0;
  background: var(--bg-4);
  border: 1px solid var(--line-2);
  border-radius: 999px;
  transition: background 0.15s var(--ease), border-color 0.15s var(--ease);
  cursor: pointer;
}
.toggle-slider::before {
  content: '';
  position: absolute;
  width: 15px; height: 15px;
  left: 2px; top: 2px;
  background: var(--ink-2);
  border-radius: 50%;
  transition: transform 0.15s var(--ease), background 0.15s var(--ease);
}
.toggle-switch input:checked + .toggle-slider { background: var(--brand); border-color: var(--brand); }
.toggle-switch input:checked + .toggle-slider::before { transform: translateX(16px); background: var(--brand-ink); }
.toggle-switch input:focus-visible + .toggle-slider { box-shadow: 0 0 0 3px var(--brand-glow); }

/* ===== MODAL ===== */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(3, 3, 5, 0.72);
  backdrop-filter: blur(3px);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 24px;
  z-index: var(--z-modal);
}
.modal-overlay.open { display: flex; animation: fadeIn 0.13s var(--ease); }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.modal-card {
  background: var(--bg-2);
  border: 1px solid var(--line-2);
  border-radius: var(--r-xl);
  width: min(540px, 100%);
  max-height: min(86vh, 900px);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: var(--sh-3), 0 0 0 1px rgba(0, 0, 0, 0.4);
  animation: modalIn 0.15s var(--ease);
}
@keyframes modalIn {
  from { opacity: 0; transform: translateY(7px); }
  to { opacity: 1; transform: none; }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 15px 20px;
  border-bottom: 1px solid var(--line-1);
}
.modal-header h3 { font-size: 0.95rem; font-weight: 600; }
.modal-close {
  width: 28px; height: 28px;
  display: flex; align-items: center; justify-content: center;
  border-radius: var(--r-sm);
  color: var(--ink-3);
  font-size: 0.8rem;
  transition: background 0.12s var(--ease), color 0.12s var(--ease);
}
.modal-close:hover { background: var(--err-veil); color: var(--red-400); }
.modal-body { padding: 20px; overflow-y: auto; }
.modal-foot {
  display: flex; align-items: center; justify-content: flex-end; gap: 10px;
  padding: 14px 20px;
  border-top: 1px solid var(--line-1);
  background: var(--bg-1);
}

/* ===== TOAST ===== */
#toastContainer {
  position: fixed;
  bottom: 20px; right: 20px;
  z-index: var(--z-toast);
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: flex-end;
  pointer-events: none;
}
.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 16px;
  background: var(--bg-3);
  border: 1px solid var(--line-2);
  border-radius: var(--r-md);
  font-size: 0.865rem;
  color: var(--ink-1);
  box-shadow: var(--sh-2), inset 0 1px 0 var(--edge);
  animation: toastIn 0.17s var(--ease);
  min-width: 200px;
  max-width: 380px;
}
.toast::before {
  content: '';
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--ink-3);
  flex-shrink: 0;
}
.toast.success::before { background: var(--green-400); }
.toast.error::before { background: var(--red-400); }
.toast.info::before { background: var(--brand-2); }
@keyframes toastIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}

/* ===== PAGINATION ===== */.page-btn {
  min-width: 30px; height: 30px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: var(--r-sm);
  font-size: 0.82rem;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  color: var(--ink-2);
  border: 1px solid transparent;
  transition: background 0.12s var(--ease), color 0.12s var(--ease);
  padding: 0 9px;
}
.page-btn:hover:not([disabled]) { background: var(--bg-3); color: var(--ink-1); }
.page-btn.active { background: var(--brand-veil); color: var(--brand-3); font-weight: 600; border-color: var(--brand-line); }
.page-btn[disabled] { opacity: 0.3; pointer-events: none; }

/* ===== TOOLBAR BUTTON ===== *//* ===== TOOLTIP (data-tip) ===== */
[data-tip] { position: relative; }
[data-tip]::after {
  content: attr(data-tip);
  position: absolute;
  bottom: calc(100% + 7px);
  left: 50%;
  transform: translateX(-50%) translateY(2px);
  padding: 4px 9px;
  background: var(--bg-5);
  border: 1px solid var(--line-2);
  border-radius: 6px;
  font-size: 0.745rem;
  font-weight: 500;
  color: var(--ink-1);
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.11s var(--ease), transform 0.11s var(--ease);
  z-index: var(--z-pop);
  box-shadow: var(--sh-2);
}
[data-tip]:hover::after { opacity: 1; transform: translateX(-50%); }

/* ===== LOGO ===== */
.logo-icon { font-size: 1.2rem; color: var(--brand-2); }
