/* ==========================================================================
   DT Nexus Cloud — design system
   Shared tokens + primitives for the landing page and the dashboard.
   ========================================================================== */

:root {
  /* surfaces */
  --bg:          #060911;
  --bg-elev:     #0b1120;
  --surface:     #0e1626;
  --surface-2:   #141f33;
  --surface-3:   #1b2942;
  --border:      rgba(148, 176, 224, 0.10);
  --border-2:    rgba(148, 176, 224, 0.18);

  /* text */
  --text:        #e9eefb;
  --text-2:      #b3c2dd;
  --dim:         #7d8fb0;
  --faint:       #55647e;

  /* brand */
  --accent:      #3b82f6;
  --accent-2:    #22d3ee;
  --accent-soft: rgba(59, 130, 246, 0.14);
  --grad:        linear-gradient(115deg, #3b82f6 0%, #22d3ee 100%);
  --grad-warm:   linear-gradient(115deg, #6366f1 0%, #3b82f6 55%, #22d3ee 100%);

  /* semantic */
  --green:       #22c55e;
  --green-soft:  rgba(34, 197, 94, 0.13);
  --red:         #f04747;
  --red-soft:    rgba(240, 71, 71, 0.13);
  --amber:       #f0a020;
  --amber-soft:  rgba(240, 160, 32, 0.13);

  /* geometry */
  --r-sm: 8px;
  --r:    12px;
  --r-lg: 18px;
  --r-xl: 26px;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .35);
  --shadow:    0 8px 30px rgba(0, 0, 0, .40);
  --shadow-lg: 0 24px 70px rgba(0, 0, 0, .55);

  --font: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, 'SF Mono', Menlo, monospace;

  --ease: cubic-bezier(.22, 1, .36, 1);

  color-scheme: dark;
}

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

html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  min-height: 100vh;
}

h1, h2, h3, h4 { line-height: 1.2; font-weight: 650; letter-spacing: -0.02em; }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: none; }
svg { display: block; }
img { max-width: 100%; display: block; }

::selection { background: rgba(59, 130, 246, .32); }

/* scrollbars */
* { scrollbar-width: thin; scrollbar-color: var(--surface-3) transparent; }
*::-webkit-scrollbar { width: 9px; height: 9px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb { background: var(--surface-3); border-radius: 99px; border: 2px solid transparent; background-clip: content-box; }
*::-webkit-scrollbar-thumb:hover { background: #2b3f63; background-clip: content-box; }

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

/* ---------- brand mark ---------- */
.logo { display: inline-flex; align-items: center; gap: 10px; font-weight: 700; letter-spacing: -0.02em; }
.logo-mark {
  width: 30px; height: 30px; border-radius: 9px;
  background: var(--grad);
  display: grid; place-items: center;
  box-shadow: 0 4px 18px rgba(59, 130, 246, .38);
  flex: none;
}
.logo-mark svg { width: 17px; height: 17px; }
.logo-text { font-size: 1.02rem; }
.logo-text b { font-weight: 700; }
.logo-text span {
  background: var(--grad); -webkit-background-clip: text; background-clip: text;
  color: transparent; font-weight: 700;
}

/* ---------- buttons ---------- */
.btn {
  --btn-bg: var(--surface-2);
  --btn-fg: var(--text);
  --btn-bd: var(--border-2);
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  background: var(--btn-bg); color: var(--btn-fg);
  border: 1px solid var(--btn-bd);
  border-radius: var(--r-sm);
  padding: 10px 18px;
  font-size: .9rem; font-weight: 550; letter-spacing: -0.01em;
  white-space: nowrap;
  transition: background .18s var(--ease), border-color .18s var(--ease),
              transform .18s var(--ease), box-shadow .18s var(--ease), opacity .18s;
}
.btn:hover:not(:disabled) { background: var(--surface-3); border-color: rgba(148,176,224,.30); transform: translateY(-1px); }
.btn:active:not(:disabled) { transform: translateY(0) scale(.985); }
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn:disabled { opacity: .45; cursor: not-allowed; }

.btn-primary {
  --btn-bg: var(--grad); --btn-fg: #04070e; --btn-bd: transparent;
  font-weight: 650;
  box-shadow: 0 6px 22px rgba(59, 130, 246, .30);
}
.btn-primary:hover:not(:disabled) {
  background: var(--grad); filter: brightness(1.08);
  box-shadow: 0 10px 30px rgba(59, 130, 246, .42);
}
.btn-ghost { --btn-bg: transparent; --btn-bd: transparent; color: var(--text-2); }
.btn-ghost:hover:not(:disabled) { background: var(--surface-2); color: var(--text); border-color: transparent; }
.btn-outline { --btn-bg: transparent; }
.btn-danger { color: #ff9d97; --btn-bd: rgba(240,71,71,.28); }
.btn-danger:hover:not(:disabled) { background: var(--red-soft); border-color: rgba(240,71,71,.55); }
.btn-success { --btn-bg: var(--green-soft); --btn-bd: rgba(34,197,94,.35); color: #7ee2a0; }
.btn-success:hover:not(:disabled) { background: rgba(34,197,94,.2); border-color: rgba(34,197,94,.6); }

.btn-sm { padding: 6px 12px; font-size: .82rem; border-radius: 7px; }
.btn-lg { padding: 14px 26px; font-size: .98rem; border-radius: 10px; }
.btn-block { width: 100%; }
.btn-icon { padding: 8px; width: 34px; height: 34px; }

/* spinner inside a button */
.btn.is-loading { position: relative; color: transparent !important; pointer-events: none; }
.btn.is-loading::after {
  content: ''; position: absolute; width: 15px; height: 15px;
  border: 2px solid rgba(255,255,255,.28); border-top-color: currentColor;
  border-radius: 50%; animation: spin .6s linear infinite;
  color: var(--text);
}
.btn-primary.is-loading::after { border-color: rgba(0,0,0,.25); border-top-color: #04070e; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- form fields ---------- */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 15px; }
.field > label, .field-label {
  font-size: .74rem; font-weight: 600; color: var(--dim);
  text-transform: uppercase; letter-spacing: .07em;
}
.input, .field input, .field select, .field textarea {
  width: 100%;
  background: var(--bg-elev);
  border: 1px solid var(--border-2);
  border-radius: var(--r-sm);
  padding: 10px 13px;
  font-size: .92rem;
  outline: none;
  transition: border-color .18s var(--ease), box-shadow .18s var(--ease), background .18s;
}
.input::placeholder, .field input::placeholder, .field textarea::placeholder { color: var(--faint); }
.input:focus, .field input:focus, .field select:focus, .field textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
  background: var(--surface);
}
.field input[type="number"] { font-variant-numeric: tabular-nums; }
.field select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath d='M2.5 4.5 6 8l3.5-3.5' stroke='%237d8fb0' stroke-width='1.5' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 11px center; background-size: 12px;
  padding-right: 32px; cursor: pointer;
}
.field textarea { font-family: var(--mono); font-size: .8rem; min-height: 110px; resize: vertical; line-height: 1.6; }
.field .hint { font-size: .76rem; color: var(--faint); line-height: 1.5; }
.field.invalid input, .field.invalid select, .field.invalid textarea { border-color: var(--red); }

.input-affix { position: relative; display: flex; align-items: center; }
.input-affix .affix {
  position: absolute; left: 12px; color: var(--faint); font-size: .88rem; pointer-events: none;
}
.input-affix input { padding-left: 27px; }
.input-affix .affix-btn {
  position: absolute; right: 6px; color: var(--faint); padding: 6px; border-radius: 6px;
  display: grid; place-items: center;
}
.input-affix .affix-btn:hover { color: var(--text); background: var(--surface-2); }
.input-affix .affix-btn svg { width: 16px; height: 16px; }

/* segmented control */
.segmented { display: inline-flex; background: var(--bg-elev); border: 1px solid var(--border-2); border-radius: var(--r-sm); padding: 3px; gap: 3px; }
.segmented button {
  padding: 7px 15px; border-radius: 6px; font-size: .84rem; font-weight: 550;
  color: var(--dim); transition: color .18s, background .18s;
}
.segmented button:hover { color: var(--text-2); }
.segmented button.active { background: var(--surface-3); color: var(--text); box-shadow: var(--shadow-sm); }

/* switch */
.switch { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; user-select: none; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch .track {
  width: 40px; height: 23px; border-radius: 99px; background: var(--surface-3);
  border: 1px solid var(--border-2); position: relative; transition: background .22s var(--ease);
  flex: none;
}
.switch .track::after {
  content: ''; position: absolute; top: 2px; left: 2px; width: 17px; height: 17px;
  background: var(--dim); border-radius: 50%; transition: transform .22s var(--ease), background .22s;
}
.switch input:checked + .track { background: var(--accent); border-color: var(--accent); }
.switch input:checked + .track::after { transform: translateX(17px); background: #fff; }
.switch input:focus-visible + .track { box-shadow: 0 0 0 3px var(--accent-soft); }
.switch .switch-label { font-size: .88rem; color: var(--text-2); }

/* ---------- badges / pills ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: .7rem; font-weight: 650; letter-spacing: .05em; text-transform: uppercase;
  padding: 3px 9px; border-radius: 99px;
  border: 1px solid var(--border-2); color: var(--dim); background: var(--surface-2);
}
.badge-accent { color: #8ec2ff; border-color: rgba(59,130,246,.35); background: var(--accent-soft); }
.badge-green  { color: #7ee2a0; border-color: rgba(34,197,94,.35);  background: var(--green-soft); }
.badge-red    { color: #ff9d97; border-color: rgba(240,71,71,.35);  background: var(--red-soft); }
.badge-amber  { color: #ffc76b; border-color: rgba(240,160,32,.35); background: var(--amber-soft); }

.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--faint); flex: none; }
.dot.live { background: var(--green); box-shadow: 0 0 0 0 rgba(34,197,94,.6); animation: pulse 2s infinite; }
.dot.warn { background: var(--amber); }
.dot.err  { background: var(--red); }
@keyframes pulse {
  0%   { box-shadow: 0 0 0 0 rgba(34,197,94,.55); }
  70%  { box-shadow: 0 0 0 7px rgba(34,197,94,0); }
  100% { box-shadow: 0 0 0 0 rgba(34,197,94,0); }
}

/* ---------- notices ---------- */
.notice {
  display: flex; gap: 11px; align-items: flex-start;
  border-radius: var(--r-sm); padding: 11px 14px;
  font-size: .86rem; line-height: 1.5;
  border: 1px solid var(--border-2); background: var(--surface-2); color: var(--text-2);
}
.notice svg { width: 16px; height: 16px; flex: none; margin-top: 2px; }
.notice-error { background: var(--red-soft); border-color: rgba(240,71,71,.4); color: #ffb4ae; }
.notice-info  { background: var(--accent-soft); border-color: rgba(59,130,246,.4); color: #a9ccff; }
.notice-warn  { background: var(--amber-soft); border-color: rgba(240,160,32,.4); color: #ffd699; }

/* ---------- numerics ---------- */
.num { font-variant-numeric: tabular-nums; font-feature-settings: 'tnum' 1; }
.pos { color: var(--green); }
.neg { color: var(--red); }
.mono { font-family: var(--mono); }
