/* ==========================================================================
   Design tokens — change the look here.
   ========================================================================== */
:root {
  --font-display: "Bricolage Grotesque", system-ui, sans-serif;
  --font-body: "Figtree", system-ui, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, monospace;

  --bg: #F6F5F1;          /* page */
  --surface: #FFFFFF;     /* cards */
  --surface-2: #FAF9F6;   /* table heads, insets */
  --ink: #16181D;         /* main text */
  --ink-2: #3F444E;
  --muted: #5B606B;       /* secondary text (4.5:1 on white) */
  --line: #E3E1DA;
  --line-2: #EFEDE7;
  --field: #CFCBC1;

  --accent: #2447D6;
  --accent-ink: #1A35A3;
  --accent-soft: #E8ECFB;
  --accent-tint: #F4F6FE;

  --dark: #15171C;        /* sidebar, dark bands */
  --dark-2: #20232A;
  --dark-3: #262932;
  --dark-line: #2A2D35;
  --dark-ink: #F2F1EC;
  --dark-muted: #9DA1AB;

  --ok-bg: #E3F3EA;   --ok: #1B6B43;
  --warn-bg: #FDF1E3; --warn: #8A4B00;
  --bad-bg: #FCE8E6;  --bad: #A1261B;
  --neutral-bg: #F1EFEA;

  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 16px;
  --shadow: 0 24px 48px -24px rgba(22, 24, 29, .18);
}

/* ========================================================================== */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 16px/1.5 var(--font-body); -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); }
a:hover { color: var(--accent-ink); }
img, svg { display: block; }
h1, h2, h3 { font-family: var(--font-display); letter-spacing: -0.01em; margin: 0; line-height: 1.1; }
p { margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.mono { font-family: var(--font-mono); }
.muted { color: var(--muted); }
.hidden { display: none !important; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 10px 18px; border-radius: 10px; border: 1px solid transparent;
  font-weight: 600; font-size: 15px; text-decoration: none; cursor: pointer; white-space: nowrap;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-ink); color: #fff; }
.btn-primary:disabled { background: #D5D2C9; color: var(--muted); cursor: not-allowed; }
.btn-secondary { background: var(--surface); color: var(--ink); border-color: #D5D2C9; }
.btn-secondary:hover { border-color: var(--ink-2); color: var(--ink); }
.btn-ghost { background: none; color: var(--ink); }
.btn-outline-accent { background: var(--surface); color: var(--accent); border-color: var(--accent); min-height: 36px; padding: 6px 12px; font-size: 13px; }
.btn-block { width: 100%; }
.btn-lg { min-height: 52px; font-size: 16px; border-radius: 12px; }

/* Pills / chips */
.pill {
  display: inline-flex; align-items: center; min-height: 40px; padding: 8px 14px;
  border-radius: 10px; border: 1px solid var(--line); background: var(--surface);
  color: var(--ink-2); font-weight: 500; font-size: 14px; cursor: pointer; white-space: nowrap;
}
.pill[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: #fff; font-weight: 600; }
.pill-round { border-radius: 999px; }

.badge { display: inline-block; font-size: 12px; font-weight: 600; padding: 3px 10px; border-radius: 999px; white-space: nowrap; }
.badge-basic { background: var(--warn-bg); color: var(--warn); }
.badge-hq { background: var(--accent-soft); color: var(--accent-ink); }
.badge-ph { background: var(--ok-bg); color: var(--ok); }
.badge-pending { background: var(--neutral-bg); color: var(--ink-2); }
.badge-progress { background: var(--accent-soft); color: var(--accent-ink); }
.badge-completed { background: var(--ok-bg); color: var(--ok); }
.badge-partial { background: var(--warn-bg); color: var(--warn); }
.badge-canceled, .badge-failed { background: var(--bad-bg); color: var(--bad); }
.badge-review { background: var(--warn-bg); color: var(--warn); }

/* Cards & fields */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); }
.field { display: flex; flex-direction: column; gap: 8px; }
.field label, .field .label { font-size: 14px; font-weight: 600; }
.input, .textarea, .select {
  width: 100%; min-height: 46px; padding: 11px 14px; border: 1px solid var(--field);
  border-radius: 10px; background: var(--surface); font-size: 16px; /* 16px stops iOS zoom */
}
.textarea { min-height: 140px; resize: vertical; line-height: 1.45; }
.input:focus, .textarea:focus, .select:focus { outline: 3px solid var(--accent-soft); border-color: var(--accent); }
.hint { font-size: 13px; color: var(--muted); }
.hint.error { color: var(--bad); font-weight: 600; }
.alert { padding: 14px 16px; border-radius: var(--radius); font-size: 15px; display: flex; gap: 12px; align-items: flex-start; }
.alert-ok { background: var(--ok-bg); color: var(--ok); }
.alert-bad { background: var(--bad-bg); color: var(--bad); }
.alert-warn { background: var(--warn-bg); color: var(--warn); }
.alert-info { background: var(--accent-soft); color: var(--accent-ink); }

/* Toast */
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%) translateY(20px);
  background: var(--ink); color: #fff; padding: 12px 18px; border-radius: 12px; font-weight: 600; font-size: 15px;
  opacity: 0; pointer-events: none; transition: .2s ease; z-index: 100; max-width: calc(100vw - 32px);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.bad { background: var(--bad); }

/* Brand */
.brand { font-family: var(--font-display); font-weight: 700; font-size: 22px; color: var(--ink); text-decoration: none; }
.brand span { color: var(--accent); }

/* ==========================================================================
   Landing
   ========================================================================== */
.wrap { max-width: 1180px; margin: 0 auto; padding: 0 20px; }
.site-header { border-bottom: 1px solid var(--line); background: var(--bg); position: sticky; top: 0; z-index: 20; }
.site-header .wrap { height: 68px; display: flex; align-items: center; gap: 28px; }
.site-nav { display: flex; gap: 24px; flex: 1; }
.site-nav a { color: var(--ink-2); text-decoration: none; font-weight: 500; font-size: 15px; }
.site-nav a:hover { color: var(--ink); }
.header-actions { display: flex; gap: 8px; }

.hero { padding: 72px 0 56px; }
.hero .wrap { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 56px; align-items: center; }
.eyebrow { display: inline-block; font-size: 13px; font-weight: 600; color: var(--accent-ink); background: var(--accent-soft); padding: 6px 12px; border-radius: 999px; }
.hero h1 { font-size: clamp(38px, 5.2vw, 60px); line-height: 1.04; letter-spacing: -0.02em; margin: 18px 0; }
.hero p.lead { font-size: 19px; color: var(--ink-2); max-width: 520px; }
.hero-cta { display: flex; gap: 12px; margin-top: 28px; flex-wrap: wrap; }
.pay-row { display: flex; gap: 10px; align-items: center; margin-top: 24px; font-size: 14px; color: var(--muted); flex-wrap: wrap; }
.pay-chip { font-weight: 600; color: var(--ink); background: var(--surface); border: 1px solid var(--line); padding: 4px 10px; border-radius: 8px; }
.hero-card { padding: 22px; display: flex; flex-direction: column; gap: 12px; box-shadow: var(--shadow); }
.svc-row { display: flex; align-items: center; gap: 12px; padding: 13px 14px; border: 1px solid var(--line); border-radius: var(--radius); }
.svc-row .grow { flex: 1; min-width: 0; }
.svc-row .t { font-weight: 600; font-size: 15px; }
.svc-row .s { font-size: 13px; color: var(--muted); }
.svc-row .p { font-weight: 700; font-size: 15px; text-align: right; white-space: nowrap; }

section.block { padding: 72px 0; }
section.block h2 { font-size: clamp(30px, 3.4vw, 40px); }
.section-head { display: flex; flex-direction: column; gap: 10px; margin-bottom: 28px; max-width: 720px; }
.section-head p { font-size: 17px; color: var(--ink-2); }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; }
.step { padding: 26px; display: flex; flex-direction: column; gap: 10px; }
.step .n { font-family: var(--font-display); font-weight: 700; color: var(--accent); font-size: 20px; }
.step h3 { font-family: var(--font-body); font-size: 19px; font-weight: 700; }
.step p { color: var(--ink-2); }

.dark-band { background: var(--dark); color: var(--dark-ink); }
.dark-band h2 { color: #fff; }
.dark-band .section-head p { color: #B9BCC4; }
.tier-card { background: var(--dark-2); border-radius: var(--radius-lg); padding: 26px; display: flex; flex-direction: column; gap: 14px; }
.tier-card p { color: #D6D8DD; }
.kv { display: flex; flex-direction: column; gap: 9px; border-top: 1px solid #33363F; padding-top: 14px; font-size: 15px; }
.kv div { display: flex; justify-content: space-between; gap: 12px; }
.kv dt, .kv .k { color: var(--dark-muted); }
.kv .v { font-weight: 600; }

.price-tabs { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }
.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-size: 13px; color: var(--muted); font-weight: 600; background: var(--surface-2); padding: 12px 18px; border-bottom: 1px solid var(--line); }
.table td { padding: 14px 18px; border-bottom: 1px solid var(--line-2); font-size: 15px; vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table .num { text-align: right; white-space: nowrap; }
.table-card { overflow: hidden; }
.table-scroll { overflow-x: auto; }

.notice { padding: 24px 26px; display: flex; gap: 16px; align-items: flex-start; }
.notice h3 { font-family: var(--font-body); font-size: 18px; margin-bottom: 8px; }
.notice p { color: var(--ink-2); }

.faq details { border-bottom: 1px solid var(--line); padding: 16px 0; }
.faq summary { font-weight: 600; font-size: 17px; cursor: pointer; list-style: none; display: flex; justify-content: space-between; gap: 12px; }
.faq summary::after { content: "+"; font-size: 22px; line-height: 1; color: var(--muted); }
.faq details[open] summary::after { content: "–"; }
.faq details p { margin-top: 10px; color: var(--ink-2); }

.site-footer { background: var(--dark); color: #B9BCC4; padding: 44px 0; }
.site-footer .wrap { display: flex; gap: 40px; flex-wrap: wrap; }
.site-footer .brand { color: #fff; }
.site-footer a { color: #D6D8DD; text-decoration: none; }
.site-footer a:hover { color: #fff; }
.footer-col { display: flex; flex-direction: column; gap: 10px; font-size: 14px; }

/* ==========================================================================
   Auth page
   ========================================================================== */
.auth-page { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.auth-card { width: 100%; max-width: 420px; padding: 28px; display: flex; flex-direction: column; gap: 18px; }
.tabs { display: grid; grid-template-columns: 1fr 1fr; background: var(--surface-2); border: 1px solid var(--line); border-radius: 12px; padding: 4px; }
.tabs button { min-height: 42px; border: 0; border-radius: 9px; background: none; font-weight: 600; color: var(--muted); cursor: pointer; }
.tabs button[aria-selected="true"] { background: var(--surface); color: var(--ink); box-shadow: 0 1px 3px rgba(0,0,0,.08); }

/* ==========================================================================
   Dashboard
   ========================================================================== */
.app { display: flex; min-height: 100vh; }
.sidebar {
  width: 248px; flex-shrink: 0; background: var(--dark); color: #E9E8E3;
  display: flex; flex-direction: column; gap: 22px; padding: 22px 16px;
  position: sticky; top: 0; height: 100vh;
}
.sidebar .brand { color: #fff; padding: 0 8px; }
.balance-card { background: var(--dark-2); border-radius: 14px; padding: 16px; display: flex; flex-direction: column; gap: 10px; }
.balance-card .k { font-size: 13px; color: var(--dark-muted); }
.balance-card .v { font-family: var(--font-display); font-size: 28px; font-weight: 700; color: #fff; }
.side-nav { display: flex; flex-direction: column; gap: 4px; }
.side-nav a {
  display: flex; align-items: center; gap: 12px; padding: 11px 12px; border-radius: 10px;
  color: #C4C7CE; text-decoration: none; font-size: 15px; font-weight: 500;
}
.side-nav a:hover { color: #fff; background: #1D2027; }
.side-nav a[aria-current="page"] { background: var(--dark-3); color: #fff; font-weight: 600; }
.side-user { margin-top: auto; display: flex; align-items: center; gap: 10px; padding: 14px 6px 0; border-top: 1px solid var(--dark-line); }
.avatar { width: 36px; height: 36px; flex-shrink: 0; border-radius: 999px; background: var(--accent); color: #fff; display: grid; place-items: center; font-weight: 700; font-size: 14px; }
.side-user .email { font-size: 13px; color: #fff; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; min-width: 0; }
.icon-btn { width: 44px; height: 44px; border: 0; background: none; color: var(--dark-muted); cursor: pointer; display: grid; place-items: center; border-radius: 10px; }
.icon-btn:hover { color: #fff; background: #1D2027; }

.main { flex: 1; min-width: 0; padding: 30px 36px 60px; display: flex; flex-direction: column; gap: 22px; }
.page-head { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.page-head h1 { font-size: 30px; flex: 1; }

.two-col { display: flex; gap: 22px; align-items: flex-start; }
.two-col > .primary { flex: 1; min-width: 0; }
.two-col > .aside { width: 340px; flex-shrink: 0; display: flex; flex-direction: column; gap: 16px; }
.panel { padding: 24px; display: flex; flex-direction: column; gap: 20px; }

.pill-row { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 2px; scrollbar-width: none; }
.pill-row::-webkit-scrollbar { display: none; }

.svc-list { display: flex; flex-direction: column; gap: 8px; max-height: 420px; overflow-y: auto; padding: 2px; }
.svc-option {
  width: 100%; display: flex; align-items: center; gap: 14px; padding: 13px 14px;
  border-radius: 12px; border: 2px solid var(--line); background: var(--surface); text-align: left; cursor: pointer;
}
.svc-option:hover { border-color: #C9C6BD; }
.svc-option[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-tint); }
.svc-option .grow { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.svc-option .t { font-weight: 600; font-size: 15px; }
.svc-option .s { font-size: 13px; color: var(--muted); }
.svc-option .p { font-weight: 700; font-size: 14px; white-space: nowrap; text-align: right; min-width: 88px; }

.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.charge-box { display: flex; align-items: center; gap: 16px; padding: 16px 18px; background: var(--bg); border-radius: 12px; flex-wrap: wrap; }
.charge-box .k { font-size: 13px; color: var(--muted); }
.charge-box .v { font-family: var(--font-display); font-size: 28px; font-weight: 700; }
.check { display: flex; gap: 12px; align-items: flex-start; font-size: 14px; color: var(--ink-2); cursor: pointer; }
.check input { width: 20px; height: 20px; margin: 1px 0 0; accent-color: var(--accent); flex-shrink: 0; }

.details { padding: 22px; display: flex; flex-direction: column; gap: 14px; }
.details h3 { font-family: var(--font-body); font-size: 16px; font-weight: 700; flex: 1; }
.details .kv { border-top-color: var(--line-2); font-size: 14px; }
.details .kv .k { color: var(--muted); }

.orders-toolbar { display: flex; gap: 12px; align-items: center; }
.orders-toolbar .pill-row { flex: 1; min-width: 0; }
.orders-toolbar .input { max-width: 280px; }
.orders-table th, .orders-table td { padding: 12px 14px; }
.orders-table td { font-size: 14px; }
.orders-table td[data-col="refill"] { white-space: nowrap; }
.orders-table .svc { font-weight: 600; }
.orders-table .link { font-size: 13px; color: var(--muted); max-width: 240px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.empty { padding: 40px 20px; text-align: center; color: var(--muted); }

.method-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.method { display: flex; align-items: center; gap: 14px; padding: 14px 16px; border-radius: 12px; border: 2px solid var(--line); background: var(--surface); cursor: pointer; text-align: left; }
.method[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-tint); }
.method .mark { width: 40px; height: 40px; border-radius: 10px; color: #fff; display: grid; place-items: center; font-weight: 700; flex-shrink: 0; }
.amount-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.amount-input { flex: 1; min-width: 140px; display: flex; align-items: center; gap: 6px; border: 1px solid var(--field); border-radius: 10px; background: var(--surface); padding: 0 14px; }
.amount-input:focus-within { outline: 3px solid var(--accent-soft); border-color: var(--accent); }
.amount-input input { border: 0; outline: 0; flex: 1; min-width: 0; min-height: 44px; font-size: 16px; background: transparent; }
.summary { background: var(--bg); border-radius: 14px; padding: 16px 18px; display: flex; flex-direction: column; gap: 10px; font-size: 15px; }
.summary div { display: flex; justify-content: space-between; gap: 12px; }
.topup-item { padding: 13px 0; border-top: 1px solid var(--line-2); display: flex; flex-direction: column; gap: 5px; }

/* Mobile top bar + bottom tabs (hidden on desktop) */
.topbar, .tabbar { display: none; }

/* ==========================================================================
   Responsive
   ========================================================================== */
@media (max-width: 980px) {
  .hero .wrap { grid-template-columns: 1fr; gap: 36px; }
  .grid-3 { grid-template-columns: 1fr; }
  .two-col { flex-direction: column; }
  .two-col > .aside { width: 100%; }
}
@media (max-width: 760px) {
  .site-nav { display: none; }
  .header-actions .btn-ghost { display: none; }
  .hero { padding: 44px 0 36px; }
  section.block { padding: 52px 0; }
  .table th, .table td { padding: 12px 14px; }

  .sidebar { display: none; }
  .topbar {
    display: flex; align-items: center; gap: 12px; position: sticky; top: 0; z-index: 30;
    background: var(--dark); color: #fff; padding: 10px 16px; min-height: 60px;
  }
  .topbar .brand { color: #fff; font-size: 19px; flex: 1; }
  .topbar .bal { font-family: var(--font-display); font-weight: 700; font-size: 17px; }
  .topbar .icon-btn { color: #C4C7CE; }
  .tabbar {
    display: grid; grid-template-columns: repeat(3, 1fr); position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
    background: var(--surface); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom);
  }
  .tabbar a { display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 9px 4px 10px; font-size: 12px; font-weight: 600; color: var(--muted); text-decoration: none; }
  .tabbar a[aria-current="page"] { color: var(--accent); }
  .app { flex-direction: column; }
  .main { padding: 20px 16px 96px; gap: 18px; }
  .page-head h1 { font-size: 26px; }
  .panel { padding: 18px; }
  .grid-2 { grid-template-columns: 1fr; }
  .svc-list { max-height: 360px; }

  .hide-mobile { display: none !important; }
  .orders-toolbar { flex-direction: column; align-items: stretch; }
  .orders-toolbar .input { max-width: none; }
  .orders-scroll { overflow-x: visible; }

  /* orders table → cards */
  .orders-table thead { display: none; }
  .orders-table, .orders-table tbody, .orders-table tr, .orders-table td { display: block; width: 100%; }
  .orders-table tr { padding: 14px 16px; border-bottom: 1px solid var(--line-2); display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; }
  .orders-table td { border: 0; padding: 0; }
  .orders-table td[data-col="svc"] { grid-column: 1 / -1; }
  .orders-table td[data-col="id"], .orders-table td[data-col="date"] { font-size: 12px; color: var(--muted); }
  .orders-table td[data-col="date"] { text-align: right; }
  .orders-table td[data-col="qty"]::before { content: "Qty "; color: var(--muted); }
  .orders-table td[data-col="remains"]::before { content: "Remains "; color: var(--muted); }
  .orders-table .num { text-align: left; }
  .orders-table td[data-col="remains"], .orders-table td[data-col="status"] { text-align: right; }
  .orders-table td[data-col="charge"] { font-size: 16px; }
  .orders-table td[data-col="refill"] { grid-column: 1 / -1; }
  .orders-table td[data-col="refill"]:has(.refill-none) { display: none; }
  .orders-table .link { max-width: none; }
}
