/* ============================================================
   Simply Statements - Main Stylesheet
   ============================================================ */

:root {
    --primary: #185FA5;
    --primary-dark: #134d87;
    --primary-light: #d6e6f5;
    --accent: #0F6E56;
    --secondary: #64748b;
    --success: #16a34a;
    --success-light: #dcfce7;
    --warning: #d97706;
    --warning-light: #fef3c7;
    --danger: #dc2626;
    --danger-light: #fee2e2;
    --info: #0891b2;
    --info-light: #cffafe;

    --bg: #f8fafc;
    --bg-white: #ffffff;
    --bg-card: #ffffff;
    --border: #e2e8f0;
    --text: #1e293b;
    --text-muted: #64748b;
    --text-light: #94a3b8;

    --sidebar-width: 260px;
    --header-height: 60px;
    --radius: 8px;
    --radius-sm: 4px;
    --shadow: 0 1px 3px rgba(0,0,0,0.1), 0 1px 2px rgba(0,0,0,0.06);
    --shadow-md: 0 4px 6px rgba(0,0,0,0.07), 0 2px 4px rgba(0,0,0,0.06);
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    font-size: 14px;
    line-height: 1.6;
    color: var(--text);
    background: var(--bg);
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Layout ─────────────────────────────────────────────── */

.app-wrapper {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: var(--sidebar-width);
    background: #1e293b;
    color: #e2e8f0;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    overflow-y: auto;
    z-index: 100;
    transition: transform 0.3s;
}

.sidebar-brand {
    padding: 14px 18px;
    border-bottom: 1px solid #334155;
    display: flex;
    align-items: center;
}

.sidebar-brand img {
    height: 36px;
    width: auto;
}

.sidebar-nav { padding: 12px 0; }

.nav-section {
    padding: 8px 20px 4px;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #64748b;
    margin-top: 8px;
}

.nav-item {
    display: flex;
    align-items: center;
    padding: 10px 20px;
    color: #cbd5e1;
    font-size: 14px;
    transition: background 0.15s, color 0.15s;
    gap: 10px;
    border-left: 3px solid transparent;
}

.nav-item:hover {
    background: #334155;
    color: #fff;
    text-decoration: none;
}

.nav-item.active {
    background: #334155;
    color: #fff;
    border-left-color: var(--primary);
}

.nav-item svg, .nav-item i {
    width: 18px;
    height: 18px;
    opacity: 0.7;
}

/* Collapsible nav groups (Customers, Suppliers, Stock, Banking, etc.) */
.nav-group {
    border: 0;
}
.nav-group > summary {
    list-style: none;
    cursor: pointer;
    user-select: none;
}
.nav-group > summary::-webkit-details-marker { display: none; }
.nav-group[open] > summary .nav-chevron { transform: rotate(180deg); }
.nav-group > summary .nav-chevron { transition: transform 0.15s; }

/* Sub-items (children of a group) */
.nav-item.nav-sub-item {
    padding: 7px 20px 7px 50px;
    font-size: 13px;
    color: #94a3b8;
    border-left: 3px solid transparent;
}
.nav-item.nav-sub-item:hover {
    color: #fff;
    background: #2c3a52;
}
.nav-item.nav-sub-item.active {
    color: #fff;
    background: #334155;
    border-left-color: var(--primary);
}

/* Coming-soon placeholders — visible but unclickable */
.nav-item.disabled {
    color: #64748b;
    cursor: not-allowed;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.nav-item.disabled:hover {
    background: transparent;
    color: #64748b;
}
.nav-tag {
    font-size: 10px;
    text-transform: uppercase;
    background: #475569;
    color: #cbd5e1;
    padding: 1px 6px;
    border-radius: 3px;
    letter-spacing: 0.05em;
}

.main-content {
    margin-left: var(--sidebar-width);
    flex: 1;
    display: flex;
    flex-direction: column;
}

/* ── Header ─────────────────────────────────────────────── */

.top-header {
    height: var(--header-height);
    background: var(--bg-white);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    position: sticky;
    top: 0;
    z-index: 50;
}

.top-header-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.top-header-right {
    display: flex;
    align-items: center;
    gap: 16px;
}

.company-selector {
    padding: 6px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg);
    font-size: 13px;
    color: var(--text);
}

.user-menu {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--text-muted);
}

.user-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--primary);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 13px;
}

.hamburger {
    display: none;
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: var(--text);
}

/* ── Page Content ───────────────────────────────────────── */

.page-content {
    padding: 24px;
    flex: 1;
}

.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
    flex-wrap: wrap;
    gap: 12px;
}

.page-title {
    font-size: 22px;
    font-weight: 700;
    color: var(--text);
}

.page-subtitle {
    font-size: 14px;
    color: var(--text-muted);
    margin-top: 2px;
}

.breadcrumb {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    color: var(--text-muted);
    margin-bottom: 12px;
}

.breadcrumb a { color: var(--text-muted); }
.breadcrumb a:hover { color: var(--primary); }

/* ── Cards ──────────────────────────────────────────────── */

.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin-bottom: 20px;
}

.card-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    font-weight: 600;
    font-size: 15px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.card-body { padding: 20px; }
.card-footer {
    padding: 12px 20px;
    border-top: 1px solid var(--border);
    background: #f8fafc;
    border-radius: 0 0 var(--radius) var(--radius);
}

/* ── Stats Grid ─────────────────────────────────────────── */

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow);
}

.stat-label {
    font-size: 13px;
    color: var(--text-muted);
    margin-bottom: 4px;
}

.stat-value {
    font-size: 28px;
    font-weight: 700;
    color: var(--text);
}

.stat-change {
    font-size: 12px;
    margin-top: 4px;
}

.stat-change.up { color: var(--success); }
.stat-change.down { color: var(--danger); }

/* ── Tables ─────────────────────────────────────────────── */

.table-responsive { overflow-x: auto; }

table {
    width: 100%;
    border-collapse: collapse;
}

th {
    text-align: left;
    padding: 10px 16px;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--text-muted);
    background: #f8fafc;
    border-bottom: 2px solid var(--border);
    white-space: nowrap;
}

td {
    padding: 10px 16px;
    border-bottom: 1px solid var(--border);
    font-size: 14px;
    vertical-align: middle;
}

tr:hover td { background: #f8fafc; }

.text-right { text-align: right; }
.text-center { text-align: center; }
.text-muted { color: var(--text-muted); }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.text-warning { color: var(--warning); }

.amount {
    font-family: 'SF Mono', 'Cascadia Code', 'Consolas', monospace;
    font-size: 13px;
    text-align: right;
    white-space: nowrap;
}

/* ── Buttons ────────────────────────────────────────────── */

.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    font-size: 14px;
    font-weight: 500;
    border-radius: var(--radius-sm);
    border: 1px solid transparent;
    cursor: pointer;
    transition: all 0.15s;
    line-height: 1.4;
    text-decoration: none;
}

.btn:hover { text-decoration: none; }

.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }

.btn-secondary { background: var(--bg); color: var(--text); border-color: var(--border); }
.btn-secondary:hover { background: #e2e8f0; }

.btn-success { background: var(--success); color: #fff; }
.btn-success:hover { background: #15803d; }

.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #b91c1c; }

.btn-outline { background: transparent; color: var(--primary); border-color: var(--primary); }
.btn-outline:hover { background: var(--primary-light); }

.btn-sm { padding: 4px 10px; font-size: 13px; }
.btn-lg { padding: 12px 24px; font-size: 16px; }

.btn-group { display: flex; gap: 8px; }

/* ── Forms ──────────────────────────────────────────────── */

.form-group {
    margin-bottom: 16px;
}

.form-label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 4px;
    color: var(--text);
}

.form-control {
    width: 100%;
    padding: 8px 12px;
    font-size: 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-white);
    color: var(--text);
    transition: border-color 0.15s;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

select.form-control { cursor: pointer; }

textarea.form-control { resize: vertical; min-height: 80px; }

.form-hint {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 4px;
}

.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 16px;
}

.form-error {
    color: var(--danger);
    font-size: 12px;
    margin-top: 4px;
}

/* ── Badges / Pills ─────────────────────────────────────── */

.badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 10px;
    font-size: 12px;
    font-weight: 600;
    border-radius: 20px;
    white-space: nowrap;
}

.badge-success { background: var(--success-light); color: var(--success); }
.badge-warning { background: var(--warning-light); color: var(--warning); }
.badge-danger  { background: var(--danger-light);  color: var(--danger); }
.badge-info    { background: var(--info-light);     color: var(--info); }
.badge-secondary { background: #f1f5f9; color: var(--secondary); }

/* ── Alerts ─────────────────────────────────────────────── */

.alert {
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    margin-bottom: 16px;
    font-size: 14px;
    border: 1px solid transparent;
}

.alert-success { background: var(--success-light); color: #166534; border-color: #bbf7d0; }
.alert-danger  { background: var(--danger-light);  color: #991b1b; border-color: #fecaca; }
.alert-warning { background: var(--warning-light); color: #92400e; border-color: #fde68a; }
.alert-info    { background: var(--info-light);     color: #155e75; border-color: #a5f3fc; }

/* ── Wizard Steps ───────────────────────────────────────── */

.wizard-steps {
    display: flex;
    margin-bottom: 32px;
    counter-reset: step;
}

.wizard-step {
    flex: 1;
    text-align: center;
    position: relative;
    padding-top: 40px;
    font-size: 13px;
    color: var(--text-muted);
}

.wizard-step::before {
    counter-increment: step;
    content: counter(step);
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: #e2e8f0;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 14px;
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
}

.wizard-step.active::before {
    background: var(--primary);
    color: #fff;
}

.wizard-step.completed::before {
    background: var(--success);
    color: #fff;
    content: '\2713';
}

.wizard-step::after {
    content: '';
    position: absolute;
    top: 16px;
    left: calc(50% + 20px);
    right: calc(-50% + 20px);
    height: 2px;
    background: var(--border);
}

.wizard-step:last-child::after { display: none; }
.wizard-step.completed::after { background: var(--success); }

/* ── File Upload ────────────────────────────────────────── */

.file-drop-zone {
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    padding: 40px 20px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
    background: var(--bg);
}

.file-drop-zone:hover,
.file-drop-zone.dragover {
    border-color: var(--primary);
    background: var(--primary-light);
}

.file-drop-zone p {
    color: var(--text-muted);
    margin-top: 8px;
    font-size: 14px;
}

/* ── Empty State ────────────────────────────────────────── */

.empty-state {
    text-align: center;
    padding: 48px 20px;
    color: var(--text-muted);
}

.empty-state h3 {
    font-size: 18px;
    margin-bottom: 8px;
    color: var(--text);
}

/* ── Responsive ─────────────────────────────────────────── */

@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .main-content {
        margin-left: 0;
    }

    .hamburger { display: block; }

    .page-content { padding: 16px; }

    .form-row {
        grid-template-columns: 1fr;
    }

    .stats-grid {
        grid-template-columns: 1fr 1fr;
    }
}

@media (max-width: 480px) {
    .stats-grid {
        grid-template-columns: 1fr;
    }
}

/* ── Utility ────────────────────────────────────────────── */

.mt-1 { margin-top: 4px; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 16px; }
.mt-4 { margin-top: 24px; }
.mb-1 { margin-bottom: 4px; }
.mb-2 { margin-bottom: 8px; }
.mb-3 { margin-bottom: 16px; }
.mb-4 { margin-bottom: 24px; }
.p-3 { padding: 16px; }
.p-4 { padding: 24px; }

.d-flex { display: flex; }
.align-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 16px; }

.w-100 { width: 100%; }
.fw-bold { font-weight: 700; }
.fs-sm { font-size: 13px; }

/* ── Account Tree (Chart of Accounts) ───────────────────── */
.account-tree .tree-group { margin-bottom: 4px; }
.account-tree .tree-parent {
    padding: 10px 16px;
    background: #f1f5f9;
    font-weight: 600;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
}
.account-tree .tree-parent:hover { background: #e2e8f0; }
.account-tree .tree-children { display: none; }
.account-tree .tree-children.open { display: block; }
.account-tree .tree-child {
    padding: 8px 16px 8px 40px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 13px;
}
.account-tree .tree-child:hover { background: #fafafa; }

/* ── Login Page ─────────────────────────────────────────── */

.login-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #1e293b 0%, #334155 100%);
}

.login-card {
    background: #fff;
    border-radius: var(--radius);
    padding: 40px;
    width: 100%;
    max-width: 420px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.2);
}

.login-card h1 {
    font-size: 24px;
    margin-bottom: 8px;
    text-align: center;
}

.login-logo {
    display: flex;
    justify-content: center;
    margin-bottom: 8px;
}

.login-logo img {
    height: 48px;
    width: auto;
}

.login-card .subtitle {
    text-align: center;
    color: var(--text-muted);
    margin-bottom: 28px;
    font-size: 14px;
}

/* ── Portal Layout ──────────────────────────────────────── */

.portal-body {
    background: #f1f5f9;
    min-height: 100vh;
}

.portal-header {
    background: linear-gradient(135deg, #1e293b 0%, #334155 100%);
    color: #fff;
    padding: 0 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: 64px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.12);
    position: sticky;
    top: 0;
    z-index: 100;
}

.portal-header .portal-brand {
    font-size: 17px;
    font-weight: 700;
    letter-spacing: -0.3px;
    white-space: nowrap;
}

.portal-header .portal-brand span {
    color: #85B7EB;
}

.portal-header .portal-brand img {
    height: 32px;
    width: auto;
}

.portal-nav {
    display: flex;
    gap: 4px;
    align-items: center;
}

.portal-nav a {
    color: rgba(255,255,255,0.7);
    text-decoration: none;
    padding: 8px 14px;
    border-radius: 6px;
    font-size: 13.5px;
    font-weight: 500;
    transition: all 0.15s;
}

.portal-nav a:hover {
    color: #fff;
    background: rgba(255,255,255,0.1);
}

.portal-nav a.active {
    color: #fff;
    background: rgba(255,255,255,0.15);
}

.portal-nav .portal-divider {
    width: 1px;
    height: 20px;
    background: rgba(255,255,255,0.15);
    margin: 0 6px;
}

.portal-nav .portal-user {
    font-size: 13px;
    color: rgba(255,255,255,0.6);
    padding: 0 8px;
}

.portal-nav a.portal-logout {
    color: rgba(255,255,255,0.5);
    font-size: 12.5px;
}

.portal-nav a.portal-logout:hover {
    color: #fca5a5;
    background: rgba(220,38,38,0.15);
}

.portal-content {
    max-width: 1000px;
    margin: 0 auto;
    padding: 28px 20px 40px;
}

/* ──────────────────────────────────────────────────────────────
   Sidebar-style portal layout (the new look). The old .portal-header
   / .portal-content classes above are kept for any third-party
   embedding but the standard tenant portal now uses .portal-shell.
   ────────────────────────────────────────────────────────────── */
.portal-shell {
    display: grid;
    grid-template-columns: 230px 1fr;
    min-height: 100vh;
}

.portal-sidebar {
    background: linear-gradient(180deg, #1e293b 0%, #0f172a 100%);
    color: #fff;
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
}

.portal-sidebar .sidebar-brand {
    padding: 20px 20px 16px;
    font-size: 15px;
    font-weight: 700;
    letter-spacing: -0.3px;
    border-bottom: 1px solid rgba(255,255,255,0.08);
}
.portal-sidebar .sidebar-brand span { color: #85B7EB; font-weight: 500; }
.portal-sidebar .sidebar-brand img  { height: 28px; width: auto; }

.portal-sidebar nav {
    padding: 12px 8px;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.portal-sidebar nav a {
    display: flex;
    align-items: center;
    gap: 10px;
    color: rgba(255,255,255,0.7);
    text-decoration: none;
    padding: 9px 12px;
    border-radius: 6px;
    font-size: 13.5px;
    font-weight: 500;
    transition: all 0.15s;
}
.portal-sidebar nav a:hover {
    color: #fff;
    background: rgba(255,255,255,0.08);
}
.portal-sidebar nav a.active {
    color: #fff;
    background: rgba(133,183,235,0.18);
}
.portal-sidebar nav a svg {
    width: 16px; height: 16px;
    flex-shrink: 0;
    opacity: 0.85;
}

.portal-sidebar .sidebar-foot {
    padding: 14px 16px;
    border-top: 1px solid rgba(255,255,255,0.08);
    font-size: 12px;
    color: rgba(255,255,255,0.55);
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.portal-sidebar .sidebar-foot a {
    color: rgba(255,255,255,0.55);
    text-decoration: none;
}
.portal-sidebar .sidebar-foot a:hover { color: #fca5a5; }

.portal-topbar {
    height: 56px;
    background: #fff;
    border-bottom: 1px solid #e2e8f0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    gap: 14px;
}
.portal-topbar .page-title {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    color: #0f172a;
}

.portal-main {
    background: #f1f5f9;
    min-height: calc(100vh - 56px);
    padding: 24px 28px 40px;
}

@media (max-width: 900px) {
    .portal-shell { grid-template-columns: 1fr; }
    .portal-sidebar { position: relative; height: auto; }
    .portal-sidebar nav { flex-direction: row; flex-wrap: wrap; }
    .portal-sidebar .sidebar-foot { display: none; }
}

/* Portal welcome section */
.portal-welcome {
    margin-bottom: 28px;
}

.portal-welcome h2 {
    font-size: 24px;
    font-weight: 700;
    color: #1e293b;
    margin: 0 0 4px;
}

.portal-welcome p {
    color: #64748b;
    margin: 0;
    font-size: 14px;
}

/* ── Inline arrow icons (replaces &larr; / &rarr; everywhere) ──
   Usage: <span class="ico-arrow-left"></span> Dashboard
   Sized via the surrounding font, inherits currentColor. */
.ico-arrow-left,
.ico-arrow-right {
    display: inline-block;
    width: 1em;
    height: 1em;
    vertical-align: -0.15em;
    background-color: currentColor;
    -webkit-mask-repeat: no-repeat;
            mask-repeat: no-repeat;
    -webkit-mask-position: center;
            mask-position: center;
    -webkit-mask-size: 100% 100%;
            mask-size: 100% 100%;
}
.ico-arrow-left {
    -webkit-mask-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.25' stroke-linecap='round' stroke-linejoin='round'><line x1='19' y1='12' x2='5' y2='12'/><polyline points='12 19 5 12 12 5'/></svg>");
            mask-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.25' stroke-linecap='round' stroke-linejoin='round'><line x1='19' y1='12' x2='5' y2='12'/><polyline points='12 19 5 12 12 5'/></svg>");
}
.ico-arrow-right {
    -webkit-mask-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.25' stroke-linecap='round' stroke-linejoin='round'><line x1='5' y1='12' x2='19' y2='12'/><polyline points='12 5 19 12 12 19'/></svg>");
            mask-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.25' stroke-linecap='round' stroke-linejoin='round'><line x1='5' y1='12' x2='19' y2='12'/><polyline points='12 5 19 12 12 19'/></svg>");
}

/* ───────────────────────────────────────────────────────────
   Portal page styling — premium-feel refresh.
   Layered surfaces, hairline rings, generous breathing room,
   restrained typography, no playful emojis.
   ─────────────────────────────────────────────────────────── */

.portal-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 18px;
    margin-bottom: 32px;
}

.portal-stat {
    background: #fff;
    border-radius: 14px;
    padding: 22px 22px 20px;
    border: 1px solid #eef1f5;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
    position: relative;
    transition: box-shadow .2s ease, transform .2s ease, border-color .2s ease;
}
.portal-stat:hover {
    box-shadow: 0 4px 18px rgba(15, 23, 42, 0.07);
    border-color: #e2e8f0;
}

/* Icon sits as a subtle accent in the top-right corner */
.portal-stat .stat-icon {
    position: absolute;
    top: 18px;
    right: 18px;
    width: 36px;
    height: 36px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #475569;
    background: #f1f5f9;
}
.portal-stat .stat-icon svg { width: 17px; height: 17px; stroke-width: 1.75; }
.portal-stat .stat-icon.red    { background: #fef2f2; color: #b91c1c; }
.portal-stat .stat-icon.green  { background: #ecfdf5; color: #047857; }
.portal-stat .stat-icon.blue   { background: #eff6ff; color: #1d4ed8; }
.portal-stat .stat-icon.amber  { background: #fffbeb; color: #b45309; }
.portal-stat .stat-icon.violet { background: #f5f3ff; color: #6d28d9; }
.portal-stat .stat-icon.slate  { background: #f1f5f9; color: #475569; }

.portal-stat .stat-label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: #64748b;
    font-weight: 600;
    margin-bottom: 12px;
    padding-right: 44px;
}

.portal-stat .stat-value {
    font-size: 26px;
    font-weight: 600;
    color: #0f172a;
    line-height: 1.2;
    letter-spacing: -0.4px;
    font-variant-numeric: tabular-nums;
}

.portal-stat .stat-hint {
    font-size: 12px;
    color: #94a3b8;
    margin-top: 6px;
}

/* ── Portal cards ───────────────────────────────────────── */
.portal-card {
    background: #fff;
    border-radius: 14px;
    border: 1px solid #eef1f5;
    margin-bottom: 22px;
    overflow: hidden;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}

.portal-card .card-header {
    padding: 18px 22px 14px;
    font-weight: 600;
    font-size: 14px;
    color: #0f172a;
    letter-spacing: -0.1px;
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 12px;
    background: #fff;
    border-bottom: 1px solid #f1f5f9;
}
.portal-card .card-header .fs-sm { font-weight: 400; color: #94a3b8; font-size: 12px; }

.portal-card .card-body { padding: 22px; }
.portal-card .card-footer {
    padding: 16px 22px;
    border-top: 1px solid #f1f5f9;
    background: #fafbfc;
}

/* Tables inside portal cards: borderless, dense, refined */
.portal-card table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13.5px;
}
.portal-card table th {
    text-align: left;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    color: #94a3b8;
    background: #fafbfc;
    padding: 12px 22px;
    border-bottom: 1px solid #f1f5f9;
}
.portal-card table th.text-right { text-align: right; }
.portal-card table td {
    padding: 14px 22px;
    border-bottom: 1px solid #f4f6f9;
    color: #1e293b;
    vertical-align: middle;
}
.portal-card table tbody tr:last-child td { border-bottom: none; }
.portal-card table tbody tr:hover td { background: #fafbfc; }
.portal-card table .amount {
    text-align: right;
    font-variant-numeric: tabular-nums;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}
.portal-card table tfoot td {
    background: #f8fafc;
    font-weight: 600;
    color: #0f172a;
    padding: 14px 22px;
    border-top: 2px solid #e2e8f0;
    border-bottom: none;
}

/* ── Portal quick-action buttons ────────────────────────── */
.portal-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.portal-action-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 18px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
    text-decoration: none;
    transition: all .15s;
    border: 1px solid transparent;
    letter-spacing: -0.1px;
}

.portal-action-btn.primary {
    background: #0f172a;
    color: #fff;
}
.portal-action-btn.primary:hover {
    background: #1e293b;
    transform: translateY(-1px);
    box-shadow: 0 4px 10px rgba(15, 23, 42, 0.18);
}

.portal-action-btn.secondary {
    background: #fff;
    color: #334155;
    border-color: #e2e8f0;
}
.portal-action-btn.secondary:hover {
    background: #f8fafc;
    border-color: #cbd5e1;
    color: #0f172a;
}

/* ── Portal dashboard hero (welcome + outstanding balance) ── */
.portal-hero {
    display: grid;
    grid-template-columns: 1.4fr 1fr;
    gap: 22px;
    margin-bottom: 28px;
}
@media (max-width: 720px) {
    .portal-hero { grid-template-columns: 1fr; }
}

.portal-hero-welcome {
    background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
    color: #fff;
    border-radius: 16px;
    padding: 30px 32px 32px;
    display: flex;
    flex-direction: column;
    justify-content: center;
}
.portal-hero-eyebrow {
    text-transform: uppercase;
    letter-spacing: 1.2px;
    font-size: 11px;
    margin: 0 0 4px;
    color: rgba(255,255,255,0.55);
    font-weight: 600;
}
.portal-hero-welcome h1 {
    margin: 0;
    font-size: 32px;
    font-weight: 600;
    letter-spacing: -0.8px;
    line-height: 1.1;
}
.portal-hero-sub {
    margin: 8px 0 0;
    color: rgba(255,255,255,0.65);
    font-size: 14px;
}

.portal-hero-balance {
    background: #fff;
    border-radius: 16px;
    padding: 28px;
    border: 1px solid #eef1f5;
    box-shadow: 0 1px 2px rgba(15,23,42,.04);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}
.portal-hero-balance.has-due { border-top: 4px solid #ef4444; }
.portal-hero-balance.is-clear { border-top: 4px solid #10b981; }

.portal-hero-balance .balance-label {
    font-size: 11px;
    letter-spacing: 0.8px;
    text-transform: uppercase;
    color: #94a3b8;
    font-weight: 600;
}
.portal-hero-balance .balance-amount {
    font-size: 38px;
    font-weight: 600;
    letter-spacing: -1px;
    margin-top: 6px;
    color: #0f172a;
    font-variant-numeric: tabular-nums;
}
.portal-hero-balance.has-due .balance-amount { color: #b91c1c; }
.portal-hero-balance .balance-hint {
    font-size: 13px;
    color: #64748b;
    margin-top: 8px;
}
.portal-hero-balance .balance-link {
    margin-top: 14px;
    color: #0f172a;
    text-decoration: none;
    font-size: 13px;
    font-weight: 500;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    align-self: flex-start;
}
.portal-hero-balance .balance-link:hover { text-decoration: underline; }

/* ── Quick action cards (download + log maintenance) ─────── */
.portal-quick {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 18px;
    margin-bottom: 32px;
}
@media (max-width: 720px) { .portal-quick { grid-template-columns: 1fr; } }

.portal-quick-card {
    background: #fff;
    border: 1px solid #eef1f5;
    border-radius: 14px;
    padding: 22px 24px;
    display: flex;
    align-items: center;
    gap: 18px;
    text-decoration: none;
    color: #0f172a;
    transition: all .2s ease;
    box-shadow: 0 1px 2px rgba(15,23,42,.04);
}
.portal-quick-card:hover {
    border-color: #cbd5e1;
    box-shadow: 0 6px 18px rgba(15,23,42,.08);
    transform: translateY(-1px);
}

.portal-quick-card .quick-icon {
    width: 52px;
    height: 52px;
    border-radius: 12px;
    background: #0f172a;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.portal-quick-card .quick-icon svg { width: 24px; height: 24px; }

.portal-quick-card .quick-title {
    font-size: 15px;
    font-weight: 600;
    letter-spacing: -0.2px;
}
.portal-quick-card .quick-sub {
    font-size: 12.5px;
    color: #64748b;
    margin-top: 3px;
}

/* ── Browse tiles ────────────────────────────────────────── */
.portal-section-title {
    font-size: 13px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: #64748b;
    margin: 0 0 14px;
}

.portal-tile-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 16px;
    margin-bottom: 28px;
}

.portal-tile {
    display: flex;
    flex-direction: column;
    padding: 22px;
    border-radius: 14px;
    background: #fff;
    border: 1px solid #eef1f5;
    text-decoration: none;
    color: inherit;
    transition: all .2s ease;
    box-shadow: 0 1px 2px rgba(15,23,42,.04);
}
.portal-tile:hover {
    border-color: #cbd5e1;
    box-shadow: 0 6px 18px rgba(15,23,42,.07);
    transform: translateY(-1px);
}
.portal-tile .tile-icon {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    background: #f1f5f9;
    color: #334155;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 14px;
}
.portal-tile .tile-icon svg { width: 20px; height: 20px; }
.portal-tile .tile-title {
    font-size: 15px;
    font-weight: 600;
    color: #0f172a;
    margin-bottom: 4px;
    letter-spacing: -0.2px;
}
.portal-tile .tile-desc {
    font-size: 12.5px;
    color: #64748b;
    line-height: 1.5;
    margin-bottom: 14px;
    flex: 1;
}
.portal-tile .tile-cta {
    font-size: 12.5px;
    font-weight: 500;
    color: #0f172a;
    display: inline-flex;
    align-items: center;
    gap: 5px;
}

/* Portal page header */
.portal-page-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    margin-bottom: 28px;
    gap: 16px;
    flex-wrap: wrap;
}

.portal-page-header h2 {
    font-size: 24px;
    font-weight: 600;
    color: #0f172a;
    letter-spacing: -0.6px;
    margin: 0;
    line-height: 1.2;
}

.portal-page-header p {
    color: #64748b;
    margin: 6px 0 0;
    font-size: 13.5px;
}

/* Portal alert banner */
.portal-alert {
    padding: 14px 18px;
    border-radius: 10px;
    font-size: 14px;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.portal-alert.danger {
    background: #fef2f2;
    color: #991b1b;
    border: 1px solid #fecaca;
}

.portal-alert.success {
    background: #f0fdf4;
    color: #166534;
    border: 1px solid #bbf7d0;
}

/* Portal table styling */
.portal-card table {
    width: 100%;
    border-collapse: collapse;
}

.portal-card table th {
    font-size: 11.5px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #64748b;
    font-weight: 600;
    padding: 10px 16px;
    border-bottom: 1px solid #e2e8f0;
    background: #f8fafc;
}

.portal-card table td {
    padding: 12px 16px;
    font-size: 13.5px;
    border-bottom: 1px solid #f1f5f9;
    color: #334155;
}

.portal-card table tbody tr:hover {
    background: #f8fafc;
}

.portal-card table tfoot td {
    background: #f8fafc;
    font-weight: 700;
    border-top: 2px solid #e2e8f0;
    border-bottom: none;
}

/* Portal detail grid */
.portal-detail-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
}

.portal-detail-item {
    margin-bottom: 16px;
}

.portal-detail-item .label {
    font-size: 11.5px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #94a3b8;
    font-weight: 600;
    margin-bottom: 4px;
}

.portal-detail-item .value {
    font-size: 15px;
    color: #1e293b;
    font-weight: 500;
}

.portal-detail-item .value.large {
    font-size: 26px;
    font-weight: 700;
}

/* Portal empty state */
.portal-empty {
    text-align: center;
    padding: 48px 20px;
    color: #94a3b8;
}

.portal-empty h3 {
    font-size: 16px;
    color: #64748b;
    margin: 0 0 6px;
}

.portal-empty p {
    font-size: 13.5px;
    margin: 0;
}

/* Mobile portal */
@media (max-width: 768px) {
    .portal-header {
        padding: 0 16px;
    }
    .portal-nav {
        gap: 2px;
    }
    .portal-nav a {
        padding: 6px 10px;
        font-size: 12.5px;
    }
    .portal-nav .portal-user {
        display: none;
    }
    .portal-stats {
        grid-template-columns: 1fr 1fr;
    }
    .portal-detail-grid {
        grid-template-columns: 1fr;
    }
    .portal-content {
        padding: 20px 16px 32px;
    }
}

/* ── Portal mobile hamburger ── */
.portal-hamburger {
    display: none;
    background: none;
    border: none;
    color: #fff;
    font-size: 24px;
    cursor: pointer;
    padding: 4px 8px;
    line-height: 1;
}

@media (max-width: 640px) {
    .portal-hamburger { display: block; }
    .portal-header {
        flex-wrap: wrap;
        height: auto;
        padding: 12px 16px;
    }
    .portal-header .portal-brand { flex: 1; }
    .portal-nav {
        display: none;
        width: 100%;
        flex-direction: column;
        gap: 2px;
        padding-top: 10px;
        border-top: 1px solid rgba(255,255,255,0.1);
        margin-top: 8px;
    }
    .portal-nav.open { display: flex; }
    .portal-nav a {
        padding: 10px 12px;
        font-size: 14px;
        border-radius: 6px;
    }
    .portal-nav .portal-divider {
        width: 100%;
        height: 1px;
        margin: 4px 0;
    }
    .portal-nav .portal-user {
        display: block;
        padding: 8px 12px;
        font-size: 13px;
    }
    .portal-nav a.portal-logout {
        font-size: 13px;
        padding: 10px 12px;
    }
    .portal-stats {
        grid-template-columns: 1fr;
    }
}
