/* CloudHS subscriber portal — pink theme, square corners
   Display: Space Grotesk · Body/UI: Inter */

:root {
    --bg: #fdf2f8;
    --bg-grad-a: #fdf2f8;
    --bg-grad-b: #fbe8f2;
    --surface: #ffffff;
    --ink: #1f2937;
    --muted: #6b7280;
    --faint: #9ca3af;
    --line: #f3d9e8;
    --line-2: #eee1ea;

    --brand: #ec4899;
    --brand-2: #db2777;
    --brand-tint: #fce7f3;

    --online: #16a34a;
    --online-tint: #dcfce7;
    --danger: #dc2626;
    --danger-tint: #fee2e2;
    --amber: #d9820a;
    --amber-tint: #fbf0e0;

    --ink-panel: #1f2937;
    --shadow: 0 1px 2px rgba(31, 41, 55, 0.04), 0 12px 30px rgba(236, 72, 153, 0.07);
    --shadow-sm: 0 1px 2px rgba(31, 41, 55, 0.05);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html { -webkit-text-size-adjust: 100%; }

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    color: var(--ink);
    background:
        radial-gradient(1200px 600px at 100% -10%, #fbdcec 0%, rgba(251, 220, 236, 0) 55%),
        linear-gradient(180deg, var(--bg-grad-a), var(--bg-grad-b));
    background-attachment: fixed;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    -webkit-font-smoothing: antialiased;
    line-height: 1.5;
}

h1, h2, h3, .display {
    font-family: 'Space Grotesk', 'Inter', sans-serif;
    letter-spacing: -0.01em;
    color: var(--ink);
}

.mono-num { font-variant-numeric: tabular-nums; font-feature-settings: 'tnum' 1; }

/* ── Brand / logo ───────────────────────────────────────────── */
.brand { display: inline-flex; align-items: center; text-decoration: none; }
.brand img { display: block; height: 40px; width: auto; }

/* ── Layout ─────────────────────────────────────────────────── */
.topbar {
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: saturate(180%) blur(12px);
    border-bottom: 1px solid var(--line);
    position: sticky; top: 0; z-index: 20;
}
.topbar-in { max-width: 680px; margin: 0 auto; padding: 14px 20px; display: flex; align-items: center; justify-content: space-between; }
.topbar .who { font-size: 12.5px; color: var(--muted); margin-top: 3px; }
.container { max-width: 680px; margin: 0 auto; padding: 22px 20px 60px; }

.eyebrow { font-size: 11px; font-weight: 600; letter-spacing: 0.12em; text-transform: uppercase; color: var(--faint); }
.page-title { font-size: 24px; font-weight: 700; margin: 4px 0 18px; }

/* ── Auth (login) ───────────────────────────────────────────── */
.auth { flex: 1; display: flex; align-items: center; justify-content: center; padding: 24px; }
.auth-card { width: 100%; max-width: 400px; background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow); padding: 34px 30px; }
.auth-head { text-align: center; margin-bottom: 26px; }
.auth-head .brand { justify-content: center; }
.auth-head .brand img { height: 72px; }
.auth-head .tag { display: block; margin-top: 12px; font-size: 13px; color: var(--muted); }
.auth-title { font-size: 20px; font-weight: 600; margin-bottom: 4px; }
.auth-sub { font-size: 13.5px; color: var(--muted); margin-bottom: 20px; }

/* ── Cards ──────────────────────────────────────────────────── */
.card { background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow); padding: 20px; margin-bottom: 16px; }
.card-lead { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.acct-name { font-family: 'Space Grotesk', sans-serif; font-size: 19px; font-weight: 600; letter-spacing: -0.01em; }
.acct-meta { font-size: 13px; color: var(--muted); margin-top: 3px; }

/* ── Status pill + live dot ─────────────────────────────────── */
.status { display: inline-flex; align-items: center; gap: 7px; padding: 5px 11px 5px 9px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.status .dot { width: 8px; height: 8px; border-radius: 50%; position: relative; }
.status.on { background: var(--online-tint); color: #067647; }
.status.on .dot { background: var(--online); }
.status.on .dot::after { content: ''; position: absolute; inset: -4px; border-radius: 50%; background: var(--online); opacity: 0.35; animation: pulse 1.8s ease-out infinite; }
.status.off { background: #f1f0f3; color: var(--muted); }
.status.off .dot { background: #c3c8d0; }
.status.susp { background: var(--danger-tint); color: #b42318; }
.status.susp .dot { background: var(--danger); }
@keyframes pulse { 0% { transform: scale(1); opacity: 0.5; } 100% { transform: scale(2.4); opacity: 0; } }

/* ── Connection readout (signature) ─────────────────────────── */
.readout { margin-top: 16px; display: flex; gap: 10px; flex-wrap: wrap; }
.readout .cell { flex: 1; min-width: 130px; background: linear-gradient(180deg, #262f3d, #1c2531); color: #dbe1ea; padding: 12px 14px; }
.readout .k { font-size: 10.5px; letter-spacing: 0.1em; text-transform: uppercase; color: #93a0b2; }
.readout .v { font-family: 'Space Grotesk', sans-serif; font-size: 17px; font-weight: 600; margin-top: 3px; color: #f2f5f9; }

/* ── Stats grid ─────────────────────────────────────────────── */
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 16px; }
.stat { border: 1px solid var(--line-2); padding: 13px 14px; }
.stat .k { font-size: 10.5px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--faint); }
.stat .v { font-family: 'Space Grotesk', sans-serif; font-size: 20px; font-weight: 600; margin-top: 4px; }

/* ── Usage meter ────────────────────────────────────────────── */
.usage { margin-top: 16px; }
.usage-top { display: flex; align-items: baseline; justify-content: space-between; }
.usage-top .used { font-family: 'Space Grotesk', sans-serif; font-size: 22px; font-weight: 700; }
.usage-top .cap { font-size: 13px; color: var(--muted); }
.meter { height: 8px; background: #f1e6ee; margin-top: 10px; overflow: hidden; }
.meter > span { display: block; height: 100%; background: linear-gradient(90deg, var(--brand), var(--brand-2)); }
.usage-note { font-size: 12px; color: var(--faint); margin-top: 8px; }

/* ── Billing strip ──────────────────────────────────────────── */
.bill { margin-top: 18px; padding: 14px 16px; background: var(--brand-tint); display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.bill.due { background: var(--amber-tint); }
.bill .lbl { font-size: 12.5px; color: var(--brand-2); font-weight: 600; }
.bill.due .lbl { color: #a15c07; }
.bill .lbl small { display: block; font-weight: 500; color: var(--muted); font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; margin-bottom: 2px; }

/* ── Card actions ───────────────────────────────────────────── */
.card-actions { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line-2); font-size: 13.5px; display: flex; flex-wrap: wrap; gap: 8px 20px; }

/* ── Buttons ────────────────────────────────────────────────── */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; font-family: 'Inter', sans-serif; font-size: 15px; font-weight: 600; border: none; padding: 13px 18px; cursor: pointer; text-decoration: none; transition: transform 0.06s ease, background 0.15s ease, filter 0.15s ease; }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--brand); color: #fff; box-shadow: 0 6px 16px rgba(236, 72, 153, 0.28); }
.btn-primary:hover { background: var(--brand-2); }
.btn-pay { background: var(--brand); color: #fff; box-shadow: 0 6px 16px rgba(236, 72, 153, 0.28); }
.btn-pay:hover { background: var(--brand-2); }
.btn-block { width: 100%; }
.btn-sm { padding: 9px 16px; font-size: 13.5px; }
.link { color: var(--brand); text-decoration: none; font-weight: 600; font-size: 14px; }
.link:hover { text-decoration: underline; }

/* ── Button loading state ───────────────────────────────────── */
.btn.is-loading, form.is-loading .btn { pointer-events: none; opacity: 0.75; }
.btn-spinner { width: 15px; height: 15px; flex: none; border-radius: 50%; border: 2px solid rgba(255, 255, 255, 0.45); border-top-color: #fff; animation: spin 0.7s linear infinite; }

/* ── Disabled form state ────────────────────────────────────── */
.input:disabled, select.input:disabled { opacity: 0.55; cursor: not-allowed; background: #f3eef2; }
form.is-loading .input,
form.is-loading select,
form.is-loading .seg .opt,
form.is-loading .chip,
form.is-loading .cc[type="button"] { pointer-events: none; opacity: 0.6; }

/* ── Fields ─────────────────────────────────────────────────── */
.field { margin-top: 16px; }
.field > label { display: block; font-size: 12.5px; font-weight: 500; color: var(--muted); margin-bottom: 8px; }
.input { width: 100%; font-family: 'Inter', sans-serif; font-size: 16px; color: var(--ink); background: #fdf7fb; border: 1px solid var(--line); padding: 14px; transition: border-color 0.15s, background 0.15s, box-shadow 0.15s; }
.input:focus { outline: none; border-color: var(--brand); background: #fff; box-shadow: 0 0 0 4px rgba(236, 72, 153, 0.12); }
.phone-row { display: flex; align-items: stretch; gap: 8px; }
.cc { display: flex; align-items: center; padding: 0 14px; background: #fbe8f2; border: 1px solid var(--line); font-weight: 600; color: var(--brand-2); font-variant-numeric: tabular-nums; }
.otp { text-align: center; letter-spacing: 0.5em; font-family: 'Space Grotesk', sans-serif; font-size: 24px; font-weight: 600; padding-left: 0.5em; }
.hint { text-align: center; font-size: 12.5px; color: var(--faint); margin-top: 14px; }

/* ── Segmented (month picker) ───────────────────────────────── */
.seg { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.seg .opt { text-align: center; padding: 13px 6px; border: 1px solid var(--line); background: #fdf7fb; cursor: pointer; user-select: none; transition: all 0.12s; }
.seg .opt .m { font-family: 'Space Grotesk', sans-serif; font-weight: 600; font-size: 15px; }
.seg .opt .s { font-size: 11px; color: var(--faint); }
.seg .opt.active { background: var(--brand); border-color: var(--brand); }
.seg .opt.active .m, .seg .opt.active .s { color: #fff; }
.seg.seg-5 { grid-template-columns: repeat(5, 1fr); }

.total { display: flex; align-items: center; justify-content: space-between; margin: 22px 0; padding: 16px 18px; background: var(--brand-tint); }
.total .k { font-size: 14px; color: var(--brand-2); font-weight: 500; }
.total .v { font-family: 'Space Grotesk', sans-serif; font-size: 24px; font-weight: 700; color: var(--brand-2); }

/* ── Alerts ─────────────────────────────────────────────────── */
.alert { padding: 12px 14px; font-size: 13.5px; margin-bottom: 8px; }
.alert.error { background: var(--danger-tint); color: #b42318; }
.alert.info { background: var(--brand-tint); color: var(--brand-2); }

/* ── Section heading ────────────────────────────────────────── */
.section-h { font-size: 13px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: var(--faint); margin: 26px 4px 12px; }

/* ── Payment history ────────────────────────────────────────── */
.pay-list { background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow-sm); overflow: hidden; }
.pay-row { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px; border-bottom: 1px solid var(--line-2); }
.pay-row:last-child { border-bottom: none; }
.pay-row .meta { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.pay-row .who { font-weight: 600; font-size: 14px; }
.pay-row .amt { font-family: 'Space Grotesk', sans-serif; font-weight: 700; color: var(--brand-2); font-variant-numeric: tabular-nums; }
.pay-method { display: inline-block; font-size: 11px; color: var(--muted); text-transform: capitalize; }

.empty { text-align: center; color: var(--faint); padding: 30px 20px; font-size: 14px; }

/* ── Pay-wait ───────────────────────────────────────────────── */
.wait { flex: 1; display: flex; align-items: center; justify-content: center; padding: 24px; }
.wait-card { width: 100%; max-width: 400px; background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow); padding: 36px 30px; text-align: center; }
.spinner { width: 56px; height: 56px; margin: 0 auto 22px; border-radius: 50%; border: 5px solid var(--brand-tint); border-top-color: var(--brand); animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.wait-title { font-size: 19px; font-weight: 600; margin-bottom: 8px; }
.wait-amount { font-family: 'Space Grotesk', sans-serif; font-size: 26px; font-weight: 700; color: var(--ink); margin: 12px 0; }
.wait-msg { font-size: 13.5px; color: var(--muted); }
.wait-icon { font-size: 46px; margin-bottom: 10px; }
.wait-state { margin-top: 8px; font-size: 13.5px; font-weight: 600; }

.back-link { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); text-decoration: none; font-size: 13.5px; font-weight: 500; margin-bottom: 14px; }
.back-link:hover { color: var(--ink); }
.logout { color: var(--muted); text-decoration: none; font-size: 13.5px; font-weight: 600; }
.logout:hover { color: var(--danger); }

/* ── Footer ─────────────────────────────────────────────────── */
.site-footer { margin-top: auto; text-align: center; padding: 26px 20px 30px; color: var(--faint); border-top: 1px solid var(--line); }
.site-footer .ft-1 { font-size: 12.5px; }
.site-footer .ft-1 b { color: var(--brand); font-weight: 700; }
.site-footer .ft-2 { font-size: 11.5px; margin-top: 3px; letter-spacing: 0.02em; }

/* ── Coverage map ───────────────────────────────────────────── */
.map-page { max-width: 1040px; width: 100%; }
.map-layout { display: grid; grid-template-columns: 1fr; gap: 16px; align-items: start; }
/* position + z-index 0 creates a stacking context that contains Leaflet's
   internal panes (z-index 400–1000) so the map can't paint over the topbar */
.map-card { padding: 0; overflow: hidden; margin-bottom: 0; position: relative; z-index: 0; }
.map-canvas {
    width: 100%;
    height: clamp(280px, 55vh, 640px);
    height: clamp(280px, 55dvh, 640px); /* dvh: stable under mobile browser chrome */
}

/* Wide screens: map beside a sticky, scrollable site list */
@media (min-width: 900px) {
    .map-layout { grid-template-columns: minmax(0, 2fr) minmax(280px, 1fr); }
    .map-canvas { height: clamp(420px, 70vh, 720px); }
    .map-side { position: sticky; top: 86px; max-height: calc(100vh - 110px); overflow-y: auto; }
}

/* Small phones: keep the list visible below the fold */
@media (max-width: 500px) {
    .map-canvas { height: clamp(240px, 45vh, 400px); height: clamp(240px, 45dvh, 400px); }
}

.site-pin { display: block; width: 18px; height: 18px; border-radius: 50%; background: var(--brand); border: 3px solid #fff; box-shadow: 0 1px 6px rgba(219, 39, 119, 0.45); position: relative; }
.site-pin::after { content: ''; position: absolute; inset: -6px; border-radius: 50%; background: var(--brand); opacity: 0.3; animation: pulse 2s ease-out infinite; }

.leaflet-popup-content-wrapper { border-radius: 0; border: 1px solid var(--line); box-shadow: var(--shadow); font-family: 'Inter', sans-serif; }
.leaflet-popup-content { margin: 12px 16px; }
.leaflet-popup-content .pop-name { font-family: 'Space Grotesk', sans-serif; font-weight: 600; font-size: 15px; color: var(--ink); }
.leaflet-popup-content .pop-addr { font-size: 12.5px; color: var(--muted); margin-top: 3px; }
.leaflet-popup-tip { border: 1px solid var(--line); border-top: none; border-left: none; }
.leaflet-container a.leaflet-popup-close-button { color: var(--faint); }
.leaflet-container { font-family: 'Inter', sans-serif; }

.site-row { cursor: pointer; }
.site-row:hover { background: var(--brand-tint); }

/* ── A11y / motion ──────────────────────────────────────────── */
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) {
    * { animation: none !important; transition: none !important; }
}
@media (max-width: 400px) {
    .stats { grid-template-columns: 1fr; }
    .seg { grid-template-columns: repeat(2, 1fr); }
}
