/* ---------- Design tokens ---------- */
:root {
    --bg: #f5f6fa;
    --surface: #ffffff;
    --border: #e5e7ef;
    --text: #1a2033;
    --muted: #667085;
    --accent: #4f46e5;
    --accent-hover: #4338ca;
    --accent-soft: #eef0ff;

    --sidebar-bg: #0f1629;
    --sidebar-text: #a9b1c6;
    --sidebar-text-strong: #ffffff;
    --sidebar-hover: rgba(255, 255, 255, .06);
    --sidebar-active: rgba(99, 102, 241, .22);
    --sidebar-border: rgba(255, 255, 255, .08);
    --sidebar-w: 264px;
    --sidebar-w-collapsed: 76px;

    --radius: 12px;
    --shadow-sm: 0 1px 2px rgba(16, 24, 40, .05);
    --shadow-md: 0 8px 24px rgba(16, 24, 40, .08);

    --bs-primary: var(--accent);
    --bs-primary-rgb: 79, 70, 229;
    --bs-body-bg: #ffffff;
    --bs-body-color: var(--text);
    --bs-link-color: var(--accent);
    --bs-link-color-rgb: 79, 70, 229;
    --bs-link-hover-color: var(--accent-hover);
    --bs-link-hover-color-rgb: 67, 56, 202;
    --bs-border-color: var(--border);
    --bs-body-font-family: Inter, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

body { background: var(--bg); color: var(--text); font-size: .95rem; -webkit-font-smoothing: antialiased; }

.btn-primary {
    --bs-btn-bg: var(--accent);
    --bs-btn-border-color: var(--accent);
    --bs-btn-hover-bg: var(--accent-hover);
    --bs-btn-hover-border-color: var(--accent-hover);
    --bs-btn-active-bg: #3730a3;
    --bs-btn-active-border-color: #3730a3;
    --bs-btn-disabled-bg: var(--accent);
    --bs-btn-disabled-border-color: var(--accent);
    --bs-btn-focus-shadow-rgb: 79, 70, 229;
}
.btn { border-radius: 9px; font-weight: 500; }
.form-control, .form-select { border-radius: 9px; padding: .55rem .8rem; border-color: #d5d8e3; background-color: #fff; }
.form-select { padding-right: 2.25rem; } /* keep room for the chevron that the padding shorthand above would remove */
.form-check-input { background-color: #fff; }
.form-control:focus, .form-select:focus, .form-check-input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 .2rem rgba(79, 70, 229, .18);
}
.form-check-input:checked { background-color: var(--accent); border-color: var(--accent); }
.form-label { font-weight: 500; font-size: .85rem; margin-bottom: .35rem; }
.invalid-text, .field-validation-error { color: #d92d20; font-size: .8rem; display: block; margin-top: .25rem; }
.input-validation-error { border-color: #d92d20; }
.validation-summary-valid { display: none; }
.validation-summary-errors ul { margin: 0; padding-left: 1.1rem; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.skip-link {
    position: absolute; left: .75rem; top: -3rem; z-index: 2000;
    background: var(--surface); color: var(--text); padding: .5rem .9rem; border-radius: 8px; box-shadow: var(--shadow-md);
}
.skip-link:focus { top: .75rem; }

/* ---------- App shell ---------- */
.app-shell { min-height: 100vh; }

.sidebar {
    position: fixed; inset: 0 auto 0 0; z-index: 1040;
    width: var(--sidebar-w);
    display: flex; flex-direction: column;
    background: var(--sidebar-bg); color: var(--sidebar-text);
    transition: width .2s ease, transform .2s ease;
    overflow: hidden;
}
.app-main { margin-left: var(--sidebar-w); min-width: 0; min-height: 100vh; transition: margin-left .2s ease; }

.sidebar-brand { padding: 1.15rem 1.25rem .5rem; }
.brand-link { display: flex; align-items: center; gap: .7rem; color: var(--sidebar-text-strong); text-decoration: none; }
.brand-link:hover { color: var(--sidebar-text-strong); }
.brand-mark {
    display: grid; place-items: center; flex: none;
    width: 38px; height: 38px; border-radius: 10px; font-size: 1.15rem; color: #fff;
    background: linear-gradient(135deg, #6366f1, #4f46e5);
}
.brand-word { font-weight: 700; font-size: 1.1rem; letter-spacing: -.01em; white-space: nowrap; }

.workspace {
    display: flex; align-items: center; gap: .7rem;
    margin: .75rem 1rem; padding: .65rem .75rem; min-width: 0;
    border: 1px solid var(--sidebar-border); border-radius: 10px; background: rgba(255, 255, 255, .03);
}
.workspace-logo { flex: none; width: 34px; height: 34px; border-radius: 8px; object-fit: contain; background: #fff; }
.workspace-initials { display: grid; place-items: center; background: var(--sidebar-active); color: #c7c9ff; font-weight: 600; font-size: .8rem; }
.workspace-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.2; }
.workspace-label { font-size: .68rem; text-transform: uppercase; letter-spacing: .06em; color: #7b849d; }
.workspace-name { color: var(--sidebar-text-strong); font-weight: 600; font-size: .9rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.sidebar-nav { flex: 1; overflow-y: auto; padding: .5rem 1rem 1rem; }
.nav-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.nav-section-label { margin: 1.25rem .75rem .4rem; font-size: .7rem; text-transform: uppercase; letter-spacing: .08em; color: #6f7893; font-weight: 600; }

.nav-item-link {
    display: flex; align-items: center; gap: .8rem;
    padding: .6rem .75rem; border-radius: 9px;
    color: var(--sidebar-text); text-decoration: none; font-weight: 500; white-space: nowrap;
    transition: background-color .15s, color .15s;
}
.nav-item-link .bi { font-size: 1.1rem; flex: none; width: 1.25rem; text-align: center; }
.nav-item-link:hover { background: var(--sidebar-hover); color: var(--sidebar-text-strong); }
.nav-item-link.active { background: var(--sidebar-active); color: var(--sidebar-text-strong); }
.nav-item-link.active .bi { color: #a5a8ff; }

.sidebar-footer { padding: .9rem 1rem 1rem; border-top: 1px solid var(--sidebar-border); display: flex; flex-direction: column; gap: .5rem; }
.user-card { display: flex; align-items: center; gap: .7rem; min-width: 0; padding: .25rem .25rem; }
.avatar {
    flex: none; display: grid; place-items: center; width: 36px; height: 36px; border-radius: 50%;
    background: var(--sidebar-active); color: #c7c9ff; font-weight: 600; font-size: .78rem;
}
.user-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.25; }
.user-name { color: var(--sidebar-text-strong); font-weight: 600; font-size: .88rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-role { font-size: .75rem; color: #7b849d; }
.signout-btn {
    display: flex; align-items: center; gap: .8rem; width: 100%;
    padding: .55rem .75rem; border: 0; border-radius: 9px; background: transparent;
    color: var(--sidebar-text); font-weight: 500; text-align: left; white-space: nowrap;
}
.signout-btn .bi { font-size: 1.1rem; flex: none; width: 1.25rem; text-align: center; }
.signout-btn:hover { background: var(--sidebar-hover); color: var(--sidebar-text-strong); }

.topbar { display: flex; align-items: center; gap: .75rem; padding: .75rem 1.5rem 0; }
.icon-btn {
    display: grid; place-items: center; width: 40px; height: 40px;
    border: 1px solid var(--border); border-radius: 10px; background: var(--surface); color: var(--text); font-size: 1.35rem;
    box-shadow: var(--shadow-sm);
}
.icon-btn:hover { background: var(--accent-soft); color: var(--accent); }

.page-content { padding: 1.25rem 1.5rem 2.5rem; max-width: 1280px; }
.sidebar-backdrop { display: none; }

/* Collapsed rail (desktop only) */
@media (min-width: 992px) {
    html.sidebar-collapsed .sidebar { width: var(--sidebar-w-collapsed); }
    html.sidebar-collapsed .app-main { margin-left: var(--sidebar-w-collapsed); }
    html.sidebar-collapsed .brand-word,
    html.sidebar-collapsed .workspace-text,
    html.sidebar-collapsed .nav-label,
    html.sidebar-collapsed .user-text,
    html.sidebar-collapsed .nav-section-label { display: none; }
    html.sidebar-collapsed .sidebar-brand { padding-inline: 0; }
    html.sidebar-collapsed .brand-link,
    html.sidebar-collapsed .workspace,
    html.sidebar-collapsed .nav-item-link,
    html.sidebar-collapsed .signout-btn,
    html.sidebar-collapsed .user-card { justify-content: center; }
    html.sidebar-collapsed .workspace { margin-inline: .9rem; padding: .5rem; }
    html.sidebar-collapsed .sidebar-nav { padding-inline: .9rem; }
}

/* Drawer (tablet & mobile) */
@media (max-width: 991.98px) {
    .sidebar { transform: translateX(-100%); box-shadow: none; }
    html.sidebar-open .sidebar { transform: none; box-shadow: var(--shadow-md); }
    .app-main { margin-left: 0; }
    .sidebar-backdrop {
        display: block; position: fixed; inset: 0; z-index: 1035;
        background: rgba(15, 22, 41, .5); opacity: 0; pointer-events: none; transition: opacity .2s;
    }
    html.sidebar-open .sidebar-backdrop { opacity: 1; pointer-events: auto; }
    .topbar { padding-inline: 1rem; }
    .page-content { padding-inline: 1rem; }
}

@media (prefers-reduced-motion: reduce) {
    .sidebar, .app-main, .sidebar-backdrop, .nav-item-link { transition: none; }
}

/* ---------- Page content ---------- */
.page-header { display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between; gap: 1rem; margin-bottom: 1.5rem; }
.page-header h1 { font-size: 1.6rem; font-weight: 700; letter-spacing: -.02em; margin: 0; }
.page-sub { color: var(--muted); margin: .25rem 0 0; }

.panel {
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
    padding: 1.35rem; margin-bottom: 1.25rem; box-shadow: var(--shadow-sm);
}
.panel-title { font-size: 1rem; font-weight: 600; margin: 0 0 1rem; }

.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 1rem; margin-bottom: 1.5rem; }
.stat-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.15rem 1.25rem; box-shadow: var(--shadow-sm); }
.stat-icon { display: inline-grid; place-items: center; width: 40px; height: 40px; border-radius: 10px; font-size: 1.15rem; margin-bottom: .9rem; }
.stat-green { background: #e7f8ef; color: #12805c; }
.stat-blue { background: #e8f0ff; color: #2563eb; }
.stat-red { background: #fdecec; color: #d92d20; }
.stat-amber { background: #fff4e0; color: #b45309; }
.stat-label { margin: 0; color: var(--muted); font-size: .85rem; font-weight: 500; }
.stat-value { margin: .2rem 0 0; font-size: 1.55rem; font-weight: 700; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }

.settings-grid { display: grid; grid-template-columns: 280px minmax(0, 1fr); gap: 1.25rem; align-items: start; }
.settings-form { min-width: 0; }
.form-actions { display: flex; justify-content: flex-end; margin-top: .25rem; }
.logo-preview {
    display: grid; place-items: center; height: 140px; margin-bottom: 1rem; padding: .75rem;
    border: 1px dashed #cfd3e0; border-radius: 10px; background: #fafbfe;
}
.logo-preview img { max-width: 100%; max-height: 100%; object-fit: contain; }
@media (max-width: 991.98px) { .settings-grid { grid-template-columns: minmax(0, 1fr); } }

.alert { border-radius: 10px; }

/* ---------- Auth pages ---------- */
.auth-shell { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 6fr); }
.auth-aside {
    display: flex; flex-direction: column; justify-content: space-between; gap: 2rem; padding: 2.5rem;
    color: #fff; background: radial-gradient(1200px 500px at 0% 0%, #3730a3 0%, transparent 60%), var(--sidebar-bg);
}
.auth-tagline { font-size: 2rem; font-weight: 700; letter-spacing: -.02em; line-height: 1.2; max-width: 16ch; }
.auth-sub { color: #b9c0d6; max-width: 38ch; margin: 0; }
.auth-foot { color: #7b849d; font-size: .85rem; margin: 0; }
.auth-main { display: grid; place-items: center; padding: 2rem 1rem; }
.auth-card {
    width: 100%; max-width: 460px; background: var(--surface); border: 1px solid var(--border);
    border-radius: 16px; padding: 2.25rem; box-shadow: var(--shadow-md);
}
.auth-card h1 { font-weight: 700; letter-spacing: -.02em; }
.error-code { font-size: 3.5rem; font-weight: 800; letter-spacing: -.04em; color: var(--accent); margin: 0; line-height: 1; }
@media (max-width: 991.98px) {
    .auth-shell { grid-template-columns: minmax(0, 1fr); }
    .auth-aside { display: none; }
    .auth-card { padding: 1.5rem; }
}

/* ---------- Lists, tables, details ---------- */
.back-link { display: inline-flex; align-items: center; gap: .4rem; margin-bottom: .75rem; color: var(--muted); text-decoration: none; font-size: .875rem; }
.back-link:hover { color: var(--accent); }

.filter-bar { display: flex; flex-wrap: wrap; align-items: center; gap: .6rem; padding: 1rem 1.15rem; border-bottom: 1px solid var(--border); }
.filter-search { position: relative; flex: 1 1 260px; min-width: 0; }
.filter-search .bi { position: absolute; left: .85rem; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.filter-search .form-control { padding-left: 2.4rem; }

.data-table { width: 100%; border-collapse: collapse; font-size: .92rem; }
.data-table th {
    padding: .7rem 1.15rem; text-align: left; white-space: nowrap;
    font-size: .72rem; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; color: var(--muted);
    background: #fafbfe; border-bottom: 1px solid var(--border);
}
.data-table th.text-end { text-align: right; }
.data-table td { padding: .8rem 1.15rem; vertical-align: middle; border-bottom: 1px solid var(--border); }
.data-table tbody tr:last-child td { border-bottom: 0; }
.data-table tbody tr:hover { background: #fafbff; }
.row-link { display: block; font-weight: 600; color: var(--text); text-decoration: none; }
.row-link:hover { color: var(--accent); text-decoration: underline; }
.cell-sub { display: block; margin-top: .1rem; font-size: .8rem; color: var(--muted); overflow-wrap: anywhere; }
.money { font-variant-numeric: tabular-nums; white-space: nowrap; }

.badge-status { display: inline-block; padding: .18rem .6rem; border-radius: 999px; font-size: .75rem; font-weight: 600; }
.badge-status.is-active { background: #e7f8ef; color: #12805c; }
.badge-status.is-inactive { background: #eef0f4; color: #667085; }

.empty-state { display: flex; flex-direction: column; align-items: center; gap: .35rem; padding: 3.5rem 1.5rem; text-align: center; }
.empty-state .bi { font-size: 2.4rem; color: #b6bcd0; }
.empty-state h2 { margin: .25rem 0 0; font-size: 1.1rem; font-weight: 600; }
.empty-state p { margin: 0 0 .75rem; color: var(--muted); max-width: 42ch; }

.pager { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .75rem; padding: .85rem 1.15rem; border-top: 1px solid var(--border); }
.pager-info { color: var(--muted); font-size: .85rem; }
.pager-buttons { display: flex; gap: .5rem; }

.detail-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 1.25rem; align-items: start; }
.detail-list { margin: 0; }
.detail-row { display: grid; grid-template-columns: 9rem minmax(0, 1fr); gap: .75rem; padding: .55rem 0; border-bottom: 1px solid var(--border); }
.detail-row:last-child { border-bottom: 0; }
.detail-row dt { font-weight: 500; color: var(--muted); font-size: .875rem; }
.detail-row dd { margin: 0; overflow-wrap: anywhere; }
.preserve-lines { white-space: pre-line; }

.segmented { display: inline-flex; gap: .5rem; }
.btn-outline-primary { --bs-btn-color: var(--accent); --bs-btn-border-color: #cfd3ff; --bs-btn-hover-bg: var(--accent-soft); --bs-btn-hover-color: var(--accent); --bs-btn-hover-border-color: var(--accent); --bs-btn-active-bg: var(--accent); --bs-btn-active-border-color: var(--accent); --bs-btn-active-color: #fff; }
fieldset { min-width: 0; }
fieldset legend.form-label { float: none; }
fieldset[disabled] .form-control, fieldset[disabled] .form-select { background-color: #f5f6fa; }

.quick-actions { display: flex; flex-wrap: wrap; gap: .6rem; margin-bottom: 1.25rem; }
.quick-actions .btn-outline-secondary { background: var(--surface); }

/* ---------- Invoices ---------- */
.nav-list-spaced { margin-top: 1rem; }

.badge-status.s-draft { background: #eef0f4; color: #475467; }
.badge-status.s-sent { background: #e8f0ff; color: #1d4ed8; }
.badge-status.s-viewed { background: #eef0ff; color: #4338ca; }
.badge-status.s-partiallypaid { background: #fff4e0; color: #b45309; }
.badge-status.s-paid { background: #e7f8ef; color: #12805c; }
.badge-status.s-overdue { background: #fdecec; color: #d92d20; }
.badge-status.s-cancelled { background: #e5e7eb; color: #6b7280; text-decoration: line-through; }

.invoice-layout { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 1.25rem; align-items: start; }
.invoice-layout > aside .panel:last-child { margin-bottom: 0; }
@media (max-width: 991.98px) { .invoice-layout { grid-template-columns: minmax(0, 1fr); } }

.totals-list { margin: 0; padding: .75rem 1.15rem 1rem; }
.totals-list > div { display: flex; justify-content: space-between; gap: 1rem; padding: .35rem 0; }
.totals-list dt { font-weight: 500; color: var(--muted); }
.totals-list dd { margin: 0; font-variant-numeric: tabular-nums; white-space: nowrap; }
.totals-list .grand { border-top: 1px solid var(--border); margin-top: .35rem; padding-top: .6rem; }
.totals-list .grand dt, .totals-list .grand dd { font-weight: 700; color: var(--text); }
.totals-list .due { border-top: 1px solid var(--border); margin-top: .35rem; padding-top: .6rem; }
.totals-list .due dt, .totals-list .due dd { font-weight: 700; font-size: 1.1rem; color: var(--accent); }
.totals-live { padding: 0; }

.lines-grid { display: flex; flex-direction: column; gap: .6rem; }
.line-head, .line-row { display: grid; grid-template-columns: 1.7fr 2.1fr .7fr 1fr .9fr .7fr 1fr 2.2rem; gap: .5rem; align-items: start; }
.line-head { padding: 0 .1rem; font-size: .72rem; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.line-head .num { text-align: right; }
.line-row { padding: .6rem; border: 1px solid var(--border); border-radius: 10px; background: #fcfcfe; }
.line-row.has-problem { border-color: #f1a9a4; background: #fff8f7; }
.line-row .form-control { padding: .45rem .6rem; }
.line-row .form-select { padding: .45rem 2rem .45rem .6rem; } /* keep room for the chevron */
.line-row .cell-num .form-control { text-align: right; }
.cell-amount { text-align: right; padding-top: .55rem; font-weight: 600; font-variant-numeric: tabular-nums; }
.btn-remove { display: grid; place-items: center; width: 2.2rem; height: 2.2rem; border: 0; border-radius: 8px; background: transparent; color: var(--muted); }
.btn-remove:hover { background: #fdecec; color: #d92d20; }
.cell::before { display: none; }
@media (max-width: 991.98px) {
    .line-head { display: none; }
    .line-row { grid-template-columns: repeat(4, minmax(0, 1fr)); }
    .cell-item, .cell-desc { grid-column: 1 / -1; }
    .cell-amount { grid-column: 1 / 4; text-align: left; }
    .cell-remove { grid-column: 4; justify-self: end; }
    .cell::before { display: block; content: attr(data-label); margin-bottom: .2rem; font-size: .7rem; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
    .cell-remove::before { display: none; }
}
@media (max-width: 575.98px) { .line-row { grid-template-columns: repeat(2, minmax(0, 1fr)); } .cell-amount { grid-column: 1 / 2; } .cell-remove { grid-column: 2; } }

.status-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: .75rem; margin-bottom: 1.25rem; }
.status-tile { display: flex; flex-direction: column; align-items: flex-start; gap: .45rem; padding: .9rem 1rem; text-decoration: none; color: inherit; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.status-tile:hover { border-color: var(--accent); }
.status-count { font-size: 1.6rem; font-weight: 700; line-height: 1; letter-spacing: -.02em; }
.stat-value { overflow-wrap: anywhere; }

.balance-strip { display: flex; flex-wrap: wrap; gap: .75rem; margin-bottom: 1rem; }
.balance { display: flex; flex-direction: column; padding: .7rem 1rem; background: #f5f6fa; border-radius: 10px; }
.balance-label { font-size: .72rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 600; }
.balance-value { font-size: 1.15rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.balance-overdue { font-size: .8rem; color: #d92d20; font-weight: 600; }
.data-table.plain td { border-bottom: 1px solid var(--border); }
.data-table.plain tbody tr:hover { background: transparent; }

/* ---------- Templates & branding ---------- */
.template-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 1rem; margin-bottom: 1.5rem; }
.template-card { display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow-sm); }
.template-card.is-default { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.template-body { padding: 1rem 1.15rem 1.15rem; }
.template-body h2 { margin: 0 0 .25rem; font-size: 1rem; font-weight: 600; }
.template-body p { margin: 0 0 .85rem; color: var(--muted); font-size: .875rem; }
.template-thumb { position: relative; height: 150px; padding: 14px; background: #f5f6fa; display: flex; flex-direction: column; gap: 7px; }
.template-thumb span { display: block; border-radius: 3px; background: #d5d9e4; }
.tt-band { height: 22px; background: var(--accent) !important; }
.tt-line { height: 6px; width: 70%; } .tt-line.short { width: 40%; }
.tt-table { flex: 1; background: repeating-linear-gradient(#e3e6ee 0 6px, transparent 6px 14px) !important; }
.tt-total { height: 14px; width: 45%; align-self: flex-end; background: var(--accent) !important; opacity: .75; }
.template-classic .tt-band { height: 4px; border-radius: 0; background: #0f1629 !important; }
.template-minimal .tt-band { height: 2px; width: 30%; }

/* ---------- Quote statuses ---------- */
.badge-status.s-accepted { background: #e7f8ef; color: #12805c; }
.badge-status.s-rejected { background: #fdecec; color: #d92d20; }
.badge-status.s-expired { background: #fff4e0; color: #b45309; }
.badge-status.s-converted { background: #eef0ff; color: #4338ca; }

/* ---------- Payments ---------- */
.badge-status.s-successful { background: #e7f8ef; color: #12805c; }
.badge-status.s-pending { background: #fff4e0; color: #b45309; }
.badge-status.s-failed { background: #fdecec; color: #d92d20; }
.badge-status.s-refunded { background: #e8f0ff; color: #1d4ed8; }
.badge-status.s-active { background: #e7f8ef; color: #12805c; }
.badge-status.s-paused { background: #fff4e0; color: #b45309; }
.badge-status.s-ended { background: #eef0f4; color: #475467; }

.alloc-input { width: 9rem; margin-left: auto; text-align: right; }
.alloc-summary { display: flex; justify-content: space-between; gap: 1rem; padding: .85rem 1.15rem; border-top: 1px solid var(--border); font-variant-numeric: tabular-nums; }
.alloc-summary.is-mismatch { background: #fff8f7; color: #b42318; }
@media (max-width: 575.98px) { .alloc-input { width: 6.5rem; } }

/* ---- Public pages (customer links) ---- */
.public-body { background: var(--bg, #f5f6fa); min-height: 100vh; display: flex; flex-direction: column; }
.public-shell { width: 100%; max-width: 860px; margin: 0 auto; padding: 1.5rem 1rem 1rem; flex: 1; }
.public-brand { display: flex; align-items: center; gap: .75rem; margin-bottom: 1rem; }
.public-logo { max-height: 44px; max-width: 160px; object-fit: contain; }
.public-company { font-weight: 700; font-size: 1.15rem; }
.public-card { margin-bottom: 1rem; }
.public-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; flex-wrap: wrap; margin-bottom: 1rem; }
.public-kind { text-transform: uppercase; letter-spacing: .06em; font-size: .75rem; font-weight: 600; color: var(--muted, #667085); margin: 0; }
.public-number { font-size: 1.6rem; margin: 0 0 .2rem; }
.public-summary { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: .75rem; margin: 0 0 1rem; }
.public-summary div { padding: .7rem .9rem; background: var(--bg, #f5f6fa); border-radius: var(--radius, 10px); }
.public-summary dt { font-size: .75rem; font-weight: 500; color: var(--muted, #667085); }
.public-summary dd { margin: 0; font-weight: 700; }
.public-respond { padding: 1rem; border: 1px solid var(--border, #e4e7ec); border-radius: var(--radius, 10px); }
.public-frame-wrap { overflow-x: auto; border: 1px solid var(--border, #e4e7ec); border-radius: var(--radius, 10px); background: #fff; }
/* The document is laid out like paper, so on a phone it scrolls sideways inside its box rather than being squashed. */
.public-frame { display: block; width: 100%; min-width: 760px; height: 900px; border: 0; }
.public-foot { text-align: center; color: var(--muted, #667085); font-size: .8rem; padding: 1rem; }

