/* ============================== 3D BUTTONS ============================== */
.btn {
  --edge: 5px;
  position: relative; display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  min-height: 50px; padding: 0 22px; border: 0; border-radius: var(--r-md);
  font-weight: 750; font-stretch: 108%; letter-spacing: .01em; font-size: var(--fs-md);
  transform: translateY(0); user-select: none; -webkit-tap-highlight-color: transparent;
  transition: transform var(--t-fast) var(--ease-out), box-shadow var(--t-fast) var(--ease-out), filter var(--t-med), opacity var(--t-med);
  isolation: isolate; white-space: nowrap;
}
.btn i { font-size: 1.25em; }
.btn::after { /* glossy top highlight */
  content: ""; position: absolute; inset: 1px 1px 50% 1px; border-radius: calc(var(--r-md) - 1px) calc(var(--r-md) - 1px) 40% 40% / calc(var(--r-md) - 1px) calc(var(--r-md) - 1px) 12px 12px;
  background: linear-gradient(180deg, rgba(255, 255, 255, .28), rgba(255, 255, 255, 0)); pointer-events: none; z-index: -1;
}
.btn-primary {
  color: var(--on-ember);
  background: linear-gradient(180deg, var(--ember-1) 0%, var(--ember-2) 55%, var(--ember-3) 100%);
  box-shadow: 0 var(--edge) 0 var(--ember-edge), 0 calc(var(--edge) + 10px) 24px -6px rgba(255, 91, 36, .55), inset 0 1px 0 rgba(255, 255, 255, .45);
}
.btn-secondary {
  color: var(--btn-2-ink); background: var(--btn-2);
  box-shadow: 0 var(--edge) 0 var(--btn-2-edge), 0 calc(var(--edge) + 8px) 20px -10px rgba(0, 0, 0, .45), inset 0 1px 0 var(--highlight), inset 0 0 0 1px var(--line);
}
.btn-ghost { background: transparent; color: var(--ink); box-shadow: none; min-height: 44px; padding: 0 14px; }
.btn-ghost::after { display: none; }
.btn-ghost:hover { background: var(--surface-hover); }
.btn-danger {
  color: #fff; background: linear-gradient(180deg, #FF6B86, #E5314F);
  box-shadow: 0 var(--edge) 0 #8E1027, 0 calc(var(--edge) + 10px) 22px -8px rgba(229, 49, 79, .55), inset 0 1px 0 rgba(255, 255, 255, .35);
}
.btn:hover:not(:disabled) { filter: brightness(1.06) saturate(1.05); transform: translateY(-1px); }
.btn-primary:hover:not(:disabled) { box-shadow: 0 calc(var(--edge) + 1px) 0 var(--ember-edge), 0 calc(var(--edge) + 16px) 32px -6px rgba(255, 91, 36, .6), inset 0 1px 0 rgba(255, 255, 255, .45); }
.btn:active:not(:disabled) { transform: translateY(calc(var(--edge) - 1px)); }
.btn-primary:active:not(:disabled) { box-shadow: 0 1px 0 var(--ember-edge), 0 4px 12px -4px rgba(255, 91, 36, .5), inset 0 1px 0 rgba(255, 255, 255, .35); }
.btn-secondary:active:not(:disabled) { box-shadow: 0 1px 0 var(--btn-2-edge), inset 0 1px 0 var(--highlight), inset 0 0 0 1px var(--line); }
.btn-danger:active:not(:disabled) { box-shadow: 0 1px 0 #8E1027; }
.btn:disabled { opacity: .45; cursor: not-allowed; filter: grayscale(.4); }
.btn-block { width: 100%; }
.btn-lg { min-height: 60px; font-size: var(--fs-lg); padding: 0 28px; border-radius: 18px; --edge: 6px; }
.btn-sm { min-height: 38px; padding: 0 14px; font-size: var(--fs-sm); --edge: 3px; border-radius: 11px; }
.btn .spinner { width: 18px; height: 18px; border: 2.5px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .7s linear infinite; }

.icon-btn {
  width: 44px; height: 44px; display: inline-grid; place-items: center; border-radius: 14px; border: 0;
  background: var(--surface-2); color: var(--ink); box-shadow: inset 0 0 0 1px var(--line), inset 0 1px 0 var(--highlight);
  transition: transform var(--t-fast) var(--ease-out), background var(--t-med);
}
.icon-btn:hover { background: var(--surface-hover); }
.icon-btn:active { transform: scale(.94); }
.icon-btn i { font-size: 1.3rem; }

/* ================================ CARDS ================================ */
.card {
  position: relative; border-radius: var(--r-lg); padding: var(--s5);
  background: linear-gradient(180deg, var(--surface) 0%, var(--surface-2) 100%);
  box-shadow: var(--shadow-md), inset 0 0 0 1px var(--line), inset 0 1px 0 var(--highlight);
}
.card-lg { padding: var(--s6); border-radius: var(--r-xl); }
.card-flat { background: var(--surface-2); box-shadow: inset 0 0 0 1px var(--line); }
.card-link { transition: transform var(--t-med) var(--ease-out), box-shadow var(--t-med) var(--ease-out); cursor: pointer; }
.card-link:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg), inset 0 0 0 1px var(--line-strong), inset 0 1px 0 var(--highlight); }
.card-link:active { transform: translateY(-1px) scale(.995); }
.tilt { transform-style: preserve-3d; transition: transform var(--t-slow) var(--ease-out); will-change: transform; }
.tilt .tilt-glare {
  position: absolute; inset: 0; border-radius: inherit; pointer-events: none; opacity: 0; transition: opacity var(--t-med);
  background: radial-gradient(600px circle at var(--gx, 50%) var(--gy, 50%), rgba(255, 255, 255, .14), transparent 45%);
}
.tilt:hover .tilt-glare { opacity: 1; }

/* Hero card: ember gradient with depth */
.hero-card {
  position: relative; overflow: hidden; border-radius: var(--r-xl); padding: var(--s6); color: #fff;
  background:
    radial-gradient(120% 140% at 100% 0%, rgba(255, 176, 77, .55), transparent 55%),
    radial-gradient(90% 120% at 0% 100%, rgba(120, 20, 0, .55), transparent 60%),
    linear-gradient(135deg, #FF6A2B 0%, #E63F0C 55%, #A92A05 100%);
  box-shadow: 0 30px 70px -24px rgba(230, 63, 12, .65), inset 0 1px 0 rgba(255, 255, 255, .35), inset 0 0 0 1px rgba(255, 255, 255, .08);
}
.hero-card::before { /* speed lines */
  content: ""; position: absolute; inset: 0; opacity: .18; pointer-events: none;
  background: repeating-linear-gradient(115deg, transparent 0 22px, rgba(255, 255, 255, .5) 22px 23px);
  mask-image: linear-gradient(90deg, transparent, #000 60%);
}
.hero-card .eyebrow { color: rgba(255, 255, 255, .85); }
.hero-card .muted { color: rgba(255, 255, 255, .82); }

/* ================================ FORMS ================================ */
.field { display: grid; gap: 6px; }
.field-label { font-size: var(--fs-sm); font-weight: 650; color: var(--ink-2); }
.input, .textarea, .select {
  width: 100%; min-height: 52px; padding: 14px 16px; border-radius: var(--r-md); border: 0;
  background: var(--surface-2); color: var(--ink);
  box-shadow: inset 0 0 0 1px var(--line-strong), inset 0 2px 4px rgba(0, 0, 0, .12);
  transition: box-shadow var(--t-med) var(--ease-out), background var(--t-med);
}
.textarea { min-height: 110px; resize: vertical; line-height: 1.5; }
.input::placeholder, .textarea::placeholder { color: var(--ink-3); }
.input:focus, .textarea:focus, .select:focus { outline: none; background: var(--surface); box-shadow: inset 0 0 0 1.5px var(--accent), 0 0 0 5px var(--accent-soft); }
.field-hint { font-size: var(--fs-xs); color: var(--ink-3); }
.check { display: flex; gap: 12px; align-items: flex-start; cursor: pointer; font-size: var(--fs-sm); color: var(--ink-2); }
.check input { appearance: none; flex: none; width: 22px; height: 22px; margin: 1px 0 0; border-radius: 7px; background: var(--surface-2); box-shadow: inset 0 0 0 1.5px var(--line-strong); display: grid; place-items: center; transition: background var(--t-fast); }
.check input:checked { background: var(--accent); box-shadow: none; }
.check input:checked::after { content: ""; width: 10px; height: 6px; border-left: 2.5px solid var(--on-ember); border-bottom: 2.5px solid var(--on-ember); transform: translateY(-1px) rotate(-45deg); }

/* Segmented control with sliding thumb */
.seg { position: relative; display: inline-grid; grid-auto-flow: column; grid-auto-columns: 1fr; padding: 4px; border-radius: 14px; background: var(--surface-3); box-shadow: inset 0 0 0 1px var(--line), inset 0 2px 5px rgba(0, 0, 0, .15); }
.seg button { position: relative; z-index: 1; border: 0; background: none; padding: 9px 14px; border-radius: 10px; font-weight: 650; font-size: var(--fs-sm); color: var(--ink-2); transition: color var(--t-med); white-space: nowrap; }
.seg button[aria-pressed="true"] { color: var(--ink); }
.seg-thumb { position: absolute; top: 4px; bottom: 4px; border-radius: 10px; background: var(--surface); box-shadow: var(--shadow-sm), inset 0 0 0 1px var(--line), inset 0 1px 0 var(--highlight); transition: left var(--t-med) var(--ease-spring), width var(--t-med) var(--ease-spring); }

/* Switch */
.switch { position: relative; width: 52px; height: 30px; flex: none; border-radius: 99px; border: 0; background: var(--surface-3); box-shadow: inset 0 0 0 1px var(--line-strong), inset 0 2px 5px rgba(0, 0, 0, .2); transition: background var(--t-med); }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%; background: linear-gradient(180deg, #fff, #E9E6E1); box-shadow: 0 2px 6px rgba(0, 0, 0, .35); transition: transform var(--t-med) var(--ease-spring); }
.switch[aria-checked="true"] { background: var(--success); }
.switch[aria-checked="true"]::after { transform: translateX(22px); }

/* ============================ SMALL PIECES ============================ */
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 5px 11px; border-radius: var(--r-pill); font-size: var(--fs-xs); font-weight: 700; letter-spacing: .02em; background: var(--surface-3); color: var(--ink-2); white-space: nowrap; }
.pill i { font-size: 1.1em; }
.pill-accent { background: var(--accent-soft); color: var(--accent-ink); }
.pill-success { background: var(--success-soft); color: var(--success); }
.pill-warning { background: var(--warning-soft); color: var(--warning); }
.pill-info { background: var(--info-soft); color: var(--info); }
.pill-danger { background: var(--danger-soft); color: var(--danger); }

.avatar { flex: none; display: grid; place-items: center; border-radius: 50%; font-weight: 800; color: #fff; font-stretch: 110%; box-shadow: inset 0 1px 0 rgba(255, 255, 255, .35), 0 4px 12px -4px rgba(0, 0, 0, .5); }

.ring { position: relative; display: grid; place-items: center; }
.ring svg { transform: rotate(-90deg); }
.ring .ring-track { stroke: var(--surface-3); }
.ring .ring-bar { transition: stroke-dashoffset 1.2s var(--ease-out); filter: drop-shadow(0 0 6px rgba(255, 91, 36, .5)); }
.ring-label { position: absolute; text-align: center; line-height: 1.1; }

.bar { height: 8px; border-radius: 99px; background: var(--surface-3); overflow: hidden; box-shadow: inset 0 1px 2px rgba(0, 0, 0, .25); }
.bar > span { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--ember-2), var(--ember-1)); transform-origin: left; animation: bar-grow 1s var(--ease-out) both; }
@keyframes bar-grow { from { transform: scaleX(0); } }

.skeleton { border-radius: var(--r-md); background: linear-gradient(90deg, var(--surface-2) 25%, var(--surface-3) 45%, var(--surface-2) 65%); background-size: 200% 100%; animation: shimmer 1.4s linear infinite; }

.divider { height: 1px; background: var(--line); border: 0; margin: 0; }

.list { display: grid; }
.list-row { display: flex; align-items: center; gap: var(--s3); padding: 14px 4px; border-bottom: 1px solid var(--line); transition: background var(--t-med); border-radius: 12px; }
.list-row:last-child { border-bottom: 0; }
.list-row.clickable { cursor: pointer; padding: 14px 10px; }
.list-row.clickable:hover { background: var(--surface-hover); }

.thumb { position: relative; flex: none; width: 60px; height: 78px; border-radius: 12px; overflow: hidden; background: var(--surface-3); box-shadow: inset 0 0 0 1px var(--line); display: grid; place-items: center; color: var(--ink-3); }
.thumb img { width: 100%; height: 100%; object-fit: cover; }

.kpi { display: grid; gap: 6px; }
.kpi-value { font-size: clamp(1.8rem, 1.3rem + 1.6vw, 2.6rem); font-weight: 800; font-stretch: 112%; letter-spacing: -.02em; line-height: 1; }
.kpi-label { font-size: var(--fs-sm); color: var(--ink-2); font-weight: 600; }
.kpi-icon { width: 38px; height: 38px; border-radius: 12px; display: grid; place-items: center; font-size: 1.25rem; }
.delta-up { color: var(--success); font-weight: 700; font-size: var(--fs-sm); }
.delta-down { color: var(--danger); font-weight: 700; font-size: var(--fs-sm); }

/* ============================== NAVIGATION ============================== */
.brand { display: flex; align-items: center; gap: 10px; padding: 6px 8px 22px; }
.brand-mark { width: 38px; height: 38px; flex: none; }
.brand-word { font-weight: 900; font-stretch: 125%; letter-spacing: -.01em; font-size: 1.15rem; }
.brand-word b { color: var(--accent); font-weight: 900; }
.nav-item { display: flex; align-items: center; gap: 12px; padding: 11px 12px; border-radius: 13px; color: var(--ink-2); font-weight: 650; position: relative; transition: color var(--t-med), background var(--t-med); }
.nav-item i { font-size: 1.35rem; }
.nav-item:hover { color: var(--ink); background: var(--surface-hover); }
.nav-item.active { color: var(--ink); background: var(--surface); box-shadow: var(--shadow-sm), inset 0 0 0 1px var(--line), inset 0 1px 0 var(--highlight); }
.nav-item.active i { color: var(--accent); }
.nav-item.active::before { content: ""; position: absolute; left: -16px; top: 10px; bottom: 10px; width: 4px; border-radius: 0 4px 4px 0; background: var(--accent); box-shadow: 0 0 12px var(--accent); }
.nav-section { margin: 18px 12px 6px; font-size: 11px; font-weight: 750; letter-spacing: .16em; text-transform: uppercase; color: var(--ink-3); }
.nav-badge { margin-left: auto; min-width: 22px; height: 22px; padding: 0 7px; border-radius: 99px; background: var(--accent); color: var(--on-ember); font-size: 12px; font-weight: 800; display: grid; place-items: center; }

.bottom-nav {
  position: fixed; left: 12px; right: 12px; bottom: calc(10px + env(safe-area-inset-bottom)); z-index: 40;
  display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; padding: 6px; border-radius: 22px;
  background: var(--glass); backdrop-filter: blur(20px) saturate(1.5); -webkit-backdrop-filter: blur(20px) saturate(1.5);
  box-shadow: var(--shadow-lg), inset 0 0 0 1px var(--line-strong), inset 0 1px 0 var(--highlight);
}
.bottom-nav a { position: relative; display: grid; justify-items: center; gap: 2px; padding: 8px 0 6px; border-radius: 16px; font-size: 11px; font-weight: 700; color: var(--ink-3); transition: color var(--t-med); }
.bottom-nav a i { font-size: 1.5rem; transition: transform var(--t-med) var(--ease-spring); }
.bottom-nav a.active { color: var(--ink); background: var(--surface); box-shadow: inset 0 0 0 1px var(--line), inset 0 1px 0 var(--highlight); }
.bottom-nav a.active i { color: var(--accent); transform: translateY(-1px) scale(1.08); }
.bottom-nav .nav-dot { position: absolute; top: 5px; right: calc(50% - 18px); width: 9px; height: 9px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 2px var(--surface); }

.topbar { display: flex; align-items: center; justify-content: space-between; gap: var(--s3); margin-bottom: var(--s5); }
@media (min-width: 960px) { .topbar.mobile-only { display: none; } }

/* ============================ OVERLAYS ============================ */
.scrim { position: fixed; inset: 0; z-index: 80; background: rgba(4, 5, 7, .55); backdrop-filter: blur(6px); animation: fade var(--t-med) var(--ease-out); display: grid; align-items: end; justify-items: center; }
@media (min-width: 720px) { .scrim { align-items: center; } }
.sheet {
  width: min(560px, 100%); max-height: 92dvh; overflow: auto; padding: var(--s6); border-radius: 28px 28px 0 0;
  background: var(--surface); box-shadow: var(--shadow-lg), inset 0 0 0 1px var(--line-strong), inset 0 1px 0 var(--highlight);
  animation: sheet-in var(--t-slow) var(--ease-out); padding-bottom: calc(var(--s6) + env(safe-area-inset-bottom));
}
@media (min-width: 720px) { .sheet { border-radius: 28px; } }
@keyframes sheet-in { from { transform: translateY(40px) scale(.98); opacity: 0; } }
.sheet-grip { width: 42px; height: 5px; border-radius: 99px; background: var(--line-strong); margin: -8px auto 16px; }

.toasts { position: fixed; z-index: 100; top: calc(14px + env(safe-area-inset-top)); left: 50%; transform: translateX(-50%); display: grid; gap: 8px; width: min(440px, calc(100% - 24px)); pointer-events: none; }
.toast { pointer-events: auto; display: flex; gap: 12px; align-items: center; padding: 14px 16px; border-radius: 16px; background: var(--glass); backdrop-filter: blur(18px) saturate(1.4); box-shadow: var(--shadow-lg), inset 0 0 0 1px var(--line-strong); font-weight: 600; font-size: var(--fs-sm); animation: toast-in 520ms var(--ease-spring); }
.toast i { font-size: 1.4rem; }
.toast.leaving { animation: toast-out 260ms var(--ease-out) forwards; }
@keyframes toast-in { from { transform: translateY(-24px) scale(.94); opacity: 0; } }
@keyframes toast-out { to { transform: translateY(-16px) scale(.96); opacity: 0; } }

.state { display: grid; justify-items: center; text-align: center; gap: 12px; padding: var(--s10) var(--s5); }
.state-icon { width: 76px; height: 76px; border-radius: 24px; display: grid; place-items: center; font-size: 2.2rem; background: var(--surface-3); color: var(--accent); box-shadow: inset 0 0 0 1px var(--line), inset 0 1px 0 var(--highlight), var(--shadow-md); }
.state p { max-width: 42ch; color: var(--ink-2); }

.banner { display: flex; gap: 12px; align-items: flex-start; padding: 14px 16px; border-radius: var(--r-md); font-size: var(--fs-sm); }
.banner i { font-size: 1.3rem; flex: none; margin-top: 1px; }
.banner-danger { background: var(--danger-soft); color: var(--ink); }
.banner-danger i { color: var(--danger); }
.banner-info { background: var(--info-soft); }
.banner-info i { color: var(--info); }

#confetti { position: fixed; inset: 0; z-index: 120; pointer-events: none; }
