/* ===========================================================================
   OptiDrive by KAN — Design System
   Brand ramp: BASE #00293b · LOGO #00426b · ELEVATE #0065ad · LIGHT #009adf
               LIGHTEST #00c9d4 · ACTION #e70000
   =========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Archivo:wght@500;600;700;800&family=Hanken+Grotesk:wght@400;500;600;700&family=IBM+Plex+Mono:wght@400;500;600&display=swap');

:root {
  /* brand */
  --brand-base: #00293b;
  --brand-logo: #00426b;
  --brand-elevate: #0065ad;
  --brand-light: #009adf;
  --brand-lightest: #00c9d4;
  --action: #e70000;
  --action-deep: #c10000;

  /* semantic */
  --pass: #0f9d6b;
  --pass-soft: #e3f6ee;
  --warn: #c77d12;
  --warn-soft: #fbf0db;
  --fail: #e70000;
  --fail-soft: #fde7e7;

  /* fonts */
  --font-display: 'Archivo', system-ui, sans-serif;
  --font-body: 'Hanken Grotesk', system-ui, sans-serif;
  --font-mono: 'IBM Plex Mono', ui-monospace, monospace;

  /* radii */
  --r-1: 8px;
  --r-2: 12px;
  --r-3: 16px;
  --r-4: 22px;
  --r-pill: 999px;

  /* density (overridden by tweak) */
  --pad: 1;
}

/* ---------- LIGHT (default) ---------- */
:root, [data-theme="light"] {
  color-scheme: light;
  --bg: #eef3f6;
  --bg-grad-1: #e9f0f4;
  --bg-grad-2: #eef3f6;
  --surface: #ffffff;
  --surface-2: #f5f9fb;
  --surface-3: #eef4f8;
  --border: #dde7ed;
  --border-strong: #c6d5de;
  --text: #062231;
  --text-2: #4a5d68;
  --text-3: #82949f;
  --primary: var(--brand-elevate);
  --primary-hover: #00558f;
  --primary-soft: #e7f1f9;
  --on-primary: #ffffff;
  --ring: rgba(0,154,223,.30);
  --shadow-sm: 0 1px 2px rgba(0,41,59,.06), 0 1px 3px rgba(0,41,59,.05);
  --shadow-md: 0 4px 14px rgba(0,41,59,.08), 0 2px 6px rgba(0,41,59,.05);
  --shadow-lg: 0 18px 50px rgba(0,41,59,.14), 0 6px 18px rgba(0,41,59,.08);
  --brand-panel: linear-gradient(155deg, #00293b 0%, #00426b 48%, #0065ad 100%);
  --track: #e4ebf0;
}

/* ---------- DARK ---------- */
[data-theme="dark"] {
  color-scheme: dark;
  --bg: #021a26;
  --bg-grad-1: #021c29;
  --bg-grad-2: #01141d;
  --surface: #052c3f;
  --surface-2: #073449;
  --surface-3: #0a3d54;
  --border: rgba(255,255,255,.10);
  --border-strong: rgba(255,255,255,.18);
  --text: #e9f2f7;
  --text-2: #a7bcc8;
  --text-3: #6f8794;
  --primary: var(--brand-light);
  --primary-hover: #2bb0ec;
  --primary-soft: rgba(0,154,223,.16);
  --on-primary: #00161f;
  --ring: rgba(0,201,212,.40);
  --shadow-sm: 0 1px 2px rgba(0,0,0,.35);
  --shadow-md: 0 6px 18px rgba(0,0,0,.40);
  --shadow-lg: 0 24px 60px rgba(0,0,0,.55);
  --brand-panel: linear-gradient(155deg, #00121a 0%, #00324f 55%, #0065ad 120%);
  --track: rgba(255,255,255,.10);
  --pass-soft: rgba(15,157,107,.16);
  --warn-soft: rgba(199,125,18,.18);
  --fail-soft: rgba(231,0,0,.16);
  --primary-soft: rgba(0,154,223,.14);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }

body {
  font-family: var(--font-body);
  background:
    radial-gradient(1200px 700px at 100% -10%, color-mix(in oklab, var(--brand-light) 7%, transparent), transparent 60%),
    linear-gradient(180deg, var(--bg-grad-1), var(--bg-grad-2));
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  min-height: 100vh;
}

#root { min-height: 100vh; }

/* ---------- typography ---------- */
h1,h2,h3,h4 { font-family: var(--font-display); margin: 0; letter-spacing: -.02em; color: var(--text); line-height: 1.08; }
p { margin: 0; }
.mono { font-family: var(--font-mono); }
.eyebrow {
  font-family: var(--font-mono);
  font-size: 11px; font-weight: 500; letter-spacing: .16em; text-transform: uppercase;
  color: var(--text-3);
}
.text-2 { color: var(--text-2); }
.text-3 { color: var(--text-3); }

/* ---------- focus ---------- */
:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--ring); border-radius: var(--r-1); }

/* ---------- buttons ---------- */
.btn {
  font-family: var(--font-body); font-weight: 600; font-size: 14px;
  display: inline-flex; align-items: center; justify-content: center; gap: 9px;
  padding: 0 18px; height: 44px; border-radius: var(--r-2);
  border: 1px solid transparent; cursor: pointer; white-space: nowrap;
  transition: transform .12s ease, background .15s ease, box-shadow .15s ease, border-color .15s ease, color .15s ease;
  text-decoration: none; user-select: none;
}
.btn:active { transform: translateY(1px); }
.btn svg { width: 17px; height: 17px; }

.btn-primary { background: var(--primary); color: var(--on-primary); box-shadow: var(--shadow-sm); }
.btn-primary:hover { background: var(--primary-hover); box-shadow: var(--shadow-md); }

.btn-action { background: var(--action); color: #fff; box-shadow: 0 6px 18px rgba(231,0,0,.22); }
.btn-action:hover { background: var(--action-deep); }

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

.btn-soft { background: var(--primary-soft); color: var(--primary); }
.btn-soft:hover { background: color-mix(in oklab, var(--primary-soft) 70%, var(--primary) 12%); }

.btn-subtle { background: var(--surface-2); color: var(--text-2); }
.btn-subtle:hover { background: var(--surface-3); color: var(--text); }

.btn-lg { height: 52px; font-size: 15px; padding: 0 24px; border-radius: var(--r-2); }
.btn-sm { height: 36px; font-size: 13px; padding: 0 13px; border-radius: var(--r-1); gap: 6px; }
.btn-block { width: 100%; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-icon { width: 44px; padding: 0; }
.btn-icon.btn-sm { width: 36px; }

/* ---------- surfaces ---------- */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-3); box-shadow: var(--shadow-sm);
}
.card-pad { padding: calc(26px * var(--pad)); }

/* ---------- inputs ---------- */
.field { display: flex; flex-direction: column; gap: 7px; }
.label { font-size: 13px; font-weight: 600; color: var(--text-2); }
.input, .textarea, .select {
  font-family: var(--font-body); font-size: 15px; color: var(--text);
  appearance: none; -webkit-appearance: none;
  background-color: var(--surface); border: 1.5px solid var(--border-strong);
  border-radius: var(--r-2); padding: 0 14px; height: 48px; width: 100%;
  transition: border-color .15s ease, box-shadow .15s ease, background .15s ease;
}
.select {
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 24 24' fill='none' stroke='%2382949f' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'><path d='M6 9l6 6 6-6'/></svg>");
  background-repeat: no-repeat; background-position: right 12px center; padding-right: 40px; cursor: pointer;
}
.textarea { height: auto; padding: 13px 14px; resize: vertical; min-height: 96px; line-height: 1.5; }
.input::placeholder, .textarea::placeholder { color: var(--text-3); }
.input:focus, .textarea:focus, .select:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--ring); }
.input-affix { position: relative; display: flex; align-items: center; }
.input-affix .input { padding-right: 46px; }
.input-affix .affix-btn {
  position: absolute; right: 6px; height: 36px; width: 36px; border: none; background: transparent;
  color: var(--text-3); cursor: pointer; display: grid; place-items: center; border-radius: var(--r-1);
}
.input-affix .affix-btn:hover { background: var(--surface-2); color: var(--text); }
.input-error { border-color: var(--fail) !important; }
.hint { font-size: 12.5px; color: var(--text-3); }
.hint-error { font-size: 12.5px; color: var(--fail); font-weight: 500; }

/* ---------- badges ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 6px;
  font-family: var(--font-mono); font-size: 11px; font-weight: 500; letter-spacing: .04em;
  text-transform: uppercase; padding: 5px 10px; border-radius: var(--r-pill);
  border: 1px solid transparent; white-space: nowrap;
}
.badge .dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.badge-neutral { background: var(--surface-3); color: var(--text-2); border-color: var(--border); }
.badge-info { background: var(--primary-soft); color: var(--primary); }
.badge-pass { background: var(--pass-soft); color: var(--pass); }
.badge-warn { background: var(--warn-soft); color: var(--warn); }
.badge-fail { background: var(--fail-soft); color: var(--fail); }

/* ---------- progress ---------- */
.track { height: 8px; border-radius: var(--r-pill); background: var(--track); overflow: hidden; }
.track > i { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--brand-elevate), var(--brand-lightest)); transition: width .6s cubic-bezier(.2,.7,.2,1); }

/* ---------- misc ---------- */
.divider { height: 1px; background: var(--border); border: none; margin: 0; }
.kbd { font-family: var(--font-mono); font-size: 12px; background: var(--surface-2); border: 1px solid var(--border); border-bottom-width: 2px; border-radius: 6px; padding: 2px 7px; color: var(--text-2); }
.link { color: var(--primary); font-weight: 600; text-decoration: none; cursor: pointer; }
.link:hover { text-decoration: underline; }
.scrim { position: fixed; inset: 0; background: rgba(0,20,30,.46); backdrop-filter: blur(3px); z-index: 60; display: grid; place-items: center; padding: 20px; }

/* avatar */
.avatar { border-radius: 50%; display: grid; place-items: center; font-family: var(--font-display); font-weight: 700; color: #fff; background: linear-gradient(150deg, var(--brand-elevate), var(--brand-lightest)); flex: none; }

/* animations */
@keyframes fadeUp { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes pop { 0% { transform: scale(.9); opacity: 0; } 100% { transform: scale(1); opacity: 1; } }
@keyframes dashdraw { to { stroke-dashoffset: 0; } }
@keyframes spin { to { transform: rotate(360deg); } }
/* Content is visible at rest. We deliberately avoid opacity:0 entrance animations
   because the preview can freeze the timeline at the hidden 0% frame. */
.animate-up, .animate-in { opacity: 1; }
.spinner { width: 18px; height: 18px; border-radius: 50%; border: 2.5px solid currentColor; border-right-color: transparent; animation: spin .7s linear infinite; display: inline-block; }

/* scrollbars */
*::-webkit-scrollbar { width: 11px; height: 11px; }
*::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 9px; border: 3px solid transparent; background-clip: padding-box; }
*::-webkit-scrollbar-thumb:hover { background: var(--text-3); background-clip: padding-box; border: 3px solid transparent; }

/* utility layout */
.row { display: flex; align-items: center; }
.col { display: flex; flex-direction: column; }
.gap-2 { gap: 8px; } .gap-3 { gap: 12px; } .gap-4 { gap: 16px; } .gap-5 { gap: 20px; } .gap-6 { gap: 24px; }
.grow { flex: 1; }
.wrap { flex-wrap: wrap; }
