/* Elyriax — HoYoLAB-Inspired Clean Product Design System
   Anti-AI-Slop: Crisp neutral surfaces, hairline borders, structured Battle Chronicle widgets,
   1:1 product cards, zero neon glows or cliché gradients. */

:root {
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;

  --radius-xs: 6px;
  --radius-sm: 10px;
  --radius-md: 14px;
  --radius-lg: 18px;
  --radius-full: 9999px;

  --sidebar-w: 240px;
  --sidebar-rail-w: 72px;
  --topbar-h: 58px;
  --bottomnav-h: 62px;

  /* HoYoLAB-aligned cobalt accent */
  --accent: #3b66f5;
  --accent-fg: #ffffff;
  --accent-soft: rgba(59, 102, 245, 0.1);
  --accent-border: rgba(59, 102, 245, 0.28);

  --ok: #10b981;
  --ok-soft: rgba(16, 185, 129, 0.12);
  --warn: #d97706;
  --warn-soft: rgba(217, 119, 6, 0.12);
  --err: #ef4444;
  --err-soft: rgba(239, 68, 68, 0.12);

  /* Game Rarity & Element Accents (restrained, authentic HoYoLAB) */
  --r5: #c98a2e;
  --r5-bg: rgba(201, 138, 46, 0.12);
  --r4: #8a63d2;
  --r4-bg: rgba(138, 99, 210, 0.12);
  --r3: #4b89c8;
  --r3-bg: rgba(75, 137, 200, 0.12);

  --el-pyro: #dc5c3b;
  --el-hydro: #2d87d8;
  --el-cryo: #47a6c9;
  --el-electro: #8d5fd3;
  --el-anemo: #35a88c;
  --el-geo: #c9922b;
  --el-dendro: #65a832;

  /* Default Dark (HoYoLAB Night Slate) */
  --bg: #0c0f16;
  --surface: #141821;
  --surface-2: #1b202c;
  --surface-hover: #222836;
  --line: rgba(255, 255, 255, 0.08);
  --line-strong: rgba(255, 255, 255, 0.15);
  --text: #f1f3f8;
  --text-dim: #9aa3b2;
  --text-faint: #6c7585;
  --glass-bg: rgba(20, 24, 33, 0.84);
  --card-shadow: 0 1px 2px rgba(0, 0, 0, 0.35);
  --shadow-lg: 0 20px 48px rgba(0, 0, 0, 0.55);
}

:root[data-theme-effective='light'] {
  --bg: #f3f5f8;
  --surface: #ffffff;
  --surface-2: #f5f7fa;
  --surface-hover: #ebeef4;
  --line: rgba(15, 23, 42, 0.08);
  --line-strong: rgba(15, 23, 42, 0.15);
  --text: #111827;
  --text-dim: #4b5563;
  --text-faint: #6b7280;
  --glass-bg: rgba(255, 255, 255, 0.88);
  --card-shadow: 0 1px 2px rgba(15, 23, 42, 0.04), 0 4px 12px rgba(15, 23, 42, 0.025);
  --shadow-lg: 0 20px 48px rgba(15, 23, 42, 0.14);
}

:root[data-theme-effective='classic_dark'] {
  --bg: #0d1117;
  --surface: #161b22;
  --surface-2: #1f2630;
  --surface-hover: #27303d;
  --line: rgba(240, 246, 252, 0.09);
  --line-strong: rgba(240, 246, 252, 0.17);
  --text: #e6edf3;
  --text-dim: #8b949e;
  --text-faint: #6e7681;
  --glass-bg: rgba(22, 27, 34, 0.86);
}

:root[data-accent='cyan']   { --accent: #0891b2; --accent-fg: #ffffff; --accent-soft: rgba(8, 145, 178, 0.11);  --accent-border: rgba(8, 145, 178, 0.28); }
:root[data-accent='blue']   { --accent: #3b66f5; --accent-fg: #ffffff; --accent-soft: rgba(59, 102, 245, 0.11); --accent-border: rgba(59, 102, 245, 0.28); }
:root[data-accent='purple'] { --accent: #7c3aed; --accent-fg: #ffffff; --accent-soft: rgba(124, 58, 237, 0.11); --accent-border: rgba(124, 58, 237, 0.28); }
:root[data-accent='pink']   { --accent: #db2777; --accent-fg: #ffffff; --accent-soft: rgba(219, 39, 119, 0.11); --accent-border: rgba(219, 39, 119, 0.28); }
:root[data-accent='red']    { --accent: #dc2626; --accent-fg: #ffffff; --accent-soft: rgba(220, 38, 38, 0.11);  --accent-border: rgba(220, 38, 38, 0.28); }
:root[data-accent='amber']  { --accent: #d97706; --accent-fg: #ffffff; --accent-soft: rgba(217, 119, 6, 0.12);  --accent-border: rgba(217, 119, 6, 0.28); }

:root[data-theme-effective='dark'][data-accent='cyan'],
:root[data-theme-effective='classic_dark'][data-accent='cyan'] { --accent: #06b6d4; --accent-fg: #041316; }
:root[data-theme-effective='dark'][data-accent='blue'],
:root[data-theme-effective='classic_dark'][data-accent='blue'] { --accent: #5b82ff; --accent-fg: #ffffff; }
:root[data-theme-effective='dark'][data-accent='purple'],
:root[data-theme-effective='classic_dark'][data-accent='purple'] { --accent: #8b5cf6; --accent-fg: #ffffff; }
:root[data-theme-effective='dark'][data-accent='amber'],
:root[data-theme-effective='classic_dark'][data-accent='amber'] { --accent: #f59e0b; --accent-fg: #181104; }

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

html, body {
  margin: 0;
  padding: 0;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  -webkit-tap-highlight-color: transparent;
  overflow-x: hidden;
}

:root[data-compact] { font-size: 13px; }
:root[data-no-motion] *, :root[data-no-motion] *::before, :root[data-no-motion] *::after {
  animation-duration: 0.001ms !important;
  transition-duration: 0.001ms !important;
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    transition-duration: 0.001ms !important;
  }
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: none; padding: 0; }
img { max-width: 100%; display: block; }
.mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--text-dim); }
.faint { color: var(--text-faint); }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.min-w-0 { min-width: 0; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); border: 0; }

/* ---------- App Shell ---------- */
.app-shell { display: flex; min-height: 100dvh; width: 100%; }

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: var(--sidebar-w);
  background: var(--surface);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  z-index: 40;
  transition: width 0.2s ease, transform 0.22s cubic-bezier(0.22, 1, 0.36, 1);
}

.sidebar-brand {
  height: var(--topbar-h);
  padding: 0 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  border-bottom: 1px solid var(--line);
  flex-shrink: 0;
}

.brand-mark {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--line-strong);
  background: var(--surface-2);
  flex-shrink: 0;
  display: grid;
  place-items: center;
}
.brand-mark img { width: 100%; height: 100%; object-fit: cover; }
.brand-title { font-weight: 700; font-size: 15.5px; letter-spacing: -0.025em; min-width: 0; }

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 12px 10px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav-section-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-faint);
  padding: 14px 10px 5px;
}
.nav-section-label:first-child { padding-top: 2px; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 38px;
  padding: 0 11px;
  border-radius: var(--radius-sm);
  color: var(--text-dim);
  font-weight: 500;
  font-size: 13.5px;
  transition: background 0.14s ease, color 0.14s ease;
  text-decoration: none;
  white-space: nowrap;
}
.nav-item:hover { background: var(--surface-hover); color: var(--text); text-decoration: none; }
.nav-item.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.nav-item .nav-badge {
  margin-left: auto;
  font-family: var(--font-mono);
  font-size: 11px;
  padding: 1px 7px;
  border-radius: var(--radius-full);
  background: var(--surface-2);
  color: var(--text-dim);
}
.nav-item.active .nav-badge { background: var(--accent); color: var(--accent-fg); }

.sidebar-footer { padding: 10px; border-top: 1px solid var(--line); flex-shrink: 0; }

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 8px;
  border-radius: var(--radius-sm);
  text-align: left;
  transition: background 0.14s ease;
}
.sidebar-user:hover { background: var(--surface-hover); }

.avatar {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  display: grid;
  place-items: center;
  font-weight: 600;
  font-size: 13px;
  color: var(--text);
  overflow: hidden;
  flex-shrink: 0;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }

.app-main {
  flex: 1;
  min-width: 0;
  margin-left: var(--sidebar-w);
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
  transition: margin-left 0.2s ease;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  height: calc(var(--topbar-h) + env(safe-area-inset-top, 0px));
  padding: env(safe-area-inset-top, 0px) 22px 0;
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--glass-bg);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
}
:root[data-no-glass] .topbar { background: var(--surface); backdrop-filter: none; -webkit-backdrop-filter: none; }

.topbar-title-wrap { display: flex; flex-direction: column; min-width: 0; }
.topbar-title { font-size: 15.5px; font-weight: 600; letter-spacing: -0.015em; line-height: 1.25; }
.topbar-sub { font-size: 11.5px; color: var(--text-faint); }
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; }

.cmd-trigger {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 36px;
  padding: 0 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text-dim);
  font-size: 12.5px;
}
.cmd-trigger:hover { border-color: var(--line-strong); color: var(--text); }
.kbd {
  font-family: var(--font-mono);
  font-size: 10.5px;
  padding: 1px 5px;
  border-radius: 5px;
  border: 1px solid var(--line-strong);
  background: var(--surface-2);
  color: var(--text-faint);
}

.workspace {
  flex: 1;
  width: 100%;
  max-width: 1240px;
  margin: 0 auto;
  padding: 22px 26px 44px;
}
:root[data-compact] .workspace { padding: 16px 20px 32px; }

/* Desktop-only collapsed rail state — never bleed into mobile/tablet drawer */
@media (min-width: 1024px) {
  :root[data-sidebar-collapsed] .sidebar { width: var(--sidebar-rail-w); }
  :root[data-sidebar-collapsed] .app-main { margin-left: var(--sidebar-rail-w); }
  :root[data-sidebar-collapsed] .sidebar .brand-title,
  :root[data-sidebar-collapsed] .sidebar .nav-label,
  :root[data-sidebar-collapsed] .sidebar .nav-badge,
  :root[data-sidebar-collapsed] .sidebar .nav-section-label,
  :root[data-sidebar-collapsed] .sidebar .user-meta { display: none; }
  :root[data-sidebar-collapsed] .sidebar .nav-item { justify-content: center; padding: 0; }
  :root[data-sidebar-collapsed] .sidebar .sidebar-brand { justify-content: center; padding: 0; }
  :root[data-sidebar-collapsed] .sidebar .sidebar-user { justify-content: center; padding: 8px 0; }
}

/* Mobile Bottom Nav */
.bottom-nav {
  display: none;
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  height: calc(var(--bottomnav-h) + env(safe-area-inset-bottom, 0px));
  padding-bottom: env(safe-area-inset-bottom, 0px);
  background: var(--glass-bg);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  border-top: 1px solid var(--line);
  z-index: 40;
  grid-template-columns: repeat(5, 1fr);
}
:root[data-no-glass] .bottom-nav { background: var(--surface); backdrop-filter: none; }

.bottom-nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  color: var(--text-faint);
  font-size: 10.5px;
  font-weight: 500;
  min-height: 44px;
  text-decoration: none;
}
.bottom-nav-item .bn-ico {
  display: grid;
  place-items: center;
  width: 44px;
  height: 28px;
  border-radius: var(--radius-full);
  transition: background 0.16s ease;
}
.bottom-nav-item.active { color: var(--accent); font-weight: 600; }
.bottom-nav-item.active .bn-ico { background: var(--accent-soft); }
.bottom-nav-item:hover { text-decoration: none; }

.sidebar-backdrop { display: none; position: fixed; inset: 0; background: rgba(0, 0, 0, 0.5); z-index: 35; }
.sidebar-backdrop.open { display: block; }

/* ---------- Breakpoints ---------- */
@media (max-width: 1023px) and (min-width: 640px) {
  .sidebar:not(.drawer-open) { width: var(--sidebar-rail-w); }
  .sidebar:not(.drawer-open) .brand-title,
  .sidebar:not(.drawer-open) .nav-label,
  .sidebar:not(.drawer-open) .nav-badge,
  .sidebar:not(.drawer-open) .nav-section-label,
  .sidebar:not(.drawer-open) .user-meta { display: none; }
  .sidebar:not(.drawer-open) .nav-item { justify-content: center; padding: 0; }
  .sidebar:not(.drawer-open) .sidebar-brand { justify-content: center; padding: 0; }
  .sidebar:not(.drawer-open) .sidebar-user { justify-content: center; padding: 8px 0; }
  .app-main { margin-left: var(--sidebar-rail-w); }
  .workspace { padding: 18px 20px 36px; }
}

@media (max-width: 1023px) {
  .sidebar-backdrop { z-index: 45; }
  .sidebar.drawer-open { z-index: 50; }
}

@media (max-width: 639px) {
  .sidebar { width: min(286px, 84vw); transform: translateX(-100%); }
  .sidebar.drawer-open { transform: translateX(0); box-shadow: var(--shadow-lg); }
  .app-main { margin-left: 0 !important; }
  .topbar { padding-left: 14px; padding-right: 14px; height: calc(54px + env(safe-area-inset-top, 0px)); }
  .topbar-sub { display: none; }
  .workspace { padding: 14px 12px calc(var(--bottomnav-h) + env(safe-area-inset-bottom, 0px) + 22px); }
  .bottom-nav { display: grid; }
  .cmd-trigger { width: 36px; padding: 0; justify-content: center; }
  .cmd-trigger .cmd-text, .cmd-trigger .kbd { display: none; }
  .desktop-only { display: none !important; }
}
@media (min-width: 640px) { .mobile-only { display: none !important; } }

/* ---------- Page Header & Cards ---------- */
.page-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}
.page-title { margin: 0; font-size: 20px; font-weight: 700; letter-spacing: -0.025em; line-height: 1.25; }
.page-desc { margin: 3px 0 0; font-size: 13px; color: var(--text-dim); }
.page-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 18px;
  box-shadow: var(--card-shadow);
}
:root[data-compact] .card { padding: 14px; }
@media (max-width: 639px) { .card { padding: 14px; } }

.card-subtle {
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
}

.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 14px; }
.card-title { margin: 0; font-size: 14.5px; font-weight: 600; letter-spacing: -0.015em; display: flex; align-items: center; gap: 8px; }

.hero-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 20px 22px;
  box-shadow: var(--card-shadow);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

/* Grids & Flex */
.grid { display: grid; gap: 14px; }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(min(100%, 310px), 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(min(100%, 245px), 1fr)); }
.grid-4 { grid-template-columns: repeat(auto-fit, minmax(min(100%, 195px), 1fr)); }
.stack { display: flex; flex-direction: column; gap: 12px; }
.row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }

/* Metrics */
.metric-label { font-size: 12.5px; color: var(--text-dim); display: flex; align-items: center; justify-content: space-between; gap: 6px; }
.metric-value { font-size: 22px; font-weight: 700; letter-spacing: -0.025em; margin-top: 6px; font-variant-numeric: tabular-nums; }
.metric-sub { font-size: 12px; color: var(--text-faint); margin-top: 4px; }

/* Progress Bar */
.progress { width: 100%; height: 7px; background: var(--surface-2); border-radius: var(--radius-full); overflow: hidden; margin-top: 8px; }
.progress-fill { height: 100%; background: var(--accent); border-radius: var(--radius-full); transition: width 0.25s ease; }
.progress-fill.ok { background: var(--ok); }
.progress-fill.warn { background: var(--warn); }
.progress-fill.err { background: var(--err); }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 36px;
  padding: 0 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--text);
  transition: background 0.14s ease, border-color 0.14s ease, transform 0.1s ease, opacity 0.14s ease;
  white-space: nowrap;
}
.btn:hover:not(:disabled) { background: var(--surface-hover); }
.btn:active:not(:disabled) { transform: scale(0.985); }
.btn:disabled { opacity: 0.48; cursor: not-allowed; }
.btn-primary { background: var(--accent); color: var(--accent-fg); border-color: transparent; font-weight: 600; }
.btn-primary:hover:not(:disabled) { filter: brightness(1.07); background: var(--accent); }
.btn-ghost { background: transparent; border-color: var(--line); }
.btn-ghost:hover:not(:disabled) { background: var(--surface-hover); border-color: var(--line-strong); }
.btn-danger { background: var(--err-soft); color: var(--err); border-color: rgba(239, 68, 68, 0.24); }
.btn-danger:hover:not(:disabled) { background: rgba(239, 68, 68, 0.18); }
.btn-sm { min-height: 32px; padding: 0 11px; font-size: 12.5px; border-radius: 8px; }
.btn-block { width: 100%; }

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text-dim);
  position: relative;
  flex-shrink: 0;
}
.icon-btn:hover { background: var(--surface-hover); color: var(--text); border-color: var(--line-strong); }
.icon-btn-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  min-width: 17px;
  height: 17px;
  padding: 0 4px;
  border-radius: var(--radius-full);
  background: var(--accent);
  color: var(--accent-fg);
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 700;
  display: grid;
  place-items: center;
}

/* Inputs & Forms */
.field { display: flex; flex-direction: column; gap: 5px; }
.label { font-size: 12.5px; font-weight: 500; color: var(--text-dim); }
.input, .select, .textarea {
  width: 100%;
  min-height: 38px;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--text);
  font-size: 13.5px;
}
.textarea { min-height: 88px; resize: vertical; line-height: 1.5; }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.input::placeholder, .textarea::placeholder { color: var(--text-faint); }
.help { font-size: 12px; color: var(--text-faint); }

/* Toggle Switch */
.switch { position: relative; display: inline-flex; align-items: center; width: 38px; height: 22px; flex-shrink: 0; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch-track {
  position: absolute;
  inset: 0;
  border-radius: var(--radius-full);
  background: var(--surface-2);
  border: 1px solid var(--line-strong);
  transition: background 0.16s ease, border-color 0.16s ease;
  cursor: pointer;
}
.switch-track::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--text-dim);
  transition: transform 0.16s ease, background 0.16s ease;
}
.switch input:checked + .switch-track { background: var(--accent); border-color: var(--accent); }
.switch input:checked + .switch-track::after { transform: translateX(16px); background: var(--accent-fg); }

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2.5px 8px;
  border-radius: var(--radius-full);
  font-size: 11px;
  font-weight: 500;
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--text-dim);
  white-space: nowrap;
}
.badge-ok { background: var(--ok-soft); color: var(--ok); border-color: rgba(16, 185, 129, 0.25); }
.badge-warn { background: var(--warn-soft); color: var(--warn); border-color: rgba(217, 119, 6, 0.25); }
.badge-err { background: var(--err-soft); color: var(--err); border-color: rgba(239, 68, 68, 0.25); }
.badge-accent { background: var(--accent-soft); color: var(--accent); border-color: var(--accent-border); }
.badge-gold { background: var(--r5-bg); color: var(--r5); border-color: rgba(201, 138, 46, 0.3); }

/* Tabs */
.tabs {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 3px;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  border: 1px solid var(--line);
  max-width: 100%;
  overflow-x: auto;
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tab-btn {
  padding: 7px 13px;
  border-radius: 7px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-dim);
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.tab-btn:hover { color: var(--text); }
.tab-btn.active { background: var(--surface); color: var(--text); font-weight: 600; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08); }

.tabs-line {
  display: flex;
  align-items: center;
  gap: 4px;
  border-bottom: 1px solid var(--line);
  overflow-x: auto;
  scrollbar-width: none;
  margin-bottom: 16px;
}
.tabs-line::-webkit-scrollbar { display: none; }
.tabs-line .tab-btn {
  border-radius: 0;
  padding: 9px 12px;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  box-shadow: none;
  background: transparent;
}
.tabs-line .tab-btn.active { background: transparent; box-shadow: none; color: var(--accent); border-bottom-color: var(--accent); }

/* ---------- Product Grid (1:1 Square) ---------- */
.product-grid {
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(4, minmax(0, 1fr));
}
@media (max-width: 1120px) { .product-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 760px)  { .product-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; } }

.product-card {
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  overflow: hidden;
  box-shadow: var(--card-shadow);
  transition: border-color 0.16s ease, transform 0.16s ease;
}
.product-card:hover { border-color: var(--line-strong); transform: translateY(-1px); }

.product-thumb {
  aspect-ratio: 1 / 1;
  width: 100%;
  background: var(--surface-2);
  border-bottom: 1px solid var(--line);
  position: relative;
  overflow: hidden;
  display: grid;
  place-items: center;
  color: var(--text-faint);
}
.product-thumb img { width: 100%; height: 100%; object-fit: cover; }

.product-wish-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--glass-bg);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid var(--line);
  color: var(--text-dim);
  display: grid;
  place-items: center;
}
.product-wish-btn.active { color: var(--err); border-color: rgba(239, 68, 68, 0.35); }

.product-body { padding: 12px; display: flex; flex-direction: column; gap: 6px; flex: 1; }
.product-name {
  text-align: left;
  font-weight: 600;
  font-size: 13.5px;
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.product-price { font-family: var(--font-mono); font-size: 14.5px; font-weight: 700; }

/* ---------- Authentic HoYoLAB Battle Chronicle Components ---------- */
.hl-profile-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 16px 18px;
  box-shadow: var(--card-shadow);
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.hl-avatar-badge {
  width: 54px;
  height: 54px;
  border-radius: 50%;
  background: var(--surface-2);
  border: 2px solid var(--accent-border);
  color: var(--accent);
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 18px;
  flex-shrink: 0;
  overflow: hidden;
}
.hl-avatar-badge img { width: 100%; height: 100%; object-fit: cover; }

.hl-note-grid {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 220px), 1fr));
}

.hl-note-tile {
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 13px 14px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.hl-dots { display: inline-flex; gap: 5px; align-items: center; }
.hl-dot {
  width: 10px;
  height: 10px;
  border-radius: 3px;
  background: var(--surface);
  border: 1px solid var(--line-strong);
}
.hl-dot.done { background: var(--ok); border-color: var(--ok); }

.hl-exp-list {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 6px;
}
.hl-exp-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px 6px 6px;
  border-radius: var(--radius-full);
  background: var(--surface);
  border: 1px solid var(--line);
}
.hl-exp-ava {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--surface-2);
  border: 1.5px solid var(--ok);
  overflow: hidden;
  flex-shrink: 0;
}
.hl-exp-ava.ongoing { border-color: var(--warn); }
.hl-exp-ava img { width: 100%; height: 100%; object-fit: cover; }

/* Stats Overview & Exploration Strips */
.hl-stat-grid {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(6, minmax(0, 1fr));
}
@media (max-width: 960px) { .hl-stat-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 480px) { .hl-stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

.hl-stat-box {
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 12px 10px;
  text-align: center;
}
.hl-stat-val { font-family: var(--font-mono); font-size: 19px; font-weight: 700; line-height: 1.2; }
.hl-stat-lbl { font-size: 11.5px; color: var(--text-dim); margin-top: 4px; }

.hl-mini-strip {
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(auto-fit, minmax(105px, 1fr));
}
.hl-mini-pill {
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-xs);
  padding: 8px 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  font-size: 12px;
}

/* HoYoLAB Character Grid */
.hl-char-grid {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(auto-fill, minmax(112px, 1fr));
}
@media (max-width: 639px) {
  .hl-char-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
}

.hl-char-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  text-align: left;
  transition: transform 0.14s ease, border-color 0.14s ease;
}
.hl-char-card:hover { transform: translateY(-2px); border-color: var(--line-strong); }
.hl-char-card.r5 { border-top: 3px solid var(--r5); }
.hl-char-card.r4 { border-top: 3px solid var(--r4); }

.hl-char-img {
  aspect-ratio: 1 / 1;
  width: 100%;
  background: var(--surface-2);
  position: relative;
  overflow: hidden;
}
.hl-char-img img { width: 100%; height: 100%; object-fit: cover; }

.hl-char-el {
  position: absolute;
  top: 5px;
  left: 5px;
  font-size: 9.5px;
  font-weight: 700;
  padding: 1px 5px;
  border-radius: 4px;
  color: #ffffff;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}
.hl-char-const {
  position: absolute;
  top: 5px;
  right: 5px;
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 700;
  padding: 1px 5px;
  border-radius: 4px;
  background: rgba(12, 15, 22, 0.78);
  color: #ffffff;
}
.hl-char-lv {
  position: absolute;
  bottom: 5px;
  right: 5px;
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 600;
  padding: 1px 5px;
  border-radius: 4px;
  background: rgba(12, 15, 22, 0.78);
  color: #ffffff;
}
.hl-char-meta {
  padding: 7px 8px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.hl-char-name {
  font-size: 12px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.hl-char-sub {
  font-size: 10.5px;
  color: var(--text-faint);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* HoYoLAB Check-in Calendar */
.hl-checkin-grid {
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(7, minmax(0, 1fr));
}
@media (max-width: 760px) { .hl-checkin-grid { grid-template-columns: repeat(5, minmax(0, 1fr)); } }
@media (max-width: 460px) { .hl-checkin-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; } }

.hl-checkin-tile {
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 9px 6px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  text-align: center;
  position: relative;
}
.hl-checkin-tile.highlight {
  background: var(--r5-bg);
  border-color: rgba(201, 138, 46, 0.35);
}
.hl-checkin-tile.signed {
  border-color: rgba(16, 185, 129, 0.45);
}
.hl-checkin-tile img { width: 34px; height: 34px; object-fit: contain; }

/* HoYoLAB Calendar Banners, Challenges & Events */
.hl-banner-items {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}
.hl-item-chip {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 4px 9px 4px 4px;
  border-radius: 8px;
  background: var(--surface);
  border: 1px solid var(--line);
  font-size: 12px;
}
.hl-item-chip.r5 { border-color: rgba(201, 138, 46, 0.42); background: var(--r5-bg); }
.hl-item-chip.r4 { border-color: rgba(138, 99, 210, 0.35); background: var(--r4-bg); }
.hl-item-chip img { width: 28px; height: 28px; border-radius: 6px; object-fit: cover; flex-shrink: 0; }

.hl-event-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.hl-event-cover {
  width: 100%;
  aspect-ratio: 16 / 7;
  background: var(--surface-2);
  border-bottom: 1px solid var(--line);
  overflow: hidden;
}
.hl-event-cover img { width: 100%; height: 100%; object-fit: cover; }
.hl-event-body { padding: 14px; display: flex; flex-direction: column; gap: 8px; flex: 1; }
.hl-reward-strip { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.hl-reward-mini {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 7px 2px 4px;
  border-radius: 6px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  font-size: 11px;
  font-family: var(--font-mono);
}
.hl-reward-mini img { width: 18px; height: 18px; object-fit: contain; }

/* Settings Theme Cards */
.theme-grid { display: grid; gap: 10px; grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 639px) { .theme-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.theme-card {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--line);
  background: var(--surface-2);
  text-align: left;
}
.theme-card.active { border-color: var(--accent); background: var(--accent-soft); }
.theme-card img { width: 100%; border-radius: 6px; border: 1px solid var(--line); }

/* Responsive Data Table */
.table-wrap { width: 100%; overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.data-table th {
  text-align: left;
  padding: 11px 14px;
  font-size: 11.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-faint);
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
.data-table td { padding: 12px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.data-table tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover { background: var(--surface-hover); }

@media (max-width: 639px) {
  .data-table.responsive-stack thead { display: none; }
  .data-table.responsive-stack,
  .data-table.responsive-stack tbody,
  .data-table.responsive-stack tr,
  .data-table.responsive-stack td { display: block; width: 100%; }
  .data-table.responsive-stack tr {
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    margin-bottom: 10px;
    padding: 6px 12px;
    background: var(--surface);
  }
  .data-table.responsive-stack td {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 8px 0;
    border-bottom: 1px solid var(--line);
    text-align: right;
  }
  .data-table.responsive-stack td:last-child { border-bottom: none; }
  .data-table.responsive-stack td::before {
    content: attr(data-label);
    font-size: 12px;
    color: var(--text-faint);
    font-weight: 500;
    text-align: left;
    flex-shrink: 0;
  }
}

/* Empty, Skeleton, Spinner, Sheet, Command Palette, Toast */
.empty-state {
  text-align: center;
  padding: 34px 20px;
  background: var(--surface);
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius-md);
  color: var(--text-dim);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}
.empty-state-icon {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  display: grid;
  place-items: center;
  color: var(--text-dim);
}

.skeleton { background: var(--surface-2); border-radius: var(--radius-sm); position: relative; overflow: hidden; }
.skeleton::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent, rgba(128, 128, 128, 0.08), transparent);
  animation: shimmer 1.4s infinite;
}
@keyframes shimmer { from { transform: translateX(-100%); } to { transform: translateX(100%); } }

.spinner {
  width: 15px;
  height: 15px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  display: inline-block;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

#sheet-root { position: fixed; inset: 0; z-index: 70; pointer-events: none; opacity: 0; transition: opacity 0.18s ease; }
#sheet-root.open { pointer-events: auto; opacity: 1; }
.sheet-backdrop { position: absolute; inset: 0; background: rgba(0, 0, 0, 0.55); }
.sheet-panel {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(460px, 100vw);
  background: var(--surface);
  border-left: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  transform: translateX(24px);
  transition: transform 0.22s cubic-bezier(0.22, 1, 0.36, 1);
  box-shadow: var(--shadow-lg);
}
.sheet-panel.sheet-wide { width: min(640px, 100vw); }
#sheet-root.open .sheet-panel { transform: translateX(0); }

@media (max-width: 639px) {
  .sheet-panel, .sheet-panel.sheet-wide {
    top: auto;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    max-height: 90dvh;
    border-left: none;
    border-top: 1px solid var(--line);
    border-radius: 20px 20px 0 0;
    transform: translateY(28px);
  }
  #sheet-root.open .sheet-panel { transform: translateY(0); }
}

.sheet-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 18px; border-bottom: 1px solid var(--line); flex-shrink: 0; }
.sheet-title { margin: 0; font-size: 16px; font-weight: 600; }
.sheet-subtitle { margin: 2px 0 0; font-size: 12.5px; color: var(--text-dim); }
.sheet-body { flex: 1; overflow-y: auto; padding: 18px; padding-bottom: calc(20px + env(safe-area-inset-bottom, 0px)); }

.cmd-modal { position: fixed; inset: 0; z-index: 80; display: none; align-items: flex-start; justify-content: center; padding: 12vh 16px 16px; }
.cmd-modal.open { display: flex; }
.cmd-box { position: relative; width: min(520px, 100%); background: var(--surface); border: 1px solid var(--line-strong); border-radius: var(--radius-md); box-shadow: var(--shadow-lg); overflow: hidden; z-index: 1; }
.cmd-input-row { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-bottom: 1px solid var(--line); }
.cmd-input-row input { flex: 1; background: transparent; border: none; outline: none; font-size: 14px; }
.cmd-list { max-height: 320px; overflow-y: auto; padding: 6px; }
.cmd-item { width: 100%; display: flex; align-items: center; gap: 10px; padding: 10px; border-radius: var(--radius-sm); font-size: 13.5px; color: var(--text); text-align: left; }
.cmd-item:hover, .cmd-item.selected { background: var(--surface-hover); }

#toast-wrap { position: fixed; top: calc(14px + env(safe-area-inset-top, 0px)); right: 14px; z-index: 95; display: flex; flex-direction: column; gap: 8px; max-width: min(360px, calc(100vw - 28px)); }
.toast { display: flex; align-items: center; gap: 9px; padding: 11px 14px; border-radius: var(--radius-sm); background: var(--surface); border: 1px solid var(--line-strong); box-shadow: var(--shadow-lg); font-size: 13px; animation: toastIn 0.18s ease; }
.toast-icon { display: flex; flex-shrink: 0; }
.toast-success .toast-icon { color: var(--ok); }
.toast-error .toast-icon { color: var(--err); }
.toast-info .toast-icon { color: var(--accent); }
.toast-out { opacity: 0; transform: translateY(-6px); transition: opacity 0.2s, transform 0.2s; }
@keyframes toastIn { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: translateY(0); } }

.code-pill {
  font-family: var(--font-mono);
  font-size: 12.5px;
  padding: 5px 10px;
  border-radius: 8px;
  background: var(--surface-2);
  border: 1px solid var(--line-strong);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.code-pill:hover { border-color: var(--accent-border); background: var(--accent-soft); }

.dropzone { border: 1.5px dashed var(--line-strong); border-radius: var(--radius-md); padding: 32px 18px; text-align: center; background: var(--surface-2); cursor: pointer; }
.dropzone.dragover { border-color: var(--accent); background: var(--accent-soft); }

.qr-frame { background: #ffffff; padding: 12px; border-radius: var(--radius-md); width: 240px; max-width: 100%; margin: 0 auto; border: 1px solid var(--line); }
.qr-frame img { width: 100%; height: auto; border-radius: 6px; }

.accent-swatch { width: 30px; height: 30px; border-radius: 50%; border: 2px solid transparent; transition: transform 0.14s ease, border-color 0.14s ease; }
.accent-swatch.active { border-color: var(--text); transform: scale(1.08); }

.setting-row { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 13px 0; border-bottom: 1px solid var(--line); }
.setting-row:last-child { border-bottom: none; }

.quick-tile {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  text-decoration: none;
}
.quick-tile:hover { border-color: var(--line-strong); background: var(--surface-hover); text-decoration: none; }
.quick-tile-ico { width: 36px; height: 36px; border-radius: 9px; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; flex-shrink: 0; }

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

/* ---------- Mobile Hybrid, Offline & OTA Status Integration ---------- */
.status-bar-strip {
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  padding: 7px 18px;
  font-size: 12.5px;
  color: var(--text);
}
.status-bar-update {
  background: var(--accent-soft);
  border-bottom-color: var(--accent-border);
}
.status-bar-inner {
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: 1280px;
  margin: 0 auto;
}
.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
}
.status-dot-warn { background: var(--warn); }
.status-dot-ok { background: var(--ok); }

.offline-fallback-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 52dvh;
  padding: 12px 0;
}
.offline-fallback-card {
  max-width: 480px;
  width: 100%;
}

/* Hide bottom nav cleanly when native soft keyboard is open */
:root[data-keyboard-open] .bottom-nav {
  display: none !important;
}
:root[data-keyboard-open] .workspace {
  padding-bottom: 18px !important;
}

/* Extra iOS/Android safe-area resilience on native app */
:root[data-native-app] .sidebar {
  padding-top: env(safe-area-inset-top, 0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
:root[data-native-app] .sheet-header {
  padding-top: max(16px, env(safe-area-inset-top, 0px));
}

/* ---------- Fintech Wallet, Mobile Transaction List & QR Payment Card ---------- */
.wallet-hero {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--card-shadow);
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.wallet-balance-amt {
  font-family: var(--font-mono);
  font-size: clamp(26px, 5vw, 34px);
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.15;
}
.wallet-sub-stats {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.tx-list {
  display: flex;
  flex-direction: column;
}
.tx-row {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px 16px;
  border-bottom: 1px solid var(--line);
  background: transparent;
  text-align: left;
  transition: background 0.14s ease;
}
.tx-row:last-child { border-bottom: none; }
.tx-row:hover { background: var(--surface-hover); }
.tx-row:active { background: var(--surface-2); }

.tx-ico {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  background: var(--surface-2);
  color: var(--text-dim);
  border: 1px solid var(--line);
}
.tx-ico.deposit { background: var(--ok-soft); color: var(--ok); border-color: rgba(16, 185, 129, 0.22); }
.tx-ico.purchase { background: var(--accent-soft); color: var(--accent); border-color: var(--accent-border); }
.tx-ico.refund { background: var(--r4-bg); color: var(--r4); border-color: rgba(138, 99, 210, 0.25); }

.tx-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.tx-title { font-size: 13.5px; font-weight: 600; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tx-meta { font-size: 11.5px; color: var(--text-faint); font-family: var(--font-mono); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.tx-right { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; flex-shrink: 0; }
.tx-amt { font-family: var(--font-mono); font-size: 14px; font-weight: 700; }
.tx-amt.pos { color: var(--ok); }
.tx-amt.neg { color: var(--text); }

@media (max-width: 639px) {
  .tx-row { padding: 12px 14px; gap: 10px; }
  .tx-ico { width: 36px; height: 36px; }
  .tx-amt { font-size: 13.5px; }
}

.qr-pay-card {
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.qr-pay-box {
  background: #ffffff;
  border-radius: 14px;
  padding: 12px;
  width: min(230px, 100%);
  margin: 0 auto;
  border: 1px solid var(--line);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.08);
}
.qr-pay-box img { width: 100%; height: auto; border-radius: 8px; display: block; }

.qr-kv-list {
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  overflow: hidden;
}
.qr-kv-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  font-size: 13px;
}
.qr-kv-row:last-child { border-bottom: none; }
.qr-kv-lbl { color: var(--text-dim); flex-shrink: 0; }
.qr-kv-val { font-weight: 600; text-align: right; min-width: 0; display: inline-flex; align-items: center; gap: 6px; }

.preset-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}


/* ---------- v3.4 Fluid Collapsed Layout & Storefront Pills ---------- */
@media (min-width: 1024px) {
  :root[data-sidebar-collapsed] .workspace {
    max-width: none;
    width: 100%;
    padding-inline: clamp(16px, 2.5vw, 32px);
  }
}
@media (min-width: 1280px) {
  :root[data-sidebar-collapsed] .product-grid {
    grid-template-columns: repeat(5, minmax(0, 1fr));
  }
}
@media (min-width: 1536px) {
  :root[data-sidebar-collapsed] .product-grid {
    grid-template-columns: repeat(6, minmax(0, 1fr));
  }
}

.cat-pills {
  display: flex;
  align-items: center;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 4px;
  scrollbar-width: thin;
}
.cat-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 32px;
  padding: 0 13px;
  border-radius: var(--radius-full);
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text-dim);
  font-size: 12.5px;
  font-weight: 500;
  white-space: nowrap;
  flex-shrink: 0;
  transition: background 0.14s ease, border-color 0.14s ease, color 0.14s ease;
}
.cat-pill:hover {
  border-color: var(--line-strong);
  color: var(--text);
  background: var(--surface-hover);
}
.cat-pill.active {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-fg);
  font-weight: 600;
}

.variant-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.variant-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 34px;
  padding: 4px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line-strong);
  background: var(--surface-2);
  color: var(--text);
  font-size: 12.5px;
  font-weight: 500;
  transition: all 0.14s ease;
}
.variant-pill:hover {
  border-color: var(--accent);
  color: var(--accent);
}
.variant-pill.active {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent);
  font-weight: 600;
}
.variant-pill.out-of-stock {
  opacity: 0.55;
}


/* ---------- v4.0 Global Overflow Fix, Settings Tabs, Compact Drawer, Cart & Shop Ops ---------- */
html, body, .app-shell, .app-main, .workspace {
  max-width: 100%;
  overflow-x: clip;
}
.avatar {
  overflow: hidden;
  flex-shrink: 0;
}
.avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* Prevent horizontal tab strips from stretching viewport on iOS Safari */
.tabs-line, .tabs {
  max-width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-x: contain;
  scrollbar-width: none;
}
.tabs-line::-webkit-scrollbar, .tabs::-webkit-scrollbar {
  display: none;
}
.tabs-line .tab-btn, .tabs .tab-btn {
  flex-shrink: 0;
  white-space: nowrap;
}

/* Cohesive Desktop Topbar */
.topbar-center {
  flex: 0 1 280px;
  display: flex;
  justify-content: center;
}
.topbar-center .cmd-trigger {
  width: 100%;
  justify-content: space-between;
}
.topbar-wallet-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 34px;
  padding: 0 6px 0 11px;
  border-radius: var(--radius-full);
  background: var(--surface-2);
  border: 1px solid var(--line);
  color: var(--text);
  font-size: 12.5px;
  font-weight: 600;
  text-decoration: none;
  transition: border-color 0.14s ease, background 0.14s ease;
}
.topbar-wallet-pill:hover {
  border-color: var(--accent);
  background: var(--surface-hover);
  text-decoration: none;
}
.topbar-wallet-pill .tw-plus {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--accent);
  color: var(--accent-fg);
  display: grid;
  place-items: center;
}

/* Compact Product Detail Drawer (TikTok Shop Style) */
.pd-head-row {
  display: flex;
  align-items: center;
  gap: 12px;
}
.pd-thumb {
  width: 72px;
  height: 72px;
  border-radius: 14px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  display: grid;
  place-items: center;
  overflow: hidden;
  flex-shrink: 0;
  padding: 4px;
}
.pd-thumb img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  border-radius: 10px;
}
.pd-meta {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.pd-price-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.pd-price {
  font-size: 20px;
  font-weight: 700;
  color: var(--accent);
  line-height: 1.1;
}
.pd-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}
.pd-desc-box {
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-size: 13px;
  line-height: 1.55;
  color: var(--text-dim);
  white-space: pre-line;
  max-height: 180px;
  overflow-y: auto;
}
.pd-qty-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.qty-stepper {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  overflow: hidden;
}
.qty-stepper button {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  background: transparent;
  color: var(--text);
}
.qty-stepper button:hover:not(:disabled) {
  background: var(--surface-hover);
}
.qty-stepper button:disabled {
  opacity: 0.4;
}
.qty-stepper span {
  min-width: 34px;
  text-align: center;
  font-size: 13px;
  font-weight: 600;
}

/* Dedicated /cart Page & Delivery Profile Selector */
.cart-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 16px;
  align-items: start;
}
@media (max-width: 900px) {
  .cart-layout {
    grid-template-columns: minmax(0, 1fr);
  }
}
.delivery-profile-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  border: 1px solid var(--line);
}
.delivery-profile-card.missing {
  border-color: rgba(245, 158, 11, 0.45);
  background: rgba(245, 158, 11, 0.06);
}
.profile-type-toggle {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  padding: 4px;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  border: 1px solid var(--line);
}
.pt-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 36px;
  border-radius: calc(var(--radius-sm) - 2px);
  font-size: 13px;
  font-weight: 500;
  color: var(--text-dim);
  background: transparent;
  transition: all 0.14s ease;
}
.pt-btn.active {
  background: var(--accent);
  color: var(--accent-fg);
  font-weight: 600;
}
.pt-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}
.dp-pick-card {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 11px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--surface-2);
  text-align: left;
  transition: border-color 0.14s ease, background 0.14s ease;
}
.dp-pick-card:hover {
  border-color: var(--line-strong);
}
.dp-pick-card.active {
  border-color: var(--accent);
  background: var(--accent-soft);
}
.dp-mgr-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  border: 1px solid var(--line);
}

/* Admin Accordion Products & Shop Ops Order Cards */
.adm-acc-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 14px;
  flex-wrap: wrap;
}
.adm-acc-variants {
  border-top: 1px solid var(--line);
  background: var(--surface-2);
}
.adm-variant-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
}
.adm-variant-row:last-child {
  border-bottom: none;
}
.ops-item-box {
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  border: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.ops-cred-box {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  background: var(--surface);
  border: 1px solid var(--line);
}
.ops-cred-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 12.5px;
  flex-wrap: wrap;
}
.ops-cred-row code {
  flex: 1;
  min-width: 120px;
  font-weight: 600;
  color: var(--text);
}
