:root {
  --bg: #0b1120;
  --bg-elev: #111827;
  --bg-card: #151f32;
  --bg-soft: #1e293b;
  --text: #f1f5f9;
  --muted: #94a3b8;
  --border: #263349;
  --accent: #3b82f6;
  --accent-strong: #2563eb;
  --gold: #f59e0b;
  --success: #10b981;
  --danger: #ef4444;
  --pw-cell-bg: #0f172a;
  --pw-cell-zebra: #162136;
  --pw-jml-bg: #1e293b;
}

html[data-theme="light"] {
  --bg: #f1f5f9;
  --bg-elev: #ffffff;
  --bg-card: #ffffff;
  --bg-soft: #e2e8f0;
  --text: #0f172a;
  --muted: #475569;
  --border: #cbd5e1;
  --accent: #1d4ed8;
  --accent-strong: #1e40af;
  --gold: #d97706;
  --success: #059669;
  --danger: #dc2626;
  --pw-cell-bg: #ffffff;
  --pw-cell-zebra: #f1f5f9;
  --pw-jml-bg: #e2e8f0;
}

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; font-family: system-ui, -apple-system, Segoe UI, Roboto, sans-serif; background: var(--bg); color: var(--text); font-size: 14px; line-height: 1.45; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.an-container { max-width: 1220px; margin: 0 auto; padding: 0 14px; }
.an-main { padding: 18px 14px 76px; min-height: 75vh; }

/* Header */
.an-header { position: sticky; top: 0; z-index: 50; background: var(--bg-elev); border-bottom: 1px solid var(--border); backdrop-filter: blur(8px); }
.an-header-inner { display: flex; align-items: center; justify-content: space-between; gap: 12px; height: 54px; }
.an-brand { display: inline-flex; align-items: center; gap: 8px; color: var(--text); font-weight: 800; font-size: 17px; white-space: nowrap; }
.an-brand:hover { text-decoration: none; }
.an-brand-badge { display: inline-flex; align-items: center; justify-content: center; width: 30px; height: 30px; border-radius: 8px; background: linear-gradient(135deg, #2563eb, #06b6d4); color: #fff; font-size: 13px; font-weight: 900; }
.an-brand-text small { font-size: 11px; color: var(--gold); font-weight: 700; }
.an-staging-pill { font-size: 10px; font-weight: 800; background: rgba(245, 158, 11, 0.16); color: var(--gold); border: 1px solid rgba(245, 158, 11, 0.4); padding: 2px 6px; border-radius: 999px; }

.an-nav { display: flex; align-items: center; gap: 4px; overflow-x: auto; scrollbar-width: none; }
.an-nav::-webkit-scrollbar { display: none; }
.an-nav-link { padding: 6px 10px; border-radius: 7px; font-size: 13px; font-weight: 600; color: var(--muted); white-space: nowrap; }
.an-nav-link:hover { color: var(--text); background: var(--bg-soft); text-decoration: none; }
.an-nav-link.active { color: #fff; background: var(--accent-strong); }

.an-btn, .an-btn-sm { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 1px solid var(--border); background: var(--bg-soft); color: var(--text); border-radius: 8px; font-weight: 600; cursor: pointer; padding: 7px 12px; font-size: 13px; }
.an-btn-sm { padding: 5px 10px; font-size: 12px; }
.an-btn:hover, .an-btn-sm:hover { border-color: var(--accent); text-decoration: none; }
.an-btn-primary { background: var(--accent-strong); color: #fff; border-color: transparent; }

/* Hero & Sections */
.an-hero { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; background: var(--bg-card); border: 1px solid var(--border); border-radius: 14px; padding: 18px 20px; margin-bottom: 20px; }
.an-hero h1 { margin: 0 0 6px; font-size: 20px; }
.an-hero p { margin: 0; color: var(--muted); max-width: 680px; }
.an-hero-badges { display: flex; gap: 8px; flex-wrap: wrap; }
.an-chip { font-size: 11px; font-weight: 700; padding: 4px 10px; border-radius: 999px; background: rgba(59,130,246,0.14); color: var(--accent); border: 1px solid rgba(59,130,246,0.3); }

.an-section { margin-top: 22px; }
.an-section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.an-section-head h2 { margin: 0; font-size: 17px; }
.an-muted { color: var(--muted); font-size: 13px; }
.an-sub { color: var(--muted); font-size: 11px; }
.an-mono { font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace; }

/* Featured Cards */
.an-featured-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 12px; }
.an-mkt-card { background: var(--bg-card); border: 1px solid var(--border); border-radius: 12px; padding: 14px; display: flex; flex-direction: column; gap: 10px; transition: border-color .15s; }
.an-mkt-card:hover { border-color: var(--accent); }
.an-mkt-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.an-mkt-title { font-weight: 800; font-size: 15px; color: var(--text); display: block; }
.an-mkt-meta { font-size: 11px; color: var(--muted); margin-top: 3px; }
.an-res-ball-badge { background: linear-gradient(135deg, #b91c1c, #ef4444); color: #fff; font-weight: 900; font-size: 18px; letter-spacing: 1px; padding: 4px 10px; border-radius: 8px; font-family: ui-monospace, monospace; white-space: nowrap; }
.an-mkt-tools { display: flex; flex-wrap: wrap; gap: 5px; }
.an-mkt-tools a, .an-inline-links a { font-size: 11px; font-weight: 600; padding: 3px 8px; border-radius: 6px; background: var(--bg-soft); color: var(--text); border: 1px solid var(--border); }
.an-mkt-tools a:hover, .an-inline-links a:hover { border-color: var(--accent); color: var(--accent); text-decoration: none; }

/* Tables */
.an-home-controls { display: flex; gap: 10px; align-items: center; justify-content: space-between; flex-wrap: wrap; margin-bottom: 12px; }
.an-input { background: var(--bg-card); color: var(--text); border: 1px solid var(--border); border-radius: 8px; padding: 8px 12px; font-size: 13px; min-width: 240px; flex: 1; max-width: 380px; }
.an-input:focus, .an-select:focus { outline: none; border-color: var(--accent); }
.an-table-wrap { background: var(--bg-card); border: 1px solid var(--border); border-radius: 12px; overflow-x: auto; }
.an-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.an-table th, .an-table td { padding: 9px 12px; border-bottom: 1px solid var(--border); text-align: left; }
.an-table th { background: var(--bg-soft); font-size: 12px; text-transform: uppercase; letter-spacing: .3px; color: var(--muted); }
.an-table tr:hover td { background: rgba(59,130,246,0.06); }
.an-link-strong { font-weight: 700; color: var(--text); }
.an-badge-top { margin-left: 6px; font-size: 10px; font-weight: 800; color: var(--gold); background: rgba(245,158,11,0.15); padding: 1px 6px; border-radius: 4px; }
.an-res-pill { display: inline-block; font-family: ui-monospace, monospace; font-weight: 800; font-size: 14px; background: var(--bg-soft); padding: 2px 9px; border-radius: 6px; border: 1px solid var(--border); }
.an-inline-links { display: flex; gap: 4px; flex-wrap: wrap; }

/* Page Head & Switchers */
.an-page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; flex-wrap: wrap; margin-bottom: 14px; }
.an-page-head h1 { margin: 0 0 4px; font-size: 20px; }
.an-tool-switcher { display: flex; gap: 6px; flex-wrap: wrap; }
.an-pill-tab { padding: 6px 11px; border-radius: 999px; font-size: 12px; font-weight: 700; background: var(--bg-card); color: var(--muted); border: 1px solid var(--border); }
.an-pill-tab.active { background: var(--accent-strong); color: #fff; border-color: transparent; }

.an-filter-bar { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; background: var(--bg-card); border: 1px solid var(--border); border-radius: 10px; padding: 10px 14px; margin-bottom: 12px; }
.an-filter-bar label { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 700; color: var(--muted); }
.an-inline-form { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.an-select { background: var(--bg-soft); color: var(--text); border: 1px solid var(--border); border-radius: 7px; padding: 6px 9px; font-size: 13px; font-weight: 600; cursor: pointer; }

/* Paint & Search Toolbar */
.an-paint-toolbar { position: sticky; top: 54px; z-index: 40; background: var(--bg-elev); border: 1px solid var(--border); border-radius: 10px; padding: 8px 10px; margin-bottom: 10px; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; justify-content: space-between; box-shadow: 0 4px 16px rgba(0,0,0,0.22); }
.an-swatches { display: flex; align-items: center; gap: 5px; flex-wrap: wrap; }
.an-swatch { width: 26px; height: 24px; border-radius: 6px; border: 2px solid rgba(255,255,255,0.25); cursor: pointer; }
.an-swatch.selected { border-color: #fff; box-shadow: 0 0 0 2px var(--accent); transform: scale(1.08); }
.an-swatch-btn { height: 26px; padding: 0 9px; border-radius: 6px; border: 1px solid var(--border); background: var(--bg-soft); color: var(--text); font-size: 11px; font-weight: 700; cursor: pointer; }
.an-swatch-btn.selected { border-color: var(--accent); background: var(--accent-strong); color: #fff; }
.an-search-digits { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.an-digit-input { width: 42px; height: 28px; text-align: center; border-radius: 6px; border: 1px solid var(--border); background: var(--bg-card); color: var(--text); font-weight: 800; font-size: 12px; }

/* Paito Warna Excel Grid */
.pw-scroll { max-height: 76vh; overflow: auto; }
.pw-table { width: 100%; border-collapse: collapse; margin: 0 auto; user-select: none; min-width: 520px; }
.pw-table th { position: sticky; top: 0; z-index: 10; background: var(--bg-soft); color: var(--text); font-size: 12px; padding: 6px 4px; border: 1px solid var(--border); }
.pw-table td { border: 1px solid var(--border); text-align: center; font-weight: 700; font-size: 15px; padding: 3px 2px; min-width: 22px; background: var(--pw-cell-bg); cursor: pointer; }
.pw-table tr.pw-row:nth-last-child(5n+1) td { background: var(--pw-cell-zebra); }
.pw-table td.pw-jml { background: var(--pw-jml-bg) !important; font-style: italic; font-weight: 600; color: var(--muted); border-right: 2px solid var(--accent); }
.pw-table td.pw-empty { color: var(--muted); opacity: 0.4; cursor: default; }
.pw-table td.pw-next { color: var(--gold); }
.ph-table td { font-size: 14px; padding: 5px 7px; }

/* Digit search highlight classes */
.hl-a { background: #ea580c !important; color: #fff !important; }
.hl-c { background: #2563eb !important; color: #fff !important; }
.hl-k { background: #16a34a !important; color: #fff !important; }
.hl-e { background: #dc2626 !important; color: #fff !important; }
.hl-j { background: #9333ea !important; color: #fff !important; }

/* Bola Merah */
.bm-table { width: 100%; border-collapse: collapse; }
.bm-table th, .bm-table td { padding: 7px 10px; border-bottom: 1px solid var(--border); text-align: left; }
.bm-table th { background: var(--bg-soft); font-size: 12px; }
.bm-balls-cell { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.ballhk { display: inline-flex; align-items: center; justify-content: center; width: 28px; height: 28px; border-radius: 50%; background: #991b1b; color: #fff; font-weight: 800; font-size: 15px; border: 1px solid rgba(255,255,255,0.25); cursor: pointer; user-select: none; }

/* Pola Dasar */
.pd-table { width: 100%; border-collapse: collapse; font-size: 11px; }
.pd-table th, .pd-table td { border: 1px solid var(--border); padding: 5px 4px; text-align: center; }
.pd-table th { background: var(--bg-soft); color: var(--muted); }
.pd-res { font-weight: 800; font-family: ui-monospace, monospace; background: var(--bg-soft); font-size: 12px; }
.pd-BS, .pd-KB { background: rgba(244,63,94,0.2); color: #fb7185; font-weight: 700; }
.pd-KC, .pd-KP { background: rgba(16,185,129,0.2); color: #34d399; font-weight: 700; }
.pd-GP, .pd-TH { background: rgba(59,130,246,0.2); color: #60a5fa; font-weight: 700; }
.pd-GJ, .pd-TP { background: rgba(245,158,11,0.2); color: #fbbf24; font-weight: 700; }
.pd-HM { background: rgba(139,92,246,0.2); color: #a78bfa; font-weight: 700; }
.pd-SL, .pd-TW { background: rgba(6,182,212,0.2); color: #22d3ee; font-weight: 700; }

/* Cards, Frequency Grids & Charts */
.an-card { background: var(--bg-card); border: 1px solid var(--border); border-radius: 12px; padding: 14px; }
.an-card h3 { margin: 0 0 12px; font-size: 14px; }
.an-freq-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 12px; }
.an-two-col { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 12px; margin-bottom: 16px; }
.an-digit-pills { display: grid; grid-template-columns: repeat(2, 1fr); gap: 6px; }
.an-shio-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.an-d-item { display: flex; justify-content: space-between; align-items: center; background: var(--bg-soft); padding: 5px 8px; border-radius: 7px; font-size: 12px; border: 1px solid var(--border); }
.an-d-item.hot { border-color: var(--gold); background: rgba(245,158,11,0.14); }
.d-num { font-weight: 800; }
.d-cnt { color: var(--muted); font-size: 11px; }

.an-bar-row { margin-bottom: 9px; }
.an-bar-labels { display: flex; justify-content: space-between; font-size: 12px; margin-bottom: 3px; }
.an-bar-track { height: 7px; border-radius: 99px; background: var(--bg-soft); overflow: hidden; }
.an-bar-fill { height: 100%; border-radius: 99px; }
.bar-bs { background: #f43f5e; }
.bar-kc { background: #10b981; }
.bar-gp { background: #3b82f6; }
.bar-gj { background: #f59e0b; }

.an-hot-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 8px; }
.an-2d-box { background: var(--bg-soft); border: 1px solid var(--border); border-radius: 8px; padding: 7px; text-align: center; }
.an-2d-box.hot { border-color: rgba(239,68,68,0.5); background: rgba(239,68,68,0.12); }
.an-2d-box.cold { border-color: rgba(59,130,246,0.5); background: rgba(59,130,246,0.12); }
.n2d { font-size: 17px; font-weight: 900; font-family: ui-monospace, monospace; }
.m2d { font-size: 10px; color: var(--muted); }

.an-100-grid { display: grid; grid-template-columns: repeat(10, minmax(0, 1fr)); gap: 6px; }
.an-100-cell { background: var(--bg-card); border: 1px solid var(--border); border-radius: 7px; padding: 6px 3px; text-align: center; }
.an-100-cell strong { display: block; font-size: 14px; font-family: ui-monospace, monospace; }
.an-100-cell span { font-size: 10px; color: var(--muted); }
.an-100-cell.zero { opacity: 0.45; border-style: dashed; }
.an-100-cell.cold { border-color: var(--accent); background: rgba(59,130,246,0.14); }

.tag-chip { font-size: 10px; font-weight: 800; padding: 2px 6px; border-radius: 5px; margin-right: 3px; }
.tag-BS, .tag-GJ { background: rgba(245,158,11,0.16); color: var(--gold); }
.tag-KC, .tag-GP { background: rgba(16,185,129,0.16); color: var(--success); }

.an-error-box { max-width: 460px; margin: 40px auto; text-align: center; padding: 28px; }
.an-error-box h1 { font-size: 46px; margin: 0 0 8px; }

.an-footer { border-top: 1px solid var(--border); padding: 16px 0 74px; color: var(--muted); font-size: 12px; }
.an-footer-inner { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 8px; }

.an-mobile-bar { display: none; }
@media (max-width: 768px) {
  .an-nav { display: none; }
  .an-mobile-bar { position: fixed; bottom: 0; left: 0; right: 0; z-index: 60; display: flex; justify-content: space-around; align-items: center; background: var(--bg-elev); border-top: 1px solid var(--border); height: 52px; padding: 0 4px; }
  .an-mobile-bar a { font-size: 11px; font-weight: 700; color: var(--muted); padding: 6px 4px; border-radius: 6px; }
  .an-mobile-bar a.active { color: #fff; background: var(--accent-strong); }
  .an-100-grid { grid-template-columns: repeat(5, minmax(0, 1fr)); }
  .pw-table td { font-size: 13px; min-width: 16px; padding: 2px 1px; }
}
