/* ══════════════════════════════════════════════════
   Agency System — Professional Stylesheet
   ══════════════════════════════════════════════════ */

:root {
    --primary: #667eea;
    --primary-dark: #5a6fd6;
    --secondary: #764ba2;
    --accent: #f59e0b;
    --success: #10b981;
    --danger: #ef4444;
    --warning: #f59e0b;
    --info: #3b82f6;
    --gray-50: #f8fafc;
    --gray-100: #f1f5f9;
    --gray-200: #e2e8f0;
    --gray-300: #cbd5e1;
    --gray-400: #94a3b8;
    --gray-500: #64748b;
    --gray-600: #475569;
    --gray-700: #334155;
    --gray-800: #1e293b;
    --gray-900: #0f172a;
    --radius: 12px;
    --radius-sm: 8px;
    --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);
    --shadow-lg: 0 10px 25px rgba(0,0,0,0.1), 0 4px 10px rgba(0,0,0,0.06);
    --transition: all 0.2s ease;
}

.form-group[style*="--field-border-color"] input,
.form-group[style*="--field-border-color"] select,
.form-group[style*="--field-border-color"] textarea {
    border-color: var(--field-border-color) !important;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: var(--gray-100);
    color: var(--gray-800);
    line-height: 1.6;
    min-height: 100vh;
}

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

.auth-page {
    background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.auth-card {
    background: white;
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    max-width: 420px;
    width: 100%;
    padding: 2.5rem;
    text-align: center;
}

.auth-card .logo { font-size: 48px; margin-bottom: 1rem; }
.auth-card h1 { font-size: 24px; font-weight: 700; color: var(--gray-900); margin-bottom: 0.25rem; }
.auth-card .subtitle { font-size: 14px; color: var(--gray-500); margin-bottom: 1.5rem; }

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

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 20px;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
    font-family: inherit;
    line-height: 1;
}

.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0); }

.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-dark); box-shadow: 0 4px 15px rgba(102,126,234,0.4); }

.btn-success { background: var(--success); color: white; }
.btn-success:hover { background: #059669; }

.btn-danger { background: var(--danger); color: white; }
.btn-danger:hover { background: #dc2626; }

.btn-outline {
    background: transparent;
    color: var(--gray-700);
    border: 1px solid var(--gray-300);
}
.btn-outline:hover { background: var(--gray-50); border-color: var(--gray-400); }

.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn-lg { padding: 14px 28px; font-size: 16px; }
.btn-block { width: 100%; }

.btn-monday {
    background: #3350FF;
    color: white;
    width: 100%;
    padding: 14px 20px;
    border-radius: var(--radius-sm);
    box-shadow: 0 4px 15px rgba(51,80,255,0.3);
}
.btn-monday:hover { background: #2540D9; }

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

.form-group { margin-bottom: 1.25rem; text-align: left; }
.form-group label { display: block; font-size: 13px; font-weight: 600; color: var(--gray-700); margin-bottom: 6px; }

.form-control, input, select, textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--gray-300);
    border-radius: 6px;
    font-size: 14px;
    transition: var(--transition);
    font-family: inherit;
    background: white;
}
.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(102,126,234,0.15);
}
.form-control::placeholder { color: var(--gray-400); }

select.form-control { appearance: auto; }

.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-error { color: var(--danger); font-size: 12px; margin-top: 4px; }
.form-hint { font-size: 12px; color: var(--gray-400); margin-top: 4px; }
.field-error { color: var(--danger); font-size: 12px; margin-top: 4px; display: none; }
.field-error-active input,
.field-error-active textarea,
.field-error-active select { border-color: var(--danger); }
.field-error-active label { color: var(--danger); }

.alert {
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    margin-bottom: 1.5rem;
    border-left: 4px solid;
    text-align: left;
}
.alert-info { background: #eff6ff; color: #1e40af; border-color: var(--info); }
.alert-success { background: #ecfdf5; color: #065f46; border-color: var(--success); }
.alert-warning { background: #fffbeb; color: #92400e; border-color: var(--warning); }
.alert-error { background: #fef2f2; color: #991b1b; border-color: var(--danger); }

/* ─── Navigation ──────────────────────────────── */

.navbar {
    background: white;
    padding: 0 2rem;
    box-shadow: var(--shadow);
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 64px;
    position: sticky;
    top: 0;
    z-index: 100;
}

.navbar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 18px;
    font-weight: 700;
    color: var(--gray-900);
    text-decoration: none;
}

.navbar-brand .brand-icon {
    width: 32px; height: 32px;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 16px;
}

.navbar-nav { display: flex; align-items: center; gap: 8px; }
.navbar-nav a { color: var(--gray-600); text-decoration: none; padding: 8px 12px; border-radius: var(--radius-sm); font-size: 14px; font-weight: 500; transition: var(--transition); }
.navbar-nav a:hover { background: var(--gray-100); color: var(--gray-900); }
.navbar-nav a.active { background: var(--gray-100); color: var(--primary); }
.navbar-user { display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--gray-600); }

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

.container { max-width: 1200px; margin: 0 auto; padding: 0 2rem; }
.page-header { padding: 2rem 0 1.5rem; }
.page-header h1 { font-size: 28px; font-weight: 700; color: var(--gray-900); }
.page-header p { color: var(--gray-500); font-size: 14px; }
.page-actions { display: flex; gap: 12px; margin-top: 1rem; }

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

.card {
    background: white;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    transition: var(--transition);
}
.card:hover { box-shadow: var(--shadow-md); }
.card-body { padding: 1.5rem; }
.card-header {
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--gray-200);
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.card-header h3 { font-size: 16px; font-weight: 600; }

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

.grid { display: grid; gap: 20px; }
.grid-2 { grid-template-columns: 1fr 1fr; }
.grid-3 { grid-template-columns: 1fr 1fr 1fr; }
.grid-4 { grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); }

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

.stat-card {
    background: white;
    border-radius: var(--radius);
    padding: 1.5rem;
    box-shadow: var(--shadow);
    display: flex;
    align-items: flex-start;
    gap: 16px;
    transition: var(--transition);
}
.stat-card:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }

.stat-icon {
    width: 48px; height: 48px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    flex-shrink: 0;
}

.stat-content { flex: 1; min-width: 0; }
.stat-content .stat-label { font-size: 13px; color: var(--gray-500); margin-bottom: 4px; }
.stat-content .stat-value { font-size: 28px; font-weight: 700; color: var(--gray-900); line-height: 1.2; }
.stat-content .stat-sub { font-size: 12px; color: var(--gray-400); margin-top: 4px; }

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

.module-card {
    background: white;
    border-radius: var(--radius);
    padding: 1.5rem;
    box-shadow: var(--shadow);
    transition: var(--transition);
    cursor: pointer;
    text-decoration: none;
    display: block;
    color: inherit;
    position: relative;
    overflow: hidden;
}
.module-card:hover { box-shadow: var(--shadow-lg); transform: translateY(-4px); }
.module-card .module-accent {
    height: 4px;
    position: absolute;
    top: 0; left: 0; right: 0;
}
.module-card .module-icon { font-size: 40px; margin-bottom: 1rem; }
.module-card h3 { font-size: 18px; font-weight: 600; color: var(--gray-900); margin-bottom: 4px; }
.module-card p { font-size: 13px; color: var(--gray-500); }
.module-card .module-stats { display: flex; gap: 16px; margin-top: 1rem; padding-top: 1rem; border-top: 1px solid var(--gray-100); }
.module-card .module-stats span { font-size: 12px; color: var(--gray-500); }
.module-card .module-stats strong { display: block; font-size: 18px; color: var(--gray-900); }

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

.table-container {
    background: white;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
}

.table-toolbar {
    padding: 1rem 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--gray-200);
    gap: 12px;
    flex-wrap: wrap;
}

.table-search {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius-sm);
    background: white;
    flex: 1;
    max-width: 320px;
}
.table-search input {
    border: none;
    outline: none;
    font-size: 14px;
    width: 100%;
    font-family: inherit;
    background: transparent;
}

table {
    width: 100%;
    border-collapse: collapse;
}
table thead { background: var(--gray-50); }
table th {
    padding: 12px 16px;
    font-size: 12px;
    font-weight: 600;
    color: var(--gray-500);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    text-align: left;
    border-bottom: 1px solid var(--gray-200);
}
table td {
    padding: 12px 16px;
    font-size: 14px;
    border-bottom: 1px solid var(--gray-100);
    color: var(--gray-700);
}
table tbody tr:hover { background: var(--gray-50); }
table tbody tr:last-child td { border-bottom: none; }

/* ─── Status Badges ───────────────────────────── */

.badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 10px;
    border-radius: 9999px;
    font-size: 12px;
    font-weight: 600;
    gap: 4px;
}
.badge-draft { background: var(--gray-100); color: var(--gray-600); }
.badge-submitted { background: #dbeafe; color: #1e40af; }
.badge-in_review { background: #fef3c7; color: #92400e; }
.badge-approved { background: #d1fae5; color: #065f46; }
.badge-rejected { background: #fee2e2; color: #991b1b; }

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

.empty-state {
    text-align: center;
    padding: 3rem 1.5rem;
    color: var(--gray-400);
}
.empty-state .empty-icon { font-size: 48px; margin-bottom: 1rem; }
.empty-state h3 { font-size: 18px; color: var(--gray-600); margin-bottom: 0.5rem; }
.empty-state p { font-size: 14px; }

/* ─── Welcome Hero ────────────────────────────── */

.hero {
    background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
    color: white;
    padding: 2rem;
    border-radius: var(--radius);
    margin-bottom: 2rem;
}
.hero h2 { font-size: 28px; font-weight: 700; margin-bottom: 0.5rem; }
.hero p { opacity: 0.9; font-size: 14px; }

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

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

/* ─── Landing Page ────────────────────────────── */

.landing {
    background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}
.landing-card {
    background: white;
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    max-width: 900px;
    width: 100%;
    padding: 3rem;
    text-align: center;
}
.landing-card h1 { font-size: 42px; font-weight: 700; color: var(--gray-900); margin-bottom: 0.5rem; }
.landing-card .lead { font-size: 16px; color: var(--gray-500); margin-bottom: 2.5rem; }
.landing-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.landing-card .footer { margin-top: 3rem; padding-top: 2rem; border-top: 1px solid var(--gray-200); font-size: 13px; color: var(--gray-400); }

.portal-card {
    background: var(--gray-50);
    border-radius: var(--radius-sm);
    padding: 2rem;
    text-align: center;
    text-decoration: none;
    color: inherit;
    display: block;
    transition: var(--transition);
}
.portal-card:hover { background: white; box-shadow: var(--shadow-md); transform: translateY(-2px); }
.portal-card .portal-icon { font-size: 48px; margin-bottom: 1rem; }
.portal-card h3 { font-size: 20px; font-weight: 600; margin-bottom: 0.5rem; }
.portal-card p { font-size: 13px; color: var(--gray-500); margin-bottom: 1.5rem; }

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

@media (max-width: 768px) {
    .grid-2, .grid-3 { grid-template-columns: 1fr; }
    .landing-grid { grid-template-columns: 1fr; }
    .form-row { grid-template-columns: 1fr; }
    .landing-card { padding: 2rem 1.5rem; }
    .container { padding: 0 1rem; }
    .navbar { padding: 0 1rem; }
    .table-toolbar { flex-direction: column; align-items: stretch; }
    .table-search { max-width: 100%; }
}

/* ─── Utilities ───────────────────────────────── */

.text-center { text-align: center; }
.text-right { text-align: right; }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }
.gap-1 { gap: 0.5rem; }
.gap-2 { gap: 1rem; }
.flex { display: flex; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.flex-center { display: flex; align-items: center; gap: 8px; }

/* ─── Toasts ──────────────────────────────────── */

.toast {
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    box-shadow: var(--shadow-lg);
    display: flex;
    align-items: center;
    gap: 8px;
    animation: slideIn 0.3s ease;
    transition: opacity 0.3s ease;
}
.toast-info { background: #eff6ff; color: #1e40af; border: 1px solid #bfdbfe; }
.toast-success { background: #ecfdf5; color: #065f46; border: 1px solid #a7f3d0; }
.toast-error { background: #fef2f2; color: #991b1b; border: 1px solid #fecaca; }
.toast-warning { background: #fffbeb; color: #92400e; border: 1px solid #fde68a; }

@keyframes slideIn {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

/* ─── Modal System ──────────────────────────────── */

.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.7);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 20px;
    opacity: 0;
    transition: opacity 0.25s ease;
}
.modal-overlay.active { opacity: 1; }

.modal {
    background: white;
    border-radius: var(--radius);
    box-shadow: 0 25px 50px rgba(0,0,0,0.25);
    width: 100%;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    transform: scale(0.95) translateY(8px);
    transition: transform 0.25s ease;
}
.modal-overlay.active .modal { transform: scale(1) translateY(0); }

.modal-sm { max-width: 420px; }
.modal-md { max-width: 560px; }
.modal-lg { max-width: 720px; }
.modal-xl { max-width: 960px; }
.modal-xxl { max-width: 1600px; width: 96%; }


.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--gray-200);
    flex-shrink: 0;
}
.modal-header h3 {
    font-size: 18px;
    font-weight: 700;
    color: var(--gray-900);
}
.modal-header .modal-badge {
    display: inline-block;
    margin-left: 8px;
    vertical-align: middle;
}

.modal-close {
    width: 32px;
    height: 32px;
    border: none;
    background: var(--gray-100);
    border-radius: 50%;
    font-size: 18px;
    line-height: 1;
    color: var(--gray-500);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}
.modal-close:hover {
    background: var(--gray-200);
    color: var(--gray-800);
}

.modal-body {
    padding: 1.5rem;
    overflow-y: auto;
    flex: 1;
    font-size: 14px;
    color: var(--gray-700);
    line-height: 1.6;
}
.modal-body:first-child { padding-top: 1.5rem; }

.modal-footer {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--gray-200);
    flex-shrink: 0;
}
.modal-footer .btn { min-width: 80px; }

/* Alert & Confirm Dialog Icon Badges (shadcn/ui style) */
.modal-icon-badge {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    flex-shrink: 0;
    margin-bottom: 12px;
}
.modal-icon-badge.success { background: rgba(16, 185, 129, 0.12); color: #10b981; }
.modal-icon-badge.error, .modal-icon-badge.danger { background: rgba(239, 68, 68, 0.12); color: #ef4444; }
.modal-icon-badge.warning { background: rgba(245, 158, 11, 0.12); color: #f59e0b; }
.modal-icon-badge.info { background: rgba(59, 130, 246, 0.12); color: #3b82f6; }

/* Anti-Double Click & Loading Button States */
.btn.btn-loading {
    opacity: 0.72 !important;
    pointer-events: none !important;
    cursor: not-allowed !important;
    user-select: none !important;
    box-shadow: none !important;
}
.btn-spinner {
    display: inline-block;
    width: 14px;
    height: 14px;
    border: 2px solid currentColor;
    border-right-color: transparent;
    border-radius: 50%;
    animation: btnSpin 0.75s linear infinite;
    vertical-align: middle;
    margin-right: 6px;
}
@keyframes btnSpin {
    to { transform: rotate(360deg); }
}

/* Shared multi-select row: checkmark toggles on the checked state of a hidden
   checkbox. Used anywhere the user picks several items from a list — PDF
   column export, agent permissions, template Logic conditions — so all three
   share one visual language instead of three different pickers. */
.ms-row { display:flex; align-items:center; justify-content:space-between; gap:8px; padding:6px 8px; border-radius:4px; cursor:pointer; font-size:13px; user-select:none; }
.ms-row:hover { background: var(--gray-50); }
.ms-row.is-checked { background: #f0faf8; }
.ms-row input[type="checkbox"] { display:none; }
.ms-list { display:flex; flex-direction:column; gap:2px; padding:6px; border:1px solid var(--gray-200); border-radius:6px; max-height:220px; overflow-y:auto; }
.ms-row .ms-check { visibility:hidden; color:#0f766e; font-weight:700; }
.ms-row.is-checked .ms-check { visibility:visible; }

/* Modal detail rows */
.modal-detail {
    display: flex;
    padding: 0.75rem 0;
    border-bottom: 1px solid var(--gray-100);
}
.modal-detail:last-child { border-bottom: none; }
.modal-detail-label {
    width: 140px;
    flex-shrink: 0;
    font-size: 12px;
    font-weight: 600;
    color: var(--gray-500);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    padding-top: 2px;
}
.modal-detail-value {
    flex: 1;
    font-size: 14px;
    color: var(--gray-800);
    word-break: break-word;
}

/* Body scroll lock */
body.modal-open { overflow: hidden; }

/* ─── Form Template Styles ─────────────────────── */

.form-group { margin-bottom: 1.25rem; text-align: left; }
.form-group label { display: block; font-size: 13px; font-weight: 600; color: #2d3748; margin-bottom: 6px; }
.form-group .req::after { content: " *"; color: #e53e3e; }

/* Override for form-template inside modal */
.section {
    background: white;
    border-radius: 10px;
    padding: 22px 24px;
    margin-bottom: 18px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}
.section h2 {
    font-size: 15px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #667eea;
    border-bottom: 2px solid #edf2f7;
    padding-bottom: 10px;
    margin-bottom: 16px;
    margin-top: 0;
}
.client-section {
    background: #f7fafc;
    border: none;
    border-radius: 0;
    padding: 16px;
    margin-bottom: 0;
}
.client-section:first-of-type {
    border-top-left-radius: 8px;
    border-top-right-radius: 8px;
}
.client-section:last-of-type {
    border-bottom-left-radius: 8px;
    border-bottom-right-radius: 8px;
}
.client-section h3 {
    font-size: 14px;
    color: #4a5568;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    margin: 0 0 12px;
}
.upload-area {
    border: 2px dashed #cbd5e0;
    border-radius: 8px;
    padding: 24px 16px;
    text-align: center;
    cursor: pointer;
    background: #fafbfc;
    transition: border-color 0.2s, background 0.2s;
    margin-top: 4px;
}
.upload-area:hover { border-color: #667eea; background: #ebf4ff; }
.upload-area .upload-icon { display: block; font-size: 28px; margin-bottom: 6px; }
.upload-area span { display: block; font-size: 13px; color: #4a5568; }
.upload-area.disabled { opacity: 0.65; cursor: not-allowed; background: #f1f5f9; }
.upload-area.disabled:hover { border-color: #cbd5e0; background: #f1f5f9; }
.file-list { margin-top: 8px; display: flex; flex-wrap: wrap; gap: 8px; }
.file-item {
    display: flex; align-items: center; gap: 8px; padding: 6px 10px;
    background: white; border: 1px solid var(--gray-200); border-radius: 6px;
    font-size: 12px;
}

/* Layout variants */
.form-section-body {
    display: grid;
    grid-template-columns: repeat(12, 1fr);
    gap: 16px;
}
.col-span-12 { grid-column: span 12; }
.col-span-8  { grid-column: span 8; }
.col-span-6  { grid-column: span 6; }
.col-span-4  { grid-column: span 4; }
.col-span-3  { grid-column: span 3; }

.full { grid-column: 1 / -1; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.three-col { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 14px; margin-bottom: 14px; }
.four-col { display: grid; grid-template-columns: 1fr 1fr 1fr 1fr; gap: 14px; margin-bottom: 14px; }
.repeat-wrap { margin-bottom: 0.5rem; }

@media (max-width: 768px) {
    .form-grid, .three-col, .four-col { grid-template-columns: 1fr; }
    .col-span-12, .col-span-8, .col-span-6, .col-span-4, .col-span-3 { grid-column: span 12; }
}

/* Color-coded groups */
.gp-personal input, .gp-personal select { border: 2px solid #667eea; }
.gp-credit input, .gp-credit select { border: 2px solid #9f7aea; }
.gp-property input, .gp-property select { border: 2px solid #ed64a6; }
.gp-employment input, .gp-employment select { border: 2px solid #48bb78; }
.gp-bank input, .gp-bank select { border: 2px solid #38b2ac; }
.gp-tax input, .gp-tax select { border: 2px solid #ed8936; }

/* ═══ Sidebar Layout ════════════════════════════ */

.app-layout {
    display: grid;
    grid-template-rows: auto 1fr auto;
    grid-template-columns: 240px 1fr;
    grid-template-areas:
        "header header"
        "sidebar main"
        "sidebar footer";
    min-height: 100vh;
}

.app-header {
    grid-area: header;
    background: white;
    height: 64px;
    padding: 0 24px;
    display: flex;
    align-items: center;
    gap: 16px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
    position: sticky;
    top: 0;
    z-index: 100;
}

.sidebar-toggle {
    display: none;
    width: 36px;
    height: 36px;
    border: none;
    background: var(--gray-100);
    border-radius: var(--radius-sm);
    font-size: 18px;
    cursor: pointer;
    align-items: center;
    justify-content: center;
    color: var(--gray-600);
}

.header-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 18px;
    font-weight: 700;
    color: var(--gray-900);
    text-decoration: none;
}
.header-brand .brand-icon {
    width: 32px; height: 32px;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 16px;
}

.header-right {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 12px;
}
.header-user {
    font-size: 14px;
    color: var(--gray-600);
}

/* ─── Sidebar ─────────────────────────────────── */

.sidebar {
    position: fixed;
    top: 64px;
    left: 0;
    width: 240px;
    bottom: 0;
    background: #1a1a2e;
    padding: 16px 0;
    overflow-y: auto;
    z-index: 99;
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 0 8px;
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    border-radius: 8px;
    color: rgba(255,255,255,0.6);
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.15s ease;
}
.sidebar-link:hover {
    background: rgba(255,255,255,0.08);
    color: rgba(255,255,255,0.9);
}
.sidebar-link.active {
    background: var(--primary);
    color: white;
}
.sidebar-icon {
    font-size: 18px;
    width: 24px;
    text-align: center;
    flex-shrink: 0;
}

/* ─── Submenu ─────────────────────────────────── */

.sidebar-link.has-sub::after {
    content: '▸';
    margin-left: auto;
    font-size: 12px;
    transition: transform 0.2s ease;
}
.sidebar-link.has-sub.open::after {
    transform: rotate(90deg);
}

.sidebar-sub {
    display: none;
    flex-direction: column;
    gap: 1px;
    padding-left: 20px;
    margin: 0 8px;
}
.sidebar-sub.open {
    display: flex;
}
.sidebar-sub .sidebar-link {
    font-size: 13px;
    padding: 7px 14px;
    border-radius: 6px;
}
.sidebar-sub .sidebar-link.active {
    background: rgba(255,255,255,0.12);
    color: white;
}

/* ─── Main Content ────────────────────────────── */

.main-content {
    grid-area: main;
    padding: 24px 32px 72px;
    background: var(--gray-100);
    min-height: calc(100vh - 64px);
}

/* ─── Footer ──────────────────────────────────── */

.hidden {
    display: none;
}

.app-footer {
    position: fixed;
    bottom: 0;
    left: 240px;
    right: 0;
    height: 48px;
    background: white;
    border-top: 1px solid var(--gray-200);
    padding: 0 32px;
    display: flex;
    align-items: center;
    z-index: 50;
    box-shadow: 0 -2px 8px rgba(0,0,0,0.06);
}
.footer-inner {
    width: 100%;
    font-size: 13px;
    color: var(--gray-400);
}

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

@media (max-width: 900px) {
    .app-layout {
        grid-template-columns: 1fr;
        grid-template-areas:
            "header"
            "main"
            "footer";
    }
    .sidebar {
        position: fixed;
        top: 64px;
        left: -260px;
        width: 240px;
        height: calc(100vh - 64px);
        z-index: 99;
        transition: left 0.25s ease;
    }
    .sidebar.open {
        left: 0;
    }
    .sidebar-toggle {
        display: flex;
    }
    .main-content {
        padding: 20px 16px;
    }
    .app-footer {
        left: 0;
        padding: 0 16px;
    }
}

/* ─── Visual Bank Selector & Pills UI ───────────────────── */
.bank-selector-container {
    background: var(--gray-50);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    padding: 12px;
    margin-top: 6px;
}
.bank-search-bar {
    position: relative;
    margin-bottom: 10px;
}
.bank-search-input {
    width: 100%;
    padding: 7px 12px 7px 32px;
    border: 1px solid var(--gray-300);
    border-radius: 6px;
    font-size: 12px;
    background: white;
    box-sizing: border-box;
    transition: var(--transition);
}
.bank-search-input:focus {
    border-color: var(--primary);
    outline: none;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}
.bank-search-icon {
    position: absolute;
    left: 10px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 12px;
    color: var(--gray-400);
    pointer-events: none;
}
.bank-chips-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    max-height: 220px;
    overflow-y: auto;
    padding-right: 4px;
}
.bank-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: white;
    border: 1px solid var(--gray-300);
    border-radius: 20px;
    font-size: 12px;
    font-weight: 500;
    color: var(--gray-700);
    cursor: pointer;
    user-select: none;
    transition: all 0.2s ease;
}
.bank-chip:hover:not(.disabled-dimmed) {
    border-color: var(--primary);
    color: var(--primary);
    background: #eff6ff;
    transform: translateY(-1px);
}
.bank-chip.selected {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
    box-shadow: 0 2px 4px rgba(37, 99, 235, 0.25);
}
.bank-chip .chip-icon {
    font-size: 13px;
}
.bank-chip .chip-check {
    font-size: 11px;
    font-weight: 700;
    margin-left: 2px;
}
.bank-chip.disabled-dimmed {
    opacity: 0.35 !important;
    filter: grayscale(80%);
    cursor: not-allowed !important;
    background: var(--gray-100) !important;
    border-color: var(--gray-300) !important;
    color: var(--gray-400) !important;
    pointer-events: none !important;
}
.bank-select-summary {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid var(--gray-200);
    font-size: 11px;
    color: var(--gray-500);
}
