@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700;800&family=Source+Serif+4:ital,opsz,wght@0,8..60,400;0,8..60,600;0,8..60,700;1,8..60,400&display=swap');

/* ============ BUSINESS SUITE - PREMIUM UI ============ */

:root {
    /* Color Palette */
    --navy-950: #241014;
    --navy-900: #2B2326;
    --navy-800: #3E3538;
    --navy-700: #534A4D;
    --navy-600: #6C6366;
    --navy-400: #A39B9E;
    --navy-200: #E4E2E3;
    --navy-50: #F7F6F6;

    --terra-600: #7A1F2B;
    --terra-500: #93293A;
    --terra-400: #B4505F;
    --terra-50: #FBF3F4;

    --forest-600: #166534;
    --forest-500: #22C55E;
    --forest-50: #F0FDF4;

    --sand-100: #FAFAFB;
    --sand-200: #F1F1F3;

    --accent: var(--terra-600);

    /* Surfaces & Borders */
    --surface: #FFFFFF;
    --border: #E4E2E3;
    --border-hover: #CFCBCD;

    /* Legacy compatibility */
    --bg-primary: var(--sand-200);
    --bg-secondary: var(--navy-50);
    --bg-tertiary: var(--navy-200);
    --text-primary: var(--navy-900);
    --text-secondary: var(--navy-700);
    --text-muted: var(--navy-600);
    --border-color: var(--border);
    --border-strong: var(--border-hover);
    --card-bg: var(--surface);
    --input-bg: #ffffff;
    --section-accent: var(--terra-600);
    --section-accent-strong: var(--terra-500);
    --section-accent-rgb: 122, 31, 43;

    /* Shadows */
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    --shadow-soft: var(--shadow-md);
    --shadow-strong: var(--shadow-lg);

    /* Typography */
    --font-main: 'Outfit', sans-serif;
    --font-serif: 'Source Serif 4', serif;

    /* Radius */
    --radius-lg: 20px;
    --radius-md: 14px;
    --radius-sm: 10px;

    /* Transitions */
    --spring: cubic-bezier(0.4, 0, 0.2, 1);
    --duration: 0.3s;

    /* Navigation */
    --nav-bg: var(--navy-950);
    --nav-text: var(--navy-400);
    --guideline-bg: var(--forest-50);
    --guideline-border: var(--forest-500);

    /* Footer */
    --footer-bg: var(--navy-950);
    --footer-text: var(--navy-400);
}

/* ============ RESET & BASE ============ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: var(--font-main);
    background: var(--sand-200);
    color: var(--navy-900);
    line-height: 1.5;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
}

button { cursor: pointer; border: none; background: none; font-family: inherit; }
a { text-decoration: none; color: inherit; }
ul { list-style: none; }
input, select, textarea { font-family: inherit; }

h1, h2, h3,
.section-card-title,
.stat-card-value,
.action-card-title {
    font-family: var(--font-serif);
    letter-spacing: -0.01em;
}

::selection { background: rgba(122, 31, 43, 0.15); }
:focus-visible { outline: 3px solid rgba(122, 31, 43, 0.3); outline-offset: 2px; }

::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--navy-200); border-radius: 10px; }

/* ============ ANIMATIONS ============ */
@keyframes slideInUp {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes rise {
    0% { opacity: 0; transform: translateY(8px); }
    100% { opacity: 1; transform: translateY(0); }
}

.anim-fade { animation: fadeIn var(--duration) var(--spring); }
.anim-up { animation: slideInUp 0.5s var(--spring) forwards; opacity: 0; }
.d1 { animation-delay: 0.1s; }
.d2 { animation-delay: 0.2s; }
.d3 { animation-delay: 0.3s; }
.d4 { animation-delay: 0.4s; }

/* ============ APP LAYOUT ============ */
.app-shell {
    display: flex;
    min-height: 100vh;
}

/* ============ SIDEBAR ============ */
.sidebar {
    width: 270px;
    background: var(--navy-950);
    color: #fff;
    display: flex;
    flex-direction: column;
    position: fixed;
    height: 100vh;
    z-index: 100;
    transition: transform var(--duration) var(--spring);
    overflow-y: auto;
}

.sidebar-brand {
    padding: 32px 24px;
    display: flex;
    align-items: center;
    border-bottom: 1px solid rgba(255,255,255,0.06);
}

.sidebar-brand .brand-link {
    display: inline-flex;
}

.brand-lockup {
    display: flex;
    align-items: center;
    gap: 12px;
}

.brand-lockup--center {
    justify-content: center;
}

.brand-logo {
    width: 64px;
    height: 64px;
    object-fit: contain;
}

.brand-stack {
    display: flex;
    flex-direction: column;
}

.brand-name {
    font-family: var(--font-serif);
    font-size: 24px;
    font-weight: 700;
    letter-spacing: -0.5px;
    line-height: 1.1;
    margin: 0;
}

.brand-tag {
    font-size: 10px;
    font-weight: 700;
    color: var(--navy-400);
    text-transform: uppercase;
    letter-spacing: 2px;
}

/* Sidebar Navigation */
.nav-section {
    padding: 0 12px;
    flex: 1;
}

.nav-label {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    color: var(--navy-400);
    letter-spacing: 1px;
    margin: 20px 12px 8px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    border-radius: 12px;
    color: var(--navy-400);
    font-weight: 500;
    font-size: 14px;
    transition: all 0.2s;
    margin-bottom: 2px;
    text-decoration: none;
    border: none;
    width: 100%;
    text-align: left;
    background: none;
    cursor: pointer;
}

.nav-item svg {
    width: 20px;
    height: 20px;
    stroke-width: 1.8;
    flex-shrink: 0;
}

.nav-item:hover {
    color: #fff;
    background: rgba(255, 255, 255, 0.05);
}

.nav-item.active {
    color: #fff;
    background: var(--terra-600);
    box-shadow: 0 4px 15px rgba(122, 31, 43, 0.3);
}

/* Sidebar User Footer */
.user-footer {
    margin-top: auto;
    padding: 20px;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
}

.user-card {
    display: flex;
    align-items: center;
    gap: 12px;
}

.user-card .avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid rgba(255, 255, 255, 0.1);
    background: var(--terra-600);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 700;
    font-size: 14px;
    flex-shrink: 0;
}

.user-card .avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
}

.user-card .user-info .name {
    font-size: 14px;
    font-weight: 600;
    display: block;
    color: #fff;
}

.user-card .user-info .role {
    font-size: 11px;
    color: var(--navy-400);
}

.sidebar-logout {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 12px;
    padding: 8px 14px;
    border-radius: 10px;
    color: #fca5a5;
    font-size: 13px;
    font-weight: 600;
    transition: all 0.2s;
    width: 100%;
    background: rgba(239, 68, 68, 0.08);
    border: 1px solid rgba(239, 68, 68, 0.15);
    cursor: pointer;
    text-decoration: none;
}

.sidebar-logout:hover {
    background: rgba(239, 68, 68, 0.2);
    color: #fecaca;
}

.sidebar-logout svg {
    width: 18px;
    height: 18px;
}

/* ============ MAIN CONTENT ============ */
.main-content {
    flex: 1;
    margin-left: 270px;
    display: flex;
    flex-direction: column;
    min-width: 0;
    min-height: 100vh;
    transition: margin var(--duration) var(--spring);
}

/* ============ TOP BAR ============ */
.top-bar {
    height: 72px;
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(12px);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 32px;
    position: sticky;
    top: 0;
    z-index: 90;
    border-bottom: 1px solid var(--border);
}

.top-bar-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

.top-bar-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.mobile-menu-btn {
    display: none;
    padding: 8px;
    color: var(--navy-600);
    border: 1px solid var(--border);
    border-radius: 10px;
    background: none;
    cursor: pointer;
}

.mobile-menu-btn svg { width: 24px; height: 24px; }

.page-title-bar {
    display: flex;
    flex-direction: column;
}

.page-title-bar h2 {
    font-size: 20px;
    font-weight: 700;
    color: var(--navy-950);
    line-height: 1.2;
}

.page-title-bar p {
    font-size: 13px;
    color: var(--navy-600);
}

/* ============ PAGE CONTENT ============ */
.page-body {
    padding: 28px 32px;
    flex: 1;
}

/* ============ FLASH MESSAGES ============ */
.flash-container {
    padding: 16px 32px 0;
}

.flash-message {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 18px;
    border-radius: var(--radius-md);
    margin-bottom: 10px;
    font-size: 14px;
    font-weight: 600;
    border: 1px solid;
    box-shadow: var(--shadow-sm);
    animation: rise 0.35s ease both;
}

.flash-error {
    background: linear-gradient(135deg, #fef2f2, #fee2e2);
    border-color: #f87171;
    color: #991b1b;
}

.flash-success {
    background: linear-gradient(135deg, #f0fdf4, #dcfce7);
    border-color: #4ade80;
    color: #166534;
}

.flash-info {
    background: linear-gradient(135deg, #eff6ff, #dbeafe);
    border-color: #60a5fa;
    color: #1e40af;
}

/* ============ DASHBOARD GRID ============ */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 20px;
    margin-bottom: 28px;
}

.dashboard-grid-3 {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
    margin-bottom: 28px;
}

.dashboard-grid-2 {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 20px;
    margin-bottom: 28px;
}

/* ============ CARDS ============ */
.card {
    background: var(--surface);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    padding: 24px;
    transition: all 0.3s var(--spring);
    animation: rise 0.5s ease both;
}

.card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-lg);
    border-color: var(--border-hover);
}

.card-flat {
    background: var(--surface);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    padding: 24px;
}

/* Stat Cards */
.stat-card {
    background: var(--surface);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    padding: 24px;
    transition: all 0.3s var(--spring);
    animation: rise 0.5s ease both;
    position: relative;
    overflow: hidden;
}

.stat-card::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--terra-600), var(--terra-400));
}

.stat-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-lg);
    border-color: var(--border-hover);
}

.stat-card .icon-box {
    width: 48px;
    height: 48px;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 14px;
}

.stat-card .icon-box svg {
    width: 24px;
    height: 24px;
    stroke-width: 1.8;
}

.stat-card .stat-value,
.stat-card-value {
    font-family: var(--font-serif);
    font-size: 26px;
    font-weight: 700;
    display: block;
    line-height: 1.15;
    color: var(--navy-950);
}

.stat-card .stat-label,
.stat-card-label {
    font-size: 12px;
    font-weight: 700;
    color: var(--navy-400);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-top: 4px;
}

.stat-card .stat-detail {
    font-size: 12px;
    color: var(--navy-400);
    margin-top: 6px;
}

.stat-card .trend {
    font-size: 12px;
    margin-top: 8px;
    display: flex;
    align-items: center;
    gap: 4px;
    font-weight: 700;
}

.trend.up { color: var(--forest-600); }
.trend.down { color: var(--terra-600); }

.stat-card:nth-child(1) { animation-delay: 0.04s; }
.stat-card:nth-child(2) { animation-delay: 0.08s; }
.stat-card:nth-child(3) { animation-delay: 0.12s; }
.stat-card:nth-child(4) { animation-delay: 0.16s; }

/* Section Cards (legacy compat) */
.section-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 24px;
    box-shadow: var(--shadow-sm);
    margin-bottom: 20px;
    transition: all 0.2s;
    position: relative;
    overflow: hidden;
    animation: rise 0.5s ease both;
}

.section-card::before {
    content: "";
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--terra-600), var(--terra-400));
}

.section-card:hover {
    box-shadow: var(--shadow-lg);
    transform: translateY(-2px);
}

.section-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    border-bottom: 1px solid var(--border);
    padding-bottom: 14px;
    margin-bottom: 16px;
}

.section-card-title {
    font-size: 16px;
    font-weight: 700;
    color: var(--navy-950);
    display: flex;
    align-items: center;
    gap: 8px;
}

.section-card-title svg {
    width: 20px;
    height: 20px;
    color: var(--terra-600);
}

/* Action Cards */
.action-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-left: 4px solid var(--terra-400);
    border-radius: var(--radius-md);
    padding: 20px;
    display: block;
    text-decoration: none;
    color: inherit;
    transition: all 0.2s;
    animation: rise 0.5s ease both;
}

.action-card:hover {
    border-color: var(--terra-400);
    transform: translateY(-3px);
    box-shadow: var(--shadow-lg);
}

.action-card-title {
    font-size: 16px;
    font-weight: 700;
    color: var(--navy-950);
    margin-bottom: 8px;
}

.action-card-hint {
    font-size: 12px;
    color: var(--terra-600);
    background: var(--terra-50);
    padding: 6px 10px;
    border-radius: 999px;
    display: inline-block;
    font-weight: 600;
}

.action-card:nth-child(1) { animation-delay: 0.04s; }
.action-card:nth-child(2) { animation-delay: 0.08s; }
.action-card:nth-child(3) { animation-delay: 0.12s; }

/* ============ TABLES ============ */
.table-container {
    background: #fff;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    overflow: hidden;
}

.data-table,
table.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table th,
table th {
    text-align: left;
    padding: 14px 20px;
    background: var(--navy-50);
    font-size: 11px;
    font-weight: 700;
    color: var(--navy-400);
    text-transform: uppercase;
    letter-spacing: 1px;
    border-bottom: 1px solid var(--border);
}

.data-table td,
table td {
    padding: 14px 20px;
    border-bottom: 1px solid var(--border);
    font-size: 14px;
    color: var(--navy-700);
}

.data-table tbody tr:last-child td,
table tbody tr:last-child td {
    border-bottom: none;
}

.data-table tbody tr:hover,
table tbody tr:hover {
    background: rgba(122, 31, 43, 0.03);
}

.data-table tfoot tr {
    background: var(--navy-50);
}

.data-table tfoot td {
    font-weight: 700;
}

.data-table tfoot.table-subtotal td {
    border-top: 2px solid var(--navy-200);
}

/* Money columns: equal-width digits so amounts line up vertically. */
.data-table td.text-right,
.data-table th.text-right {
    font-variant-numeric: tabular-nums;
}

.finance-loans-table {
    min-width: 980px;
}

.finance-schedule-table {
    min-width: 760px;
}

.finance-actions {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px 12px;
    min-width: 170px;
}

.finance-actions a,
.finance-actions button {
    white-space: nowrap;
}

.loan-detail-grid,
.loan-detail-grid > * {
    min-width: 0;
}

@media (max-width: 900px) {
    .finance-loans-table {
        min-width: 860px;
    }

    .modal-content {
        width: min(96vw, 720px);
    }
}

/* Status Pills */
.status-pill {
    padding: 4px 10px;
    border-radius: 100px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.status-active { background: var(--forest-50); color: var(--forest-600); }
.status-pending { background: #fef9c3; color: #854d0e; }
.status-urgent { background: var(--terra-50); color: var(--terra-600); }

/* ============ BADGES ============ */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 10px;
    font-size: 11px;
    font-weight: 700;
    border-radius: 999px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.badge-success { background: #dcfce7; color: #166534; }
.badge-warning { background: #fef3c7; color: #92400e; }
.badge-danger { background: #fee2e2; color: #991b1b; }
.badge-info { background: #dbeafe; color: #1e40af; }

/* ============ BUTTONS ============ */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 20px;
    border-radius: 12px;
    font-size: 14px;
    font-weight: 600;
    transition: all 0.2s;
    border: 1px solid transparent;
    cursor: pointer;
    text-decoration: none;
}

.btn svg { width: 18px; height: 18px; }

.btn-primary {
    background: var(--terra-600);
    color: #fff;
    box-shadow: 0 4px 12px rgba(122, 31, 43, 0.2);
}

.btn-primary:hover {
    background: var(--terra-500);
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(122, 31, 43, 0.3);
}

.btn-secondary {
    background: var(--navy-50);
    color: var(--navy-700);
    border: 1px solid var(--border);
}

.btn-secondary:hover {
    background: var(--navy-200);
    transform: translateY(-1px);
}

.btn-success {
    background: linear-gradient(135deg, #22c55e, #16a34a);
    color: white;
}

.btn-success:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(34, 197, 94, 0.3);
}

.btn-danger {
    background: linear-gradient(135deg, #ef4444, #dc2626);
    color: white;
}

.btn-danger:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(239, 68, 68, 0.3);
}

.btn-outline {
    background: transparent;
    color: var(--terra-600);
    border: 1px solid var(--terra-400);
}

.btn-outline:hover {
    background: var(--terra-50);
    transform: translateY(-1px);
}

.btn-sm {
    padding: 6px 14px;
    font-size: 12px;
    border-radius: 999px;
}

/* ============ FORMS ============ */
.form-group { margin-bottom: 18px; }

.form-label {
    display: block;
    font-size: 12px;
    font-weight: 700;
    color: var(--navy-600);
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.form-input,
.form-select,
.form-textarea {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 14px;
    background-color: var(--input-bg);
    color: var(--navy-900);
    transition: all 0.2s;
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
    outline: none;
    border-color: var(--terra-400);
    box-shadow: 0 0 0 3px rgba(122, 31, 43, 0.1);
}

.form-input::placeholder,
.form-textarea::placeholder {
    color: var(--navy-400);
}

.form-textarea { resize: vertical; }

.form-select {
    appearance: none;
    background-image: linear-gradient(45deg, transparent 50%, var(--navy-400) 50%),
        linear-gradient(135deg, var(--navy-400) 50%, transparent 50%);
    background-position: calc(100% - 18px) 52%, calc(100% - 12px) 52%;
    background-size: 6px 6px, 6px 6px;
    background-repeat: no-repeat;
}

/* ============ PRODUCT GRID (BOUTIQUE POS) ============ */
.product-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 16px;
}

.product-item {
    background: #fff;
    border-radius: 16px;
    border: 1px solid var(--border);
    overflow: hidden;
    transition: all 0.2s;
    cursor: pointer;
}

.product-item:hover {
    border-color: var(--terra-400);
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.product-img {
    height: 140px;
    background: var(--navy-50);
    position: relative;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}

.product-img img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.product-img .placeholder-icon {
    font-size: 40px;
    color: var(--navy-200);
}

.product-info {
    padding: 12px;
}

.product-name {
    font-size: 14px;
    font-weight: 600;
    display: block;
    margin-bottom: 4px;
    color: var(--navy-900);
}

.product-price {
    font-size: 15px;
    font-weight: 700;
    color: var(--terra-600);
}

.product-stock {
    font-size: 11px;
    color: var(--navy-400);
    margin-top: 2px;
}

/* ============ PROGRESS BAR ============ */
.progress-bar {
    height: 8px;
    background: var(--navy-50);
    border-radius: 4px;
    overflow: hidden;
    margin: 8px 0;
}

.progress-fill {
    height: 100%;
    background: var(--forest-500);
    border-radius: 4px;
    transition: width 0.6s var(--spring);
}

/* ============ MODALS ============ */
.modal {
    display: none;
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background-color: rgba(8, 12, 20, 0.6);
    backdrop-filter: blur(6px);
    z-index: 200;
}

.modal.active {
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-content {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 24px;
    max-width: 520px;
    width: 92%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-xl);
}

/* ============ ALERTS ============ */
.alert-low-stock {
    background: #fef9c3;
    border-left: 4px solid #f59e0b;
    padding: 12px 16px;
    margin-bottom: 10px;
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

.alert-overdue {
    background: #fee2e2;
    border-left: 4px solid #ef4444;
    padding: 12px 16px;
    margin-bottom: 10px;
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

/* ============ GUIDELINES / TIPS ============ */
.guideline {
    background: var(--guideline-bg);
    border-left: 4px solid var(--guideline-border);
    padding: 12px 16px;
    margin-bottom: 16px;
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    font-size: 14px;
    color: #166534;
}

.quick-tip {
    background: var(--terra-50);
    border: 1px solid rgba(122, 31, 43, 0.2);
    border-radius: var(--radius-sm);
    padding: 12px 16px;
    margin-bottom: 16px;
    font-size: 14px;
}

.quick-tip-title {
    font-weight: 700;
    color: var(--terra-600);
    margin-bottom: 4px;
}

/* ============ UPLOAD ZONE ============ */
.upload-zone {
    border: 2px dashed var(--border-hover);
    border-radius: var(--radius-sm);
    padding: 2rem;
    text-align: center;
    background: var(--navy-50);
    transition: all 0.2s;
    cursor: pointer;
}

.upload-zone:hover,
.upload-zone.dragover {
    border-color: var(--terra-400);
    background: var(--terra-50);
}

/* ============ AGREEMENT PREVIEW ============ */
.agreement-preview {
    background: var(--surface);
    border: 1px solid var(--border-hover);
    border-radius: var(--radius-sm);
    padding: 2rem;
    font-family: "Times New Roman", serif;
    line-height: 1.8;
}

.agreement-header {
    text-align: center;
    padding-bottom: 1.5rem;
    margin-bottom: 1.5rem;
    border-bottom: 3px double var(--navy-800);
}

.agreement-header .agreement-logo {
    height: 64px;
    width: auto;
    margin: 0 auto 12px;
    display: block;
}

.agreement-header .agreement-title {
    font-family: 'Outfit', sans-serif;
    font-size: 15px;
    font-weight: 600;
    color: var(--terra-600);
    letter-spacing: 0.15em;
    text-transform: uppercase;
    margin: 10px 0 0;
}

.agreement-header .agreement-accent {
    width: 80px;
    height: 3px;
    background: linear-gradient(90deg, var(--terra-600), var(--terra-400));
    margin: 12px auto 0;
    border-radius: 2px;
}

.agreement-preview .section-title {
    font-family: 'Outfit', sans-serif;
    font-size: 13px;
    font-weight: 700;
    color: var(--navy-800);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    padding-bottom: 6px;
    margin-bottom: 10px;
    border-bottom: 2px solid var(--terra-600);
}

.agreement-preview .signature-line {
    border-bottom: 1px solid var(--navy-400);
    min-width: 200px;
    height: 40px;
}

/* ============ CHART CONTAINERS ============ */
.chart-container {
    height: 200px;
    display: flex;
    align-items: flex-end;
    gap: 12px;
    padding-top: 20px;
}

.chart-column {
    flex: 1;
    background: var(--terra-400);
    border-radius: 6px 6px 0 0;
    position: relative;
    min-height: 20px;
    transition: height 1s var(--spring);
}

.chart-column:hover { background: var(--terra-600); }

.chart-column::after {
    content: attr(data-label);
    position: absolute;
    bottom: -24px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 10px;
    color: var(--navy-400);
    font-weight: 600;
}

/* ============ AUTH (LOGIN) PAGE ============ */
.auth-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2.5rem 1.5rem;
    background: var(--sand-200);
    background-image:
        radial-gradient(900px circle at 10% -15%, rgba(122, 31, 43, 0.1), transparent 40%),
        radial-gradient(800px circle at 90% -20%, rgba(122, 31, 43, 0.06), transparent 40%);
}

.auth-card {
    width: 100%;
    max-width: 480px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xl);
    overflow: hidden;
    animation: rise 0.5s ease both;
}

.auth-header {
    padding: 24px 24px 20px;
    background: var(--navy-950);
    color: #f8fafc;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
}

.auth-header::after {
    content: "";
    position: absolute;
    bottom: 0;
    left: 0; right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--terra-600), var(--terra-400));
}

.auth-brand {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
}

.auth-subtitle {
    color: var(--navy-400);
    font-size: 13px;
}

.auth-tag {
    padding: 5px 12px;
    border-radius: 999px;
    background: rgba(122, 31, 43, 0.2);
    border: 1px solid rgba(122, 31, 43, 0.4);
    color: #e2e8f0;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

.auth-body {
    padding: 24px;
}

.auth-preview {
    background: var(--navy-50);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 12px;
}

.auth-preview-row {
    display: flex;
    align-items: center;
    gap: 12px;
}

.auth-preview-info { flex: 1; min-width: 0; }

.auth-preview-name {
    font-weight: 700;
    color: var(--navy-900);
    font-size: 14px;
}

.auth-preview-username {
    font-size: 12px;
    color: var(--navy-400);
}

.auth-avatar {
    width: 42px;
    height: 42px;
    border-radius: 999px;
    background: linear-gradient(135deg, var(--terra-600), var(--terra-400));
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 700;
    position: relative;
    overflow: hidden;
    flex-shrink: 0;
}

.auth-avatar img,
.auth-avatar-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.auth-avatar-lg {
    width: 56px;
    height: 56px;
    font-size: 18px;
}

.auth-status {
    font-size: 10px;
    padding: 3px 8px;
    border-radius: 999px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.auth-status-locked {
    background: rgba(148, 163, 184, 0.2);
    color: #475569;
    border: 1px solid rgba(148, 163, 184, 0.4);
}

.auth-status-open {
    background: rgba(34, 197, 94, 0.16);
    color: #166534;
    border: 1px solid rgba(34, 197, 94, 0.35);
}

.auth-divider {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 16px 0;
    color: var(--navy-400);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

.auth-divider::before,
.auth-divider::after {
    content: "";
    height: 1px;
    flex: 1;
    background: var(--border);
}

.auth-switcher {
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
    text-align: center;
}

.auth-switch-label {
    font-size: 12px;
    color: var(--navy-400);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    margin-bottom: 8px;
}

.auth-switch {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px;
}

.auth-switch a {
    padding: 5px 12px;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: var(--navy-50);
    color: var(--navy-600);
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    transition: all 0.2s;
}

.auth-switch a:hover {
    border-color: var(--terra-400);
    color: var(--terra-600);
}

.auth-modal {
    position: fixed;
    inset: 0;
    background: rgba(8, 12, 20, 0.6);
    backdrop-filter: blur(6px);
    z-index: 200;
    display: none;
    align-items: center;
    justify-content: center;
}

.auth-modal.flex { display: flex; }

.auth-modal-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 24px;
    width: 100%;
    max-width: 360px;
    box-shadow: var(--shadow-xl);
}

/* ============ FOOTER ============ */
.footer-main {
    background: var(--navy-950);
    color: var(--navy-400);
    padding: 20px 32px;
    margin-top: auto;
    text-align: center;
    font-size: 13px;
}

/* ============ TAILWIND CLASS OVERRIDES ============ */
.text-gray-900, .text-gray-800 { color: var(--navy-900) !important; }
.text-gray-700, .text-gray-600 { color: var(--navy-700) !important; }
.text-gray-500, .text-gray-400 { color: var(--navy-400) !important; }
.bg-white { background-color: var(--surface) !important; }
.bg-gray-100 { background-color: var(--navy-50) !important; }
.bg-gray-50 { background-color: var(--sand-200) !important; }
.border-gray-200, .border-gray-300 { border-color: var(--border) !important; }
.text-indigo-600 { color: var(--terra-600) !important; }
.text-indigo-700 { color: var(--terra-500) !important; }
.border-indigo-500 { border-color: var(--terra-400) !important; }

/* ============ LOGO ============ */
.logo-img {
    height: 36px;
    width: auto;
    filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.2));
}

/* ============ PRINT STYLES ============ */
@media print {
    .sidebar, .top-bar, footer, .no-print { display: none !important; }
    .main-content { margin-left: 0; }
    body { background: white; }
}

/* ============ RESPONSIVE ============ */
@media (max-width: 1200px) {
    .dashboard-grid { grid-template-columns: repeat(2, 1fr); }
    .dashboard-grid-3 { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 900px) {
    .sidebar {
        transform: translateX(-100%);
        position: fixed;
        z-index: 200;
    }
    .sidebar.open {
        transform: translateX(0);
    }
    .main-content {
        margin-left: 0;
    }
    .mobile-menu-btn {
        display: flex;
        align-items: center;
        justify-content: center;
    }
    .top-bar {
        padding: 0 16px;
    }
    .page-body {
        padding: 16px;
    }
    .flash-container {
        padding: 12px 16px 0;
    }
    .dashboard-grid,
    .dashboard-grid-3,
    .dashboard-grid-2 {
        grid-template-columns: 1fr;
    }
    .product-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

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

/* Sidebar overlay on mobile */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(8, 12, 20, 0.5);
    z-index: 150;
}

.sidebar-overlay.active { display: block; }

/* ============ MISC UTILITY ============ */
.hidden { display: none !important; }
.text-center { text-align: center; }
.font-bold { font-weight: 700; }
.font-medium { font-weight: 500; }
.mt-1 { margin-top: 4px; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 12px; }
.mt-4 { margin-top: 16px; }
.mb-2 { margin-bottom: 8px; }
.mb-4 { margin-bottom: 16px; }
.mb-6 { margin-bottom: 24px; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.gap-4 { gap: 16px; }
.w-full { width: 100%; }
.mx-auto { margin-left: auto; margin-right: auto; }
.flex { display: flex; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.space-y-2 > * + * { margin-top: 8px; }
.space-y-3 > * + * { margin-top: 12px; }
.grid { display: grid; }
.overflow-x-auto { overflow-x: auto; }
.inline-flex { display: inline-flex; }
.text-sm { font-size: 14px; }
.text-xs { font-size: 12px; }
.text-right { text-align: right; }
.text-green-600 { color: #16a34a !important; }
.text-green-500 { color: #22c55e !important; }
.text-red-600 { color: #dc2626 !important; }
.text-red-500 { color: #ef4444 !important; }
.text-orange-600 { color: #ea580c !important; }
.text-blue-600 { color: #2563eb !important; }
.border-red-500 { border-color: #ef4444 !important; }

/* ============ PERIOD FILTER ============ */
.period-filter {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    margin-bottom: 20px;
}

.period-chip {
    padding: 6px 12px;
    border: 1px solid var(--border);
    border-radius: 999px;
    font-size: 13px;
    font-weight: 600;
    color: var(--navy-700);
    background: var(--surface);
    text-decoration: none;
}

.period-chip:hover,
.period-chip:focus-visible {
    border-color: var(--navy-400);
}

.period-chip.is-active {
    background: var(--navy-900);
    border-color: var(--navy-900);
    color: #fff;
}

.period-custom {
    display: inline-flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
}

.form-input.form-input-sm {
    padding: 5px 8px;
    font-size: 13px;
    width: auto;
}

.period-range {
    font-size: 12px;
    color: var(--navy-600);
    margin-left: auto;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* ============ KPI CARDS ============ */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
    margin-bottom: 16px;
}

.kpi-grid--secondary {
    margin-bottom: 24px;
}

.kpi-card {
    display: block;
    background: var(--surface);
    border: 1px solid var(--border);
    border-left: 4px solid var(--navy-200);
    border-radius: 12px;
    padding: 16px 18px;
    color: inherit;
    text-decoration: none;
}

.kpi-card.tone-green { border-left-color: var(--forest-500); }
.kpi-card.tone-emerald { border-left-color: #10b981; }
.kpi-card.tone-navy { border-left-color: var(--navy-900); }
.kpi-card.tone-red { border-left-color: #dc2626; }
.kpi-card.tone-amber { border-left-color: #d97706; }

.kpi-label {
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--navy-600);
}

.kpi-value {
    margin-top: 6px;
    font-size: 24px;
    font-weight: 700;
    color: var(--navy-900);
    font-variant-numeric: tabular-nums;
    line-height: 1.2;
}

.kpi-value--muted {
    font-size: 18px;
    color: var(--navy-600);
}

.kpi-change {
    display: inline-block;
    margin-top: 6px;
    font-size: 12px;
    font-weight: 600;
}

.kpi-change.is-up { color: var(--forest-600); }
.kpi-change.is-down { color: #b91c1c; }
.kpi-change.is-flat { color: var(--navy-400); }

.kpi-note {
    margin-top: 4px;
    font-size: 12px;
    color: var(--navy-600);
}

.kpi-card--action:hover,
.kpi-card--action:focus-visible {
    border-color: var(--navy-400);
}

/* ============ DRILL-DOWN CARDS ============ */
.drill-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.drill-card {
    display: flex;
    flex-direction: column;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 18px 20px;
    color: inherit;
    text-decoration: none;
    transition: border-color 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease;
}

.drill-card:hover,
.drill-card:focus-visible {
    border-color: var(--navy-900);
    box-shadow: var(--shadow-md);
    transform: translateY(-1px);
}

.drill-card:focus-visible {
    outline: 3px solid rgba(15, 23, 42, 0.25);
    outline-offset: 2px;
}

.drill-card__head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.drill-card__head h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 700;
}

.drill-card__go {
    font-size: 18px;
    color: var(--accent);
}

.drill-card__rows {
    display: grid;
    gap: 8px;
    margin: 0;
    flex: 1;
}

.drill-card__rows > div {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    font-size: 14px;
}

.drill-card__rows dt {
    color: var(--navy-600);
}

.drill-card__rows dd {
    margin: 0;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    text-align: right;
}

.drill-card__rows dd.is-bad {
    color: #b91c1c;
}

.drill-card__hint {
    margin: 14px 0 0;
    font-size: 12px;
    color: var(--navy-400);
}

/* ============ PAGE HELPERS ============ */
.back-link {
    display: inline-block;
    margin-bottom: 4px;
    font-size: 13px;
    font-weight: 600;
    color: var(--navy-600);
    text-decoration: none;
}

.back-link:hover {
    color: var(--navy-900);
}

.filter-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin: -8px 0 20px;
}

.filter-tab {
    padding: 5px 11px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    color: var(--navy-600);
    text-decoration: none;
}

.filter-tab:hover {
    background: var(--navy-50);
}

.filter-tab.is-active {
    background: var(--terra-50);
    color: var(--terra-600);
}

@media (max-width: 640px) {
    .kpi-value { font-size: 20px; }
    .period-range { margin-left: 0; width: 100%; }
}

/* ============ LIST PAGES (toolbar, search, row actions) ============ */
.list-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 16px;
}

.list-search {
    display: flex;
    flex: 1 1 320px;
    gap: 8px;
    max-width: 560px;
}

.list-search .form-input {
    flex: 1;
}

.btn-ghost {
    background: transparent;
    border: 1px solid transparent;
    color: var(--navy-600);
}

.btn-ghost:hover {
    color: var(--navy-900);
}

.badge-sm {
    margin-left: 6px;
    padding: 1px 7px;
    font-size: 10px;
}

.cell-sub {
    display: block;
    font-size: 11px;
    color: var(--navy-400);
    font-weight: 500;
}

.nowrap {
    white-space: nowrap;
}

.row-link {
    font-weight: 600;
    color: var(--navy-900);
    text-decoration: none;
}

.row-link:hover {
    text-decoration: underline;
}

.row-actions {
    white-space: nowrap;
    text-align: right;
}

.action-menu {
    position: relative;
    display: inline-block;
    margin-left: 4px;
}

.action-menu > summary {
    list-style: none;
    cursor: pointer;
    padding: 4px 10px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-weight: 700;
    color: var(--navy-600);
    background: var(--surface);
}

.action-menu > summary::-webkit-details-marker {
    display: none;
}

.action-menu[open] > summary,
.action-menu > summary:focus-visible {
    border-color: var(--navy-400);
}

.action-menu__list {
    position: absolute;
    right: 0;
    top: calc(100% + 4px);
    z-index: 20;
    min-width: 180px;
    padding: 6px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    box-shadow: var(--shadow-lg);
    text-align: left;
}

.action-menu__list a,
.action-menu__list button {
    display: block;
    width: 100%;
    padding: 8px 10px;
    border: 0;
    border-radius: 6px;
    background: none;
    font-size: 13px;
    color: var(--navy-800);
    text-align: left;
    text-decoration: none;
    cursor: pointer;
}

.action-menu__list a:hover,
.action-menu__list button:hover {
    background: var(--navy-50);
}

.action-menu__list form {
    margin: 0;
}

.action-menu__list .is-danger {
    color: #b91c1c;
}

.help-details {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 10px 14px;
    font-size: 13px;
    color: var(--navy-700);
}

.help-details > summary {
    cursor: pointer;
    font-weight: 600;
}

.help-details ol {
    margin: 8px 0 0 18px;
    list-style: decimal;
}

/* Phones: each table row becomes a card with labelled values. */
@media (max-width: 640px) {
    .responsive-table {
        min-width: 0 !important;
    }

    .responsive-table thead {
        display: none;
    }

    .responsive-table,
    .responsive-table tbody,
    .responsive-table tfoot,
    .responsive-table tr,
    .responsive-table td {
        display: block;
        width: 100%;
    }

    .responsive-table tr {
        padding: 12px 14px;
        border-bottom: 1px solid var(--border);
    }

    .responsive-table td {
        display: flex;
        justify-content: space-between;
        gap: 12px;
        padding: 3px 0 !important;
        border: 0 !important;
        text-align: right;
    }

    .responsive-table td[data-label]::before {
        content: attr(data-label);
        color: var(--navy-600);
        font-weight: 500;
        text-align: left;
    }

    .responsive-table td[data-label=""]::before {
        content: none;
    }

    .responsive-table td:first-child {
        justify-content: flex-start;
        gap: 6px;
        text-align: left;
        font-size: 15px;
    }

    .responsive-table td:first-child::before {
        content: none;
    }

    .responsive-table .row-actions {
        justify-content: flex-start;
        padding-top: 8px !important;
    }

    .responsive-table .hide-mobile {
        display: none;
    }

    .list-search {
        max-width: none;
    }
}

@media (max-width: 640px) {
    .responsive-table td > span:only-child {
        text-align: right;
    }
}

/* ============ PAYMENT PREVIEW ============ */
.payment-preview {
    margin: 4px 0 16px;
    padding: 12px 14px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--navy-50);
    font-size: 13px;
}

.payment-preview > div {
    display: flex;
    justify-content: space-between;
    padding: 2px 0;
    font-variant-numeric: tabular-nums;
}

.payment-preview__total {
    margin-top: 4px;
    padding-top: 6px !important;
    border-top: 1px solid var(--border);
}

.payment-preview__warn {
    margin: 0 0 6px;
    color: #b91c1c;
    font-weight: 600;
}

.payment-preview__ok {
    margin: 6px 0 0;
    color: var(--forest-600);
    font-weight: 600;
}

/* ============ PAYMENT METHOD FIELDS ============ */
.payment-fields {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 0 12px;
    width: 100%;
}

/* ============ REPORT BAR ============ */
.report-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    margin-bottom: 16px;
    font-size: 13px;
    font-weight: 600;
    color: var(--navy-700);
}

/* ============ REMINDERS ============ */
.section-heading {
    margin: 0 0 10px;
    font-size: 15px;
    font-weight: 700;
    color: var(--navy-900);
}

.reminder-message {
    display: block;
    max-width: 340px;
    font-size: 12px;
    line-height: 1.45;
    color: var(--navy-700);
}

/* ============ NOTICE CARD ============ */
.notice-card {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 18px;
    background: var(--terra-50);
    border: 1px solid rgba(122, 31, 43, 0.25);
    border-left: 4px solid var(--terra-600);
    border-radius: 12px;
    font-size: 14px;
    color: var(--navy-800);
}
