/* GenGadgets investor portal. Tokens follow the "GenGadgets Investor Ledger" design direction. */

@font-face {
  font-family: "Geist";
  src: url("../fonts/Geist-Variable.woff2") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

:root {
  color-scheme: light;
  --bg: #f6f5f3;
  --surface: #ffffff;
  --ink: #211e1c;
  --muted: #6b6560;
  --line: #e7e3df;
  --line-strong: #d6d0ca;
  --accent: #e2412e;
  --accent-ink: #c2321f;
  --accent-soft: #fdecea;
  --series-1: #2a78d6;
  --series-1-soft: #9ec5f4;
  --series-2: #e2412e;
  --negative: #b42318;
  --focus: 0 0 0 3px rgba(226, 65, 46, 0.28);
  --r-sm: 6px;
  --r-md: 12px;
  --r-btn: 10px;
  --font: "Geist", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #151413;
    --surface: #1e1c1b;
    --ink: #f1eeea;
    --muted: #a39c95;
    --line: #302c2a;
    --line-strong: #423d3a;
    --accent: #ef5a44;
    --accent-ink: #f37a68;
    --accent-soft: #3a1f1a;
    --series-1: #3987e5;
    --series-1-soft: #184f95;
    --series-2: #e8553f;
    --negative: #f0806f;
    --focus: 0 0 0 3px rgba(239, 90, 68, 0.4);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #151413;
  --surface: #1e1c1b;
  --ink: #f1eeea;
  --muted: #a39c95;
  --line: #302c2a;
  --line-strong: #423d3a;
  --accent: #ef5a44;
  --accent-ink: #f37a68;
  --accent-soft: #3a1f1a;
  --series-1: #3987e5;
  --series-1-soft: #184f95;
  --series-2: #e8553f;
  --negative: #f0806f;
}

/* ---------- Base (scoped so nothing from the parent theme matters) ---------- */
html { -webkit-text-size-adjust: 100%; }
html, body.gg-portal { max-width: 100%; overflow-x: clip; }
body.gg-portal {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
.gg-portal *, .gg-portal *::before, .gg-portal *::after { box-sizing: border-box; }
.gg-portal :where(h1, h2, h3, p, dl, dd, ul, figure) { margin: 0; padding: 0; }
.gg-portal :where(h1, h2, h3) { font-weight: 600; line-height: 1.15; letter-spacing: -0.01em; color: var(--ink); }
.gg-portal :where(a) { color: var(--accent-ink); text-decoration: none; }
.gg-portal :where(a:hover) { text-decoration: underline; }
.gg-portal :where(button, input, select, textarea) { font: inherit; color: inherit; }
.gg-portal :where(button, a, input, select, summary):focus-visible { outline: none; box-shadow: var(--focus); border-radius: var(--r-sm); }
.gg-sr { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.gg-muted { color: var(--muted); }
.gg-right { text-align: right; }
.is-neg { color: var(--negative); }
#wpadminbar { position: fixed !important; }

/* ---------- Brand ---------- */
.gg-brand { display: inline-flex; align-items: center; gap: 10px; color: var(--ink); }
.gg-brand img { width: 32px; height: 32px; border-radius: 8px; display: block; }
.gg-brand__name { font-weight: 700; font-size: 19px; letter-spacing: -0.02em; }
.gg-brand__tag {
  font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--muted); border-left: 1px solid var(--line-strong); padding-left: 10px;
}

/* ---------- Buttons & inputs ---------- */
.gg-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 42px; padding: 0 16px; border-radius: var(--r-btn);
  border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink);
  font-weight: 600; font-size: 14px; cursor: pointer; text-decoration: none;
  transition: transform 0.06s ease, background-color 0.15s ease;
}
.gg-btn:hover { text-decoration: none; background: var(--bg); }
.gg-btn:active { transform: translateY(1px); }
.gg-btn[disabled] { opacity: 0.55; cursor: not-allowed; }
.gg-btn--primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.gg-btn--primary:hover { background: var(--accent-ink); border-color: var(--accent-ink); }
.gg-btn--ghost { background: transparent; }
.gg-btn--sm { min-height: 34px; padding: 0 12px; font-size: 13px; }
.gg-btn--block { width: 100%; }
.gg-link { background: none; border: 0; padding: 4px 0; color: var(--accent-ink); font-weight: 600; font-size: 14px; cursor: pointer; }
.gg-link[disabled] { color: var(--muted); cursor: default; font-weight: 500; }
.gg-label { display: block; font-size: 13px; font-weight: 600; color: var(--muted); margin-bottom: 6px; }
.gg-input {
  width: 100%; min-height: 48px; padding: 0 14px; border-radius: var(--r-btn);
  border: 1px solid var(--line-strong); background: var(--surface); font-size: 16px;
}
.gg-input:focus { outline: none; border-color: var(--accent); box-shadow: var(--focus); }
.gg-input--code { font-size: 28px; letter-spacing: 0.4em; text-align: center; font-variant-numeric: tabular-nums; font-weight: 600; padding-left: 0.4em; }
.gg-check { display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--muted); margin: 14px 0 0; }
.gg-check input { width: 16px; height: 16px; accent-color: var(--accent); }
.gg-alert {
  margin: 14px 0 0; padding: 10px 12px; border-radius: var(--r-sm);
  background: var(--accent-soft); color: var(--negative); font-size: 14px;
}
.gg-alert[hidden] { display: none; }

/* ---------- Login ---------- */
.gg-login { min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 32px 16px; }
.gg-login__panel {
  width: 100%; max-width: 420px; background: var(--surface); border: 1px solid var(--line);
  border-radius: 16px; padding: 32px 28px;
}
.gg-login__brand { margin-bottom: 28px; }
.gg-login h1 { font-size: 26px; margin-bottom: 8px; }
.gg-login__lead { color: var(--muted); margin-bottom: 22px; max-width: 36ch; }
.gg-login form .gg-btn { margin-top: 18px; }
.gg-login__links { display: flex; justify-content: space-between; gap: 12px; margin-top: 18px; flex-wrap: wrap; }
.gg-login__foot { margin-top: 20px; color: var(--muted); font-size: 13px; }
.gg-turnstile:not(:empty) { margin-top: 16px; }
[data-step][hidden] { display: none; }

/* ---------- Top bar ---------- */
.gg-wrap { width: 100%; max-width: 1200px; margin: 0 auto; padding: 0 24px; }
.gg-top { background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20; }
.admin-bar .gg-top { top: 32px; }
.gg-top__inner { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 64px; }
.gg-top__brand:hover { text-decoration: none; }
.gg-top__right { display: flex; align-items: center; gap: 10px; }
.gg-view select {
  min-height: 34px; padding: 0 30px 0 10px; border-radius: var(--r-btn); border: 1px solid var(--line-strong);
  background: var(--surface); font-size: 13px; font-weight: 600; max-width: 200px;
}
.gg-view[hidden] { display: none; }
.gg-menu { position: relative; }
.gg-menu summary { list-style: none; display: flex; align-items: center; gap: 8px; cursor: pointer; padding: 4px; }
.gg-menu summary::-webkit-details-marker { display: none; }
.gg-avatar {
  width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center;
  background: var(--ink); color: var(--surface); font-weight: 600; font-size: 14px;
}
.gg-menu__name { font-weight: 600; font-size: 14px; }
.gg-menu__pop {
  position: absolute; right: 0; top: calc(100% + 6px); min-width: 200px; background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--r-md); padding: 6px; display: flex; flex-direction: column;
}
.gg-menu__item { display: block; text-align: left; padding: 10px 12px; border-radius: var(--r-sm); background: none; border: 0; color: var(--ink); font-size: 14px; cursor: pointer; }
.gg-menu__item:hover { background: var(--bg); text-decoration: none; }

/* ---------- Dashboard layout ---------- */
.gg-dash { padding-top: 24px; padding-bottom: 56px; }
.gg-banner {
  display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap;
  background: var(--surface); border: 1px solid var(--line); border-left: 3px solid var(--accent);
  border-radius: var(--r-md); padding: 14px 18px; margin-bottom: 20px;
}
.gg-banner p { color: var(--muted); font-size: 14px; }
.gg-banner[hidden] { display: none; }
.gg-banner__actions { display: flex; align-items: center; gap: 14px; }
.gg-banner--install { border-left-color: var(--series-1); }
/* Installed app: respect the phone's notch and home bar. */
@supports (padding: env(safe-area-inset-top)) {
  .gg-top { padding-top: env(safe-area-inset-top); }
  .gg-dash { padding-bottom: calc(56px + env(safe-area-inset-bottom)); }
}

.gg-toolbar { display: flex; align-items: center; flex-wrap: wrap; gap: 10px 16px; margin-bottom: 20px; }
.gg-tabs { display: flex; gap: 2px; padding: 3px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-btn); overflow-x: auto; scrollbar-width: none; max-width: 100%; }
.gg-tabs::-webkit-scrollbar { display: none; }
.gg-tabs button {
  border: 0; background: none; padding: 7px 12px; border-radius: 7px; font-size: 13px; font-weight: 600;
  color: var(--muted); cursor: pointer; white-space: nowrap;
}
.gg-tabs button:hover { color: var(--ink); }
.gg-tabs button[aria-selected="true"] { background: var(--ink); color: var(--surface); }
.gg-tabs--sm { background: var(--bg); }
.gg-custom { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; color: var(--muted); font-size: 13px; }
.gg-custom[hidden] { display: none; }
.gg-custom input { min-height: 34px; border: 1px solid var(--line-strong); border-radius: var(--r-btn); background: var(--surface); padding: 0 8px; font-size: 13px; }
.gg-updated { margin-left: auto; font-size: 13px; color: var(--muted); }

.gg-panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); padding: 20px 22px; }
.gg-panel h2 { font-size: 16px; }
.gg-panel__head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.gg-panel__head .gg-muted { font-size: 13px; margin-top: 2px; }

[data-root] { display: flex; flex-direction: column; gap: 16px; transition: opacity 0.15s ease; }
[data-root].is-loading { opacity: 0.55; }

/* Hero */
.gg-hero { display: grid; grid-template-columns: 1.1fr 1fr; gap: 16px; }
.gg-label { font-size: 13px; font-weight: 600; color: var(--muted); }
.gg-figure { display: block; font-size: clamp(38px, 5vw, 54px); font-weight: 600; line-height: 1.05; letter-spacing: -0.03em; margin: 8px 0 10px; }
.gg-figure--md { font-size: clamp(28px, 3.4vw, 34px); margin-bottom: 14px; }
.gg-figure small { font-size: 15px; font-weight: 500; letter-spacing: 0; }
.gg-hero__main { display: flex; flex-direction: column; justify-content: center; }
.gg-hero__main .gg-muted { font-size: 14px; }
.gg-hero__capital-head { display: flex; justify-content: space-between; gap: 12px; }
.gg-hero__capital-head .gg-muted { font-size: 13px; line-height: 1.5; }

/* Segmented bar (one whole split into parts) */
.gg-seg { display: flex; gap: 2px; height: 28px; border-radius: 4px; overflow: hidden; background: var(--bg); }
.gg-seg__part { display: flex; align-items: center; min-width: 4px; border-radius: 4px; }
.gg-seg__part em { font-style: normal; font-size: 12px; font-weight: 600; color: #fff; padding-left: 8px; }
.gg-seg__part:nth-child(2) em { color: var(--ink); }
.gg-seg__part--empty { flex-grow: 1; background: var(--line); }
.gg-legend { list-style: none; display: flex; flex-wrap: wrap; gap: 6px 18px; margin: 12px 0 0; font-size: 13px; color: var(--muted); }
.gg-legend li { display: flex; align-items: center; gap: 6px; }
.gg-legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.gg-legend b { color: var(--ink); font-weight: 600; }
.gg-legend--inline { margin: 0; }

/* Stat tiles */
.gg-tiles { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
.gg-tiles > *, .gg-grid > *, .gg-hero > * { min-width: 0; }
.gg-tile { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); padding: 16px 18px; display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.gg-tile__label { font-size: 13px; font-weight: 600; color: var(--muted); }
.gg-tile__value { font-size: clamp(22px, 2.4vw, 28px); font-weight: 600; line-height: 1.15; letter-spacing: -0.02em; overflow-wrap: anywhere; }
.gg-tile__sub { font-size: 12px; color: var(--muted); }
.gg-tile--accent { border-top: 3px solid var(--accent); padding-top: 14px; }

/* Charts */
.gg-grid { display: grid; grid-template-columns: 2fr 1fr; gap: 16px; }
.gg-chart__canvas { position: relative; height: 260px; }
.gg-data { margin-top: 12px; font-size: 13px; }
.gg-data summary { cursor: pointer; color: var(--muted); font-weight: 600; width: max-content; }
.gg-data .gg-table-wrap { max-height: 280px; margin-top: 10px; }

/* Breakdown */
.gg-breakdown .gg-muted { font-size: 13px; margin: 2px 0 14px; }
.gg-breakdown dl > div { display: flex; justify-content: space-between; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.gg-breakdown dt { color: var(--muted); }
.gg-breakdown dd { font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.gg-breakdown .gg-total { border-bottom: 0; border-top: 1px solid var(--ink); margin-top: -1px; }
.gg-breakdown .gg-total dt { color: var(--ink); font-weight: 600; }
.gg-note { margin-top: 14px; font-size: 12px; color: var(--muted); }

/* Tables */
.gg-table-wrap { overflow: auto; -webkit-overflow-scrolling: touch; }
.gg-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.gg-table th { position: sticky; top: 0; background: var(--surface); text-align: left; font-size: 12px; font-weight: 600; color: var(--muted); padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.gg-table td { padding: 11px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.gg-table tr:last-child td { border-bottom: 0; }
.gg-table .num { text-align: right; font-variant-numeric: tabular-nums; }
.gg-table a { font-weight: 600; }
.gg-badge { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; background: var(--bg); color: var(--muted); border: 1px solid var(--line); }
.gg-badge--completed { color: #0b6b3a; background: #e3f4ea; border-color: #c7e7d3; }
.gg-badge--cancelled, .gg-badge--returned { color: var(--negative); background: var(--accent-soft); border-color: transparent; }
.gg-badge--shipped, .gg-badge--processing { color: #1c5cab; background: #e7f0fb; border-color: #cfe0f6; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .gg-badge--completed { color: #7fd6a3; background: #13281d; border-color: #1f3d2c; }
  :root:not([data-theme="light"]) .gg-badge--shipped, :root:not([data-theme="light"]) .gg-badge--processing { color: #8cbcf3; background: #142338; border-color: #1d3352; }
}
.gg-filter select { min-height: 34px; border: 1px solid var(--line-strong); border-radius: var(--r-btn); background: var(--surface); padding: 0 8px; font-size: 13px; }
.gg-pager { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 14px; font-size: 13px; color: var(--muted); }
.gg-empty { padding: 28px 0; text-align: center; color: var(--muted); }
[data-table-body].is-loading { opacity: 0.5; }

/* Skeleton */
.gg-skeleton { display: flex; flex-direction: column; gap: 16px; }
.gg-sk { height: 96px; border-radius: var(--r-md); background: var(--surface); border: 1px solid var(--line); }
.gg-sk--hero { height: 170px; }
.gg-sk--chart { height: 320px; }
.gg-sk-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }

/* ---------- Responsive ---------- */
@media (max-width: 960px) {
  .gg-hero, .gg-grid { grid-template-columns: 1fr; }
  .gg-tiles, .gg-sk-row { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 782px) {
  .admin-bar .gg-top { top: 46px; }
}
@media (max-width: 640px) {
  .gg-wrap { padding: 0 16px; }
  /* Header: brand + account on the first row, manager view picker full width below. */
  .gg-top__inner { flex-wrap: wrap; min-height: 56px; gap: 8px 10px; padding-top: 8px; padding-bottom: 8px; }
  .gg-top__brand { min-width: 0; }
  .gg-brand__name { font-size: 17px; }
  .gg-top__right { gap: 8px; }
  .gg-top__inner > .gg-top__right > .gg-view { order: 3; flex: 1 0 100%; }
  .gg-top__inner > .gg-top__right { display: contents; }
  .gg-top__inner > .gg-top__right > * { flex: 0 0 auto; }
  .gg-top__inner > .gg-top__right > .gg-btn { margin-left: auto; }
  .gg-view select { max-width: none; width: 100%; min-height: 40px; }
  .gg-banner { padding: 14px; }
  .gg-banner .gg-btn { width: 100%; }
  .gg-banner__actions { width: 100%; flex-direction: column; align-items: stretch; gap: 6px; }
  .gg-dash { padding-top: 16px; }
  .gg-menu__name, .gg-brand__tag { display: none; }
  .gg-panel { padding: 16px; }
  .gg-tiles { gap: 10px; }
  .gg-tile { padding: 14px; }
  .gg-updated { margin-left: 0; width: 100%; }
  .gg-chart__canvas { height: 220px; }
  .gg-login__panel { padding: 26px 20px; }
  /* Orders become stacked cards on phones. */
  .gg-table--orders thead { display: none; }
  .gg-table--orders tr { display: grid; grid-template-columns: 1fr auto; gap: 2px 12px; padding: 12px 0; border-bottom: 1px solid var(--line); }
  .gg-table--orders td { border: 0; padding: 0; text-align: left !important; white-space: normal; }
  .gg-table--orders td:nth-child(2) { color: var(--muted); font-size: 13px; grid-column: 1; }
  .gg-table--orders td:nth-child(3) { grid-column: 2; grid-row: 1; text-align: right !important; }
  .gg-table--orders td:nth-child(n+4) { grid-column: 1 / -1; display: flex; justify-content: space-between; font-size: 13px; }
  .gg-table--orders td:nth-child(n+4)::before { content: attr(data-label); color: var(--muted); }
}
@media (prefers-reduced-motion: reduce) {
  .gg-portal * { transition: none !important; }
}
