/* ============================================================================
   File-Portal — light, high-end fintech theme
   Soft gray canvas · crisp white cards · near-black accents · subtle orange brand
   ========================================================================== */
:root {
  --bg: #eceef3;             /* page canvas (cool light gray)        */
  --bg-2: #f5f6f9;           /* recessed surfaces / inputs bg        */
  --panel: #ffffff;          /* elevated card surface                */
  --panel-2: #f1f2f6;        /* control / hover                      */
  --panel-3: #e7e9ef;        /* pressed / stronger control           */
  --line: rgba(17, 18, 24, .08);    /* hairline separators           */
  --line-2: rgba(17, 18, 24, .14);
  --text: #14151b;           /* near-black primary text              */
  --muted: #767884;          /* secondary text                       */
  --white: #ffffff;          /* foreground on dark accent surfaces   */

  /* Near-black is the primary accent (buttons, active nav) */
  --accent: #14151b;
  --accent-2: #26272f;
  --accent-soft: #33343d;
  --accent-tint: rgba(20, 21, 27, .05);   /* neutral hover wash      */
  --accent-ring: rgba(20, 21, 27, .12);

  /* Orange kept as a subtle brand highlight (logo, small accents) */
  --orange: #ff6a1a;
  --orange-2: #ff8a3d;
  --orange-deep: #e85c0c;
  --orange-glow: rgba(255, 106, 26, .28);
  --orange-tint: rgba(255, 106, 26, .1);

  --ok: #16a34a;             /* green   */
  --warn: #d99400;           /* amber   */
  --err: #e5484d;            /* red     */

  --radius-lg: 24px;
  --radius: 18px;
  --radius-sm: 13px;
  --r-ctl: 11px;             /* buttons / inputs   */
  --shadow-sm: 0 1px 2px rgba(17, 18, 24, .05), 0 1px 3px rgba(17, 18, 24, .04);
  --shadow: 0 10px 30px -12px rgba(17, 18, 24, .16), 0 2px 8px -4px rgba(17, 18, 24, .08);
  --shadow-lg: 0 28px 70px -20px rgba(17, 18, 24, .22), 0 8px 24px -12px rgba(17, 18, 24, .12);
  --shadow-accent: 0 10px 24px -10px rgba(20, 21, 27, .4);
  --glass: rgba(255, 255, 255, .72);
  --ease: cubic-bezier(.4, 0, .2, 1);
  --ease-out: cubic-bezier(.16, 1, .3, 1);

  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text", "Inter", "Segoe UI", system-ui, Roboto, Helvetica, Arial, sans-serif;
  color-scheme: light;
}
* { box-sizing: border-box; }
html { -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; text-rendering: optimizeLegibility; -webkit-text-size-adjust: 100%; }
body {
  margin: 0; color: var(--text); overflow-x: hidden; min-height: 100vh;
  letter-spacing: -.01em; line-height: 1.5;
  background:
    radial-gradient(1200px 700px at 84% -14%, rgba(255, 106, 26, .05), transparent 60%),
    radial-gradient(900px 700px at -12% 112%, rgba(20, 21, 27, .03), transparent 55%),
    var(--bg);
  background-attachment: fixed;
}
.hidden { display: none !important; }
.muted { color: var(--muted); font-size: .86rem; }
.error { color: var(--err); min-height: 1.2em; font-size: .85rem; }
a { color: var(--accent); text-decoration: none; cursor: pointer; font-weight: 560; transition: color .15s var(--ease), opacity .15s var(--ease); }
a:hover { opacity: .7; }
::selection { background: rgba(20, 21, 27, .12); color: var(--text); }

/* Thin, unobtrusive scrollbars */
::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-thumb { background: rgba(17, 18, 24, .16); border-radius: 20px; border: 2px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-thumb:hover { background: rgba(17, 18, 24, .28); background-clip: padding-box; }

/* ---- Buttons ------------------------------------------------------------ */
.btn {
  border: 1px solid var(--line); background: var(--panel); color: var(--text);
  padding: .62rem 1.05rem; border-radius: var(--r-ctl); cursor: pointer; font-size: .9rem;
  font-weight: 590; font-family: inherit; letter-spacing: -.01em; display: inline-flex; align-items: center; gap: .45rem;
  box-shadow: var(--shadow-sm);
  transition: transform .12s var(--ease-out), background .18s var(--ease), border-color .18s var(--ease), box-shadow .2s var(--ease), filter .18s var(--ease), opacity .18s var(--ease);
}
.btn:hover { background: var(--panel-2); border-color: var(--line-2); }
.btn:active { transform: scale(.97); }
.btn.primary {
  position: relative; background: linear-gradient(180deg, var(--accent-2), var(--accent));
  border: none; color: var(--white); font-weight: 620; box-shadow: var(--shadow-accent);
}
.btn.primary::after {
  content: ""; position: absolute; inset: 0; border-radius: inherit; pointer-events: none;
  background: linear-gradient(180deg, rgba(255, 255, 255, .16), transparent 42%); opacity: .8;
}
.btn.primary:hover { filter: brightness(1.15); box-shadow: 0 14px 30px -10px rgba(20, 21, 27, .5); }
.btn.ghost { background: transparent; border-color: transparent; box-shadow: none; }
.btn.ghost:hover { background: var(--panel-2); border-color: var(--line); }
.btn.small { padding: .38rem .7rem; font-size: .82rem; border-radius: 9px; }
.btn.danger { color: var(--err); background: rgba(229, 72, 77, .08); border-color: rgba(229, 72, 77, .24); box-shadow: none; }
.btn.danger:hover { background: rgba(229, 72, 77, .14); border-color: rgba(229, 72, 77, .4); }
.btn:disabled { opacity: .45; cursor: not-allowed; transform: none; filter: none; }

/* ---- Inputs ------------------------------------------------------------- */
label { display: flex; flex-direction: column; gap: .4rem; font-size: .8rem; color: var(--muted); font-weight: 500; }
input, select, textarea {
  background: var(--bg-2); border: 1px solid var(--line); color: var(--text);
  border-radius: var(--r-ctl); padding: .7rem .85rem; font-size: .92rem; font-family: inherit; letter-spacing: -.01em;
  max-width: 100%;
  transition: border-color .16s var(--ease), box-shadow .16s var(--ease), background .16s var(--ease);
}
input[type=file] { width: 100%; }
input::placeholder { color: #a0a1ab; }
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--accent); background: var(--panel);
  box-shadow: 0 0 0 3.5px var(--accent-ring);
}
input[type=file] { padding: .5rem; cursor: pointer; }
input[type=file]::file-selector-button {
  background: var(--panel); color: var(--text); border: 1px solid var(--line-2);
  border-radius: 9px; padding: .4rem .75rem; margin-right: .75rem; cursor: pointer; font-family: inherit; font-weight: 550;
  transition: .15s var(--ease);
}
input[type=file]::file-selector-button:hover { background: var(--panel-2); }

/* ---- Login -------------------------------------------------------------- */
.login-wrap {
  min-height: 100vh; display: grid; place-items: center; padding: 1rem;
  position: relative; overflow: hidden;
  background:
    radial-gradient(1100px 620px at 50% -24%, rgba(255, 106, 26, .1), transparent 60%),
    radial-gradient(760px 520px at 88% 118%, rgba(20, 21, 27, .05), transparent 55%),
    linear-gradient(180deg, #f7f8fb, var(--bg));
}
/* soft floating orbs behind the card */
.login-wrap::before, .login-wrap::after {
  content: ""; position: absolute; border-radius: 50%; pointer-events: none; z-index: 0;
  filter: blur(60px);
}
.login-wrap::before { width: 460px; height: 460px; top: -120px; left: -80px;
  background: radial-gradient(circle, rgba(255, 138, 61, .28), transparent 70%); animation: float1 18s var(--ease) infinite alternate; }
.login-wrap::after { width: 520px; height: 520px; bottom: -160px; right: -120px;
  background: radial-gradient(circle, rgba(20, 21, 27, .1), transparent 70%); animation: float2 22s var(--ease) infinite alternate; }
@keyframes float1 { to { transform: translate(40px, 30px) scale(1.1); } }
@keyframes float2 { to { transform: translate(-36px, -24px) scale(1.08); } }

.login-card {
  position: relative; z-index: 1; width: 400px; max-width: 100%; background: var(--glass);
  -webkit-backdrop-filter: blur(30px) saturate(1.6); backdrop-filter: blur(30px) saturate(1.6);
  border: 1px solid rgba(255, 255, 255, .8); border-radius: var(--radius-lg); padding: 2.7rem 2.4rem;
  box-shadow: var(--shadow-lg), inset 0 1px 0 rgba(255, 255, 255, .9);
  display: flex; flex-direction: column; gap: 1rem; animation: pop .6s var(--ease-out) both;
}
.login-card::before {
  content: ""; position: absolute; inset: 0; border-radius: inherit; padding: 1px; pointer-events: none;
  background: linear-gradient(180deg, rgba(255, 255, 255, .9), rgba(255, 255, 255, 0) 40%);
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor; mask-composite: exclude;
}
.brand { display: flex; align-items: center; gap: .6rem; }
.brand h1 { font-size: 1.5rem; margin: 0; letter-spacing: -.02em; font-weight: 800; }
.logo {
  display: grid; place-items: center; width: 40px; height: 40px; border-radius: 11px; flex: none;
  background: linear-gradient(135deg, var(--orange), var(--orange-deep));
  box-shadow: 0 8px 22px -8px var(--orange-glow); color: #fff; font-size: 1.25rem; font-weight: 800;
}
.brand-logo { height: 30px; width: auto; display: block;
  /* white source artwork → render as near-black silhouette on the light theme */
  filter: brightness(0) saturate(100%); opacity: .92; }
.login-logo { height: 60px; }
.login-card p.muted { letter-spacing: -.01em; }

/* ---- Segmented control (language switch) -------------------------------- */
.lang-switch { display: inline-flex; gap: 2px; background: var(--panel-2); border: 1px solid var(--line); border-radius: 999px; padding: 3px; }
.lang-switch button {
  border: none; background: transparent; color: var(--muted); font-family: inherit; font-weight: 600;
  font-size: .74rem; letter-spacing: .02em; padding: .32rem .66rem; border-radius: 999px; cursor: pointer;
  transition: color .18s var(--ease), background .18s var(--ease), box-shadow .18s var(--ease);
}
.lang-switch button:hover { color: var(--text); }
.lang-switch button.active { background: var(--panel); color: var(--text); box-shadow: var(--shadow-sm); }
.login-lang { position: absolute; top: 1.1rem; right: 1.1rem; z-index: 2; }

/* ---- App shell ---------------------------------------------------------- */
.app { display: grid; grid-template-columns: 266px 1fr; min-height: 100vh; }
.sidebar {
  background: rgba(255, 255, 255, .72);
  -webkit-backdrop-filter: blur(24px) saturate(1.5); backdrop-filter: blur(24px) saturate(1.5);
  border-right: 1px solid var(--line); display: flex; flex-direction: column; padding: 1.3rem 1.1rem; gap: 1.3rem;
  position: sticky; top: 0; height: 100vh;
}
.sidebar .brand { padding: .3rem .5rem; }
.sidebar-top { display: flex; align-items: center; justify-content: space-between; }
.nav-toggle { display: none; background: var(--panel); border: 1px solid var(--line); color: var(--text); width: 42px; height: 42px; border-radius: var(--r-ctl); cursor: pointer; align-items: center; justify-content: center; box-shadow: var(--shadow-sm); transition: background .15s var(--ease); }
.nav-toggle:hover { background: var(--panel-2); }
.nav-toggle svg { width: 22px; height: 22px; stroke: currentColor; }
.sidebar .brand strong { font-size: 1.1rem; letter-spacing: -.01em; }
#nav { display: flex; flex-direction: column; gap: .12rem; flex: 1; }
#nav a {
  position: relative; padding: .64rem .8rem; border-radius: var(--r-ctl); color: var(--muted);
  font-size: .92rem; font-weight: 550; letter-spacing: -.01em; display: flex; align-items: center; gap: .72rem;
  transition: color .18s var(--ease), background .18s var(--ease);
}
#nav a svg { width: 19px; height: 19px; flex: none; stroke: currentColor; opacity: .85; transition: transform .2s var(--ease-out); }
#nav a:hover { background: var(--accent-tint); color: var(--text); }
#nav a.active { background: var(--accent); color: var(--white); box-shadow: var(--shadow-accent); }
#nav a.active svg { color: var(--white); opacity: 1; }
.sidebar-foot { border-top: 1px solid var(--line); padding-top: 1rem; display: flex; flex-direction: column; gap: .7rem; }
#who { font-size: .8rem; }

.content { display: flex; flex-direction: column; min-width: 0; }
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: 1.1rem 1.8rem; border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 5; background: rgba(236, 238, 243, .72);
  -webkit-backdrop-filter: blur(24px) saturate(1.5); backdrop-filter: blur(24px) saturate(1.5);
}
.topbar h2 { margin: 0; font-size: 1.28rem; font-weight: 700; letter-spacing: -.025em; }
.view { padding: 1.8rem; max-width: 1180px; width: 100%; }
.view.anim { animation: viewIn .45s var(--ease-out) both; }

/* ---- Cards + grid ------------------------------------------------------- */
.grid { display: grid; gap: 1rem; }
.cards { grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); }
.card {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.4rem;
  box-shadow: var(--shadow-sm);
  transition: transform .22s var(--ease-out), border-color .18s var(--ease), box-shadow .22s var(--ease);
}
.card:hover { border-color: var(--line-2); }
.cards .card { position: relative; overflow: hidden; }
.cards .card:hover { transform: translateY(-3px); box-shadow: var(--shadow); border-color: var(--line-2); }
.stat { font-size: 2.3rem; font-weight: 750; letter-spacing: -.04em; line-height: 1.05; color: var(--text); }
.stat-label { color: var(--muted); font-size: .72rem; text-transform: uppercase; letter-spacing: .08em; font-weight: 600; margin-top: .3rem; }

/* ---- Tables ------------------------------------------------------------- */
table { width: 100%; border-collapse: collapse; font-size: .88rem; }
th, td { text-align: left; padding: .78rem .9rem; border-bottom: 1px solid var(--line); }
th { color: var(--muted); font-weight: 600; font-size: .7rem; text-transform: uppercase; letter-spacing: .06em; }
tbody tr { transition: background .12s var(--ease); }
tbody tr:hover { background: var(--accent-tint); }
tbody tr:last-child td { border-bottom: none; }
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-sm); }

/* ---- Dropzone ----------------------------------------------------------- */
.dropzone {
  border: 1.5px dashed var(--line-2); border-radius: var(--radius); padding: 3.2rem 2rem; text-align: center;
  color: var(--muted); cursor: pointer; background: var(--bg-2); font-weight: 500;
  transition: border-color .2s var(--ease), background .2s var(--ease), color .2s var(--ease), transform .12s var(--ease-out);
}
.dropzone:hover { border-color: var(--accent); color: var(--text); background: var(--panel-2); }
.dropzone.drag { border-color: var(--accent); background: var(--accent-tint); color: var(--text); transform: scale(1.005); }

/* ---- Badges ------------------------------------------------------------- */
.badge { display: inline-flex; align-items: center; gap: .3rem; padding: .22rem .62rem; border-radius: 999px; font-size: .72rem; font-weight: 600; letter-spacing: -.01em; border: 1px solid var(--line-2); background: var(--panel-2); }
.badge.ok { color: var(--ok); border-color: rgba(22, 163, 74, .3); background: rgba(22, 163, 74, .1); }
.badge.err { color: var(--err); border-color: rgba(229, 72, 77, .3); background: rgba(229, 72, 77, .1); }
.badge.warn { color: var(--warn); border-color: rgba(217, 148, 0, .32); background: rgba(217, 148, 0, .12); }
.badge.role { color: var(--orange-deep); border-color: rgba(255, 106, 26, .34); background: var(--orange-tint); }

/* ---- Similarity bar ----------------------------------------------------- */
.simbar { height: 7px; background: var(--panel-3); border-radius: 999px; overflow: hidden; min-width: 90px; }
.simbar > span { display: block; height: 100%; background: linear-gradient(90deg, var(--accent-soft), var(--accent)); border-radius: 999px; animation: grow .6s var(--ease-out) both; }

/* ---- Checks / stages / diff -------------------------------------------- */
.checklist { display: grid; gap: .45rem; }
.check {
  display: flex; align-items: center; gap: .6rem; padding: .6rem .85rem; background: var(--bg-2);
  border: 1px solid var(--line); border-radius: var(--radius-sm); font-size: .85rem;
  animation: slideIn .35s var(--ease-out) both;
}
.check .dot { width: 9px; height: 9px; border-radius: 50%; flex: none; }
.check.ok .dot { background: var(--ok); box-shadow: 0 0 8px rgba(22, 163, 74, .5); }
.check.bad .dot { background: var(--err); box-shadow: 0 0 8px rgba(229, 72, 77, .5); }
.diff {
  font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: .8rem; white-space: pre; overflow-x: auto;
  background: var(--bg-2); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: .9rem; max-height: 360px;
}
.diff > div { padding: 0 .3rem; border-radius: 3px; }
.diff .a { color: var(--ok); background: rgba(22, 163, 74, .1); }
.diff .d { color: var(--err); background: rgba(229, 72, 77, .1); }

/* ---- Datalog / log analysis --------------------------------------------- */
.log-grid { display: grid; grid-template-columns: 264px 1fr; gap: 1rem; align-items: start; }
.chan-panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: .6rem; max-height: 560px; overflow-y: auto; box-shadow: var(--shadow-sm); }
.chan {
  display: grid; grid-template-columns: 14px 1fr auto; gap: .5rem; align-items: center;
  padding: .48rem .55rem; border-radius: var(--radius-sm); cursor: pointer; border: 1px solid transparent;
  transition: background .12s var(--ease);
}
.chan:hover { background: var(--panel-2); }
.chan.on { background: var(--accent-tint); }
.chan .swatch { width: 12px; height: 12px; border-radius: 4px; border: 1px solid rgba(0,0,0,.15); }
.chan .cname { font-size: .82rem; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chan .cval { font-size: .72rem; color: var(--muted); font-family: ui-monospace, monospace; text-align: right; }
.chan.off .swatch { opacity: .25; }
.chan.off .cname { color: var(--muted); font-weight: 500; }
.chart-wrap { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: .7rem; position: relative; box-shadow: var(--shadow-sm); }
.chart-canvas { width: 100%; height: 380px; display: block; cursor: crosshair; touch-action: none; }
.chart-tip {
  position: absolute; pointer-events: none; background: rgba(255, 255, 255, .92); border: 1px solid var(--line-2);
  -webkit-backdrop-filter: blur(16px); backdrop-filter: blur(16px);
  border-radius: 12px; padding: .55rem .65rem; font-size: .74rem; z-index: 3; min-width: 124px;
  box-shadow: var(--shadow); display: none;
}
.chart-tip .trow { display: flex; align-items: center; gap: .4rem; white-space: nowrap; }
.chart-tip .tsw { width: 9px; height: 9px; border-radius: 3px; flex: none; }
.chart-tip .tval { margin-left: auto; font-family: ui-monospace, monospace; font-weight: 600; }
@media (max-width: 720px) { .log-grid { grid-template-columns: 1fr; } }

/* ---- Datalog insights (metric tiles) ------------------------------------ */
.metrics { display: flex; flex-wrap: wrap; gap: .6rem; }
.metric { display: flex; flex-direction: column; gap: .12rem; padding: .65rem .95rem; background: var(--bg-2); border: 1px solid var(--line); border-radius: var(--radius-sm); min-width: 100px; }
.metric .mval { font-size: 1.28rem; font-weight: 700; letter-spacing: -.02em; line-height: 1.1; }
.metric .mlabel { font-size: .7rem; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; font-weight: 600; }
.metric.warn { border-color: rgba(217, 148, 0, .42); background: rgba(217, 148, 0, .09); }
.metric.warn .mval { color: var(--warn); }

/* ---- Progress bar + success check --------------------------------------- */
.progress-track { height: 8px; background: var(--panel-3); border-radius: 999px; overflow: hidden; }
.progress-fill { height: 100%; width: 0; border-radius: 999px; background: linear-gradient(90deg, var(--accent-soft), var(--accent)); transition: width .2s var(--ease); }
.progress-fill.indet { width: 100%; animation: indet 1.1s var(--ease) infinite; }
@keyframes indet { 0% { opacity: .5; } 50% { opacity: 1; } 100% { opacity: .5; } }
.check-anim { display: inline-flex; width: 26px; height: 26px; flex: none; }
.check-anim svg { width: 26px; height: 26px; }
.check-anim circle { fill: none; stroke: var(--ok); stroke-width: 3; stroke-dasharray: 151; stroke-dashoffset: 151; animation: draw .5s var(--ease-out) forwards; }
.check-anim path { fill: none; stroke: var(--ok); stroke-width: 4.5; stroke-linecap: round; stroke-linejoin: round; stroke-dasharray: 42; stroke-dashoffset: 42; animation: draw .35s .32s var(--ease-out) forwards; }
@keyframes draw { to { stroke-dashoffset: 0; } }

/* ---- Toast -------------------------------------------------------------- */
.toast { padding: .58rem 1rem; border-radius: var(--r-ctl); font-size: .85rem; font-weight: 550; border: 1px solid var(--line-2); background: rgba(255, 255, 255, .92); -webkit-backdrop-filter: blur(16px); backdrop-filter: blur(16px); box-shadow: var(--shadow); animation: slideIn .3s var(--ease-out) both; }
.toast.ok { background: rgba(22, 163, 74, .12); color: var(--ok); border-color: rgba(22, 163, 74, .3); }
.toast.err { background: rgba(229, 72, 77, .12); color: var(--err); border-color: rgba(229, 72, 77, .3); }

/* ---- Layout helpers ----------------------------------------------------- */
.row { display: flex; gap: .7rem; flex-wrap: wrap; align-items: center; }
.row > * { flex: none; }
.spacer { flex: 1; }
h3 { margin: 0 0 .95rem; font-weight: 650; font-size: 1.08rem; letter-spacing: -.02em; }
.section { margin-bottom: 1.8rem; }
.mono { font-family: ui-monospace, monospace; font-size: .82rem; color: var(--muted); }

/* ---- WinOLS .OLS import ------------------------------------------------- */
.ols-import {
  background:
    radial-gradient(120% 140% at 0% 0%, var(--orange-tint), transparent 55%),
    var(--panel);
  border: 1px solid var(--line-2);
}
.ols-import h3 { color: var(--orange-deep); }
.ols-or {
  display: flex; align-items: center; gap: .8rem;
  margin: .9rem 0 -.2rem; font-size: .82rem; text-transform: none;
}
.ols-or::before, .ols-or::after { content: ""; flex: 1; height: 1px; background: var(--line); }

/* Inline notice (non-badge, wraps naturally) */
.notice { border-radius: var(--r-ctl); padding: .7rem .85rem; font-size: .9rem; border: 1px solid var(--line-2); background: var(--panel-2); }
.notice.warn { color: var(--warn); border-color: rgba(217, 148, 0, .32); background: rgba(217, 148, 0, .1); }
.notice.err { color: var(--err); border-color: rgba(229, 72, 77, .32); background: rgba(229, 72, 77, .1); }

/* ---- Loading spinner ---------------------------------------------------- */
.spinner { display: inline-block; width: 16px; height: 16px; border: 2px solid var(--line-2); border-top-color: var(--accent); border-radius: 50%; animation: spin .7s linear infinite; vertical-align: middle; }

/* ---- Animations --------------------------------------------------------- */
@keyframes viewIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes pop { from { opacity: 0; transform: scale(.97) translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes slideIn { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }
@keyframes grow { from { transform: scaleX(0); transform-origin: left; } to { transform: scaleX(1); } }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

/* ---- Responsive --------------------------------------------------------- */
@media (max-width: 820px) {
  .app { grid-template-columns: 1fr; }

  /* Sidebar becomes a sticky top app-bar with a collapsible menu (drawer). */
  .sidebar {
    position: sticky; top: 0; z-index: 20; height: auto; flex-direction: column; gap: 0;
    padding: .6rem .95rem; padding-top: calc(.6rem + env(safe-area-inset-top));
    border-right: none; border-bottom: 1px solid var(--line);
  }
  .nav-toggle { display: inline-flex; }
  .sidebar .brand { padding: 0; }
  .sidebar .brand-logo { height: 26px; }

  /* Collapsed by default; the menu expands only when .open is set. */
  #nav, .sidebar-foot { display: none; }
  .sidebar.open #nav { display: flex; flex-direction: column; gap: .12rem; margin-top: .85rem; }
  .sidebar.open .sidebar-foot { display: flex; margin-top: .85rem; padding-top: .85rem; }
  #nav a { padding: .85rem .9rem; font-size: 1rem; }
  .sidebar-foot { flex-direction: column; align-items: stretch; gap: .7rem; }
  .sidebar-foot .lang-switch { align-self: flex-start; }

  /* Content: tighter, non-sticky header, safe-area aware. */
  .topbar { position: static; padding: .9rem 1rem; }
  .topbar h2 { font-size: 1.14rem; }
  .view { padding: 1rem .9rem calc(1.6rem + env(safe-area-inset-bottom)); }
  .card { padding: 1.1rem; }
  .section { margin-bottom: 1.2rem; }
  h3 { font-size: 1.05rem; }

  /* Two/three-column form grids stack to one column. */
  .grid[style*="1fr 1fr"] { grid-template-columns: 1fr !important; }
  /* 16px inputs stop iOS Safari from auto-zooming when a field is focused. */
  input, select, textarea { font-size: 16px; }

  /* Wide tables stay readable and scroll horizontally instead of squishing. */
  table { font-size: .84rem; }
  th, td { white-space: nowrap; }

  .chart-canvas { height: 300px; }
  .chan-panel { max-height: 320px; }

  .login-card { padding: 1.9rem 1.5rem; }
  .login-lang { top: calc(.8rem + env(safe-area-inset-top)); right: .8rem; }
}

@media (max-width: 430px) {
  .btn { padding: .58rem .85rem; }
  .topbar h2 { font-size: 1.04rem; }
  .stat { font-size: 2rem; }
  .cards { grid-template-columns: 1fr 1fr; }
}

/* ============================================================================
   ECU / hex + calibration editor
   ========================================================================== */
.ed-drop { border: 1.5px dashed var(--line-2); border-radius: var(--radius); padding: 2.2rem; text-align: center; color: var(--muted); cursor: pointer; transition: .15s var(--ease); background: var(--bg-2); }
.ed-drop:hover, .ed-drop.over { border-color: var(--accent); color: var(--text); background: var(--panel-2); }
.ed-select { background: var(--panel); color: var(--text); border: 1px solid var(--line-2); border-radius: var(--r-ctl); padding: .5rem .6rem; font-size: .9rem; }
.ed-select.tiny { padding: .3rem .45rem; font-size: .82rem; }

.ed-root { display: flex; flex-direction: column; height: calc(100vh - 120px); min-height: 520px; }
.ed-toolbar { display: flex; align-items: center; gap: .4rem; padding: .3rem .2rem .6rem; flex-wrap: wrap; }
.ed-fname { font-weight: 600; font-size: .92rem; max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ed-tab.active { background: var(--accent); border-color: var(--accent); color: var(--white); }

.ed-grid { flex: 1; display: grid; grid-template-columns: 220px 1fr 260px; grid-template-rows: 1fr 150px;
  grid-template-areas: "left mid right" "left bottom right"; gap: 8px; min-height: 0; }
.ed-pane { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius-sm); overflow: hidden; display: flex; flex-direction: column; min-height: 0; box-shadow: var(--shadow-sm); }
.ed-left { grid-area: left; } .ed-mid { grid-area: mid; } .ed-right { grid-area: right; } .ed-bottom { grid-area: bottom; }
.ed-pane-title { font-size: .72rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); padding: .5rem .7rem; border-bottom: 1px solid var(--line); flex: none; }
.ed-tree, .ed-props, .ed-console, .ed-center { overflow: auto; padding: .6rem .7rem; flex: 1; min-height: 0; }
.ed-center { padding: 0; display: flex; flex-direction: column; }

/* left tree */
.tree-item { display: flex; justify-content: space-between; align-items: center; gap: .4rem; padding: .32rem .5rem; border-radius: 8px; cursor: default; font-size: .86rem; }
.tree-item.map span:first-child { cursor: pointer; }
.tree-item.active { background: var(--accent); color: var(--white); }
.tree-item.map:hover { background: var(--panel-2); }
.tree-del { cursor: pointer; color: var(--muted); font-size: .78rem; }
.tree-del:hover { color: var(--err); }
.tree-info { font-size: .74rem; color: var(--muted); padding: .1rem .5rem .5rem; }
.tree-sec { font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: .6rem 0 .2rem; padding: 0 .5rem; }
.tree-hint { font-size: .78rem; padding: 0 .5rem; }
.tree-acts { display: flex; gap: .3rem; margin-top: .7rem; padding: 0 .3rem; }

/* hex view */
.hex-wrap { display: flex; flex-direction: column; height: 100%; font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 12.5px; }
.hex-head { display: flex; align-items: center; gap: 0; padding: .45rem .6rem; border-bottom: 1px solid var(--line); color: var(--muted); font-size: 11px; background: var(--bg-2); }
.hex-scroll { flex: 1; overflow: auto; outline: none; padding: .2rem .6rem; }
.hex-scroll:focus { box-shadow: inset 0 0 0 1px var(--line-2); }
.hex-spacer { position: relative; }
.hex-rows { position: absolute; top: 0; left: 0; right: 0; }
.hex-row { display: flex; align-items: center; white-space: pre; }
.hex-addr { color: var(--muted); width: 78px; flex: none; -webkit-user-select: none; user-select: none; }
.hex-cols { display: inline-flex; }
.hex-col { width: 21px; text-align: center; }
.hex-col.grp, .hex-b.grp { margin-left: 5px; }
.hex-b { width: 21px; text-align: center; cursor: pointer; border-radius: 3px; }
.hex-b:hover { background: var(--panel-2); }
.hex-b.sel, .a.sel { background: rgba(20, 21, 27, .16); }
.hex-b.cur, .a.cur { background: var(--accent); color: var(--white); }
.hex-b.empty { color: transparent; }
.hex-ascii, .hex-ascii-h { margin-left: 12px; display: inline-flex; }
.hex-ascii-h { color: var(--muted); font-size: 11px; }
.a { width: 8px; text-align: center; cursor: pointer; }
.a.empty { color: transparent; }
.hex-grp { margin-left: auto; }

/* inspector / kv */
.ed-kv { width: 100%; border-collapse: collapse; }
.ed-kv td { padding: .22rem .35rem; border-bottom: 1px solid var(--line); font-size: .82rem; }
.ed-kv td:first-child { color: var(--muted); white-space: nowrap; }
.ed-insp strong { display: block; margin-bottom: .5rem; }
.ed-insp-sel { margin-top: .8rem; padding-top: .7rem; border-top: 1px solid var(--line); font-size: .82rem; }

/* console */
.log-line { font-size: .76rem; padding: .12rem 0; color: var(--muted); border-bottom: 1px solid rgba(17,18,24,.05); }

/* map editor */
.map-area, .mp { display: flex; flex-direction: column; height: 100%; min-height: 0; }
.mp-tb { display: flex; align-items: center; gap: .35rem; padding: .5rem .6rem; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.mp-name { font-weight: 600; font-size: .9rem; }
.mp-views { margin: .5rem .6rem 0; align-self: flex-start; }
.mp-body { flex: 1; overflow: auto; padding: .6rem; min-height: 0; }
.mp-scroll { overflow: auto; }
.mp-table { border-collapse: collapse; font-family: ui-monospace, monospace; font-size: 12px; }
.mp-table th { background: var(--bg-2); color: var(--muted); padding: .28rem .5rem; font-weight: 500; position: sticky; border: 1px solid var(--line); }
.mp-table th.corner { position: sticky; left: 0; z-index: 2; }
.mp-cell { padding: .28rem .5rem; text-align: right; border: 1px solid var(--line); cursor: cell; min-width: 44px; -webkit-user-select: none; user-select: none; }
.mp-cell:hover { outline: 1px solid var(--line-2); }
.mp-cell.sel { background: rgba(20, 21, 27, .16) !important; color: var(--text); }
.mp-table.heat .mp-cell { color: #0a0a0c; font-weight: 600; }
.mp-legend { display: flex; align-items: center; gap: .5rem; margin-top: .6rem; font-family: ui-monospace, monospace; font-size: 11px; color: var(--muted); }
.mp-legend .grad { flex: 1; max-width: 220px; height: 10px; border-radius: 5px; background: linear-gradient(90deg, hsl(220,70%,52%), hsl(140,60%,48%), hsl(60,70%,52%), hsl(0,70%,55%)); }
.mp-2d { height: 100%; min-height: 300px; }
.mp-canvas { width: 100%; height: 100%; min-height: 300px; }
.ed-empty { display: flex; flex-direction: column; gap: 1rem; align-items: center; justify-content: center; height: 100%; color: var(--muted); text-align: center; padding: 2rem; }

/* save menu */
.ed-menu-wrap { position: fixed; inset: 0; z-index: 60; }
.ed-menu { position: absolute; top: 96px; right: 28px; background: var(--panel); border: 1px solid var(--line-2); border-radius: var(--radius-sm); box-shadow: var(--shadow-lg); padding: .5rem; display: flex; flex-direction: column; gap: .35rem; min-width: 180px; }

@media (max-width: 900px) {
  .ed-grid { grid-template-columns: 1fr; grid-template-rows: auto auto 200px 140px;
    grid-template-areas: "left" "mid" "right" "bottom"; }
  .ed-root { height: auto; }
  .ed-mid { min-height: 420px; }
}

/* ---- editor: WinOLS-style tree folders + map polish -------------------- */
.tree-search { width: 100%; margin: .3rem 0 .5rem; padding: .4rem .55rem; font-size: .82rem; background: var(--bg-2); border: 1px solid var(--line); border-radius: 8px; }
.tree-folders { display: flex; flex-direction: column; }
.tree-folder { display: flex; align-items: center; gap: .4rem; padding: .34rem .4rem; border-radius: 7px; cursor: pointer; font-size: .84rem; font-weight: 560; -webkit-user-select: none; user-select: none; }
.tree-folder:hover { background: var(--panel-2); }
.tree-folder .caret { width: 12px; color: var(--muted); font-size: .7rem; }
.tree-folder .fname { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tree-folder .fcount { font-size: .72rem; color: var(--muted); background: var(--panel-2); border-radius: 20px; padding: 0 .45rem; }
.tree-item.map { padding-left: 1.3rem; font-size: .82rem; }
.tree-item.map .mn { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* stats bar */
.mp-bar { display: flex; align-items: center; gap: .8rem; padding: .45rem .6rem; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.mp-stats { display: flex; align-items: center; gap: .5rem; margin-left: auto; flex-wrap: wrap; }
.stat-chip { font-family: ui-monospace, monospace; font-size: .78rem; background: var(--bg-2); border: 1px solid var(--line); border-radius: 7px; padding: .18rem .5rem; }
.stat-chip em { color: var(--muted); font-style: normal; margin-right: .35rem; }
.mp-units { font-size: .78rem; color: var(--orange-deep); font-weight: 600; }
.mp-views { margin: 0; }

/* colored table cells keep readable text */
.mp-table:not(.heat) .mp-cell { color: var(--text); }
.mp-table .mp-cell { transition: background .1s; }
.mp-table th { z-index: 1; }
.mp-table th.corner { z-index: 3; background: var(--panel-3); }
.mp-canvas { cursor: grab; }
.mp-canvas:active { cursor: grabbing; }

/* ---- editor: maximize + map preview ----------------------------------- */
.ed-root.maxi { height: calc(100vh - 96px); }
.ed-grid.maxi { grid-template-columns: 1fr; grid-template-rows: 1fr; grid-template-areas: "mid"; }
.ed-grid.maxi .ed-left, .ed-grid.maxi .ed-right, .ed-grid.maxi .ed-bottom { display: none; }
.tree-item.map.preview { background: var(--accent-tint); outline: 1px solid var(--line-2); }
.tree-item.map.preview .mn::after { content: " ⇢"; color: var(--accent); }

/* ---- editor: map overlay in hex + change highlighting ----------------- */
.hex-b.inmap { background: rgba(90, 130, 255, .14); }
.hex-b.inmap:hover { background: rgba(90, 130, 255, .26); }
.hex-b.m-start { box-shadow: inset 2px 0 0 rgba(70, 110, 235, .9); }
.hex-b.m-end { box-shadow: inset -2px 0 0 rgba(70, 110, 235, .9); }
.hex-b.m-start.m-end { box-shadow: inset 2px 0 0 rgba(70,110,235,.9), inset -2px 0 0 rgba(70,110,235,.9); }
.hex-b.chg { color: var(--err); font-weight: 700; }
.hex-b.chg.inmap { background: rgba(229, 72, 77, .18); }
.a.chg { color: var(--err); font-weight: 700; }
/* selection + cursor keep priority over the overlays */
.hex-b.sel { background: rgba(20, 21, 27, .16); }
.hex-b.cur { background: var(--accent) !important; color: var(--white) !important; }

.mp-cell.chg { box-shadow: inset 0 0 0 2px var(--err); font-weight: 700; }
.mp-table.heat .mp-cell.chg { box-shadow: inset 0 0 0 2px #fff; }

.chg-badge { font-family: ui-monospace, monospace; font-size: .74rem; color: var(--err); background: rgba(229,72,77,.1); border: 1px solid rgba(229,72,77,.28); border-radius: 20px; padding: .12rem .5rem; align-self: center; }

/* ---- coming soon ------------------------------------------------------- */
.nav-soon { margin-left: auto; font-size: .6rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em;
  color: var(--orange-deep); background: var(--orange-tint); border: 1px solid rgba(255,138,61,.3); border-radius: 20px; padding: .1rem .4rem; }
#nav a.active .nav-soon { color: var(--white); background: rgba(255,255,255,.18); border-color: transparent; }
.coming-soon { display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; gap: .8rem; padding: 4rem 1.5rem; min-height: 50vh; }
.coming-soon h2 { font-size: 1.8rem; letter-spacing: -.02em; margin: 0; }
.coming-soon p { max-width: 420px; }
.cs-badge { font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: var(--orange-deep);
  background: var(--orange-tint); border: 1px solid rgba(255,138,61,.3); border-radius: 20px; padding: .3rem .85rem; }

/* ---- bulk OLS import queue -------------------------------------------- */
.ols-queue { margin-top: .3rem; }
.ols-queue:empty { display: none; }
.ols-q-head { display: flex; flex-direction: column; gap: .5rem; margin: .6rem 0; }
.ols-counts { display: flex; flex-wrap: wrap; gap: .5rem; font-size: .82rem; }
.ols-counts .oc { background: var(--panel-2); border: 1px solid var(--line); border-radius: 7px; padding: .12rem .5rem; }
.ols-counts .oc.ok { color: var(--ok); } .ols-counts .oc.warn { color: var(--warn); } .ols-counts .oc.err { color: var(--err); }
.ols-issues { display: flex; flex-direction: column; gap: 2px; max-height: 240px; overflow: auto; margin-top: .3rem; }
.ols-issue { display: flex; gap: .6rem; font-size: .8rem; padding: .3rem .5rem; border-radius: 7px; background: var(--bg-2); }
.ols-issue.warn { border-left: 2px solid var(--warn); } .ols-issue.err { border-left: 2px solid var(--err); }
.ols-issue-name { font-family: ui-monospace, monospace; color: var(--muted); flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ols-issue-msg { color: var(--text); }

/* ============================================================================
   Platform modernization pass — depth, motion, refined accents
   ========================================================================== */
/* Cards: crisp white surface, hover lift, and a cursor-following spotlight
   (JS sets --mx/--my; off-screen by default). */
.card {
  position: relative;
  background:
    radial-gradient(280px 280px at var(--mx, -200px) var(--my, -200px), rgba(20,21,27,.035), transparent 60%),
    var(--panel);
  transition: transform .25s var(--ease-out), border-color .25s var(--ease), box-shadow .25s var(--ease);
}
.card::before {
  content: ""; position: absolute; inset: 0 0 auto 0; height: 1px; border-radius: inherit;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,.8), transparent);
}
.card:hover { border-color: var(--line-2); box-shadow: var(--shadow); }

/* Dashboard stat tiles: bigger numerals, faint accent corner glow on hover */
.cards .card { overflow: hidden; }
.cards .card::after {
  content: ""; position: absolute; right: -30px; top: -30px; width: 90px; height: 90px; border-radius: 50%;
  background: radial-gradient(circle, var(--orange-glow), transparent 70%); opacity: .28; transition: opacity .25s var(--ease);
}
.cards .card:hover { transform: translateY(-3px); }
.cards .card:hover::after { opacity: .55; }
.stat {
  font-size: 2.5rem; font-weight: 750; letter-spacing: -.03em; line-height: 1; color: var(--text);
}
.stat-label { color: var(--muted); font-size: .82rem; font-weight: 550; margin-top: .45rem; }

/* Nav: rounded items, solid black active pill */
#nav a { position: relative; border-radius: 12px; transition: background .16s var(--ease), color .16s var(--ease); }
#nav a:hover { background: var(--accent-tint); }
#nav a.active {
  background: var(--accent); color: var(--white); box-shadow: var(--shadow-accent);
}
#nav a svg { transition: transform .16s var(--ease-out); }
#nav a:hover svg { transform: scale(1.08); }

/* Section headings with a small accent tick */
.view h3 { position: relative; }

/* Tables: subtle row hover, cleaner header */
table tbody tr, .card tr { transition: background .12s var(--ease); }
.card table td { border-color: var(--line); }

/* Buttons: crisper press + focus ring */
.btn:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--accent-ring); }

/* Topbar title: heavier, tighter */
.topbar h2 { font-weight: 700; letter-spacing: -.025em; }

/* Subtle entrance for view content */
.view.anim { animation: viewIn .32s var(--ease-out) both; }

/* Sidebar: faint gradient + stronger separation */
.sidebar { background: linear-gradient(180deg, rgba(255,255,255,.82), rgba(245,246,249,.72)); }

/* ---- working file / patch stack --------------------------------------- */
.work-panel { position: sticky; top: 8px; z-index: 5; }
.patch-stack { display: flex; flex-direction: column; gap: 4px; }
.patch-stack-row { display: flex; align-items: center; gap: .6rem; padding: .4rem .6rem; background: var(--bg-2); border-radius: 8px; font-size: .84rem; }
.ps-idx { width: 20px; height: 20px; flex: none; display: grid; place-items: center; border-radius: 50%; background: var(--accent); color: var(--white); font-size: .72rem; font-weight: 700; }
.ps-label { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---- readable native <select> dropdowns ------------------------------- */
select { color-scheme: light; }
select option, select optgroup {
  background-color: #ffffff; color: var(--text);
  padding: .4rem .6rem;
}
select option:checked, select option:hover { background-color: var(--panel-3); color: var(--text); }

/* ---- OLS inspect preview ---------------------------------------------- */
.ols-inspect:empty { display: none; }
.ols-inspect-card { margin: .3rem 0 .6rem; border-color: var(--line-2); }
.ols-img-list { display: flex; flex-direction: column; gap: 4px; }
.ols-img-row { display: flex; align-items: center; gap: .6rem; padding: .4rem .6rem; background: var(--bg-2); border-radius: 8px; }
.ols-img-name { flex: 1; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ============================================================================
   "Living" motion layer — aurora, spotlight, stagger, micro-interactions
   ========================================================================== */

/* Slow-drifting aurora behind everything (soft, light) */
body::before {
  content: ""; position: fixed; inset: -25%; z-index: -1; pointer-events: none;
  background:
    radial-gradient(38% 38% at 22% 28%, rgba(255,106,26,.06), transparent 60%),
    radial-gradient(32% 32% at 82% 18%, rgba(255,138,61,.05), transparent 60%),
    radial-gradient(42% 42% at 62% 88%, rgba(20,21,27,.03), transparent 60%);
  filter: blur(40px); opacity: .9;
  animation: aurora 26s var(--ease) infinite alternate;
}
@keyframes aurora {
  0%   { transform: translate(0,0) scale(1)    rotate(0deg); }
  50%  { transform: translate(3%,-2.5%) scale(1.08) rotate(3deg); }
  100% { transform: translate(-2.5%,2%) scale(1.05) rotate(-2deg); }
}

/* Staggered entrance for the first children of a freshly navigated view */
.view.anim > * { animation: riseIn .5s var(--ease-out) both; }
.view.anim > *:nth-child(1){animation-delay:.02s}
.view.anim > *:nth-child(2){animation-delay:.07s}
.view.anim > *:nth-child(3){animation-delay:.12s}
.view.anim > *:nth-child(4){animation-delay:.17s}
.view.anim > *:nth-child(5){animation-delay:.22s}
.view.anim > *:nth-child(6){animation-delay:.27s}
.cards .card { animation: riseIn .55s var(--ease-out) both; }
.cards .card:nth-child(1){animation-delay:.05s}
.cards .card:nth-child(2){animation-delay:.12s}
.cards .card:nth-child(3){animation-delay:.19s}
.cards .card:nth-child(4){animation-delay:.26s}
@keyframes riseIn { from { opacity: 0; transform: translateY(14px) scale(.99); } to { opacity: 1; transform: none; } }

/* Buttons: press feel, primary sheen sweep on hover, click ripple */
.btn { position: relative; overflow: hidden; }
.btn:active { transform: scale(.96); }
.btn.primary::before {
  content: ""; position: absolute; inset: 0; border-radius: inherit; pointer-events: none;
  background: linear-gradient(115deg, transparent 20%, rgba(255,255,255,.22) 45%, transparent 60%);
  transform: translateX(-120%); transition: transform .6s var(--ease-out);
}
.btn.primary:hover::before { transform: translateX(120%); }
.ripple { position: absolute; border-radius: 50%; pointer-events: none; transform: translate(-50%,-50%) scale(0);
  background: rgba(255,255,255,.35); animation: ripple .55s var(--ease-out) forwards; }
@keyframes ripple { to { transform: translate(-50%,-50%) scale(1); opacity: 0; } }

/* Nav: active pill pops in; icon spring on hover */
#nav a.active { animation: pillPop .35s var(--ease-out) both; }
@keyframes pillPop { from { transform: scale(.97); } to { transform: scale(1); } }
#nav a:active svg { transform: scale(.9); }
#nav a { transition: background .16s var(--ease), color .16s var(--ease), transform .12s var(--ease-out); }
#nav a:active { transform: scale(.98); }

/* Count-up stats sit crisp; a subtle live pulse on the accent glow */
.cards .card::after { animation: glowPulse 4s var(--ease) infinite; }
@keyframes glowPulse { 0%,100% { opacity: .24; } 50% { opacity: .5; } }

/* Badges & chips: gentle pop when they appear */
.badge, .chg-badge, .stat-chip { animation: pop .3s var(--ease-out) both; }

/* Toast: slide up + fade */
.toast:not(.hidden) { animation: toastIn .35s var(--ease-out) both; }
@keyframes toastIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

/* Nicer dual-ring spinner */
.spinner { border-top-color: var(--accent); border-right-color: var(--accent-soft); }

/* Links get an animated underline */
.view a:not(.btn):not([data-view]) { background-image: linear-gradient(var(--accent),var(--accent)); background-size: 0% 1px; background-position: 0 100%; background-repeat: no-repeat; transition: background-size .25s var(--ease-out); }
.view a:not(.btn):not([data-view]):hover { background-size: 100% 1px; opacity: 1; }

/* Interactive rows lift slightly */
tr:hover .btn.small { transform: none; }

/* Honor reduced-motion: kill the ambient/looping stuff, keep instant states */
@media (prefers-reduced-motion: reduce) {
  body::before { animation: none; }
  .cards .card::after { animation: none; }
  .login-wrap::before, .login-wrap::after { animation: none; }
  .view.anim > *, .cards .card, .badge, .chg-badge, .stat-chip { animation: none !important; }
  .card { transition: none; }
}
