/* Billing SaaS — single stylesheet, no build step. */
:root {
  --bg: #f4f5f7;
  --surface: #ffffff;
  --surface-2: #f9fafb;
  --border: #e4e7ec;
  --text: #101828;
  --text-2: #475467;
  --muted: #667085;
  --primary: #1d4ed8;
  --primary-ink: #ffffff;
  --primary-soft: #eef2ff;
  --side: #0f172a;
  --side-text: #cbd5e1;
  --side-active: #1e293b;
  --green: #067647; --green-bg: #ecfdf3;
  --amber: #b54708; --amber-bg: #fffaeb;
  --red: #b42318; --red-bg: #fef3f2;
  --blue: #175cd3; --blue-bg: #eff8ff;
  --gray: #475467; --gray-bg: #f2f4f7;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06);
  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { font-family: var(--font); font-size: 14px; line-height: 1.5; color: var(--text); background: var(--bg); }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0; line-height: 1.25; }
h1 { font-size: 22px; font-weight: 650; }
h2 { font-size: 16px; font-weight: 600; }
h3 { font-size: 14px; font-weight: 600; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12.5px; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.mt { margin-top: 16px; } .mt-sm { margin-top: 8px; } .mb { margin-bottom: 16px; }

/* ---------- App shell ---------- */
.shell { display: grid; grid-template-columns: 240px 1fr; min-height: 100vh; }
.sidebar { background: var(--side); color: var(--side-text); padding: 16px 12px; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.brand { display: flex; align-items: center; gap: 10px; padding: 6px 10px 18px; color: #fff; font-weight: 650; font-size: 15px; }
.brand-mark { width: 30px; height: 30px; border-radius: 8px; background: var(--primary); display: grid; place-items: center; font-size: 14px; font-weight: 700; color: #fff; }
.nav-label { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: #64748b; padding: 14px 10px 6px; }
.nav a { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 10px; border-radius: 8px; color: var(--side-text); font-weight: 500; }
.nav a:hover { background: var(--side-active); color: #fff; text-decoration: none; }
.nav a.active { background: var(--side-active); color: #fff; box-shadow: inset 3px 0 0 var(--primary); }
.nav .count { background: #f59e0b; color: #111; border-radius: 999px; font-size: 11px; padding: 0 7px; font-weight: 700; }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar { background: var(--surface); border-bottom: 1px solid var(--border); padding: 10px 24px; display: flex; align-items: center; justify-content: space-between; gap: 12px; position: sticky; top: 0; z-index: 5; }
.topbar .who { display: flex; align-items: center; gap: 12px; color: var(--text-2); }
.menu-btn { display: none; background: none; border: 1px solid var(--border); border-radius: 8px; padding: 6px 10px; cursor: pointer; font-size: 16px; }
.content { padding: 24px; max-width: 1280px; width: 100%; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.page-head p { margin: 4px 0 0; color: var(--muted); }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* ---------- Cards & grid ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-head { padding: 14px 16px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.card-body { padding: 16px; }
.grid { display: grid; gap: 16px; }
.g-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.g-main { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }

.stat { padding: 16px; }
.stat .label { color: var(--muted); font-size: 12.5px; font-weight: 500; }
.stat .value { font-size: 24px; font-weight: 650; margin-top: 4px; font-variant-numeric: tabular-nums; }
.stat .sub { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.stat .up { color: var(--green); } .stat .down { color: var(--red); }
.stat-link { display: block; color: inherit; }
.stat-link:hover { text-decoration: none; border-color: #c7d2fe; }

dl.details { display: grid; grid-template-columns: 140px 1fr; gap: 8px 12px; margin: 0; }
dl.details dt { color: var(--muted); }
dl.details dd { margin: 0; word-break: break-word; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 10px 14px; text-align: left; border-bottom: 1px solid var(--border); vertical-align: middle; }
th { font-size: 12px; font-weight: 600; color: var(--muted); background: var(--surface-2); white-space: nowrap; }
tbody tr:hover { background: #fafbfc; }
tbody tr:last-child td { border-bottom: 0; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.empty { padding: 32px; text-align: center; color: var(--muted); }

/* ---------- Badges ---------- */
.badge { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.badge-green { color: var(--green); background: var(--green-bg); }
.badge-amber { color: var(--amber); background: var(--amber-bg); }
.badge-red { color: var(--red); background: var(--red-bg); }
.badge-blue { color: var(--blue); background: var(--blue-bg); }
.badge-gray { color: var(--gray); background: var(--gray-bg); }

/* ---------- Buttons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 8px 14px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface); color: var(--text); font: inherit; font-weight: 600; cursor: pointer; white-space: nowrap; }
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: var(--primary-ink); }
.btn-primary:hover { background: #1e40af; }
.btn-danger { color: var(--red); border-color: #fecdca; }
.btn-danger:hover { background: var(--red-bg); }
.btn-success { color: var(--green); border-color: #abefc6; }
.btn-success:hover { background: var(--green-bg); }
.btn-sm { padding: 5px 10px; font-size: 12.5px; }
.btn-block { width: 100%; }
.btn-link { background: none; border: 0; padding: 0; color: var(--primary); font: inherit; cursor: pointer; }

/* ---------- Forms ---------- */
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 16px; }
.form-grid .full { grid-column: 1 / -1; }
.field label { display: block; font-weight: 600; font-size: 13px; margin-bottom: 5px; color: var(--text-2); }
.field .hint { font-size: 12px; color: var(--muted); margin-top: 4px; }
.req::after { content: " *"; color: var(--red); }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=date], input[type=datetime-local], input[type=search], input[type=file], select, textarea {
  width: 100%; padding: 9px 11px; border: 1px solid #d0d5dd; border-radius: 8px; font: inherit; color: var(--text); background: #fff;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(29, 78, 216, .15); }
textarea { min-height: 80px; resize: vertical; }
.has-error input, .has-error select, .has-error textarea { border-color: var(--red); }
.field-error { color: var(--red); font-size: 12.5px; margin-top: 4px; }
.check { display: flex; align-items: center; gap: 8px; font-weight: 500; color: var(--text); }
.check input { width: 16px; height: 16px; }
.checks { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.form-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 18px; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; padding: 12px 16px; border-bottom: 1px solid var(--border); }
.filters input, .filters select { width: auto; min-width: 150px; padding: 7px 10px; }
.filters input[type=search] { min-width: 240px; }
.radio-cards { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.radio-cards label { border: 1px solid #d0d5dd; border-radius: 8px; padding: 10px 12px; cursor: pointer; display: flex; gap: 8px; align-items: flex-start; font-weight: 500; color: var(--text); margin: 0; }
.radio-cards label:has(input:checked) { border-color: var(--primary); background: var(--primary-soft); }

/* ---------- Alerts ---------- */
.alert { padding: 11px 14px; border-radius: 8px; margin-bottom: 14px; border: 1px solid; font-weight: 500; }
.alert-success { color: var(--green); background: var(--green-bg); border-color: #abefc6; }
.alert-error { color: var(--red); background: var(--red-bg); border-color: #fecdca; }
.alert-warning { color: var(--amber); background: var(--amber-bg); border-color: #fedf89; }
.alert-info { color: var(--blue); background: var(--blue-bg); border-color: #b2ddff; }

/* ---------- Misc ---------- */
.pagination { display: flex; gap: 8px; align-items: center; justify-content: flex-end; padding: 12px 16px; border-top: 1px solid var(--border); }
.pagination .muted { margin-right: auto; }
details.panel { border: 1px solid var(--border); border-radius: 8px; background: var(--surface); }
details.panel > summary { padding: 10px 14px; cursor: pointer; font-weight: 600; list-style: none; display: flex; justify-content: space-between; }
details.panel > summary::after { content: "+"; color: var(--muted); }
details.panel[open] > summary::after { content: "–"; }
details.panel > div { padding: 0 14px 14px; }
.stack > * + * { margin-top: 12px; }
.bars { display: grid; gap: 8px; }
.bar-row { display: grid; grid-template-columns: 70px 1fr 110px; gap: 10px; align-items: center; font-size: 12.5px; }
.bar { height: 10px; border-radius: 999px; background: var(--gray-bg); overflow: hidden; }
.bar > span { display: block; height: 100%; background: var(--primary); border-radius: 999px; }
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { padding: 8px 0; border-bottom: 1px dashed var(--border); font-size: 13px; }
.timeline li:last-child { border-bottom: 0; }
pre.json { margin: 0; white-space: pre-wrap; word-break: break-word; font-size: 11.5px; color: var(--text-2); max-width: 420px; }
.plan-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }
.plan-card { border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; background: #fff; }
.plan-card .price { font-size: 24px; font-weight: 700; margin: 6px 0 2px; }
.plan-card.current { border-color: var(--primary); box-shadow: 0 0 0 2px var(--primary-soft); }

/* ---------- Auth pages ---------- */
.auth-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; background: linear-gradient(180deg, #eef2ff 0%, var(--bg) 60%); }
.auth-card { width: 100%; max-width: 420px; }
.auth-card .card-body { padding: 28px; }
.auth-card h1 { font-size: 20px; margin-bottom: 4px; }
.auth-brand { display: flex; align-items: center; gap: 10px; justify-content: center; margin-bottom: 18px; font-weight: 650; font-size: 16px; }
.auth-wide { max-width: 560px; }

/* ---------- Lock screen ---------- */
.lock { max-width: 640px; margin: 24px auto; text-align: center; }
.lock .icon { width: 56px; height: 56px; border-radius: 50%; display: grid; place-items: center; margin: 0 auto 14px; font-size: 26px; background: var(--red-bg); color: var(--red); }

/* ---------- Responsive ---------- */
@media (max-width: 1024px) {
  .g-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .g-main { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 760px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; inset: 0 auto 0 0; width: 260px; z-index: 20; transform: translateX(-100%); transition: transform .2s; }
  body.nav-open .sidebar { transform: none; box-shadow: 0 0 0 100vmax rgba(0, 0, 0, .4); }
  .menu-btn { display: inline-block; }
  .content { padding: 16px; }
  .topbar { padding: 10px 16px; }
  .g-2, .g-3, .g-4, .form-grid, .checks, .radio-cards { grid-template-columns: minmax(0, 1fr); }
  .shell { grid-template-columns: minmax(0, 1fr); }
  .filters input, .filters select, .filters input[type=search] { min-width: 0; width: 100%; }
  dl.details { grid-template-columns: 110px 1fr; }
  .hide-sm { display: none; }
}
input::placeholder, textarea::placeholder { text-transform: none; color: #98a2b3; }

/* Password show / hide eye */
.pw-wrap { position: relative; display: block; }
.pw-wrap input { width: 100%; padding-right: 44px; }
.pw-toggle { position: absolute; top: 0; right: 0; bottom: 0; width: 42px; display: flex; align-items: center; justify-content: center;
  border: 0; background: none; color: var(--muted, #667085); cursor: pointer; padding: 0; border-radius: 0 8px 8px 0; }
.pw-toggle:hover, .pw-toggle:focus-visible { color: var(--primary, #2563eb); }
.pw-toggle:focus-visible { outline: 2px solid var(--primary, #2563eb); outline-offset: -2px; }