/* HewaLink design system — simple, light, mobile-first. */
:root {
    --brand: #16a34a;
    --brand-ink: #ffffff;
    --brand-soft: color-mix(in srgb, var(--brand) 12%, white);
    --ink: #0f172a;
    --muted: #64748b;
    --line: #e2e8f0;
    --bg: #f4f6f9;
    --card: #ffffff;
    --nav: #0f1b2d;
    --nav-ink: #cbd5e1;
    --ok: #15803d;
    --ok-soft: #dcfce7;
    --warn: #b45309;
    --warn-soft: #fef3c7;
    --bad: #b91c1c;
    --bad-soft: #fee2e2;
    --info: #1d4ed8;
    --info-soft: #dbeafe;
    --radius: 12px;
    --shadow: 0 1px 2px rgba(15, 23, 42, .06), 0 4px 14px rgba(15, 23, 42, .05);
    --font: -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font-family: var(--font); color: var(--ink); background: var(--bg); line-height: 1.45; font-size: 15px; }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { line-height: 1.2; margin: 0 0 .4em; }
h1 { font-size: 1.6rem; } h2 { font-size: 1.15rem; } h3 { font-size: 1rem; }
p { margin: 0 0 .8em; }
code, .mono { font-family: var(--mono); font-size: .88em; }
hr { border: 0; border-top: 1px solid var(--line); margin: 1.2rem 0; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.right { text-align: right; }
.center { text-align: center; }
.nowrap { white-space: nowrap; }
.stack > * + * { margin-top: 1rem; }
.row { display: flex; gap: .75rem; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.grow { flex: 1 1 auto; }
.hide { display: none !important; }

/* ---------- panel shell ---------- */
.app { display: grid; grid-template-columns: 248px 1fr; min-height: 100vh; }
.sidebar { background: var(--nav); color: var(--nav-ink); padding: 1rem .75rem; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.brand { display: flex; gap: .6rem; align-items: center; padding: .4rem .6rem 1rem; color: #fff; }
.brand .logo { width: 36px; height: 36px; border-radius: 10px; background: var(--brand); display: grid; place-items: center; color: #fff; font-weight: 700; flex: none; overflow: hidden; }
.brand .logo img { width: 100%; height: 100%; object-fit: cover; }
.brand b { display: block; font-size: 1rem; }
.brand small { display: block; font-size: .72rem; color: #94a3b8; max-width: 150px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-section { margin-top: 1.1rem; }
.nav-title { text-transform: uppercase; letter-spacing: .08em; font-size: .68rem; color: #64748b; padding: 0 .6rem .3rem; }
.nav-link { display: flex; align-items: center; gap: .65rem; padding: .55rem .7rem; border-radius: 9px; color: var(--nav-ink); font-size: .93rem; }
.nav-link:hover { background: rgba(255, 255, 255, .06); text-decoration: none; color: #fff; }
.nav-link.active { background: var(--brand); color: #fff; font-weight: 600; }
.nav-link svg { width: 18px; height: 18px; flex: none; opacity: .9; }
.main { min-width: 0; display: flex; flex-direction: column; }
.topbar { display: flex; align-items: center; gap: 1rem; padding: .7rem 1.5rem; background: var(--card); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; }
.topbar .title { font-weight: 700; font-size: 1.05rem; }
.btn.menu-btn { display: none; }
.userbox { display: flex; align-items: center; gap: .6rem; }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--brand-soft); color: var(--brand); display: grid; place-items: center; font-weight: 700; font-size: .85rem; }
.content { padding: 1.5rem; max-width: 1280px; width: 100%; margin: 0 auto; }
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.2rem; border-bottom: 1px solid var(--line); padding-bottom: 1rem; }
.eyebrow { text-transform: uppercase; letter-spacing: .1em; font-size: .7rem; color: var(--brand); font-weight: 700; }
.page-head p { margin: 0; color: var(--muted); }

/* ---------- surfaces ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-top: 3px solid var(--brand); border-radius: var(--radius); box-shadow: var(--shadow); }
.card.plain { border-top-width: 1px; }
.card-head { padding: .9rem 1.2rem; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; gap: .6rem; flex-wrap: wrap; }
.card-head h2, .card-head h3 { margin: 0; }
.card-body { padding: 1.2rem; }
.grid { display: grid; gap: 1rem; }
.grid.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.stat { padding: 1rem 1.2rem; }
.stat .label { color: var(--muted); font-size: .8rem; }
.stat .value { font-size: 1.5rem; font-weight: 700; margin-top: .15rem; }
.stat .hint { color: var(--muted); font-size: .78rem; margin-top: .15rem; }
.stat.bad .value { color: var(--bad); } .stat.ok .value { color: var(--ok); }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .92rem; }
th { text-align: left; font-weight: 600; color: var(--muted); font-size: .76rem; text-transform: uppercase; letter-spacing: .04em; padding: .6rem .8rem; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: .7rem .8rem; border-bottom: 1px solid var(--line); vertical-align: top; }
tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #f8fafc; }
td.actions { white-space: nowrap; text-align: right; }
td.actions form { display: inline; }
.link-btn { background: none; border: 0; color: var(--brand); cursor: pointer; font: inherit; padding: 0 .3rem; }
.link-btn:hover { text-decoration: underline; }
.link-btn.danger { color: var(--bad); }

/* ---------- badges, alerts ---------- */
.badge { display: inline-block; padding: .12rem .55rem; border-radius: 999px; font-size: .74rem; font-weight: 600; background: #e2e8f0; color: #334155; white-space: nowrap; }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.bad { background: var(--bad-soft); color: var(--bad); }
.badge.info { background: var(--info-soft); color: var(--info); }
.badge.muted { background: #f1f5f9; color: var(--muted); }
.dot { display: inline-block; width: .6rem; height: .6rem; border-radius: 50%; background: #94a3b8; margin-right: .35rem; }
.dot.ok { background: #22c55e; } .dot.warn { background: #f59e0b; } .dot.bad { background: #ef4444; }
.alert { padding: .75rem 1rem; border-radius: 10px; border: 1px solid; margin-bottom: 1rem; font-size: .92rem; }
.alert.ok { background: var(--ok-soft); border-color: #86efac; color: #14532d; }
.alert.err, .alert.bad { background: var(--bad-soft); border-color: #fca5a5; color: #7f1d1d; }
.alert.warn { background: var(--warn-soft); border-color: #fcd34d; color: #78350f; }
.alert.info { background: var(--info-soft); border-color: #93c5fd; color: #1e3a8a; }
.banner { background: #fef3c7; color: #78350f; text-align: center; padding: .5rem 1rem; font-size: .88rem; }
.banner.impersonate { background: #7c2d12; color: #fff; }
.banner.impersonate form { display: inline; }

/* ---------- forms ---------- */
.field { margin-bottom: 1rem; }
.field label { display: block; font-weight: 600; font-size: .85rem; margin-bottom: .3rem; }
.input, select, textarea { width: 100%; padding: .65rem .8rem; border: 1px solid #cbd5e1; border-radius: 9px; font: inherit; color: var(--ink); background: #fff; }
.input:focus, select:focus, textarea:focus { outline: 2px solid color-mix(in srgb, var(--brand) 35%, transparent); border-color: var(--brand); }
textarea { min-height: 90px; resize: vertical; }
.help { color: var(--muted); font-size: .8rem; margin-top: .25rem; }
.err-text { color: var(--bad); font-size: .82rem; margin-top: .25rem; }
.check { display: flex; gap: .5rem; align-items: center; font-weight: 500; }
.check input { width: auto; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 1rem; }
.form-actions { display: flex; gap: .6rem; margin-top: .5rem; flex-wrap: wrap; }
.toolbar { display: flex; gap: .6rem; flex-wrap: wrap; align-items: center; margin-bottom: 1rem; }
.toolbar .input, .toolbar select { width: auto; min-width: 160px; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: .4rem; padding: .62rem 1rem; border-radius: 9px; border: 1px solid transparent; background: var(--brand); color: var(--brand-ink); font: inherit; font-weight: 600; cursor: pointer; text-decoration: none; }
.btn:hover { filter: brightness(.95); text-decoration: none; }
.btn.ghost { background: #fff; border-color: #cbd5e1; color: var(--ink); }
.btn.dark { background: var(--nav); color: #fff; }
.btn.danger { background: var(--bad); color: #fff; }
.btn.sm { padding: .35rem .7rem; font-size: .85rem; }
.btn.block { width: 100%; }
.btn:disabled, .btn[disabled] { background: #cbd5e1; color: #fff; cursor: not-allowed; filter: none; }

.tabs { display: flex; gap: .2rem; border-bottom: 1px solid var(--line); margin-bottom: 1rem; overflow-x: auto; }
.tab { padding: .6rem 1rem; color: var(--muted); border-bottom: 2px solid transparent; white-space: nowrap; font-weight: 600; }
.tab.active { color: var(--brand); border-color: var(--brand); }
.tab:hover { text-decoration: none; color: var(--ink); }

.empty { text-align: center; padding: 2.5rem 1rem; color: var(--muted); }
.empty h3 { color: var(--ink); }
.pager { display: flex; gap: .3rem; align-items: center; justify-content: space-between; padding: .8rem 1rem; flex-wrap: wrap; color: var(--muted); font-size: .85rem; }
.pager a, .pager span.cur { padding: .25rem .6rem; border-radius: 7px; border: 1px solid var(--line); background: #fff; color: var(--ink); }
.pager span.cur { background: var(--brand); color: #fff; border-color: var(--brand); }
.bar { height: 10px; background: #e2e8f0; border-radius: 999px; overflow: hidden; }
.bar > span { display: block; height: 100%; background: var(--brand); border-radius: 999px; }
.bar.warn > span { background: #f59e0b; } .bar.bad > span { background: #ef4444; }
.copy-box { display: flex; gap: .5rem; align-items: stretch; }
.copy-box code { flex: 1; background: #0f172a; color: #e2e8f0; padding: .6rem .8rem; border-radius: 9px; overflow-x: auto; white-space: pre; }
pre.code { background: #0f172a; color: #e2e8f0; padding: 1rem; border-radius: 10px; overflow-x: auto; font-family: var(--mono); font-size: .82rem; line-height: 1.5; margin: 0; }
.kv { display: grid; grid-template-columns: 180px 1fr; gap: .45rem 1rem; font-size: .92rem; }
.kv dt { color: var(--muted); } .kv dd { margin: 0; word-break: break-word; }
.steps { counter-reset: s; list-style: none; padding: 0; margin: 0; }
.steps li { counter-increment: s; position: relative; padding: .2rem 0 1rem 2.6rem; }
.steps li::before { content: counter(s); position: absolute; left: 0; top: 0; width: 1.8rem; height: 1.8rem; border-radius: 50%; background: var(--brand-soft); color: var(--brand); display: grid; place-items: center; font-weight: 700; font-size: .85rem; }
.chart { width: 100%; height: auto; display: block; }
.chart text { font-family: var(--font); font-size: 11px; fill: var(--muted); }
.legend { display: flex; gap: 1rem; font-size: .8rem; color: var(--muted); flex-wrap: wrap; margin-top: .4rem; }
.legend i { display: inline-block; width: .7rem; height: .7rem; border-radius: 3px; margin-right: .3rem; vertical-align: -1px; }

/* ---------- public / auth pages ---------- */
.public { min-height: 100vh; display: grid; place-items: center; padding: 1rem; }
.public .card { width: 100%; max-width: 420px; }
.public .brand { color: var(--ink); justify-content: center; padding-bottom: 1.2rem; }
.public .brand small { color: var(--muted); }

/* ---------- captive portal / customer area ---------- */
.portal-wrap { max-width: 560px; margin: 0 auto; padding: 0 1rem 3rem; }
.portal-head { display: flex; align-items: center; justify-content: space-between; padding: 1rem 0; gap: .6rem; }
.portal-head .brand { padding: 0; color: var(--ink); }
.portal-head .brand small { color: var(--muted); }
.lang { display: flex; gap: .3rem; font-size: .82rem; }
.lang a, .lang b { padding: .2rem .5rem; border-radius: 7px; border: 1px solid var(--line); background: #fff; color: var(--ink); }
.lang b { background: var(--brand); color: #fff; border-color: var(--brand); }
.hero { background: linear-gradient(135deg, var(--brand), color-mix(in srgb, var(--brand) 60%, #0f172a)); color: #fff; border-radius: 16px; padding: 1.3rem; margin-bottom: 1rem; }
.hero h1 { margin: 0 0 .3rem; font-size: 1.4rem; }
.hero p { margin: 0; opacity: .92; }
.pkg-grid { display: grid; gap: .75rem; }
.pkg { background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: 1rem; display: grid; grid-template-columns: 1fr auto; gap: .2rem 1rem; align-items: center; box-shadow: var(--shadow); }
.pkg.featured { border-color: var(--brand); box-shadow: 0 0 0 2px var(--brand-soft), var(--shadow); }
.pkg .name { font-weight: 700; font-size: 1.05rem; }
.pkg .allow { font-size: 1.25rem; font-weight: 800; color: var(--brand); }
.pkg .meta { color: var(--muted); font-size: .8rem; grid-column: 1 / 2; }
.pkg .price { text-align: right; font-weight: 800; font-size: 1.05rem; }
.pkg .btn { grid-column: 2; grid-row: 2 / 4; align-self: end; }
.portal-card { background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: 1rem; margin-top: 1rem; }
.portal-card summary { cursor: pointer; font-weight: 700; }
.sheet-backdrop { position: fixed; inset: 0; background: rgba(15, 23, 42, .55); display: none; align-items: flex-end; justify-content: center; z-index: 50; }
.sheet-backdrop.show { display: flex; }
.sheet { background: #fff; width: 100%; max-width: 560px; border-radius: 20px 20px 0 0; padding: 1.3rem 1.2rem 1.6rem; max-height: 92vh; overflow-y: auto; }
.sheet .status { text-align: center; padding: .6rem 0; }
.spinner { width: 46px; height: 46px; border: 4px solid #e2e8f0; border-top-color: var(--brand); border-radius: 50%; margin: .5rem auto 1rem; animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.bigcheck { width: 60px; height: 60px; border-radius: 50%; background: var(--ok-soft); color: var(--ok); display: grid; place-items: center; font-size: 2rem; margin: 0 auto .6rem; }
.receipt-code { font-family: var(--mono); font-size: 1.5rem; letter-spacing: .15em; font-weight: 800; background: #f1f5f9; padding: .5rem .8rem; border-radius: 10px; display: inline-block; }
.cnav { display: flex; gap: .25rem; overflow-x: auto; margin-bottom: 1rem; border-bottom: 1px solid var(--line); }
.cnav a { padding: .6rem .9rem; color: var(--muted); font-weight: 600; border-bottom: 2px solid transparent; white-space: nowrap; }
.cnav a.active { color: var(--brand); border-color: var(--brand); text-decoration: none; }
.footer { text-align: center; color: var(--muted); font-size: .8rem; padding: 1.5rem 0; }

/* ---------- responsive ---------- */
@media (max-width: 960px) {
    .app { grid-template-columns: 1fr; }
    .sidebar { position: fixed; left: 0; top: 0; bottom: 0; width: 260px; z-index: 40; transform: translateX(-100%); transition: transform .2s; }
    .sidebar.open { transform: none; }
    .btn.menu-btn { display: inline-flex; }
    .grid.cols-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .grid.cols-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .content { padding: 1rem; }
    .topbar { padding: .6rem 1rem; }
}
@media (max-width: 640px) {
    .grid.cols-2, .grid.cols-3, .grid.cols-4, .form-grid { grid-template-columns: 1fr; }
    .kv { grid-template-columns: 1fr; gap: 0; } .kv dd { margin-bottom: .6rem; }
    h1 { font-size: 1.35rem; }
    .toolbar .input, .toolbar select { width: 100%; }
}
@media print {
    .sidebar, .topbar, .no-print { display: none !important; }
    .app { display: block; } body { background: #fff; }
}
