/* ==========================================================================
   DT Nexus Cloud — design tokens + shared primitives
   Brand source: dt-nexus-app (assets/css/style.css, whats-new-modal.css):
   red #e41f28, near-black #070a13 / #0e0e0e, light #f4f5f7, Unbounded for
   display, Poppins for text, IBM Plex Mono for "// LABELS".
   Theme: <html data-theme="light|dark"> is resolved before paint by the inline
   script in each document head (system default, user override in storage).
   ========================================================================== */

:root {
  --font-display: "Unbounded", "Arial Black", system-ui, sans-serif;
  --font-body: "Poppins", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, monospace;

  /* brand */
  --brand: #e41f28;
  --brand-ink: #c3141c;
  --brand-tint: rgba(228, 31, 40, 0.09);
  --night: #070a13;          /* the app's brand rail — always dark */
  --night-2: #0f1320;
  --night-line: rgba(255, 255, 255, 0.09);
  --night-text: #eceef0;
  --night-muted: #969da6;

  /* surfaces (light) */
  --bg: #f4f5f7;
  --surface: #ffffff;
  --surface-2: #f4f5f7;
  --surface-3: #eceef3;
  --line: #dde1ec;
  --line-strong: #c9cfdd;
  --text: #0e0e0e;
  --text-2: #4f4c60;
  --text-3: #7d7a90;

  /* semantic */
  --win: #0f8a47;
  --win-strong: #12a150;
  --win-tint: rgba(18, 161, 80, 0.1);
  --loss: #d4202a;
  --loss-tint: rgba(228, 31, 40, 0.09);
  --real: #b45309;           /* real-money text on light */
  --real-fill: #f59e0b;      /* real-money chip */
  --real-ink: #1f1300;
  --real-tint: rgba(245, 158, 11, 0.12);
  --info: #2459c9;
  --info-tint: rgba(36, 89, 201, 0.09);
  --warn: #a15c00;
  --warn-tint: rgba(245, 158, 11, 0.13);

  --focus: 0 0 0 3px rgba(228, 31, 40, 0.35);
  --shadow-sm: 0 1px 2px rgba(14, 14, 14, 0.05);
  --shadow: 0 1px 2px rgba(14, 14, 14, 0.04), 0 8px 24px -12px rgba(14, 14, 14, 0.14);
  --shadow-lg: 0 24px 60px -20px rgba(7, 10, 19, 0.45);

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

  --ease: cubic-bezier(0.2, 0.7, 0.2, 1);
  color-scheme: light;
}

:root[data-theme="dark"] {
  --bg: #070a13;
  --surface: #0e121c;
  --surface-2: #141927;
  --surface-3: #1b2131;
  --line: #222a3b;
  --line-strong: #2f3850;
  --text: #eceef0;
  --text-2: #aab0bb;
  --text-3: #79808d;

  --brand-tint: rgba(228, 31, 40, 0.16);
  --win: #2bd97c;
  --win-strong: #20b866;
  --win-tint: rgba(43, 217, 124, 0.12);
  --loss: #ff5a60;
  --loss-tint: rgba(255, 90, 96, 0.13);
  --real: #fbbf24;
  --real-fill: #f59e0b;
  --real-tint: rgba(245, 158, 11, 0.14);
  --info: #7aa2ff;
  --info-tint: rgba(122, 162, 255, 0.13);
  --warn: #fbbf24;
  --warn-tint: rgba(251, 191, 36, 0.12);

  --focus: 0 0 0 3px rgba(255, 77, 85, 0.45);
  --shadow-sm: none;
  --shadow: 0 1px 0 rgba(255, 255, 255, 0.02);
  color-scheme: dark;
}

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

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
}

img, svg { display: block; max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: inherit; }
h1, h2, h3, h4 { margin: 0; line-height: 1.15; }
p { margin: 0; }

:focus { outline: none; }
:focus-visible { outline: none; box-shadow: var(--focus); border-radius: 6px; }

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

.num { font-variant-numeric: tabular-nums; font-feature-settings: "tnum" 1; }
.mono { font-family: var(--font-mono); }

/* "// LABEL" micro-label, the app's signature */
.eyebrow {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--text-3);
}
.eyebrow::before { content: "// "; color: var(--brand); }
.eyebrow.plain::before { content: none; }

/* wordmark: DT + NEXUS(red) */
.wordmark {
  font-family: var(--font-display);
  font-weight: 700;
  letter-spacing: 0.01em;
  line-height: 1;
  white-space: nowrap;
  color: var(--text);
}
.wordmark em { font-style: normal; color: var(--brand); }

/* ---------- buttons ---------- */
.btn {
  --bh: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: var(--bh);
  padding: 0 18px;
  border-radius: var(--r);
  border: 1px solid transparent;
  background: var(--surface-2);
  color: var(--text);
  font-weight: 600;
  font-size: 14.5px;
  line-height: 1;
  text-decoration: none;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s var(--ease), border-color 0.15s var(--ease), transform 0.08s var(--ease), opacity 0.15s;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}
.btn:hover { background: var(--surface-3); }
.btn:active { transform: translateY(1px); }
.btn[disabled], .btn.is-disabled { opacity: 0.45; pointer-events: none; }
.btn svg { width: 18px; height: 18px; flex: none; }

.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-ink); }
.btn-go { background: var(--win-strong); color: #fff; }
.btn-go:hover { background: #0f8a47; }
.btn-stop { background: var(--brand); color: #fff; }
.btn-stop:hover { background: var(--brand-ink); }
.btn-outline { background: transparent; border-color: var(--line-strong); }
.btn-outline:hover { background: var(--surface-2); }
.btn-ghost { background: transparent; }
.btn-ghost:hover { background: var(--surface-2); }
.btn-danger-ghost { background: transparent; color: var(--loss); }
.btn-danger-ghost:hover { background: var(--loss-tint); }
.btn-sm { --bh: 36px; padding: 0 13px; font-size: 13.5px; border-radius: 10px; }
.btn-lg { --bh: 52px; padding: 0 24px; font-size: 15.5px; }
.btn-block { width: 100%; }
.btn-icon { --bh: 40px; width: 40px; padding: 0; }

.btn.is-loading { position: relative; color: transparent !important; pointer-events: none; }
.btn.is-loading::after {
  content: "";
  position: absolute;
  width: 18px; height: 18px;
  border-radius: 50%;
  border: 2px solid currentColor;
  border-color: rgba(255, 255, 255, 0.9) rgba(255, 255, 255, 0.9) rgba(255, 255, 255, 0.9) transparent;
  animation: spin 0.7s linear infinite;
}
.btn:not(.btn-primary):not(.btn-go):not(.btn-stop).is-loading::after {
  border-color: var(--text-2) var(--text-2) var(--text-2) transparent;
}

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(18, 161, 80, 0.55); }
  70% { box-shadow: 0 0 0 7px rgba(18, 161, 80, 0); }
  100% { box-shadow: 0 0 0 0 rgba(18, 161, 80, 0); }
}
@keyframes shimmer { 100% { transform: translateX(100%); } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}
