/* Cards Realm ERP - design system. Light by default, dark via [data-theme="dark"]
   (explicit toggle, static/js/theme.js) or prefers-color-scheme (no toggle set yet). */

:root {
  --bg: #f5f6fb;
  --bg-elevated: #ffffff;
  --bg-subtle: #eef0f7;
  --text: #14171f;
  --text-muted: #676e7d;
  --border: #e6e8f0;
  --primary: #3d5afe;
  --primary-hover: #2f46e0;
  --primary-contrast: #ffffff;
  --success: #16a34a;
  --success-bg: #e8f8ee;
  --danger: #dc2626;
  --danger-bg: #fdecec;
  --warning: #d97706;
  --warning-bg: #fdf3e2;
  --radius-lg: 16px;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow-sm: 0 1px 2px rgba(20, 23, 31, 0.06);
  --shadow: 0 2px 8px rgba(20, 23, 31, 0.06), 0 8px 24px rgba(20, 23, 31, 0.06);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, Helvetica, Arial, sans-serif;

  --store-primary: #1c1c1c;
  --store-secondary: #eae393;
  --store-accent: #ffffff;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0d0f14;
    --bg-elevated: #171a22;
    --bg-subtle: #1e222c;
    --text: #eef0f5;
    --text-muted: #9aa1b0;
    --border: #2a2f3c;
    --primary: #6684ff;
    --primary-hover: #869cff;
    --success: #34d377;
    --success-bg: #113321;
    --danger: #f45b5b;
    --danger-bg: #3a1818;
    --warning: #f0a83c;
    --warning-bg: #3a2c11;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow: 0 2px 8px rgba(0, 0, 0, 0.35), 0 12px 32px rgba(0, 0, 0, 0.35);
  }
}

:root[data-theme="dark"] {
  --bg: #0d0f14;
  --bg-elevated: #171a22;
  --bg-subtle: #1e222c;
  --text: #eef0f5;
  --text-muted: #9aa1b0;
  --border: #2a2f3c;
  --primary: #6684ff;
  --primary-hover: #869cff;
  --success: #34d377;
  --success-bg: #113321;
  --danger: #f45b5b;
  --danger-bg: #3a1818;
  --warning: #f0a83c;
  --warning-bg: #3a2c11;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow: 0 2px 8px rgba(0, 0, 0, 0.35), 0 12px 32px rgba(0, 0, 0, 0.35);
}

* { box-sizing: border-box; }

html { color-scheme: light dark; }

body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  transition: background-color 0.15s ease, color 0.15s ease;
}

h1, h2, h3 { letter-spacing: -0.02em; line-height: 1.2; }
h1 { font-size: 1.75rem; font-weight: 700; margin: 0 0 0.25rem; }
h2 { font-size: 1.3rem; font-weight: 650; }
h3 { font-size: 1.05rem; font-weight: 650; margin: 0.5rem 0 0.15rem; }

a { color: var(--primary); }

/* ---------- App shell / top nav ---------- */
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding: 0.85rem 1.5rem;
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 20;
}

/* Breadcrumb trail (templates/breadcrumb.html) - below the topbar on every
   merchant-admin page (base.html), one store's worth of settings pages was
   getting hard to navigate back out of with no trail. */
.breadcrumb {
  padding: 0.6rem 1.5rem;
  background: var(--bg-subtle);
  border-bottom: 1px solid var(--border);
  font-size: 0.85rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-wrap: wrap;
}
.breadcrumb a { color: var(--text-muted); text-decoration: none; }
.breadcrumb a:hover { color: var(--primary); text-decoration: underline; }
.breadcrumb-sep { color: var(--border); }
.breadcrumb-current { color: var(--text); font-weight: 600; }

.topbar .brand {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 750;
  font-size: 1.05rem;
  text-decoration: none;
  color: var(--text);
}
.topbar .brand .brand-mark {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--primary), #8fa4ff);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 800;
  font-size: 0.85rem;
}

.topbar nav { display: flex; align-items: center; gap: 1.1rem; }
.topbar nav a { color: var(--text-muted); text-decoration: none; font-size: 0.92rem; font-weight: 550; }
.topbar nav a:hover { color: var(--text); }
.topbar .user-name { color: var(--text-muted); font-size: 0.9rem; }

.theme-toggle {
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  color: var(--text);
  width: 36px;
  height: 36px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
}
.theme-toggle:hover { background: var(--border); }
.icon-moon { display: none; }
:root[data-theme="dark"] .icon-sun { display: none; }
:root[data-theme="dark"] .icon-moon { display: block; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .icon-sun { display: none; }
  :root:not([data-theme="light"]) .icon-moon { display: block; }
}

/* Storefront cart icon (templates/cart_icon.html) - sits next to the
   theme toggle on every public storefront-family page. The badge only
   appears once there's at least one item (server-rendered on page load,
   updated live by erpUpdateCartBadge() right after an add-to-cart POST). */
.cart-icon-link {
  position: relative;
  display: inline-flex;
  align-items: center;
  color: var(--text);
  text-decoration: none;
  width: 36px;
  height: 36px;
  justify-content: center;
}
.cart-badge {
  position: absolute;
  top: -4px;
  right: -6px;
  background: var(--danger);
  color: #fff;
  font-size: 0.7rem;
  font-weight: 700;
  line-height: 1;
  min-width: 18px;
  height: 18px;
  border-radius: 999px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
}

/* Floating WhatsApp chat button (templates/whatsapp_button.html) - fixed
   bottom-right on every storefront page when the store enabled it. Uses
   WhatsApp's own brand green deliberately, NOT the store's --store-primary:
   it's a recognizable third-party affordance, and a store whose brand color
   happens to be white/dark would otherwise render an unrecognizable or
   invisible button. */
.whatsapp-float {
  position: fixed;
  right: 1.25rem;
  bottom: 1.25rem;
  z-index: 1000;
  width: 56px;
  height: 56px;
  border-radius: 999px;
  background: #25d366;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow);
  transition: transform 0.1s ease, box-shadow 0.15s ease;
}
.whatsapp-float:hover { transform: translateY(-2px); box-shadow: 0 8px 20px rgba(0, 0, 0, 0.25); }

.main-content { max-width: 1020px; margin: 0 auto; padding: 2rem 1.5rem 4rem; }

/* ---------- Cards / surfaces ---------- */
.card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 1.5rem;
  margin-bottom: 1.5rem;
}

.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1.25rem;
  flex-wrap: wrap;
}
.page-header a { font-size: 0.9rem; font-weight: 600; text-decoration: none; }

.muted { color: var(--text-muted); font-size: 0.9rem; }

/* ---------- Forms ---------- */
label { display: block; margin-bottom: 0.9rem; font-size: 0.88rem; font-weight: 600; color: var(--text); }
/* [hidden] must win over any other display rule on the same element - the
   input/select/textarea rule below sets `display: block` unconditionally,
   which silently overrides the browser's own `[hidden] { display: none }`
   default the moment `hidden` is used on one of those elements (found by
   actually rendering a hidden file input, not by reading the CSS - it had
   simply never been exercised on a form control before). */
[hidden] { display: none !important; }

input, select, textarea {
  display: block;
  width: 100%;
  padding: 0.6rem 0.75rem;
  margin-top: 0.35rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
  font-family: inherit;
  background: var(--bg-elevated);
  color: var(--text);
  font-weight: 400;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 20%, transparent);
}

button, .button {
  background: var(--primary);
  color: var(--primary-contrast);
  border: none;
  border-radius: var(--radius-sm);
  padding: 0.65rem 1.3rem;
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
  font-size: 0.95rem;
  font-weight: 650;
  transition: background-color 0.15s ease, transform 0.05s ease;
}
button:hover, .button:hover { background: var(--primary-hover); }
button:active, .button:active { transform: translateY(1px); }
button.secondary, .button.secondary {
  background: var(--bg-subtle);
  color: var(--text);
  border: 1px solid var(--border);
}
button.secondary:hover { background: var(--border); }
button.danger-button, .danger-button {
  background: var(--danger);
  color: #fff;
}
button.danger-button:hover, .danger-button:hover { filter: brightness(0.92); }

.form-error { color: var(--danger); margin-top: 0.75rem; font-size: 0.9rem; font-weight: 600; }

.color-row { display: flex; gap: 1rem; }
.color-row label { flex: 1; }
.color-row input { width: 100%; padding: 0.25rem; height: 42px; cursor: pointer; }

.slug-input { display: flex; align-items: center; gap: 0.4rem; }
.slug-input span { color: var(--text-muted); white-space: nowrap; }

/* ---------- Badges ---------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.25rem 0.65rem;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 650;
}
.badge-success { background: var(--success-bg); color: var(--success); }
.badge-warning { background: var(--warning-bg); color: var(--warning); }
.badge-danger { background: var(--danger-bg); color: var(--danger); }
.badge-muted { background: var(--bg-subtle); color: var(--text-muted); }

/* ---------- Dashboard store grid ---------- */
/* "What can I do in my store" menu (templates/store_settings.html) - the
   user pointed out the old flat row of bare "Nome →" text links was too
   simple/unclear about what each one actually does - each tile now has a
   one-line description, not just a label. */
.menu-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 1rem; margin-bottom: 1.5rem; }
.menu-tile {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 1rem 1.1rem;
  text-decoration: none;
  color: inherit;
  transition: box-shadow 0.15s ease, transform 0.1s ease, border-color 0.15s ease;
}
.menu-tile:hover { box-shadow: var(--shadow); transform: translateY(-2px); border-color: var(--primary); }
.menu-tile strong { color: var(--text); font-size: 0.98rem; }
.menu-tile span { color: var(--text-muted); font-size: 0.85rem; line-height: 1.4; }

.store-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 1.1rem; }

.docs-category-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 1.1rem; }
.docs-category-card h2 { margin-top: 0; font-size: 1.15rem; }
.docs-article-list { list-style: none; padding: 0; margin: 0.75rem 0 0; }
.docs-article-list li { margin-bottom: 0.5rem; }
.docs-article-list a { text-decoration: none; font-weight: 600; }
.docs-article-list a:hover { text-decoration: underline; }
.docs-article h1 { margin-top: 0; }
.docs-article p { line-height: 1.6; }
.docs-breadcrumb { text-transform: uppercase; font-size: 0.8rem; letter-spacing: 0.03em; margin-bottom: 0.25rem; }
.store-card { transition: box-shadow 0.15s ease, transform 0.1s ease; }
.store-card:hover { box-shadow: var(--shadow); transform: translateY(-2px); }
.store-card h2 { margin-bottom: 0.2rem; }
.store-card-badges { display: flex; flex-wrap: wrap; gap: 0.4rem; margin: 0.5rem 0; }
/* Was a flat vertical list of ~13 undifferentiated text links - too many
   with no hierarchy to be legible at a glance (see templates/store_home.html
   for the one clear entry point that replaced most of them). Now just a
   primary "open the store" button + a couple of real secondary shortcuts. */
.store-card-actions { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: 0.9rem; }
.store-card-actions .button { font-size: 0.85rem; padding: 0.5rem 0.9rem; }

.empty-state {
  text-align: center;
  padding: 3rem 1.5rem;
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  color: var(--text-muted);
}

/* ---------- Auth ---------- */
.auth-card { max-width: 380px; margin: 3rem auto 0; }

/* ---------- Add-card / search ---------- */
.add-card-row { position: relative; }
.search-results {
  position: absolute;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
  width: 100%;
  max-height: 260px;
  overflow-y: auto;
  z-index: 10;
  margin-top: 0.25rem;
}
.search-results div { padding: 0.55rem 0.75rem; cursor: pointer; display: flex; align-items: center; gap: 0.6rem; }
.search-results div:hover { background: var(--bg-subtle); }
.search-results img { width: 32px; border-radius: 4px; }

.add-card-selected { display: flex; align-items: center; gap: 0.6rem; margin: 0.6rem 0; }
.add-card-selected img { width: 48px; border-radius: var(--radius-sm); }

.flags-row { display: flex; flex-wrap: wrap; gap: 0.75rem; margin-bottom: 0.9rem; }
.flag-label {
  display: flex; align-items: center; gap: 0.35rem; width: auto; font-size: 0.85rem;
  font-weight: 500; background: var(--bg-subtle); padding: 0.3rem 0.6rem; border-radius: 999px;
}
.flag-label input { width: auto; display: inline; margin: 0; }

/* ---------- Inventory table ---------- */
.inventory-table { width: 100%; border-collapse: collapse; margin-top: 1rem; }
.inventory-table th {
  text-align: left; padding: 0.6rem; font-size: 0.78rem; text-transform: uppercase;
  letter-spacing: 0.04em; color: var(--text-muted); border-bottom: 1px solid var(--border);
}
.inventory-table td { text-align: left; padding: 0.65rem 0.6rem; border-bottom: 1px solid var(--border); font-size: 0.92rem; }
.inventory-table tr:hover td { background: var(--bg-subtle); }
.inventory-table .thumb { width: 32px; vertical-align: middle; margin-right: 0.5rem; border-radius: 4px; }
.qty-input, .price-input { width: 90px; margin-top: 0; }

.inventory-search { display: flex; gap: 0.6rem; margin-bottom: 1.25rem; }
.inventory-search input { margin: 0; }

/* ---------- Storefront (branded per-store) ---------- */
body.storefront { background: var(--bg); }
.storefront-header {
  background: linear-gradient(135deg, var(--store-primary), color-mix(in srgb, var(--store-primary) 70%, black));
  color: var(--store-accent);
  padding: 2.75rem 1.5rem 3.25rem;
  text-align: center;
}
.storefront-header h1 { margin: 0.6rem 0 0; font-size: 1.9rem; }
.storefront-header p { color: color-mix(in srgb, var(--store-accent) 80%, transparent); }
.storefront-logo { max-height: 64px; border-radius: var(--radius-sm); }

.product-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 1.1rem; margin-top: 1.5rem; }
.product-card {
  display: block;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 1.1rem;
  text-align: center;
  text-decoration: none;
  color: inherit;
  transition: box-shadow 0.15s ease, transform 0.1s ease;
}
.product-card:hover { box-shadow: var(--shadow); transform: translateY(-2px); }
.product-card img { max-width: 100%; border-radius: var(--radius-sm); margin-bottom: 0.5rem; }
/* Uses a text token, not --store-primary - a merchant's branding color has
   no guaranteed contrast against the page's own background (it's chosen to
   pair with a button, not to stand alone as body text) - found by actually
   looking at a storefront with the schema's default #1c1c1c primary color
   in dark mode, where the price was nearly invisible. */
.product-price { font-weight: 750; color: var(--text); font-size: 1.05rem; margin: 0.3rem 0; }
.product-card form { margin-top: 0.6rem; }
.product-card button { width: 100%; }

/* Generic drag-and-drop file dropzone - originally built for CSV bulk
   import (templates/custom_products.html), reused as-is for the image
   upload widget (static/js/image_upload.js) since the visual language
   (dashed border, hover/active highlight) is identical for any single-
   file drop target. */
.dropzone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 2rem 1rem;
  text-align: center;
  cursor: pointer;
  color: var(--text-muted);
  transition: border-color 0.15s ease, background-color 0.15s ease;
}
.dropzone:hover, .dropzone-active {
  border-color: var(--primary);
  background: color-mix(in srgb, var(--primary) 6%, transparent);
}
.csv-import-progress { margin-top: 1rem; }
.csv-import-bar { height: 8px; border-radius: 999px; background: var(--bg-subtle); overflow: hidden; }
.csv-import-bar-fill { height: 100%; width: 0%; background: var(--primary); transition: width 0.15s ease; }

/* Image dropzone (static/js/image_upload.js) - store logo / custom product
   photo. The dropzone itself doubles as the preview frame once a file is
   chosen (or an existing image is already set) - a data URI shown in the
   same box that says "drop here" when empty, not two separate elements. */
.image-dropzone { padding: 1rem; min-height: 120px; display: flex; align-items: center; justify-content: center; }
.dropzone-preview-img { max-width: 100%; max-height: 160px; border-radius: var(--radius-sm); }
.dropzone-hint { margin: 0; font-size: 0.9rem; }

/* Non-blocking toast notifications - one per CSV row imported, so a
   multi-row import doesn't require dismissing a native alert() per row */
.toast-container {
  position: fixed;
  top: 1rem;
  right: 1rem;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.toast {
  background: var(--success);
  color: #fff;
  padding: 0.6rem 1rem;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
  font-size: 0.9rem;
  font-weight: 600;
  animation: toast-in 0.15s ease;
}
.toast-error { background: var(--danger); }
@keyframes toast-in {
  from { opacity: 0; transform: translateY(-6px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Store style screen (templates/store_settings.html) - live preview mockup
   of the storefront header/card so a lojista sees the effect of a color/
   logo/name change before saving, without needing to open the real public
   page in another tab. */
.style-editor { display: flex; gap: 1.5rem; flex-wrap: wrap; align-items: flex-start; }
.style-editor .card { flex: 1; min-width: 300px; }
.style-preview {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  transition: background-color 0.15s ease;
}
.style-preview-header {
  padding: 1.25rem 1rem;
  text-align: center;
  color: #fff;
  transition: background-color 0.15s ease;
}
.style-preview-header img { max-height: 40px; display: block; margin: 0 auto 0.4rem; border-radius: 4px; }
.style-preview-body { padding: 1.25rem; }
.style-preview-card-mock {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 1rem;
  text-align: center;
}
.style-preview-price { font-weight: 750; font-size: 1.1rem; margin-bottom: 0.6rem; transition: color 0.15s ease; }
.style-preview-card-mock button { width: 100%; border: none; color: #fff; padding: 0.5rem; border-radius: var(--radius-sm); cursor: default; transition: background-color 0.15s ease; }

/* Promotional (compare-at) pricing - original price struck through, sale
   price in the store's accent color so it reads as "the deal" */
.price-was { text-decoration: line-through; color: var(--text-muted); margin-right: 0.4rem; }
.price-now { font-weight: 750; color: var(--danger); }

/* Variant selector on a grouped card product page (Mox Land/Meruru-style) */
.variant-list { display: flex; flex-direction: column; gap: 0.6rem; margin: 1rem 0; }
.variant-row {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: 0.75rem 1rem; border: 1px solid var(--border); border-radius: var(--radius-sm);
}
.variant-row.out-of-stock { opacity: 0.55; }
.variant-badges { display: flex; gap: 0.35rem; flex-wrap: wrap; margin-top: 0.25rem; }
.variant-badge {
  font-size: 0.72rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.03em;
  padding: 0.15rem 0.5rem; border-radius: 999px; background: var(--bg-subtle); color: var(--text-muted);
}

.cart-row { display: flex; align-items: center; gap: 0.9rem; padding: 0.7rem 0; border-bottom: 1px solid var(--border); }
.cart-row:last-child { border-bottom: none; }
.cart-row .thumb { width: 44px; border-radius: var(--radius-sm); }
.cart-row-info { flex: 1; }
.cart-row-price { font-weight: 650; }
.cart-summary { margin-top: 1rem; }
.cart-total { font-size: 1.2rem; font-weight: 750; }

.site-footer { text-align: center; padding: 2rem 1.5rem; color: var(--text-muted); font-size: 0.85rem; }
.storefront-contact { margin-bottom: 1rem; }
.storefront-contact p { margin: 0.15rem 0; }
.legal-links { margin-top: 0.25rem; }
.legal-links a { color: var(--text-muted); text-decoration: underline; }

/* ---------- Legal pages (Terms / Privacy) ---------- */
.legal-doc { max-width: 760px; margin: 0 auto; line-height: 1.6; }
.legal-doc h2 { margin-top: 1.75rem; }
.legal-doc ul { padding-left: 1.25rem; }
.legal-doc li { margin-bottom: 0.4rem; }
.legal-notice {
  background: var(--warning-bg);
  color: var(--warning);
  border-radius: var(--radius-sm);
  padding: 0.85rem 1rem;
  font-size: 0.9rem;
  font-weight: 600;
}

.consent-checkbox { display: flex; align-items: flex-start; gap: 0.5rem; font-weight: 400; font-size: 0.88rem; }
.consent-checkbox input { width: auto; margin: 0.2rem 0 0; }

/* ---------- API docs code blocks ---------- */
.legal-doc code {
  background: var(--bg-subtle);
  padding: 0.15rem 0.4rem;
  border-radius: 4px;
  font-size: 0.85em;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
.legal-doc pre {
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 1rem;
  overflow-x: auto;
}
.legal-doc pre code { background: none; padding: 0; font-size: 0.85rem; }

/* ---------- Reports: stat tiles + chart (see dataviz skill guidance) ---------- */
:root {
  --chart-series: #2a78d6;
  --chart-series-dark: #3987e5;
  --chart-grid: var(--border);
}
:root[data-theme="dark"] { --chart-series: var(--chart-series-dark); }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) { --chart-series: var(--chart-series-dark); }
}

.kpi-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 1rem; margin-bottom: 1.5rem; }
.stat-tile {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.1rem 1.2rem;
  box-shadow: var(--shadow-sm);
}
.stat-tile .stat-label { color: var(--text-muted); font-size: 0.82rem; font-weight: 600; }
.stat-tile .stat-value { font-size: 1.6rem; font-weight: 700; margin-top: 0.2rem; letter-spacing: -0.01em; }

.range-picker { display: flex; gap: 0.5rem; margin-bottom: 1.25rem; }
.range-picker a {
  padding: 0.4rem 0.9rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.88rem;
  font-weight: 600;
}
.range-picker a.active { background: var(--primary); color: #fff; border-color: var(--primary); }

.chart-wrap { position: relative; }
.chart-tooltip {
  position: absolute;
  background: var(--text);
  color: var(--bg-elevated);
  padding: 0.4rem 0.6rem;
  border-radius: 6px;
  font-size: 0.78rem;
  pointer-events: none;
  white-space: nowrap;
  transform: translate(-50%, -110%);
  opacity: 0;
  transition: opacity 0.1s ease;
  z-index: 5;
}
.chart-tooltip.visible { opacity: 1; }
.chart-bar { fill: var(--chart-series); rx: 4; }
.chart-bar:hover { opacity: 0.85; cursor: pointer; }
.chart-axis-label { fill: var(--muted, var(--text-muted)); font-size: 11px; }
.chart-gridline { stroke: var(--chart-grid); stroke-width: 1; }

/* ---------- Responsive ---------- */
@media (max-width: 640px) {
  .main-content { padding: 1.25rem 1rem 3rem; }
  .topbar { padding: 0.7rem 1rem; }
  .color-row { flex-direction: column; }
}
