/* ============================================================
   Meliora POS — design system
   Mobile-first, touch-friendly, optimised for handheld tills.
   ============================================================ */
:root {
    --green-900: #1f3320;
    --green-700: #2f4a30;
    --green-600: #3d5a3e;
    --green-500: #4a7a4d;
    --accent: #43a047;
    --accent-bright: #6fbf73;
    --bg: #eef1ee;
    --card: #ffffff;
    --ink: #1d281e;
    --muted: #6b766c;
    --line: #e2e7e2;
    --danger: #c0392b;
    --danger-soft: #fdecea;
    --warn: #e08a1e;
    --radius: 16px;
    --radius-sm: 10px;
    --shadow-sm: 0 1px 3px rgba(31, 51, 32, .08), 0 1px 2px rgba(31, 51, 32, .04);
    --shadow-md: 0 6px 20px rgba(31, 51, 32, .12);
    --shadow-lg: 0 18px 50px rgba(31, 51, 32, .22);
    --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    height: 100%;
}

body {
    font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg);
    color: var(--ink);
    -webkit-font-smoothing: antialiased;
    font-size: 15px;
    line-height: 1.45;
}

button { font-family: inherit; cursor: pointer; }
input, select, button { font-size: 16px; } /* >=16px prevents iOS zoom on focus */

.muted { color: var(--muted); }
.nowrap { white-space: nowrap; }

/* ── App shell ─────────────────────────────────────────────── */
.app {
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 30;
    background: linear-gradient(120deg, var(--green-700), var(--green-500));
    color: #fff;
    padding: 10px 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    box-shadow: var(--shadow-md);
}
.topbar .brand { display: flex; align-items: center; gap: 10px; font-weight: 800; letter-spacing: .2px; }
.topbar .brand-logo {
    height: 38px; width: 38px; object-fit: cover; border-radius: 9px;
    background: #fff; padding: 2px; box-shadow: 0 1px 3px rgba(0,0,0,.18); flex-shrink: 0;
}
.topbar .brand small { display: block; font-weight: 500; opacity: .8; font-size: 11px; letter-spacing: .3px; }
.topbar .spacer { flex: 1; }
.topbar .clerk { text-align: right; font-size: 13px; line-height: 1.2; }
.topbar .clerk b { display: block; font-weight: 600; }
.topbar .logout {
    background: rgba(255,255,255,.16);
    border: none; color: #fff; padding: 8px 12px;
    border-radius: 10px; font-weight: 600; font-size: 13px;
    transition: background .15s;
}
.topbar .logout:active { background: rgba(255,255,255,.3); }

/* ── POS layout ────────────────────────────────────────────── */
.pos {
    flex: 1;
    display: grid;
    grid-template-columns: 1fr;
    gap: 16px;
    padding: 16px;
    padding-bottom: calc(120px + var(--safe-bottom)); /* room for mobile charge bar */
    max-width: 1280px;
    width: 100%;
    margin: 0 auto;
}

.card {
    background: var(--card);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--line);
}
.card .card-head {
    padding: 14px 18px;
    border-bottom: 1px solid var(--line);
    font-weight: 700;
    display: flex; align-items: center; gap: 8px;
}
.card .card-body { padding: 18px; }

/* ── Scan / search ─────────────────────────────────────────── */
.scan-row { display: flex; gap: 10px; }
.scan-input-wrap { position: relative; flex: 1; }
.scan-input-wrap .ico {
    position: absolute; left: 14px; top: 50%; transform: translateY(-50%);
    font-size: 18px; opacity: .5; pointer-events: none;
}
input.field, select.field {
    width: 100%;
    padding: 14px 14px 14px 44px;
    border: 2px solid var(--line);
    border-radius: var(--radius-sm);
    background: #fbfdfb;
    transition: border-color .15s, box-shadow .15s;
    outline: none;
}
input.field.plain { padding-left: 14px; }
input.field:focus, select.field:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 4px rgba(67,160,71,.14);
    background: #fff;
}

.btn {
    border: none; border-radius: var(--radius-sm);
    padding: 14px 18px; font-weight: 700; font-size: 15px;
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    transition: transform .05s, filter .15s, background .15s;
    white-space: nowrap;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { filter: brightness(1.05); }
.btn-dark { background: var(--green-700); color: #fff; }
.btn-ghost { background: #f0f3f0; color: var(--green-700); }
.btn-danger-ghost { background: var(--danger-soft); color: var(--danger); }
.btn-block { width: 100%; }
.btn-lg { padding: 17px 20px; font-size: 17px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* search results */
.results { margin-top: 14px; display: flex; flex-direction: column; gap: 8px; }
.result {
    display: flex; align-items: center; gap: 12px;
    padding: 12px 14px; border: 1px solid var(--line); border-radius: var(--radius-sm);
    background: #fff; text-align: left; width: 100%;
    transition: border-color .12s, background .12s;
}
.result:hover { border-color: var(--accent-bright); background: #f7fbf7; }
.result .r-main { flex: 1; min-width: 0; }
.result .r-name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.result .r-sub { font-size: 12.5px; color: var(--muted); }
.result .r-price { font-weight: 700; color: var(--green-700); }
.result .r-add { font-size: 22px; color: var(--accent); }

.empty { text-align: center; color: var(--muted); padding: 26px 10px; }
.empty .big { font-size: 30px; display: block; margin-bottom: 6px; opacity: .5; }

/* ── Selected product (add panel) ──────────────────────────── */
.addpanel { display: none; }
.addpanel.show { display: block; }
.addpanel .ap-name { font-weight: 700; font-size: 17px; }
.addpanel .ap-meta { color: var(--muted); font-size: 13px; margin-top: 2px; }
.addpanel .ap-controls { display: flex; align-items: flex-end; gap: 12px; margin-top: 14px; flex-wrap: wrap; }
.addpanel .ap-field { display: flex; flex-direction: column; gap: 5px; }
.addpanel .ap-field > label { font-size: 12px; font-weight: 600; color: var(--muted); }
.addpanel .ap-priceinput {
    width: 120px; height: 50px; padding: 0 12px; border: 2px solid var(--line); border-radius: 12px;
    font-size: 18px; font-weight: 800; color: var(--green-700); background: #fbfdfb; outline: none;
    -moz-appearance: textfield;
}
.addpanel .ap-priceinput::-webkit-outer-spin-button,
.addpanel .ap-priceinput::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.addpanel .ap-priceinput:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(67,160,71,.14); background: #fff; }
.addpanel #apAdd { flex: 1; min-width: 140px; height: 50px; }
.addpanel .ap-hint { font-size: 12px; margin-top: 10px; }

/* qty stepper */
.stepper { display: inline-flex; align-items: center; border: 2px solid var(--line); border-radius: 12px; overflow: hidden; }
.stepper button {
    width: 46px; height: 46px; border: none; background: #f3f6f3;
    font-size: 22px; font-weight: 700; color: var(--green-700);
}
.stepper button:active { background: #e6ece6; }
.stepper input {
    width: 56px; height: 46px; border: none; text-align: center;
    font-size: 17px; font-weight: 700; background: #fff; outline: none;
    -moz-appearance: textfield;
}
.stepper input::-webkit-outer-spin-button,
.stepper input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }

/* ── Cart panel ────────────────────────────────────────────── */
.cart-head { display: flex; align-items: center; justify-content: space-between; }
.cart-head .badge {
    background: var(--green-600); color: #fff; border-radius: 999px;
    min-width: 24px; height: 24px; padding: 0 7px; font-size: 13px; font-weight: 700;
    display: inline-flex; align-items: center; justify-content: center;
}
.cart-list { display: flex; flex-direction: column; }
.cart-item {
    display: grid; grid-template-columns: 1fr auto; gap: 4px 12px;
    padding: 13px 0; border-bottom: 1px solid var(--line);
}
.cart-item:last-child { border-bottom: none; }
.ci-name { font-weight: 600; }
.ci-unit { font-size: 12.5px; color: var(--muted); }
.ci-priceedit { display: inline-flex; align-items: center; gap: 4px; margin-top: 4px; color: var(--muted); font-size: 12.5px; }
.ci-priceedit .ci-sym { font-weight: 600; }
.ci-priceedit .ci-price {
    width: 84px; height: 32px; border: 1.5px solid var(--line); border-radius: 8px;
    padding: 0 8px; font-size: 14px; font-weight: 700; color: var(--ink); background: #fbfdfb;
    outline: none; -moz-appearance: textfield;
}
.ci-priceedit .ci-price::-webkit-outer-spin-button,
.ci-priceedit .ci-price::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.ci-priceedit .ci-price:focus { border-color: var(--accent); background: #fff; }
.ci-total { font-weight: 700; text-align: right; align-self: center; }
.ci-actions { grid-column: 1 / -1; display: flex; align-items: center; gap: 10px; margin-top: 4px; }
.ci-actions .stepper button { width: 38px; height: 38px; font-size: 19px; }
.ci-actions .stepper input { width: 44px; height: 38px; font-size: 15px; }
.ci-remove { margin-left: auto; background: none; border: none; color: var(--danger); font-weight: 600; font-size: 13px; padding: 8px; }

.totals { margin-top: 16px; border-top: 2px dashed var(--line); padding-top: 14px; }
.totals .row { display: flex; justify-content: space-between; margin-bottom: 6px; color: var(--muted); }
.totals .grand { display: flex; justify-content: space-between; align-items: baseline; margin-top: 8px; }
.totals .grand .lbl { font-weight: 700; }
.totals .grand .val { font-size: 28px; font-weight: 800; color: var(--green-700); }

.cart-actions { margin-top: 16px; display: flex; gap: 10px; }

/* ── Mobile sticky charge bar ──────────────────────────────── */
.chargebar {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 25;
    background: #fff; border-top: 1px solid var(--line);
    box-shadow: 0 -6px 24px rgba(31,51,32,.12);
    padding: 12px 16px calc(12px + var(--safe-bottom));
    display: flex; align-items: center; gap: 14px;
}
.chargebar .cb-total { line-height: 1.1; }
.chargebar .cb-total small { color: var(--muted); font-size: 12px; }
.chargebar .cb-total b { font-size: 22px; color: var(--green-700); display: block; }
.chargebar .btn { flex: 1; }

/* ── Modal / sheet (payment) ──────────────────────────────── */
.overlay {
    position: fixed; inset: 0; z-index: 50;
    background: rgba(20,30,20,.45);
    display: none; align-items: flex-end; justify-content: center;
    backdrop-filter: blur(2px);
}
.overlay.show { display: flex; }
.sheet {
    background: var(--card); width: 100%; max-width: 480px;
    border-radius: 22px 22px 0 0;
    box-shadow: var(--shadow-lg);
    padding: 8px 20px calc(22px + var(--safe-bottom));
    max-height: 92dvh; overflow-y: auto;
    animation: slideUp .22s ease;
}
@keyframes slideUp { from { transform: translateY(100%); } to { transform: translateY(0); } }
.sheet .grip { width: 42px; height: 5px; background: #d7ddd7; border-radius: 99px; margin: 8px auto 14px; }
.sheet h2 { margin: 0 0 4px; font-size: 20px; }
.sheet .due {
    background: #f3f8f3; border: 1px solid #dfeadf; border-radius: var(--radius-sm);
    padding: 14px 16px; margin: 14px 0; display: flex; justify-content: space-between; align-items: baseline;
}
.sheet .due b { font-size: 26px; color: var(--green-700); }

.seg { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 14px 0; }
.seg button {
    padding: 14px 6px; border: 2px solid var(--line); background: #fbfdfb;
    border-radius: 12px; font-weight: 700; color: var(--ink);
    display: flex; flex-direction: column; align-items: center; gap: 4px; transition: all .12s;
}
.seg button .ico { font-size: 22px; }
.seg button.active { border-color: var(--accent); background: #eef7ef; color: var(--green-700); box-shadow: 0 0 0 3px rgba(67,160,71,.12); }

.field-group { margin: 12px 0; }
.field-group label { display: block; font-size: 13px; font-weight: 600; color: var(--muted); margin-bottom: 6px; }

.change-line { display: flex; justify-content: space-between; align-items: baseline; margin: 12px 2px; font-size: 15px; }
.change-line b { font-size: 22px; }
.change-line.ok b { color: var(--accent); }
.change-line.short b { color: var(--danger); }

.toast {
    position: fixed; left: 50%; bottom: calc(96px + var(--safe-bottom)); transform: translateX(-50%);
    background: var(--green-900); color: #fff; padding: 12px 20px; border-radius: 999px;
    font-weight: 600; font-size: 14px; box-shadow: var(--shadow-md); z-index: 80;
    opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; max-width: 90vw; text-align: center;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.err { background: var(--danger); }

/* ── Desktop layout ────────────────────────────────────────── */
@media (min-width: 900px) {
    .pos { grid-template-columns: 1fr 410px; align-items: start; padding-bottom: 24px; }
    .cart-panel { position: sticky; top: 78px; }
    .chargebar { display: none; }
    .overlay { align-items: center; }
    .sheet { border-radius: 22px; animation: pop .18s ease; }
}
@keyframes pop { from { transform: scale(.96); opacity: 0; } to { transform: scale(1); opacity: 1; } }

/* ── Login screen ──────────────────────────────────────────── */
.login-wrap {
    min-height: 100dvh; display: flex; align-items: center; justify-content: center;
    padding: 24px; background: radial-gradient(1200px 600px at 50% -10%, #3d5a3e22, transparent), var(--bg);
}
.login-card {
    background: var(--card); border-radius: 22px; box-shadow: var(--shadow-lg);
    width: 100%; max-width: 400px; padding: 32px 28px calc(32px + var(--safe-bottom)); border: 1px solid var(--line);
}
.login-card .logo { text-align: center; margin-bottom: 22px; }
.login-card .login-logo-img {
    width: 76px; height: 76px; border-radius: 20px; margin: 0 auto 14px; display: block;
    object-fit: cover; background: #fff; padding: 4px; box-shadow: var(--shadow-md);
}
.login-card h1 { margin: 0; font-size: 22px; text-align: center; }
.login-card p.sub { text-align: center; color: var(--muted); margin: 4px 0 24px; font-size: 14px; }
.login-card .field-group { margin-bottom: 16px; }
.login-card.register-card { max-width: 440px; }
.login-card .field-row { display: flex; gap: 12px; }
.login-card .field-row .field-group { flex: 1; }
.auth-alt { text-align: center; margin: 18px 0 0; font-size: 14px; color: var(--muted); }
.auth-alt a { color: var(--green-600); font-weight: 600; text-decoration: none; }
.auth-alt a:hover { text-decoration: underline; }

/* ── Admin console (client provisioning) ───────────────────── */
.topbar .admin-link {
    background: rgba(255,255,255,.16); color: #fff; padding: 8px 12px;
    border-radius: 10px; font-weight: 600; font-size: 13px; text-decoration: none; margin-right: 4px;
}
.topbar .admin-link:active { background: rgba(255,255,255,.3); }
.client-list { display: flex; flex-direction: column; gap: 10px; }
.client-row {
    display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
    padding: 14px 16px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: #fff;
}
.client-row .cr-main { flex: 1; min-width: 180px; }
.client-row .cr-name { font-weight: 700; }
.client-row .cr-sub { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.client-badge { padding: 4px 11px; border-radius: 999px; font-size: 12px; font-weight: 700; }
.badge-active { background: #e7f6e8; color: #2f7a34; }
.badge-pending { background: #fff3e0; color: #b06a12; }
.badge-suspended { background: var(--danger-soft); color: var(--danger); }

/* ── Management screens (products / cashiers) ──────────────── */
.banner { padding: 12px 16px; border-radius: var(--radius-sm); font-weight: 600; font-size: 14px; }
.banner.ok { background: #e7f6e8; color: #2f7a34; border: 1px solid #cce8cf; }
.banner.err { background: var(--danger-soft); color: var(--danger); border: 1px solid #f3c6c0; }
.mgmt-grid { display: grid; grid-template-columns: 1fr; gap: 16px; }
@media (min-width: 760px) { .mgmt-grid { grid-template-columns: 1.4fr 1fr; align-items: start; } }
.provision-grid { display: grid; grid-template-columns: 1fr; gap: 16px; }
@media (min-width: 620px) { .provision-grid { grid-template-columns: 1fr 1fr; } }
.prov-label { display: block; font-size: 13px; font-weight: 600; color: var(--muted); margin-bottom: 6px; }

.prod-table { display: flex; flex-direction: column; }
.pt-head, .pt-row {
    display: grid; grid-template-columns: 1fr 90px 60px 120px; gap: 10px; align-items: center;
}
.pt-head { font-size: 11px; text-transform: uppercase; letter-spacing: .5px; color: var(--muted);
    padding-bottom: 8px; border-bottom: 1px solid var(--line); }
.pt-row { padding: 11px 0; border-bottom: 1px solid #f1f4f1; }
.pt-row .num, .pt-head .num { text-align: right; }
.pt-name { font-weight: 600; }
.pt-sub { font-size: 12px; color: var(--muted); }
.pt-actions { text-align: right; white-space: nowrap; }
.link-btn { background: none; border: none; font-weight: 600; font-size: 13px; color: var(--green-600); padding: 6px; cursor: pointer; }
.link-btn.danger { color: var(--danger); }

/* ── Pager ─────────────────────────────────────────────────── */
.pager {
    display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap;
    gap: 12px; margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--line);
}
.pager-info { font-size: 13px; color: var(--muted); }
.pager-controls { display: flex; align-items: center; gap: 8px; }
.pager-btn {
    border: 1px solid var(--line); background: #fff; color: var(--green-700);
    padding: 9px 14px; border-radius: 10px; font-weight: 600; font-size: 14px; text-decoration: none;
}
.pager-btn:hover { border-color: var(--accent-bright); background: #f7fbf7; }
.pager-btn.disabled { color: #bcc4bc; background: #f6f8f6; pointer-events: none; }
.pager-page { font-size: 13px; font-weight: 600; color: var(--ink); padding: 0 4px; }

/* ── Dashboards ────────────────────────────────────────────── */
.dash { flex: 1; padding: 16px; max-width: 1200px; width: 100%; margin: 0 auto; }
.daterange { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px; margin-bottom: 16px; }
.daterange .dr-field { display: flex; flex-direction: column; gap: 5px; }
.daterange .dr-field label { font-size: 12px; font-weight: 600; color: var(--muted); }
.daterange .dr-field .field { width: 160px; }
.dr-presets { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; margin-left: auto; }
.dr-presets a { font-size: 12.5px; font-weight: 600; color: var(--green-700); background: #eef3ee; padding: 8px 12px; border-radius: 999px; text-decoration: none; }
.dr-presets a:hover { background: #e2ebe2; }

.alert-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 16px; }

.kpi-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; margin-bottom: 18px; }
@media (min-width: 640px) { .kpi-grid { grid-template-columns: repeat(3, 1fr); } }
@media (min-width: 980px) { .kpi-grid { grid-template-columns: repeat(6, 1fr); } }
.kpi-card {
    background: var(--card); border: 1px solid var(--line); border-radius: var(--radius-sm);
    padding: 14px 16px; display: flex; flex-direction: column; gap: 6px;
    border-left: 4px solid var(--line);
}
.kpi-card .k-label { font-size: 12px; color: var(--muted); font-weight: 600; }
.kpi-card .k-value { font-size: 21px; font-weight: 800; color: var(--ink); line-height: 1.1; }
.kpi-card.primary { border-left-color: var(--green-600); }
.kpi-card.primary .k-value { color: var(--green-700); }
.kpi-card.success { border-left-color: var(--accent); }
.kpi-card.warning { border-left-color: var(--warn); }
.kpi-card.danger  { border-left-color: var(--danger); }

.section-heading { margin: 6px 0 12px; }
.section-heading h2 { font-size: 16px; margin: 0; color: var(--green-700); }

.dash-2col { display: grid; grid-template-columns: 1fr; gap: 16px; margin-bottom: 16px; }
@media (min-width: 900px) { .dash-2col { grid-template-columns: 1fr 1fr; } }

.panel {
    background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
    box-shadow: var(--shadow-sm); padding: 16px 18px; margin-bottom: 16px;
}
.panel h3 { margin: 0 0 12px; font-size: 15px; }

table.mini { width: 100%; border-collapse: collapse; }
table.mini th { text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .4px; color: var(--muted); padding: 0 8px 8px 0; border-bottom: 1px solid var(--line); }
table.mini th.num, table.mini td.num { text-align: right; padding-right: 0; }
table.mini td { padding: 9px 8px 9px 0; border-bottom: 1px solid #f1f4f1; font-size: 13.5px; vertical-align: top; }
table.mini td .sub { font-size: 11.5px; color: var(--muted); }

/* ── Reports ───────────────────────────────────────────────── */
.report-grid { display: grid; grid-template-columns: 1fr; gap: 14px; }
@media (min-width: 640px) { .report-grid { grid-template-columns: 1fr 1fr; } }
@media (min-width: 980px) { .report-grid { grid-template-columns: 1fr 1fr 1fr; } }
.report-card {
    display: flex; flex-direction: column; gap: 4px; text-decoration: none;
    background: var(--card); border: 1px solid var(--line); border-left: 4px solid var(--green-600);
    border-radius: var(--radius-sm); padding: 16px 18px; box-shadow: var(--shadow-sm); transition: border-color .12s, transform .05s;
}
.report-card:hover { border-color: var(--accent-bright); }
.report-card:active { transform: translateY(1px); }
.report-card .rc-icon { font-size: 22px; }
.report-card .rc-title { font-weight: 700; color: var(--ink); }
.report-card .rc-desc { font-size: 12.5px; color: var(--muted); }

.rpt-head { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 12px; margin-bottom: 8px; }
.rpt-head h2 { margin: 0; font-size: 18px; color: var(--green-700); }
.rpt-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.rpt-meta { font-size: 12.5px; color: var(--muted); margin-bottom: 10px; }
.rpt-print-title { font-weight: 700; font-size: 15px; margin-bottom: 10px; }
.rpt-table tfoot .rpt-total td { border-top: 2px solid var(--line); border-bottom: none; font-weight: 800; color: var(--green-700); padding-top: 10px; }

@media print {
    .topbar, .no-print { display: none !important; }
    .dash { padding: 0; }
    .panel { box-shadow: none; border: none; padding: 0; }
}

/* ── Billing / subscription ────────────────────────────────── */
.grace-bar {
    background: #fff3e0; color: #8a5212; border-bottom: 1px solid #f0d9b5;
    padding: 10px 16px; font-size: 13.5px; font-weight: 600; text-align: center;
}
.grace-bar a { color: var(--green-700); margin-left: 8px; font-weight: 700; }
.sub-status { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.sub-status .sub-plan { font-size: 22px; font-weight: 800; color: var(--green-700); text-transform: capitalize; }
.plan-grid { display: grid; grid-template-columns: 1fr; gap: 14px; margin-bottom: 8px; }
@media (min-width: 640px) { .plan-grid { grid-template-columns: 1fr 1fr 1fr; } }
.plan-card {
    background: var(--card); border: 1px solid var(--line); border-top: 4px solid var(--green-600);
    border-radius: var(--radius); box-shadow: var(--shadow-sm); padding: 18px; text-align: center;
}
.plan-card .plan-name { font-weight: 700; font-size: 16px; }
.plan-card .plan-price { font-size: 26px; font-weight: 800; color: var(--green-700); margin: 6px 0 0; }
.plan-card .plan-cadence { font-size: 12.5px; margin-bottom: 14px; }
@media (max-width: 620px) {
    .pt-head { display: none; }
    .pt-row { grid-template-columns: 1fr auto; gap: 4px 10px; }
    .pt-row .num { text-align: left; font-size: 13px; color: var(--muted); }
    .pt-actions { grid-column: 1 / -1; text-align: left; }
}
.alert {
    background: var(--danger-soft); color: var(--danger); border: 1px solid #f3c6c0;
    padding: 11px 14px; border-radius: var(--radius-sm); font-size: 14px; font-weight: 500; margin-bottom: 16px;
}

/* ── Receipt screen ────────────────────────────────────────── */
.receipt-page { min-height: 100dvh; padding: 18px; padding-bottom: calc(28px + var(--safe-bottom)); max-width: 460px; margin: 0 auto; }
.receipt-success {
    text-align: center; color: var(--green-700); margin-bottom: 14px;
}
.receipt-success .tick {
    width: 64px; height: 64px; border-radius: 50%; margin: 6px auto 10px;
    background: #eaf6ea; color: var(--accent); display: flex; align-items: center; justify-content: center;
    font-size: 34px; box-shadow: 0 0 0 6px #f1faf1;
}
.receipt-success h1 { margin: 0; font-size: 22px; }
.receipt-success .change-chip {
    display: inline-block; margin-top: 8px; background: var(--green-700); color: #fff;
    padding: 7px 16px; border-radius: 999px; font-weight: 700;
}
/* The on-screen receipt mimics an 80mm thermal slip: a narrow, centered paper. */
.receipt {
    background: #fff; border-radius: var(--radius); box-shadow: var(--shadow-sm); border: 1px solid var(--line);
    padding: 20px 18px; margin: 14px auto; width: 320px; max-width: 100%;
}
.receipt .r-store { text-align: center; border-bottom: 1.5px dashed #cdd5cd; padding-bottom: 14px; margin-bottom: 12px; }
.receipt .r-logo { height: 56px; width: 56px; object-fit: cover; border-radius: 12px; margin: 0 auto 8px; display: block; }
.receipt .r-store h2 { margin: 0 0 3px; font-size: 18px; color: var(--green-700); }
.receipt .r-store .r-client { font-size: 13px; font-weight: 700; color: var(--ink); margin: 7px 0 0; }
.receipt .r-store .r-addr { color: var(--muted); font-size: 12px; line-height: 1.5; }

.receipt .r-meta { font-size: 12.5px; margin-bottom: 12px; }
.receipt .r-meta div { display: flex; justify-content: space-between; gap: 14px; padding: 1px 0; }
.receipt .r-meta div span { color: var(--muted); }
.receipt .r-meta div b { color: var(--ink); font-weight: 600; text-align: right; }

/* Line items: name on its own line, then "qty x price" on the left and the
   amount on the right — so Price and Amount never crowd each other. */
.receipt .r-items { border-top: 1.5px dashed #cdd5cd; padding-top: 10px; }
.receipt .r-items-head {
    display: flex; justify-content: space-between;
    font-size: 11px; text-transform: uppercase; letter-spacing: .5px; color: var(--muted);
    padding-bottom: 8px; border-bottom: 1px solid var(--line); margin-bottom: 8px;
}
.receipt .r-item { padding: 7px 0; border-bottom: 1px solid #f1f4f1; }
.receipt .r-item:last-child { border-bottom: none; }
.receipt .ri-name { font-weight: 600; font-size: 13.5px; margin-bottom: 3px; }
.receipt .ri-calc { display: flex; justify-content: space-between; align-items: baseline; gap: 24px; }
.receipt .ri-qp { color: var(--muted); font-size: 12.5px; }
.receipt .ri-amt { font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }

.receipt .r-grand { display: flex; justify-content: space-between; align-items: baseline; gap: 16px; margin-top: 12px; padding-top: 12px; border-top: 1.5px dashed #cdd5cd; }
.receipt .r-grand .val { font-size: 24px; font-weight: 800; color: var(--green-700); white-space: nowrap; }
.receipt .r-foot { text-align: center; color: var(--muted); font-size: 12px; line-height: 1.5; margin-top: 16px; padding-top: 12px; border-top: 1.5px dashed #cdd5cd; }

.receipt-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 18px; }
.receipt-actions .full { grid-column: 1 / -1; }
.btn-whatsapp { background: #25d366; color: #fff; }
.btn-email { background: #2f6fed; color: #fff; }
.btn-share { background: #6a4cff; color: #fff; }

.inline-form { display: flex; gap: 8px; margin-top: 10px; }
.inline-form input { flex: 1; }

/* ── 80mm thermal print ────────────────────────────────────────
   Drives the printout to 80mm roll paper: full-bleed, black ink,
   compact type. Content sits in ~72mm after side padding. */
@media print {
    @page { size: 80mm auto; margin: 0; }
    html, body { width: 80mm; margin: 0; padding: 0; background: #fff; }
    .no-print { display: none !important; }
    .receipt-page { width: 80mm; max-width: 80mm; min-height: 0; margin: 0; padding: 0; }
    .receipt {
        width: 80mm; max-width: 80mm; margin: 0; padding: 3mm 4mm;
        border: none; border-radius: 0; box-shadow: none; color: #000;
        font-size: 12px; line-height: 1.4;
    }
    .receipt .r-logo { height: 46px; width: 46px; }
    .receipt .r-store h2 { color: #000; font-size: 15px; }
    .receipt .r-store .r-client,
    .receipt .r-store .r-addr,
    .receipt .r-meta div span,
    .receipt .ri-qp,
    .receipt .r-foot { color: #000; }
    .receipt .r-meta div b,
    .receipt .ri-name,
    .receipt .ri-amt { color: #000; }
    .receipt .r-store,
    .receipt .r-items,
    .receipt .r-grand,
    .receipt .r-foot { border-color: #000 !important; }
    .receipt .r-item { border-bottom: 1px dotted #999; }
    .receipt .r-grand .val { color: #000; font-size: 16px; }
}
