/* WL Billing — FlyWP-style dashboard */
:root {
  --primary: #4F46E5;
  --bg: #F4F5F7;
  --side: #F7F7F8;
  --card: #FFFFFF;
  --border: #E5E7EB;
  --border-strong: #D1D5DB;
  --text: #111827;
  --muted: #6B7280;
  --soft: #9CA3AF;
  --green: #16A34A; --green-bg: #DCFCE7;
  --red: #DC2626;   --red-bg: #FEE2E2;
  --amber: #B45309; --amber-bg: #FEF3C7;
  --blue: #2563EB;  --blue-bg: #DBEAFE;
  --gray-bg: #F3F4F6;
  --radius: 8px;
  --shadow: 0 1px 2px rgba(16,24,40,.04);
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 14px; line-height: 1.5; color: var(--text); background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
code, .mono { font-family: "JetBrains Mono", ui-monospace, Menlo, monospace; font-size: 12.5px; }
h1, h2, h3 { margin: 0; font-weight: 600; letter-spacing: -.01em; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }

/* ---------- Admin shell ---------- */
.sidebar {
  position: fixed; inset: 0 auto 0 0; width: 256px; background: var(--side);
  border-right: 1px solid var(--border); display: flex; flex-direction: column; z-index: 30;
}
.sidebar-brand { height: 64px; display: flex; align-items: center; gap: 10px; padding: 0 20px; border-bottom: 1px solid var(--border); }
.brand-dot {
  width: 30px; height: 30px; border-radius: 50%; background: var(--primary); color: #fff;
  display: grid; place-items: center; font-weight: 700; font-size: 12px;
}
.brand-name { font-weight: 700; font-size: 16px; letter-spacing: -.02em; }
.brand-logo { max-height: 34px; max-width: 180px; object-fit: contain; }
.side-nav { padding: 12px; display: flex; flex-direction: column; gap: 2px; overflow-y: auto; }
.side-label { font-size: 11px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--soft); padding: 14px 12px 6px; }
.side-nav a {
  display: flex; align-items: center; gap: 10px; padding: 8px 12px; border-radius: 8px;
  color: #374151; font-weight: 500; border: 1px solid transparent;
}
.side-nav a svg { color: var(--muted); }
.side-nav a:hover { background: #EEEFF1; text-decoration: none; }
.side-nav a.active { background: #fff; border-color: var(--border); box-shadow: var(--shadow); color: var(--text); }
.side-nav a.active svg { color: var(--primary); }

.main { margin-left: 256px; min-height: 100vh; }
.topbar {
  height: 64px; background: #fff; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 12px; padding: 0 32px; position: sticky; top: 0; z-index: 20;
}
.topbar-title { font-weight: 600; color: var(--muted); }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.user-chip { display: flex; align-items: center; gap: 8px; font-weight: 500; }
.avatar {
  width: 30px; height: 30px; border-radius: 50%; background: #EA580C; color: #fff;
  display: grid; place-items: center; font-weight: 600; font-size: 12px;
}
.icon-btn {
  width: 36px; height: 36px; display: grid; place-items: center; border-radius: 8px; color: var(--muted);
  background: transparent; border: 1px solid transparent; cursor: pointer;
}
.icon-btn:hover { background: var(--gray-bg); color: var(--text); text-decoration: none; }
.mobile-only { display: none; }

.page-head {
  display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap;
  padding: 24px 32px; border-bottom: 1px solid var(--border); background: var(--bg);
}
.page-head h1 { font-size: 22px; }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.content { padding: 24px 32px 48px; max-width: 1280px; }

/* ---------- Cards ---------- */
.card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); margin-bottom: 16px; }
.card-head { padding: 20px 24px; border-bottom: 1px solid var(--border); display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.card-head h2 { font-size: 17px; }
.card-head p { margin: 4px 0 0; color: var(--muted); }
.card-body { padding: 20px 24px; }
.card-foot { padding: 14px 24px; border-top: 1px solid var(--border); display: flex; gap: 8px; justify-content: flex-end; background: #FCFCFD; border-radius: 0 0 var(--radius) var(--radius); }

.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.split { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: 16px; align-items: start; }

.stat { padding: 20px 24px; }
.stat-label { color: var(--muted); font-weight: 500; font-size: 13px; }
.stat-value { font-size: 28px; font-weight: 600; letter-spacing: -.02em; margin-top: 6px; font-variant-numeric: tabular-nums; }
.stat-sub { color: var(--muted); font-size: 12.5px; margin-top: 2px; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th {
  text-align: left; font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .04em;
  padding: 10px 24px; background: #FAFAFB; border-bottom: 1px solid var(--border); white-space: nowrap;
}
td { padding: 14px 24px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #FAFAFB; }
td .sub { color: var(--muted); font-size: 12.5px; }
.cust { display: flex; align-items: center; gap: 12px; }
.cust .avatar { background: var(--primary); }
.empty { padding: 48px 24px; text-align: center; color: var(--muted); }

/* ---------- Badges ---------- */
.badge { display: inline-flex; align-items: center; padding: 2px 8px; border-radius: 6px; font-size: 12px; font-weight: 500; white-space: nowrap; }
.badge-green { background: var(--green-bg); color: #15803D; }
.badge-red   { background: var(--red-bg); color: #B91C1C; }
.badge-amber { background: var(--amber-bg); color: var(--amber); }
.badge-blue  { background: var(--blue-bg); color: #1D4ED8; }
.badge-gray  { background: var(--gray-bg); color: #4B5563; }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; background: var(--soft); }
.dot.ok { background: var(--green); } .dot.bad { background: var(--red); } .dot.warn { background: #F59E0B; }

/* ---------- Forms ---------- */
.field { margin-bottom: 18px; }
.field:last-child { margin-bottom: 0; }
label, .label { display: block; font-weight: 500; margin-bottom: 6px; }
.req { color: var(--red); }
.hint { color: var(--muted); font-size: 13px; margin-top: 6px; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=url], select, textarea {
  width: 100%; height: 40px; padding: 0 12px; border: 1px solid var(--border-strong); border-radius: 6px;
  font: inherit; color: var(--text); background: #fff; transition: border-color .15s, box-shadow .15s;
}
textarea { height: auto; min-height: 92px; padding: 10px 12px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 18%, transparent); }
input.mono { font-family: "JetBrains Mono", monospace; font-size: 13px; }
.color-field { display: flex; gap: 8px; align-items: center; }
.color-field input[type=color] { width: 40px; height: 40px; padding: 3px; border: 1px solid var(--border-strong); border-radius: 6px; background: #fff; }
.color-field input[type=text] { max-width: 140px; font-family: "JetBrains Mono", monospace; }
.check { display: flex; gap: 10px; align-items: flex-start; font-weight: 400; }
.check input { margin-top: 3px; width: 16px; height: 16px; accent-color: var(--primary); }
.inline-form { display: inline; }
.input-row { display: flex; gap: 8px; }
.input-row > * { flex: 1; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 38px; padding: 0 16px;
  border-radius: 6px; border: 1px solid transparent; font: inherit; font-weight: 500; cursor: pointer; white-space: nowrap;
  text-decoration: none !important; transition: filter .15s, background .15s;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { filter: brightness(.92); }
.btn-secondary { background: #fff; color: var(--text); border-color: var(--border-strong); }
.btn-secondary:hover { background: var(--gray-bg); }
.btn-danger { background: #fff; color: var(--red); border-color: #FCA5A5; }
.btn-danger:hover { background: var(--red-bg); }
.btn-ghost { background: transparent; color: var(--text); }
.btn-ghost:hover { background: var(--gray-bg); }
.btn-sm { height: 32px; padding: 0 12px; font-size: 13px; }
.btn-block { width: 100%; }

/* ---------- Alerts ---------- */
.alert { padding: 12px 16px; border-radius: 8px; margin-bottom: 16px; border: 1px solid; font-weight: 500; }
.alert-success { background: #F0FDF4; border-color: #BBF7D0; color: #166534; }
.alert-error   { background: #FEF2F2; border-color: #FECACA; color: #991B1B; }
.alert-warning { background: #FFFBEB; border-color: #FDE68A; color: #92400E; }
.alert-info    { background: #EFF6FF; border-color: #BFDBFE; color: #1E40AF; }

/* ---------- Setup checklist / KV ---------- */
.checklist { list-style: none; margin: 0; padding: 0; }
.checklist li { display: flex; align-items: center; gap: 12px; padding: 12px 24px; border-bottom: 1px solid var(--border); }
.checklist li:last-child { border-bottom: 0; }
.checklist .tick { width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; background: var(--gray-bg); color: var(--soft); flex: none; }
.checklist .tick.done { background: var(--green); color: #fff; }
.checklist .grow { flex: 1; }
.kv { display: grid; grid-template-columns: 160px 1fr; gap: 10px 16px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; word-break: break-word; }
.copy-box { display: flex; align-items: center; gap: 8px; background: var(--gray-bg); border: 1px solid var(--border); border-radius: 6px; padding: 8px 8px 8px 12px; }
.copy-box code { flex: 1; overflow-x: auto; white-space: nowrap; }

.log { list-style: none; margin: 0; padding: 0; }
.log li { display: flex; gap: 12px; padding: 12px 24px; border-bottom: 1px solid var(--border); }
.log li:last-child { border-bottom: 0; }
.log .dot { margin-top: 7px; flex: none; }
.log .when { margin-left: auto; color: var(--soft); font-size: 12.5px; white-space: nowrap; }
.dot.info { background: var(--soft); } .dot.success { background: var(--green); } .dot.warning { background: #F59E0B; } .dot.error { background: var(--red); }

/* ---------- Auth ---------- */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; background: var(--bg); }
.auth-card { width: 100%; max-width: 400px; }
.auth-brand { display: flex; align-items: center; justify-content: center; gap: 10px; margin-bottom: 20px; }

/* ---------- Public ---------- */
.pub-header {
  height: 64px; display: flex; align-items: center; justify-content: space-between; padding: 0 32px;
  background: #fff; border-bottom: 1px solid var(--border);
}
.pub-brand { display: flex; align-items: center; gap: 10px; color: var(--text); text-decoration: none !important; }
.pub-header nav { display: flex; align-items: center; gap: 16px; }
.pub-header nav > a:not(.btn) { color: var(--muted); font-weight: 500; }
.pub-main { max-width: 1120px; margin: 0 auto; padding: 48px 24px 64px; }
.hero { text-align: center; padding: 40px 24px; border-radius: 16px; margin-bottom: 40px;
  background: color-mix(in srgb, var(--primary) 7%, #fff); }
.hero h1 { font-size: clamp(28px, 4vw, 40px); letter-spacing: -.03em; }
.hero p { color: var(--muted); font-size: 16px; max-width: 560px; margin: 12px auto 0; }
.pricing { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 16px; }
.price-card { display: flex; flex-direction: column; padding: 28px; position: relative; }
.price-card.featured { border-color: var(--primary); box-shadow: 0 0 0 1px var(--primary), 0 8px 24px rgba(16,24,40,.08); }
.price-card .ribbon { position: absolute; top: -11px; left: 28px; background: var(--primary); color: #fff; font-size: 12px; font-weight: 600; padding: 2px 10px; border-radius: 999px; }
.price-card h3 { font-size: 18px; }
.price { font-size: 36px; font-weight: 700; letter-spacing: -.03em; margin: 12px 0 2px; }
.price small { font-size: 14px; color: var(--muted); font-weight: 500; }
.features { list-style: none; padding: 0; margin: 20px 0 24px; display: grid; gap: 10px; flex: 1; align-content: start; }
.features li { display: flex; gap: 10px; align-items: flex-start; }
.features li svg { color: var(--green); flex: none; margin-top: 2px; }
.pub-narrow { max-width: 560px; margin: 0 auto; }
.pub-footer { text-align: center; color: var(--muted); padding: 24px; border-top: 1px solid var(--border); background: #fff; font-size: 13px; }
.summary { display: flex; justify-content: space-between; align-items: center; padding: 16px 24px; background: #FAFAFB; border-bottom: 1px solid var(--border); }

/* ---------- Responsive ---------- */
@media (max-width: 1024px) {
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .split, .grid-3 { grid-template-columns: 1fr; }
}
@media (max-width: 820px) {
  .sidebar { transform: translateX(-100%); transition: transform .2s; }
  body.nav-open .sidebar { transform: none; }
  .scrim { display: none; }
  body.nav-open .scrim { display: block; position: fixed; inset: 0; background: rgba(0,0,0,.3); z-index: 25; }
  .main { margin-left: 0; }
  .mobile-only { display: grid; }
  .topbar, .page-head { padding-left: 16px; padding-right: 16px; }
  .content { padding: 16px; }
  .grid-2 { grid-template-columns: 1fr; }
  .hide-sm { display: none; }
  th, td { padding-left: 16px; padding-right: 16px; }
  .kv { grid-template-columns: 1fr; gap: 2px 0; }
  .kv dd { margin-bottom: 10px; }
  .pub-header { padding: 0 16px; }
  .pub-main { padding: 24px 16px 48px; }
}
@media (max-width: 480px) { .grid-4 { grid-template-columns: 1fr; } }
