/* Myu Collectibles Sales Data - self-hosted, system fonts only */
:root {
  --bg: #F1F5F9; --card: #FFFFFF; --ink: #0F172A; --text: #1E293B; --muted: #475569; --line: #E2E8F0; --line2: #CBD5E1;
  --shopee: #EA580C; --shopee-dark: #C2410C; --shopee-soft: #FFF1E8;
  --vending: #0D9488; --vending-dark: #0F766E; --vending-soft: #E6F6F4;
  --neg: #B91C1C; --radius: 14px;
  --shadow: 0 1px 2px rgba(15,23,42,.06), 0 4px 14px rgba(15,23,42,.06);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif;
  --navh: 68px;
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: calc(var(--navh) + 12px); -webkit-text-size-adjust: 100%; }
body { margin: 0; font-family: var(--font); font-size: 19px; line-height: 1.5; color: var(--text); background: var(--bg); }
h1, h2, h3 { color: var(--ink); line-height: 1.2; margin: 0; }
a { color: var(--vending-dark); }
:focus-visible { outline: 3px solid #2563EB; outline-offset: 2px; }
[hidden] { display: none !important; }
.ico { width: 26px; height: 26px; display: block; }

/* ---------- header ---------- */
.appbar { background: var(--ink); color: #fff; }
.appbar-inner { max-width: 1400px; margin: 0 auto; padding: 18px 24px; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 16px 24px; }
.brandbox { display: flex; align-items: center; gap: 16px; min-width: 0; }
.logo { width: 52px; height: 52px; flex: none; display: block; }
.title { color: #fff; font-size: 1.6rem; font-weight: 800; letter-spacing: -.01em; }
.title span { color: #FDBA74; font-weight: 700; }
.updated { margin: 4px 0 0; color: #CBD5E1; font-size: 1rem; }
.appbar-actions { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.years { display: flex; align-items: center; gap: 6px; background: rgba(255,255,255,.08); border: 1px solid rgba(255,255,255,.18); border-radius: 999px; padding: 5px 6px 5px 16px; }
.years-label { color: #CBD5E1; font-size: .95rem; font-weight: 600; margin-right: 4px; }
.years button { font: inherit; font-size: 1.05rem; font-weight: 700; color: #fff; background: transparent; border: 0; border-radius: 999px; padding: 6px 16px; cursor: pointer; min-height: 40px; }
.years button:hover { background: rgba(255,255,255,.12); }
.years button[aria-pressed="true"] { background: var(--shopee); }
.logout { margin: 0; }
.btn-logout { display: inline-flex; align-items: center; gap: 8px; font: inherit; font-size: 1.05rem; font-weight: 700; color: var(--ink); background: #fff; border: 0; border-radius: 999px; padding: 10px 22px; min-height: 48px; cursor: pointer; }
.btn-logout svg { width: 22px; height: 22px; }
.btn-logout:hover { background: #FFE4D2; }

/* ---------- sticky pill nav ---------- */
.pillnav { position: sticky; top: 0; z-index: 20; background: rgba(241,245,249,.94); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); }
.pillnav-inner { max-width: 1400px; margin: 0 auto; padding: 10px 24px; display: flex; gap: 10px; overflow-x: auto; scrollbar-width: none; }
.pillnav-inner::-webkit-scrollbar { display: none; }
.pillnav a { flex: none; text-decoration: none; color: var(--ink); background: #fff; border: 2px solid var(--line2); border-radius: 999px; padding: 8px 22px; font-weight: 700; font-size: 1.05rem; min-height: 48px; display: inline-flex; align-items: center; }
.pillnav a:hover { border-color: var(--shopee); color: var(--shopee-dark); }
.pillnav a.active { background: var(--ink); border-color: var(--ink); color: #fff; }

/* ---------- layout ---------- */
main { max-width: 1400px; margin: 0 auto; padding: 8px 24px 40px; }
.block { margin-top: 36px; }
.block-head { margin-bottom: 16px; }
.block-head h2 { font-size: 1.75rem; font-weight: 800; display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.block-head .sub { margin: 6px 0 0; color: var(--muted); font-size: 1.02rem; }
.yr-chip { font-size: 1rem; font-weight: 700; color: var(--shopee-dark); background: var(--shopee-soft); border-radius: 999px; padding: 3px 12px; }
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); border: 1px solid var(--line); }
.card.pad { padding: 22px 24px; margin-top: 20px; }
.card.pad h3, .chart figcaption { font-size: 1.25rem; font-weight: 800; color: var(--ink); margin: 0 0 14px; }
section.card.block { padding: 22px 24px; }
.msg { background: #FEF2F2; color: #7F1D1D; border: 2px solid #FCA5A5; border-radius: 12px; padding: 14px 18px; font-weight: 600; margin: 20px 0 0; }

/* ---------- KPI tiles ---------- */
.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 18px; }
.kpi { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px 22px; display: flex; flex-direction: column; gap: 8px; position: relative; overflow: hidden; }
.kpi::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 6px; background: var(--line2); }
.kpi.shopee::before { background: var(--shopee); }
.kpi.vending::before { background: var(--vending); }
.kpi-top { display: flex; align-items: center; gap: 12px; }
.kpi-icon { width: 46px; height: 46px; border-radius: 12px; display: grid; place-items: center; background: #F1F5F9; color: var(--ink); flex: none; }
.kpi.shopee .kpi-icon { background: var(--shopee-soft); color: var(--shopee-dark); }
.kpi.vending .kpi-icon { background: var(--vending-soft); color: var(--vending-dark); }
.kpi-label { font-size: 1.1rem; font-weight: 700; color: var(--muted); }
.kpi-value { font-size: clamp(1.7rem, 2.3vw, 2.2rem); font-weight: 800; color: var(--ink); letter-spacing: -.01em; font-variant-numeric: tabular-nums; line-height: 1.15; }
.kpi-sub { font-size: 1rem; color: var(--muted); }
.kpi-bar { height: 10px; border-radius: 99px; background: #EEF2F6; overflow: hidden; margin-top: 4px; }
.kpi-bar span { display: block; height: 100%; border-radius: 99px; background: var(--line2); }
.kpi.shopee .kpi-bar span { background: var(--shopee); }
.kpi.vending .kpi-bar span { background: var(--vending); }
.kpi.hero { grid-column: span 2; grid-row: span 2; background: linear-gradient(135deg, #0F172A 0%, #1E293B 60%, #7C2D12 140%); color: #fff; border: 0; padding: 28px 30px; justify-content: center; gap: 12px; }
.kpi.hero::before { background: linear-gradient(var(--shopee), var(--vending)); }
.kpi.hero .kpi-icon { background: rgba(255,255,255,.14); color: #fff; width: 56px; height: 56px; }
.kpi.hero .kpi-icon .ico { width: 30px; height: 30px; }
.kpi.hero .kpi-label { color: #E2E8F0; font-size: 1.35rem; }
.kpi.hero .kpi-value { color: #fff; font-size: clamp(2.6rem, 5vw, 4rem); }
.kpi.hero .kpi-value.neg { color: #FCA5A5; }
.kpi.hero .kpi-sub { color: #E2E8F0; font-size: 1.1rem; }
.stats { display: grid; grid-template-columns: 1.6fr repeat(5, minmax(0, 1fr)); gap: 14px; margin-top: 18px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px 16px; display: flex; align-items: center; gap: 12px; }
.stat-icon { width: 42px; height: 42px; border-radius: 10px; background: #F1F5F9; color: var(--muted); display: grid; place-items: center; flex: none; }
.stat-icon .ico { width: 22px; height: 22px; }
.stat-value { font-size: 1.4rem; font-weight: 800; color: var(--ink); font-variant-numeric: tabular-nums; line-height: 1.1; }
.stat-label { font-size: .98rem; color: var(--muted); font-weight: 600; }

/* ---------- tables ---------- */
.table-wrap { width: 100%; }
.rtable { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 1.05rem; font-variant-numeric: tabular-nums; }
.rtable th, .rtable td { padding: 12px 14px; text-align: left; border-bottom: 1px solid var(--line); white-space: nowrap; }
.rtable .num { text-align: right; }
.rtable thead th { position: sticky; top: var(--navh); z-index: 5; background: #E2E8F0; color: var(--ink); font-weight: 800; font-size: 1rem; border-bottom: 2px solid var(--line2); }
.rtable thead th:first-child { border-top-left-radius: 10px; }
.rtable thead th:last-child { border-top-right-radius: 10px; }
.rtable tbody tr:nth-child(even) { background: #F8FAFC; }
.rtable tbody tr:hover { background: #FFF7F0; }
.rtable tbody th { font-weight: 700; color: var(--ink); }
.rtable td.strong { font-weight: 800; color: var(--ink); }
.rtable td.neg, .neg { color: var(--neg) !important; }
.rtable td.zero, .rtable td.blank { color: #94A3B8; }
.rtable tr.empty th, .rtable tr.empty td { color: #94A3B8; font-weight: 500; }
.rtable tfoot th, .rtable tfoot td { background: #FFF1E8; color: var(--ink); font-weight: 800; border-top: 2px solid var(--shopee); border-bottom: 0; font-size: 1.1rem; }
.rtable tfoot th:first-child { border-bottom-left-radius: 10px; }
.rtable tfoot td:last-child { border-bottom-right-radius: 10px; }

/* ---------- machines ---------- */
.machine-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 18px; }
.machine { padding: 22px 24px; display: flex; flex-direction: column; gap: 6px; }
.machine-head { display: flex; align-items: center; gap: 10px; }
.machine-head h3 { font-size: 1.3rem; font-weight: 800; }
.dot { width: 14px; height: 14px; border-radius: 50%; background: var(--vending); flex: none; }
.spark-wrap { margin-top: 10px; }
.spark { width: 100%; height: auto; display: block; }
.spark-axis { display: flex; justify-content: space-between; font-size: .9rem; color: var(--muted); margin-top: 4px; }

/* ---------- charts ---------- */
.chart-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; }
.chart { margin: 0; padding: 20px 22px 18px; }
.cbox { position: relative; height: 360px; }
.donut-centre { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); text-align: center; pointer-events: none; }
.donut-centre span { display: block; color: var(--muted); font-size: .95rem; font-weight: 700; }
.donut-centre strong { display: block; color: var(--ink); font-size: 1.35rem; font-weight: 800; font-variant-numeric: tabular-nums; }

/* ---------- top products ---------- */
.prod-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; }
.prod-grid .card.pad { margin-top: 0; }
.plist { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.prod { display: flex; gap: 14px; align-items: flex-start; padding: 12px 6px; border-bottom: 1px solid var(--line); }
.prod:last-child { border-bottom: 0; }
.rank { flex: none; width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; font-weight: 800; font-size: 1.1rem; background: #F1F5F9; color: var(--muted); border: 2px solid var(--line2); }
.rank.medal { color: #fff; border: 0; box-shadow: inset 0 -3px 0 rgba(0,0,0,.18); }
.rank.m1 { background: linear-gradient(135deg, #FACC15, #CA8A04); color: #422006; }
.rank.m2 { background: linear-gradient(135deg, #E2E8F0, #94A3B8); color: #0F172A; }
.rank.m3 { background: linear-gradient(135deg, #FDBA74, #B45309); color: #431407; }
.prod-body { flex: 1; min-width: 0; }
.prod-line { display: flex; justify-content: space-between; gap: 12px; align-items: baseline; }
.prod-name { font-weight: 700; color: var(--ink); font-size: 1.02rem; overflow-wrap: anywhere; }
.prod-var { color: var(--muted); font-weight: 500; }
.prod-amt { font-weight: 800; color: var(--ink); white-space: nowrap; font-variant-numeric: tabular-nums; font-size: 1.08rem; }
.prod-meta { display: flex; gap: 10px; align-items: center; color: var(--muted); font-size: .95rem; margin-top: 4px; }
.tag { font-size: .85rem; font-weight: 800; border-radius: 999px; padding: 2px 10px; letter-spacing: .02em; }
.tag.shopee { background: var(--shopee-soft); color: var(--shopee-dark); }
.tag.vending { background: var(--vending-soft); color: var(--vending-dark); }
.prod-bar { height: 8px; background: #EEF2F6; border-radius: 99px; margin-top: 8px; overflow: hidden; }
.prod-bar span { display: block; height: 100%; border-radius: 99px; }
.prod-bar.shopee span { background: var(--shopee); }
.prod-bar.vending span { background: var(--vending); }

.foot { text-align: center; margin: 36px 0 0; font-weight: 700; }

/* ---------- responsive ---------- */
@media (max-width: 1180px) {
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kpi.hero { grid-row: auto; }
  .stats { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .stat.wide { grid-column: span 3; }
  .chart-grid, .prod-grid { grid-template-columns: 1fr; }
}
@media (max-width: 900px) {
  /* tables turn into stacked cards */
  .rtable thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .rtable, .rtable tbody, .rtable tfoot, .rtable tr, .rtable th, .rtable td { display: block; width: 100%; }
  .rtable tr { border: 1px solid var(--line); border-radius: 12px; margin-bottom: 12px; overflow: hidden; background: #fff !important; }
  .rtable tbody th, .rtable tfoot th { background: #F1F5F9; font-size: 1.1rem; border-bottom: 1px solid var(--line); }
  .rtable tfoot tr { border: 2px solid var(--shopee); }
  .rtable tfoot th, .rtable tfoot td { border-top: 0; border-radius: 0 !important; }
  .rtable td { display: flex; justify-content: space-between; gap: 12px; white-space: normal; }
  .rtable td::before { content: attr(data-label); font-weight: 600; color: var(--muted); text-align: left; }
  .rtable tr.empty td { display: none; }
  .rtable tr.empty th::after { content: " — no sales yet"; font-weight: 500; }
}
@media (max-width: 700px) {
  body { font-size: 18px; }
  :root { --navh: 62px; }
  .appbar-inner, .pillnav-inner, main { padding-left: 14px; padding-right: 14px; }
  .title { font-size: 1.3rem; }
  .logo { width: 44px; height: 44px; }
  .appbar-actions { width: 100%; justify-content: space-between; }
  .pillnav a { padding: 8px 16px; font-size: 1rem; }
  .kpis { grid-template-columns: 1fr; gap: 14px; }
  .kpi.hero { grid-column: auto; padding: 24px 22px; }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stat.wide { grid-column: span 2; }
  .block-head h2 { font-size: 1.5rem; }
  .cbox { height: 320px; }
  .cbox.donut { height: 440px; }
  .card.pad, section.card.block, .machine, .chart { padding: 18px 16px; }
  .machine-grid { grid-template-columns: 1fr; }
}

/* ---------- sign-in / set password pages ---------- */
.auth-body { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; background: radial-gradient(1200px 600px at 10% -10%, #FFE4D2 0%, transparent 60%), radial-gradient(1000px 600px at 110% 110%, #CCF0EC 0%, transparent 60%), var(--bg); }
.auth-card { width: 100%; max-width: 480px; background: #fff; border-radius: 18px; box-shadow: 0 10px 40px rgba(15,23,42,.12); border: 1px solid var(--line); padding: 36px 34px 30px; }
.auth-logo { display: flex; justify-content: center; margin-bottom: 12px; }
.auth-logo .logo { width: 64px; height: 64px; }
.auth-card .brand { text-align: center; font-size: 1.7rem; font-weight: 800; color: var(--ink); }
.auth-card .brand span { color: var(--shopee-dark); font-size: 1.25rem; font-weight: 700; }
.auth-card h2 { font-size: 1.4rem; margin: 26px 0 10px; text-align: center; }
.auth-card p { color: var(--muted); }
.auth-card label { display: block; font-weight: 700; color: var(--ink); margin: 18px 0 6px; font-size: 1.1rem; }
.auth-card input { width: 100%; font: inherit; font-size: 1.25rem; padding: 14px 16px; border: 2px solid var(--line2); border-radius: 12px; background: #fff; color: var(--ink); }
.auth-card input:focus { outline: none; border-color: var(--shopee); box-shadow: 0 0 0 4px rgba(234,88,12,.2); }
.big-btn { display: block; width: 100%; margin-top: 24px; font: inherit; font-size: 1.25rem; font-weight: 800; color: #fff; background: var(--shopee); border: 0; border-radius: 12px; padding: 16px; min-height: 58px; cursor: pointer; box-shadow: 0 4px 12px rgba(234,88,12,.3); }
.big-btn:hover { background: var(--shopee-dark); }
.auth-card .hint { font-size: 1rem; color: var(--muted); margin-top: 18px; text-align: center; }
.auth-card form .hint { text-align: left; margin-top: 8px; font-size: .95rem; overflow-wrap: anywhere; }
.auth-card .msg { margin-top: 14px; }
