/* Kai Shop — Unified design system (Material Design 3 + 异次元发卡网 brand accent)
 * public/css/base.css
 * Loaded on EVERY page (shop, admin, merchant, auth).
 * Defines: tokens · reset · utilities · shared components.
 * Frontend-only composition lives in main.css; admin/merchant in admin.css.
 */

/* =========================================================================
 * 1. Design tokens
 * ========================================================================= */
:root {
  /* ---- MD3 reference color roles ---- */
  /* Primary: confident, grounded blue (no purple) — the 异次元 / marketplace blue */
  --md-sys-color-primary: #2196F3;
  /* primary-strong: deeper blue for text/links/accents on light surfaces
     (a light --md-sys-color-primary alone would fail contrast there). */
  --md-sys-color-primary-strong: #0B66C3;
  --md-sys-color-on-primary: #FFFFFF;
  --md-sys-color-primary-container: #D3E3FD;
  --md-sys-color-on-primary-container: #041E49;
  --md-sys-color-secondary: #565F71;
  --md-sys-color-on-secondary: #FFFFFF;
  --md-sys-color-secondary-container: #DAE2F9;
  --md-sys-color-on-secondary-container: #131C2E;
  --md-sys-color-tertiary: #386C6A;
  --md-sys-color-on-tertiary: #FFFFFF;
  --md-sys-color-tertiary-container: #BCECE9;
  --md-sys-color-on-tertiary-container: #00201F;
  /* Brand accent (red) — 发卡网 price/CTA emphasis, not a gradient */
  --md-sys-color-accent: #D8392B;
  --md-sys-color-on-accent: #FFFFFF;
  --md-sys-color-accent-container: #FFDAD5;
  --md-sys-color-on-accent-container: #410002;
  --md-sys-color-success: #146C2E;
  --md-sys-color-on-success-container: #02240F;
  --md-sys-color-success-container: #A5F0B4;
  --md-sys-color-error: #BA1A1A;
  --md-sys-color-on-error: #FFFFFF;
  --md-sys-color-error-container: #FFDAD6;
  --md-sys-color-on-error-container: #410002;
  --md-sys-color-warning: #8C5100;
  --md-sys-color-on-warning-container: #2B1700;
  --md-sys-color-warning-container: #FFDDAC;
  --md-sys-color-info: #00639B;
  --md-sys-color-on-info-container: #001E33;
  --md-sys-color-info-container: #CDE5FF;

  --md-sys-color-background: #F4F8FC;
  --md-sys-color-on-background: #16202B;
  --md-sys-color-surface: #FFFFFF;
  --md-sys-color-on-surface: #16202B;
  --md-sys-color-surface-variant: #E2E9F1;
  --md-sys-color-on-surface-variant: #45596B;
  --md-sys-color-surface-container: #ECF1F8;
  --md-sys-color-surface-container-high: #E3ECF5;
  --md-sys-color-surface-container-highest: #DCE5EF;
  --md-sys-color-outline: #6A7C8E;
  --md-sys-color-outline-variant: #C8D4E0;
  --md-sys-color-inverse-surface: #14202B;
  --md-sys-color-inverse-on-surface: #ECF2F9;
  --md-sys-color-inverse-primary: #A8C7FA;
  --md-sys-color-surface-tint: #2196F3;

  /* ---- Brand / surface tokens (solid MD3 surfaces, minimal tint) ---- */
  --brand-gradient: linear-gradient(135deg, #2196F3 0%, #64B5F6 100%);
  --brand-gradient-accent: linear-gradient(135deg, #2196F3 0%, #64B5F6 100%);
  --surface-glass: rgba(255, 255, 255, 0.94);
  --surface-glass-strong: rgba(255, 255, 255, 0.97);
  --nav-bg: rgba(255, 255, 255, 0.94);
  --footer-bg: rgba(250, 251, 252, 0.94);
  --hairline: rgba(16, 24, 40, 0.08);
  --shadow-soft: 0 10px 30px rgba(33, 150, 243, 0.08);

  /* ---- MD3 radius ---- */
  --md-radius-small: 8px;
  --md-radius-medium: 12px;
  --md-radius-large: 16px;
  --md-radius-extra-large: 28px;
  --md-radius-full: 999px;

  /* ---- MD3 elevation (cool neutral shadow, no purple) ---- */
  --md-sys-elevation-0: none;
  --md-sys-elevation-1: 0 1px 2px rgba(15,23,42,0.08), 0 1px 3px 1px rgba(15,23,42,0.06);
  --md-sys-elevation-2: 0 1px 2px rgba(15,23,42,0.08), 0 2px 6px 2px rgba(15,23,42,0.08);
  --md-sys-elevation-3: 0 4px 8px 3px rgba(15,23,42,0.10);
  --md-sys-elevation-4: 0 6px 10px 4px rgba(15,23,42,0.12);

  /* ---- Backwards-compat aliases (main.css / admin.css use --md-elevation-*) ---- */
  --md-elevation-0: var(--md-sys-elevation-0);
  --md-elevation-1: var(--md-sys-elevation-1);
  --md-elevation-2: var(--md-sys-elevation-2);
  --md-elevation-3: var(--md-sys-elevation-3);
  --md-elevation-4: var(--md-sys-elevation-4);

  /* ---- MD3 typography scale ---- */
  --md-sys-typescale-display-small: 2.25rem;
  --md-sys-typescale-headline-large: 2rem;
  --md-sys-typescale-headline-medium: 1.5rem;
  --md-sys-typescale-headline-small: 1.25rem;
  --md-sys-typescale-title-large: 1.25rem;
  --md-sys-typescale-title-medium: 1.125rem;
  --md-sys-typescale-title-small: 1rem;
  --md-sys-typescale-body-large: 1rem;
  --md-sys-typescale-body-medium: 0.95rem;
  --md-sys-typescale-body-small: 0.85rem;
  --md-sys-typescale-label-large: 0.95rem;
  --md-sys-typescale-label-medium: 0.85rem;
  --md-sys-typescale-label-small: 0.75rem;

  /* ---- MD3 font weight ---- */
  --md-sys-font-weight-regular: 400;
  --md-sys-font-weight-medium: 500;
  --md-sys-font-weight-bold: 700;

  /* ---- MD3 line height ---- */
  --md-sys-line-height-headline: 1.25;
  --md-sys-line-height-body: 1.55;

  /* ---- MD3 motion ---- */
  --md-duration-short: 150ms;
  --md-duration-medium: 250ms;
  --md-duration-long: 400ms;
  --md-easing-standard: cubic-bezier(0.20, 0, 0, 1);
  --md-easing-emphasized: cubic-bezier(0.16, 1, 0.3, 1);
  --md-easing-decelerate: cubic-bezier(0, 0, 0, 1);

  /* ---- Spacing scale (4px base) ---- */
  --space-0: 0;
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-7: 28px;
  --space-8: 32px;
  --space-9: 36px;
  --space-10: 48px;
  --space-11: 56px;
  --space-12: 64px;

  /* ---- Legacy ACG tokens (kept for inline compatibility) ---- */
  --acg-primary: #2196F3;
  --acg-secondary: #565F71;
  --acg-danger: #D8392B;
  --acg-text-strong: #1A1C1E;
  --acg-text-muted: #5F6368;
  --acg-card-bg: #FFFFFF;
  --acg-border: rgba(16, 24, 40, 0.10);
  --acg-bg-overlay: rgba(10, 12, 28, 0.45);
  --acg-radius: 14px;
  --acg-radius-full: 999px;
  --acg-shadow-card: rgba(15, 23, 42, 0.10) 0px 7px 24px 0px;
  --acg-shadow-nav: 0 8px 30px 0px rgba(15, 23, 42, 0.06);
  --acg-gradient: linear-gradient(135deg, #2196F3, #64B5F6);
  --acg-gradient-danger: linear-gradient(135deg, #FF6B5E, #D8392B);
  --acg-hero-bg: rgba(255, 255, 255, 0.94);
  --acg-chip-bg: rgba(239, 241, 244, 0.9);
}

/* =========================================================================
 * 2. Reset
 * ========================================================================= */
*, *::before, *::after { box-sizing: border-box; }
html { font-size: 15px; -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: var(--md-sys-typescale-body-medium);
  line-height: var(--md-sys-line-height-body);
  color: var(--md-sys-color-on-background);
  background-color: var(--md-sys-color-background);
  background-image: linear-gradient(180deg, rgba(33,150,243,0.04), transparent 240px);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  min-height: 100vh;
}
a { color: inherit; text-decoration: none; }
a:hover { text-decoration: none; }
button { font-family: inherit; cursor: pointer; }
img, svg, video { max-width: 100%; display: block; }
input, select, textarea, button { font-family: inherit; font-size: inherit; color: inherit; }
h1, h2, h3, h4, h5, h6 { margin: 0; line-height: var(--md-sys-line-height-headline); font-weight: var(--md-sys-font-weight-medium); color: var(--md-sys-color-on-surface); }
p { margin: 0; }
ul, ol { margin: 0; padding: 0; list-style: none; }
code, pre { font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace; }

/* =========================================================================
 * 3. Layout primitives
 * ========================================================================= */
.container { width: 100%; max-width: 1140px; margin-inline: auto; padding-inline: 16px; }
.container-narrow { max-width: 880px; }

/* =========================================================================
 * 4. Utilities
 * ========================================================================= */
.hidden { display: none !important; }
.text-center { text-align: center; }
.text-muted { color: var(--md-sys-color-on-surface-variant); }
.text-error { color: var(--md-sys-color-error); }
.w-full { width: 100%; }
.flex-1 { flex: 1 1 0%; }

/* SVG icons (referenced from the shared sprite via <use href="#icon-..">) */
.icon {
  width: 1.4em; height: 1.4em; flex: none; display: inline-block;
  fill: none; stroke: currentColor; stroke-width: 1.8;
  stroke-linecap: round; stroke-linejoin: round; vertical-align: -0.22em;
}
.icon--brand { width: 20px; height: 20px; vertical-align: -0.32em; }

.flex { display: flex; }
.inline-flex { display: inline-flex; }
.grid { display: grid; }
.block { display: block; }

.items-start { align-items: flex-start; }
.items-center { align-items: center; }
.items-end { align-items: flex-end; }
.items-stretch { align-items: stretch; }

.justify-start { justify-content: flex-start; }
.justify-center { justify-content: center; }
.justify-between { justify-content: space-between; }
.justify-end { justify-content: flex-end; }

.flex-wrap { flex-wrap: wrap; }
.flex-col { flex-direction: column; }
.grow { flex: 1 1 0%; }

.gap-1 { gap: var(--space-1); }
.gap-2 { gap: var(--space-2); }
.gap-3 { gap: var(--space-3); }
.gap-4 { gap: var(--space-4); }
.gap-5 { gap: var(--space-5); }
.gap-6 { gap: var(--space-6); }

.mt-1 { margin-top: var(--space-1); }
.mt-2 { margin-top: var(--space-2); }
.mt-3 { margin-top: var(--space-3); }
.mt-4 { margin-top: var(--space-4); }
.mt-5 { margin-top: var(--space-5); }
.mt-6 { margin-top: var(--space-6); }
.mb-1 { margin-bottom: var(--space-1); }
.mb-2 { margin-bottom: var(--space-2); }
.mb-3 { margin-bottom: var(--space-3); }
.mb-4 { margin-bottom: var(--space-4); }
.mb-5 { margin-bottom: var(--space-5); }
.mb-6 { margin-bottom: var(--space-6); }

/* Form layout helpers (used by settings & merchant forms) */
.form-row { display: grid; gap: var(--space-2); padding-block: var(--space-2); border-bottom: 1px solid var(--md-sys-color-outline-variant); }
.form-row:last-child { border-bottom: none; }
.form-label { font-size: var(--md-sys-typescale-body-small); font-weight: var(--md-sys-font-weight-medium); color: var(--md-sys-color-on-surface-variant); }

/* =========================================================================
 * 5. Buttons
 * ========================================================================= */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 10px 22px;
  font-size: var(--md-sys-typescale-label-large);
  font-weight: var(--md-sys-font-weight-medium); line-height: 1;
  border-radius: var(--md-radius-full); border: 1px solid transparent;
  background: var(--md-sys-color-surface-container-high);
  color: var(--md-sys-color-on-surface);
  cursor: pointer; white-space: nowrap;
  transition: background-color var(--md-duration-short) var(--md-easing-standard),
              box-shadow var(--md-duration-short) var(--md-easing-standard),
              transform var(--md-duration-short) var(--md-easing-standard),
              color var(--md-duration-short) var(--md-easing-standard);
}
.btn:hover { background: var(--md-sys-color-surface-container-highest); }
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: 2px solid var(--md-sys-color-primary); outline-offset: 2px; }

.btn-primary {
  background: var(--md-sys-color-primary); color: #fff;
  box-shadow: 0 2px 6px rgba(33,150,243,0.28);
}
.btn-primary:hover { box-shadow: var(--md-elevation-2); background: var(--md-sys-color-primary); filter: brightness(1.05); }
.btn-primary:active { filter: brightness(0.96); }

.btn-secondary {
  background: var(--md-sys-color-surface);
  color: var(--md-sys-color-primary);
  border-color: var(--md-sys-color-outline-variant);
}
.btn-secondary:hover { background: var(--md-sys-color-surface-container); }

.btn-filled { background: var(--md-sys-color-primary); color: #fff; }

.btn-text {
  background: transparent; color: var(--md-sys-color-primary);
  padding-inline: 12px; min-height: 36px;
}
.btn-text:hover { background: var(--md-sys-color-primary-container); }

.btn-error {
  background: var(--md-sys-color-error-container);
  color: var(--md-sys-color-on-error-container);
}
.btn-error:hover { background: var(--md-sys-color-error); color: var(--md-sys-color-on-error); }

.btn-icon {
  min-width: 44px; width: 44px; height: 44px; padding: 0;
  background: transparent; color: var(--md-sys-color-on-surface-variant);
  border-radius: 50%;
}
.btn-icon:hover { background: var(--md-sys-color-surface-container-high); color: var(--md-sys-color-on-surface); }

.btn-sm { min-height: 32px; padding: 6px 14px; font-size: var(--md-sys-typescale-label-medium); }
.btn-lg { min-height: 48px; padding: 12px 28px; font-size: var(--md-sys-typescale-title-small); }

.btn:disabled, .btn[aria-disabled="true"] {
  opacity: 0.45; cursor: not-allowed; filter: grayscale(0.2);
  box-shadow: none; transform: none;
}

/* =========================================================================
 * 6. Form controls
 * ========================================================================= */
.input, .select, .textarea {
  width: 100%; min-height: 44px; padding: 10px 14px;
  color: var(--md-sys-color-on-surface);
  background: var(--md-sys-color-surface);
  border: 1px solid var(--md-sys-color-outline-variant);
  border-radius: var(--md-radius-medium);
  transition: border-color var(--md-duration-short) var(--md-easing-standard),
              box-shadow var(--md-duration-short) var(--md-easing-standard),
              background-color var(--md-duration-short) var(--md-easing-standard);
}
.textarea { min-height: 88px; resize: vertical; line-height: var(--md-sys-line-height-body); }
.input::placeholder, .textarea::placeholder { color: #9aa0ad; }
.input:hover, .select:hover, .textarea:hover { border-color: var(--md-sys-color-outline); }
.input:focus, .select:focus, .textarea:focus {
  border-color: var(--md-sys-color-primary);
  box-shadow: 0 0 0 4px rgba(33,150,243,0.16);
  outline: none; background: var(--md-sys-color-surface);
}
.input:disabled, .select:disabled, .textarea:disabled {
  opacity: 0.5; cursor: not-allowed; background: var(--md-sys-color-surface-container);
}
.select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%234A4458' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; padding-right: 36px; }

/* Toggle switch */
.switch { display: inline-flex; align-items: center; gap: var(--space-2); cursor: pointer; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch::before {
  content: ""; width: 44px; height: 26px; border-radius: var(--md-radius-full);
  background: var(--md-sys-color-surface-variant);
  transition: background-color var(--md-duration-short) var(--md-easing-standard);
  flex: 0 0 auto;
}
.switch::after {
  content: ""; position: absolute; left: 3px; width: 20px; height: 20px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,0.3);
  transform: translateY(-1px);
  transition: transform var(--md-duration-short) var(--md-easing-standard);
}
.switch:has(input:checked)::before { background: var(--md-sys-color-primary); }
.switch:has(input:checked)::after { transform: translate(18px, -1px); }
.switch input:focus-visible + ::before { outline: 2px solid var(--md-sys-color-primary); }

/* =========================================================================
 * 7. Chips
 * ========================================================================= */
.chip-list { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2); }
.chip-list--scroll { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; }
.chip-list--scroll::-webkit-scrollbar { display: none; }

.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 16px; border-radius: var(--md-radius-full);
  background: var(--md-sys-color-surface-container-high);
  color: var(--md-sys-color-on-surface-variant);
  border: 1px solid transparent; cursor: pointer; white-space: nowrap;
  font-size: var(--md-sys-typescale-label-medium); font-weight: var(--md-sys-font-weight-medium);
  transition: background-color var(--md-duration-short) var(--md-easing-standard),
              color var(--md-duration-short) var(--md-easing-standard),
              box-shadow var(--md-duration-short) var(--md-easing-standard);
}
.chip:hover { background: var(--md-sys-color-surface-container-highest); color: var(--md-sys-color-on-surface); }
.chip.is-active {
  color: var(--md-sys-color-on-primary-container);
  background: var(--md-sys-color-primary-container);
}
.chip.is-active:hover { color: var(--md-sys-color-on-primary-container); }

/* =========================================================================
 * 8. Panel & Card
 * ========================================================================= */
.panel {
  background: var(--md-sys-color-surface);
  color: var(--md-sys-color-on-surface);
  border: 1px solid var(--md-sys-color-outline-variant);
  border-radius: var(--md-radius-large);
  box-shadow: var(--md-sys-elevation-1);
  padding: var(--space-5);
}
.panel + .panel { margin-top: var(--space-4); }
.panel__title { font-size: var(--md-sys-typescale-title-large); font-weight: var(--md-sys-font-weight-medium); margin-bottom: var(--space-4); color: var(--md-sys-color-on-surface); }
.panel-header { display: flex; align-items: center; gap: 10px; padding: 14px 18px; border-bottom: 1px solid var(--md-sys-color-outline-variant); }
.panel-header h3 { font-size: var(--md-sys-typescale-title-medium); font-weight: var(--md-sys-font-weight-medium); }
.panel-body { padding: var(--space-4) var(--space-5); }

.card {
  background: var(--md-sys-color-surface);
  border: 1px solid var(--md-sys-color-outline-variant);
  border-radius: var(--md-radius-large);
  box-shadow: var(--md-sys-elevation-1);
  overflow: hidden;
}
.card__header {
  display: flex; align-items: center; justify-content: space-between; gap: var(--space-3);
  padding: 14px 18px; border-bottom: 1px solid var(--md-sys-color-outline-variant);
}
.card__label { font-size: var(--md-sys-typescale-body-medium); font-weight: var(--md-sys-font-weight-medium); color: var(--md-sys-color-on-surface-variant); }
.card__body { padding: var(--space-4) var(--space-5); }

/* =========================================================================
 * 9. Status badges
 * ========================================================================= */
.badge {
  display: inline-flex; align-items: center; gap: 6px;
  min-height: 24px; padding: 2px 12px;
  font-size: var(--md-sys-typescale-label-medium); font-weight: var(--md-sys-font-weight-medium);
  line-height: 1; border-radius: var(--md-radius-full); white-space: nowrap;
}
.badge-success { background: var(--md-sys-color-success-container); color: var(--md-sys-color-on-success-container); }
.badge-warning { background: var(--md-sys-color-warning-container); color: var(--md-sys-color-on-warning-container); }
.badge-error { background: var(--md-sys-color-error-container); color: var(--md-sys-color-on-error-container); }
.badge-info { background: var(--md-sys-color-info-container); color: var(--md-sys-color-on-info-container); }

/* =========================================================================
 * 10. Toast / snackbar
 * ========================================================================= */
.toast {
  position: fixed; left: 50%; bottom: var(--space-6); z-index: 2000;
  transform: translateX(-50%) translateY(140%);
  display: inline-flex; align-items: center; gap: var(--space-3);
  min-height: 48px; padding: var(--space-2) var(--space-5);
  color: var(--md-sys-color-inverse-on-surface);
  background: var(--md-sys-color-inverse-surface);
  border-radius: var(--md-radius-small);
  box-shadow: var(--md-sys-elevation-3);
  font-size: var(--md-sys-typescale-body-medium);
  opacity: 0; pointer-events: none;
  transition: transform var(--md-duration-medium) var(--md-easing-emphasized),
              opacity var(--md-duration-medium) var(--md-easing-emphasized);
}
.toast.is-visible { transform: translateX(-50%) translateY(0); opacity: 1; pointer-events: auto; }
.toast--success { color: var(--md-sys-color-on-success-container); background: var(--md-sys-color-success-container); }
.toast--error { color: var(--md-sys-color-on-error-container); background: var(--md-sys-color-error-container); }

/* =========================================================================
 * 11. Empty state
 * ========================================================================= */
.empty-state {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: var(--space-3); padding: var(--space-10) var(--space-4); text-align: center;
  color: var(--md-sys-color-on-surface-variant);
}
.empty-state__icon { width: 88px; height: 88px; color: var(--md-sys-color-outline); }
.empty-state__title { font-size: var(--md-sys-typescale-title-large); font-weight: var(--md-sys-font-weight-medium); color: var(--md-sys-color-on-surface); }
.empty-state__action { margin-top: var(--space-2); }

/* =========================================================================
 * 12. Skeleton & spinner
 * ========================================================================= */
.skeleton {
  position: relative; overflow: hidden; border-radius: var(--md-radius-medium);
  background: var(--md-sys-color-surface-container-high); min-height: 16px;
}
.skeleton::after {
  content: ""; position: absolute; inset: 0; transform: translateX(-100%);
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.55), transparent);
  animation: skeleton-shimmer 1.4s infinite;
}
@keyframes skeleton-shimmer { to { transform: translateX(100%); } }

.spinner { display: inline-grid; width: 20px; height: 20px; place-items: center; }
.spinner::before {
  content: ""; width: 18px; height: 18px; border-radius: 50%;
  border: 2px solid var(--md-sys-color-outline-variant); border-top-color: var(--md-sys-color-primary);
  animation: spinner-rotate 0.8s linear infinite;
}
@keyframes spinner-rotate { to { transform: rotate(360deg); } }

/* =========================================================================
 * 13. Generic table
 * ========================================================================= */
.table-wrap {
  overflow-x: auto; border-radius: var(--md-radius-large);
  border: 1px solid var(--md-sys-color-outline-variant);
  background: var(--md-sys-color-surface); box-shadow: var(--md-sys-elevation-1);
}
.table { width: 100%; border-collapse: collapse; font-size: var(--md-sys-typescale-body-medium); text-align: left; color: var(--md-sys-color-on-surface); }
.table thead { background: var(--md-sys-color-surface-container-high); }
.table th, .table td { padding: var(--space-3) var(--space-4); border-bottom: 1px solid var(--md-sys-color-outline-variant); white-space: nowrap; }
.table th { font-size: var(--md-sys-typescale-label-large); font-weight: var(--md-sys-font-weight-medium); color: var(--md-sys-color-on-surface-variant); }
.table tbody tr { transition: background-color var(--md-duration-short) var(--md-easing-standard); }
.table tbody tr:hover { background: var(--md-sys-color-surface-container); }
.table tbody tr:last-child td { border-bottom: none; }
.table__empty { text-align: center; color: var(--md-sys-color-on-surface-variant); padding: var(--space-8) var(--space-4); }

/* =========================================================================
 * 14. Glass surface (auth / checkout cards on the brand gradient)
 * ========================================================================= */
.glass {
  background: var(--surface-glass);
  backdrop-filter: blur(18px) saturate(160%);
  -webkit-backdrop-filter: blur(18px) saturate(160%);
  border: 1px solid rgba(255,255,255,0.55);
  box-shadow: var(--md-sys-elevation-3);
}

/* =========================================================================
 * 14b. Entrance motion
 * ========================================================================= */
@keyframes fade-up {
  from { opacity: 0; transform: translateY(14px); }
  to   { opacity: 1; transform: translateY(0); }
}
.reveal { opacity: 0; animation: fade-up var(--md-duration-long) var(--md-easing-emphasized) forwards; }

/* =========================================================================
 * 15. Focus & selection
 * ========================================================================= */
:focus-visible { outline: 2px solid var(--md-sys-color-primary); outline-offset: 2px; }
::selection { background: rgba(33,150,243,0.18); color: inherit; }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; scroll-behavior: auto !important; }
}

/* =========================================================================
 * 16. Dark theme — driven by [data-theme="dark"] on <html>
 *     (set by theme.js / inline guard). Overrides every color role so the
 *     whole MD3 system re-skins automatically; glass surfaces get darkened
 *     below in main.css / admin.css via the same selector.
 * ========================================================================= */
:root[data-theme="dark"] {
  /* Brand color roles (dark) */
  --md-sys-color-primary: #A8C7FA;
  --md-sys-color-on-primary: #0A305F;
  --md-sys-color-primary-container: #284777;
  --md-sys-color-on-primary-container: #D3E3FD;
  --md-sys-color-secondary: #BEC6DC;
  --md-sys-color-on-secondary: #283141;
  --md-sys-color-secondary-container: #3E4759;
  --md-sys-color-on-secondary-container: #DAE2F9;
  --md-sys-color-tertiary: #A6D6D2;
  --md-sys-color-on-tertiary: #003735;
  --md-sys-color-tertiary-container: #1F4D4B;
  --md-sys-color-on-tertiary-container: #BCECE9;

  --md-sys-color-accent: #FFB4AB;
  --md-sys-color-on-accent: #5E110A;
  --md-sys-color-accent-container: #93000A;
  --md-sys-color-on-accent-container: #FFDAD5;

  --md-sys-color-success: #A5F0B4;
  --md-sys-color-on-success-container: #02240F;
  --md-sys-color-success-container: #0E4D2F;
  --md-sys-color-error: #FFB4AB;
  --md-sys-color-on-error: #690005;
  --md-sys-color-error-container: #93000A;
  --md-sys-color-on-error-container: #FFDAD6;
  --md-sys-color-warning: #FFCB7A;
  --md-sys-color-on-warning-container: #2B1700;
  --md-sys-color-warning-container: #5C3A00;
  --md-sys-color-info: #BEC2FF;
  --md-sys-color-on-info-container: #001E33;
  --md-sys-color-info-container: #28339B;

  /* Neutral surfaces (dark) */
  --md-sys-color-background: #0D131A;
  --md-sys-color-on-background: #DCE5EF;
  --md-sys-color-surface: #141C25;
  --md-sys-color-on-surface: #DCE5EF;
  --md-sys-color-surface-variant: #29343F;
  --md-sys-color-on-surface-variant: #A6B4C2;
  --md-sys-color-surface-container: #18222D;
  --md-sys-color-surface-container-high: #212D3A;
  --md-sys-color-surface-container-highest: #2A3744;
  --md-sys-color-outline: #3C4A58;
  --md-sys-color-outline-variant: #29343F;
  --md-sys-color-inverse-surface: #DCE5EF;
  --md-sys-color-inverse-on-surface: #141C25;
  --md-sys-color-inverse-primary: #2196F3;
  --md-sys-color-surface-tint: #A8C7FA;

  /* Brand / glass tokens (dark) */
  --brand-gradient: linear-gradient(135deg, #64B5F6 0%, #2196F3 100%);
  --brand-gradient-accent: linear-gradient(135deg, #64B5F6 0%, #2196F3 100%);
  --surface-glass: rgba(26, 28, 32, 0.92);
  --surface-glass-strong: rgba(26, 28, 32, 0.96);
  --nav-bg: rgba(26, 28, 32, 0.92);
  --footer-bg: rgba(17, 19, 23, 0.92);
  --hairline: rgba(255, 255, 255, 0.09);
  --shadow-soft: 0 10px 30px rgba(0, 0, 0, 0.40);

  /* Elevation reads softer on dark surfaces */
  --md-sys-elevation-1: 0 1px 2px rgba(0,0,0,0.40), 0 1px 3px 1px rgba(0,0,0,0.30);
  --md-sys-elevation-2: 0 1px 2px rgba(0,0,0,0.40), 0 2px 6px 2px rgba(0,0,0,0.36);
  --md-sys-elevation-3: 0 4px 8px 3px rgba(0,0,0,0.44);
  --md-sys-elevation-4: 0 6px 10px 4px rgba(0,0,0,0.48);
}

:root[data-theme="dark"] body {
  background-image: linear-gradient(180deg, rgba(168,199,250,0.06), transparent 240px);
}

/* Form control placeholder contrast in dark mode */
:root[data-theme="dark"] .input::placeholder,
:root[data-theme="dark"] .textarea::placeholder { color: #8C8893; }
