:root {
    --primary: #1a2332;
    --primary-light: #2d3e50;
    --accent: #0077b6;
    --accent-light: #00b4d8;
    --success: #06d6a0;
    --warning: #ffd60a;
    --danger: #ef476f;
    --bg: #f8f9fa;
    --bg-card: #ffffff;
    --text: #1a2332;
    --text-light: #6c757d;
    --border: #e9ecef;
    --shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.12);
    --radius: 12px;
    --radius-sm: 8px;
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
}

/* ─── Header ─────────────────────────────────────────── */
header {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
    padding: 1.5rem 2rem;
    color: white;
}

.header-content { max-width: 1400px; margin: 0 auto; }

.logo { display: flex; align-items: center; gap: 0.75rem; }
.logo-icon { font-size: 1.75rem; color: var(--accent-light); }
.logo h1 { font-size: 1.5rem; font-weight: 700; letter-spacing: -0.5px; }
.logo .pro { color: var(--accent-light); font-weight: 300; }
.tagline { margin-top: 0.2rem; color: rgba(255,255,255,0.7); font-size: 0.85rem; }

/* ─── Tabs ───────────────────────────────────────────── */
nav.tabs {
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    padding: 0 2rem;
    max-width: 1400px;
    margin: 0 auto;
    display: flex;
    overflow-x: auto;
    box-shadow: var(--shadow);
}

.tab {
    padding: 0.9rem 1.5rem;
    border: none;
    background: none;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-light);
    cursor: pointer;
    border-bottom: 3px solid transparent;
    transition: all 0.2s;
    white-space: nowrap;
}

.tab:hover:not(.disabled) { color: var(--accent); background: rgba(0,119,182,0.04); }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }
.tab.disabled { opacity: 0.4; cursor: not-allowed; }

/* ─── Main ───────────────────────────────────────────── */
main { max-width: 1400px; margin: 0 auto; padding: 1.5rem 2rem; }
.tab-content { display: none; }
.tab-content.active { display: block; }

/* ─── Client Welcome Banner ──────────────────────────── */
.client-welcome-banner {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
    border-radius: var(--radius);
    padding: 1.75rem 2rem;
    margin-bottom: 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: white;
}

.welcome-banner-left h2 {
    font-size: 1.3rem;
    font-weight: 700;
    margin-bottom: 0.25rem;
}

.welcome-banner-left p {
    font-size: 0.88rem;
    color: rgba(255,255,255,0.7);
}

.welcome-banner-right {
    display: flex;
    gap: 1.5rem;
}

.welcome-stat {
    display: flex;
    flex-direction: column;
    align-items: center;
    background: rgba(255,255,255,0.1);
    border: 1px solid rgba(255,255,255,0.15);
    border-radius: var(--radius-sm);
    padding: 0.75rem 1.5rem;
}

.welcome-stat-value {
    font-size: 1.5rem;
    font-weight: 700;
}

.welcome-stat-label {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: rgba(255,255,255,0.7);
}

/* ─── Context Bar ────────────────────────────────────── */
.context-bar {
    display: flex;
    gap: 1.5rem;
    align-items: center;
    background: var(--bg-card);
    padding: 1rem 1.5rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
}

.context-group {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.context-group label {
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text-light);
    white-space: nowrap;
}

.context-group select {
    padding: 0.5rem 0.75rem;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.88rem;
    min-width: 180px;
    background: white;
}

.context-group select:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(0,119,182,0.1);
}

.btn-icon {
    width: 32px;
    height: 32px;
    border: 1.5px solid var(--accent);
    background: white;
    color: var(--accent);
    border-radius: 50%;
    font-size: 1.2rem;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.btn-icon:hover { background: var(--accent); color: white; }
.btn-icon:disabled { opacity: 0.3; cursor: not-allowed; }
.btn-icon:disabled:hover { background: white; color: var(--accent); }

/* ─── Empty State ────────────────────────────────────── */
.empty-state {
    text-align: center;
    padding: 4rem 2rem;
    background: var(--bg-card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    border: 2px dashed var(--border);
}

.empty-icon { font-size: 3.5rem; margin-bottom: 1rem; }
.empty-state h2 { margin-bottom: 0.5rem; }
.empty-state p { color: var(--text-light); margin-bottom: 1.5rem; max-width: 500px; margin-left: auto; margin-right: auto; }

/* ─── Buttons ────────────────────────────────────────── */
.btn-primary {
    padding: 0.7rem 1.5rem;
    background: linear-gradient(135deg, var(--accent), var(--accent-light));
    color: white;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.1s, box-shadow 0.2s;
}

.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 4px 16px rgba(0,119,182,0.3); }

.btn-secondary {
    padding: 0.6rem 1.2rem;
    background: var(--accent);
    color: white;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-secondary:hover { background: var(--accent-light); }

.btn-export {
    padding: 0.6rem 1.2rem;
    border: 1.5px solid var(--border);
    background: white;
    border-radius: var(--radius-sm);
    font-size: 0.82rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-export:hover { border-color: var(--accent); color: var(--accent); }

.btn-sm {
    padding: 0.35rem 0.75rem;
    border: 1px solid var(--border);
    background: white;
    border-radius: 6px;
    font-size: 0.78rem;
    cursor: pointer;
    transition: all 0.15s;
}

.btn-sm:hover { border-color: var(--accent); color: var(--accent); }
.btn-sm.btn-danger:hover { border-color: var(--danger); color: var(--danger); }

/* ─── Workspace ──────────────────────────────────────── */
.workspace-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.workspace-header h2 { font-size: 1.4rem; font-weight: 700; }
.report-meta { font-size: 0.82rem; color: var(--text-light); margin-top: 0.2rem; }
.workspace-actions { display: flex; gap: 0.75rem; }

/* ─── Aggregated Summary ─────────────────────────────── */
.aggregated-summary {
    margin-bottom: 1.5rem;
}

.aggregated-summary h3 {
    font-size: 0.95rem;
    font-weight: 600;
    margin-bottom: 0.75rem;
    color: var(--text-light);
}

.summary-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
}

.summary-card {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 1.25rem;
    box-shadow: var(--shadow);
    border-left: 4px solid var(--accent);
}

.summary-card.liability { border-left-color: var(--danger); }
.summary-card.interest { border-left-color: var(--warning); }
.summary-card.depreciation { border-left-color: var(--success); }

.card-label {
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--text-light);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.card-value {
    font-size: 1.3rem;
    font-weight: 700;
    margin-top: 0.25rem;
}

/* ─── Lease Cards ────────────────────────────────────── */
.lease-list { display: flex; flex-direction: column; gap: 1rem; }

.lease-card {
    background: var(--bg-card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
}

.lease-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--border);
    flex-wrap: wrap;
    gap: 0.5rem;
}

.lease-card-header h4 { font-size: 1rem; font-weight: 600; }
.lease-meta { font-size: 0.78rem; color: var(--text-light); margin-top: 0.15rem; display: block; }
.lease-card-actions { display: flex; gap: 0.4rem; }

.lease-card-summary {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 0.75rem;
    padding: 1rem 1.5rem;
    background: var(--bg);
}

.mini-card { display: flex; flex-direction: column; }
.mini-label { font-size: 0.72rem; color: var(--text-light); text-transform: uppercase; letter-spacing: 0.3px; }
.mini-value { font-size: 1rem; font-weight: 600; margin-top: 0.1rem; }

.lease-detail { padding: 1.5rem; border-top: 1px solid var(--border); }

.empty-leases {
    text-align: center;
    padding: 3rem;
    background: var(--bg-card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    border: 2px dashed var(--border);
    color: var(--text-light);
}

/* ─── Schedule Tables ────────────────────────────────── */
.schedule-section-inline { overflow-x: auto; }

.schedule-section-inline h4 {
    font-size: 0.9rem;
    font-weight: 600;
    margin: 1.5rem 0 0.75rem;
}

.lease-info-bar {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0.6rem 1rem;
    font-size: 0.85rem;
    margin-bottom: 1rem;
    display: inline-block;
}

.totals-row {
    margin-bottom: 0;
}

.schedule-totals {
    margin-bottom: 0 !important;
    border-bottom: none !important;
}

.schedule-totals th {
    background: var(--primary) !important;
    color: white !important;
    font-size: 0.78rem !important;
    font-weight: 600 !important;
    text-transform: none !important;
    letter-spacing: 0 !important;
}

.opening-row {
    background: var(--bg);
    font-weight: 600;
}

.journal-entries { margin-bottom: 1rem; }
.journal-entries h4 { font-size: 0.9rem; font-weight: 600; margin-bottom: 0.75rem; }

.journal-table { width: 100%; border-collapse: collapse; max-width: 500px; }
.journal-table th {
    text-align: left;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-light);
    text-transform: uppercase;
    padding: 0.6rem 0.75rem;
    background: var(--bg);
    border-bottom: 1px solid var(--border);
}
.journal-table td { padding: 0.5rem 0.75rem; font-size: 0.85rem; border-bottom: 1px solid var(--border); }
.dr { color: var(--accent); font-weight: 500; }
.cr { color: var(--danger); font-weight: 500; }

.schedule-table { width: 100%; border-collapse: collapse; font-size: 0.8rem; }
.schedule-table th {
    text-align: right;
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--text-light);
    text-transform: uppercase;
    padding: 0.6rem 0.5rem;
    background: var(--bg);
    border-bottom: 2px solid var(--border);
    white-space: nowrap;
}
.schedule-table th:first-child { text-align: center; }
.schedule-table td { text-align: right; padding: 0.45rem 0.5rem; border-bottom: 1px solid var(--border); white-space: nowrap; }
.schedule-table td:first-child { text-align: center; }
.schedule-table tbody tr:hover { background: rgba(0,119,182,0.03); }

/* ─── Modals ─────────────────────────────────────────── */
.modal {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 1rem;
}

.modal-content {
    background: white;
    border-radius: var(--radius);
    padding: 2rem;
    width: 100%;
    max-width: 420px;
    box-shadow: var(--shadow-lg);
    max-height: 90vh;
    overflow-y: auto;
}

.modal-content.modal-wide { max-width: 560px; }

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.modal-header h3 { font-size: 1.15rem; font-weight: 600; }

.modal-close {
    width: 32px;
    height: 32px;
    border: none;
    background: var(--bg);
    border-radius: 50%;
    font-size: 1.3rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-light);
    transition: all 0.2s;
}

.modal-close:hover { background: var(--danger); color: white; }

/* ─── Forms ──────────────────────────────────────────── */
.form-group { margin-bottom: 1rem; }
.form-group label {
    display: block;
    font-size: 0.82rem;
    font-weight: 500;
    margin-bottom: 0.3rem;
}

.form-group input,
.form-group select {
    width: 100%;
    padding: 0.6rem 0.9rem;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    transition: border-color 0.2s, box-shadow 0.2s;
    background: var(--bg);
}

.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(0,119,182,0.1);
}

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

@media (max-width: 500px) {
    .form-row { grid-template-columns: 1fr; }
}

/* ─── Coming Soon ────────────────────────────────────── */
.coming-soon {
    text-align: center;
    padding: 4rem 2rem;
    background: var(--bg-card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.coming-soon p { color: var(--text-light); font-size: 1.1rem; margin-top: 0.5rem; }

/* ─── Login Screen ───────────────────────────────────── */
.login-screen {
    min-height: 100vh;
    display: flex;
    align-items: stretch;
    background: var(--bg);
}

.login-wrapper {
    display: grid;
    grid-template-columns: 1fr 1fr;
    width: 100%;
    min-height: 100vh;
}

.login-branding {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 60%, #1b3a4b 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 3rem;
    position: relative;
    overflow: hidden;
}

.login-branding::before {
    content: '';
    position: absolute;
    top: -50%;
    right: -30%;
    width: 80%;
    height: 200%;
    background: radial-gradient(ellipse, rgba(0,119,182,0.15) 0%, transparent 70%);
    pointer-events: none;
}

.branding-content {
    position: relative;
    z-index: 1;
    color: white;
    max-width: 400px;
}

.login-logo-large {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
}

.logo-icon-lg {
    font-size: 2.5rem;
    color: var(--accent-light);
}

.login-logo-large h1 {
    font-size: 2rem;
    font-weight: 700;
    color: white;
}

.login-logo-large .pro {
    color: var(--accent-light);
    font-weight: 300;
}

.branding-tagline {
    font-size: 1.1rem;
    color: rgba(255,255,255,0.7);
    margin-bottom: 2.5rem;
}

.branding-features {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.feature-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 0.95rem;
    color: rgba(255,255,255,0.85);
}

.feature-check {
    width: 24px;
    height: 24px;
    background: rgba(0,180,216,0.2);
    border: 1px solid rgba(0,180,216,0.4);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    color: var(--accent-light);
    flex-shrink: 0;
}

.login-form-panel {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    background: var(--bg);
}

.login-card {
    width: 100%;
    max-width: 380px;
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 2.5rem;
    box-shadow: var(--shadow-lg);
}

.login-card-header {
    margin-bottom: 1.5rem;
    padding-bottom: 1.25rem;
    border-bottom: 1px solid var(--border);
}

.login-logo-sm {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.login-logo-sm .logo-icon { font-size: 1.5rem; color: var(--accent); }
.login-logo-sm h2 { font-size: 1.2rem; font-weight: 700; color: var(--text); }
.login-logo-sm .pro { color: var(--accent); font-weight: 300; }

.login-subtitle {
    color: var(--text-light);
    font-size: 0.88rem;
    margin-bottom: 1.5rem;
}

.login-footer {
    margin-top: 1.5rem;
    padding-top: 1.25rem;
    border-top: 1px solid var(--border);
    text-align: center;
}

.login-footer p {
    font-size: 0.75rem;
    color: var(--text-light);
}

.login-error {
    background: #fef2f2;
    border: 1px solid #fecaca;
    color: #dc2626;
    padding: 0.6rem 0.9rem;
    border-radius: var(--radius-sm);
    font-size: 0.82rem;
    margin-bottom: 1rem;
}

.btn-full { width: 100%; }

@media (max-width: 900px) {
    .login-wrapper {
        grid-template-columns: 1fr;
    }
    .login-branding {
        display: none;
    }
}

/* ─── Header User Bar ────────────────────────────────── */
.header-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.user-bar {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.user-name {
    font-size: 0.85rem;
    font-weight: 500;
    color: rgba(255,255,255,0.9);
}

.role-badge {
    font-size: 0.65rem;
    font-weight: 700;
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    letter-spacing: 0.5px;
}

.role-admin { background: var(--warning); color: var(--primary); }
.role-client { background: var(--accent-light); color: white; }

.btn-logout {
    padding: 0.4rem 0.9rem;
    background: rgba(255,255,255,0.1);
    border: 1px solid rgba(255,255,255,0.3);
    color: white;
    border-radius: 6px;
    font-size: 0.78rem;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-logout:hover { background: rgba(255,255,255,0.2); }

/* ─── Admin Panel ────────────────────────────────────── */
.admin-panel {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 1.5rem;
    box-shadow: var(--shadow);
}

.admin-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.admin-header h2 { font-size: 1.3rem; font-weight: 700; }

.admin-table-wrapper { overflow-x: auto; }

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

.admin-table th {
    text-align: left;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-light);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 0.75rem 1rem;
    background: var(--bg);
    border-bottom: 2px solid var(--border);
}

.admin-table td {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border);
    font-size: 0.88rem;
}

.admin-table code {
    background: var(--bg);
    padding: 0.15rem 0.5rem;
    border-radius: 4px;
    font-size: 0.82rem;
}

.admin-table tr:hover { background: rgba(0,119,182,0.02); }

.text-muted { color: var(--text-light); font-size: 0.82rem; }

.modal-info {
    margin-bottom: 1rem;
    font-size: 0.9rem;
    color: var(--text-light);
}

/* ─── Client Login Display ───────────────────────────── */
.client-id-display {
    margin-bottom: 1.25rem;
}

.client-welcome-badge {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    background: linear-gradient(135deg, rgba(0,119,182,0.06), rgba(0,180,216,0.06));
    border: 1.5px solid rgba(0,119,182,0.15);
    border-radius: var(--radius-sm);
    padding: 0.9rem 1.1rem;
}

.client-welcome-icon {
    font-size: 1.5rem;
    width: 40px;
    height: 40px;
    background: var(--accent);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    flex-shrink: 0;
}

.client-welcome-text {
    display: flex;
    flex-direction: column;
}

.client-welcome-label {
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-light);
}

.client-welcome-id {
    font-size: 1rem;
    font-weight: 700;
    color: var(--accent);
}

/* ─── Admin Table Links ──────────────────────────────── */
.client-link {
    font-size: 0.78rem;
    color: var(--accent);
    text-decoration: none;
    word-break: break-all;
}

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

.btn-copy {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 0.9rem;
    padding: 0.2rem 0.4rem;
    border-radius: 4px;
    vertical-align: middle;
    margin-left: 0.3rem;
}

.btn-copy:hover { background: var(--bg); }

/* ─── Form Hints ─────────────────────────────────────── */
.form-hint {
    display: block;
    font-size: 0.75rem;
    color: var(--accent);
    margin-top: 0.3rem;
    font-family: monospace;
}

/* ─── Footer ─────────────────────────────────────────── */
footer {
    text-align: center;
    padding: 2rem;
    color: var(--text-light);
    font-size: 0.82rem;
    border-top: 1px solid var(--border);
    margin-top: 2rem;
}

/* ─── Responsive ─────────────────────────────────────── */
@media (max-width: 768px) {
    header { padding: 1rem; }
    nav.tabs { padding: 0 1rem; }
    main { padding: 1rem; }
    .context-bar { padding: 0.75rem 1rem; }
    .summary-cards { grid-template-columns: 1fr 1fr; }
    .lease-card-summary { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 480px) {
    .summary-cards { grid-template-columns: 1fr; }
    .context-bar { flex-direction: column; align-items: stretch; }
    .context-group { flex-wrap: wrap; }
}
