/* =========================================================
   1. VARIABLES & BASE ELEMENTS
   ========================================================= */
:root {
    --bg-color: #f0f2f5; 
    --card-bg: #ffffff; 
    --input-bg: #ffffff;
    --border-color: #d1d5db; 
    --text-main: #111827; 
    --text-muted: #6b7280; 
    --accent-red: #d50000; 
    --accent-hover: #b91c1c; 
    --success: #10b981;
    --font-main: 'Inter', sans-serif;
}

body { 
    font-family: var(--font-main); 
    background-color: var(--bg-color); 
    color: var(--text-main); 
    margin: 0; 
    padding: 0px 20px; 
    -webkit-font-smoothing: antialiased; 
}

.container { max-width: 1450px; margin: auto; }

h1 { 
    font-size: 1.8rem; 
    font-weight: 800; 
    letter-spacing: 1px; 
    margin-bottom: 40px; 
    border-bottom: 1px solid var(--border-color); 
    padding-bottom: 15px; 
    color: #000; 
}
h2 { 
    font-size: 1.1rem; 
    font-weight: 600; 
    color: var(--text-main); 
    margin-top: 0; 
    margin-bottom: 10px; 
}

/* =========================================================
   2. FORM & BUTTON ELEMENTS
   ========================================================= */
.form-group { margin-bottom: 20px; }
label { display: block; font-size: 0.85rem; color: var(--text-main); margin-bottom: 8px; font-weight: 600; }

input[type="text"], input[type="email"], input[type="url"], input[type="password"], select { 
    width: 100%; 
    padding: 12px; 
    background: var(--input-bg); 
    border: 1px solid var(--border-color); 
    color: var(--text-main); 
    font-family: var(--font-main); 
    font-size: 0.95rem; 
    border-radius: 4px; 
    box-sizing: border-box; 
    transition: border-color 0.3s ease, box-shadow 0.3s ease; 
}

select:not([multiple]) { 
    appearance: none; 
    background-image: url('data:image/svg+xml;utf8,<svg fill="%236b7280" height="24" viewBox="0 0 24 24" width="24" xmlns="http://www.w3.org/2000/svg"><path d="M7 10l5 5 5-5z"/><path d="M0 0h24v24H0z" fill="none"/></svg>'); 
    background-repeat: no-repeat; 
    background-position-x: 98%; 
    background-position-y: 50%; 
}
select[multiple] { height: auto; min-height: 140px; padding: 8px; }
select[multiple] option { padding: 10px; margin-bottom: 2px; border-radius: 4px; }
select[multiple] option:checked { background: var(--accent-red) linear-gradient(0deg, var(--accent-red) 0%, var(--accent-red) 100%); color: white; }

input[type="text"]:focus, input[type="email"]:focus, input[type="url"]:focus, input[type="password"]:focus, select:focus { 
    outline: none; 
    border-color: var(--accent-red); 
    box-shadow: 0 0 0 3px rgba(213, 0, 0, 0.1); 
}

.btn { 
    padding: 12px 20px; 
    border: none; 
    background: #e5e7eb; 
    color: #374151; 
    font-family: var(--font-main); 
    font-weight: 600; 
    font-size: 0.9rem; 
    cursor: pointer; 
    border-radius: 4px; 
    transition: all 0.2s ease; 
}
.btn:hover { background: #d1d5db; color: #111827; }
.btn-success { background: var(--accent-red); color: #fff; width: 100%; }
.btn-success:hover { background: var(--accent-hover); color: #fff;}
.btn-update { background: #f3f4f6; border: 1px solid #d1d5db; color: #374151; }
.btn-update:hover { background: #e5e7eb; border-color: #9ca3af; }
.btn-delete { color: var(--accent-red); text-decoration: none; font-weight: 600; font-size: 0.85rem; }
.btn-delete:hover { color: var(--accent-hover); }

/* =========================================================
   3. TABLES & BADGES
   ========================================================= */
.table-header { display: flex; font-size: 0.8rem; text-transform: uppercase; color: var(--text-muted); border-bottom: 1px solid var(--border-color); padding-bottom: 10px; margin-bottom: 10px; font-weight: 600; }
.edit-row { display: flex; gap: 15px; margin-bottom: 8px; background: #f9fafb; padding: 12px; border: 1px solid #f3f4f6; border-radius: 4px; align-items: center; transition: border-color 0.2s; }
.edit-row:hover { border-color: var(--border-color); }

table { width: 100%; border-collapse: collapse; margin-top: 10px; }
th, td { text-align: left; padding: 16px 12px; border-bottom: 1px solid var(--border-color); }
th { font-size: 0.8rem; text-transform: uppercase; color: var(--text-muted); border-bottom: 2px solid #d1d5db; }
td { font-size: 0.95rem; }

.highlight { font-weight: 800; background: #e5e7eb; padding: 4px 8px; border-radius: 4px;}
.badge-multi { border: 1px solid rgba(213, 0, 0, 0.3); background: #fef2f2; color: var(--accent-red); font-size: 0.75rem; padding: 3px 8px; border-radius: 4px; font-weight: 600; }
.badge-global { border: 1px solid var(--border-color); background: #f3f4f6; color: var(--text-muted); font-size: 0.75rem; padding: 3px 8px; border-radius: 4px; font-weight: 600; }

/* =========================================================
   4. ALERTS & MODALS
   ========================================================= */
.alert { background: #ecfdf5; border-left: 4px solid var(--success); color: #065f46; padding: 16px 20px; margin-bottom: 30px; font-weight: 600; font-size: 0.9rem; box-shadow: 0 2px 4px rgba(0,0,0,0.05); }
.alert.error { background: #fef2f2; border-left-color: var(--accent-red); color: #991b1b; }

.modal-overlay { position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: rgba(17, 24, 39, 0.7); z-index: 1000; display: flex; align-items: center; justify-content: center; backdrop-filter: blur(2px); }
.modal-content { background: #fff; padding: 30px; border-radius: 8px; max-width: 500px; width: 90%; box-shadow: 0 10px 25px rgba(0,0,0,0.1); border-top: 4px solid var(--accent-red); }

/* Inline validation errors */
.inline-error { color: var(--accent-red); font-size: 0.8rem; font-weight: 600; margin-top: 6px; display: none; }
.input-error-border { border-color: var(--accent-red) !important; box-shadow: 0 0 0 3px rgba(213, 0, 0, 0.1) !important; }

/* Scrollbar Styles */
::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-track { background: var(--bg-color); }
::-webkit-scrollbar-thumb { background: #d1d5db; border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: #9ca3af; }

/* =========================================================
   5. LAYOUT (Settings Wrapper, Ladder, Compact Forms)
   ========================================================= */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 30px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1.5fr; gap: 20px; align-items: end; }

.settings-wrapper { display: flex; gap: 40px; align-items: flex-start; max-width: 1100px; margin: 0 auto; }
.settings-sidebar { width: 260px; position: sticky; top: 20px; flex-shrink: 0; z-index: 10; }
.settings-content { flex: 1; min-width: 0; }

.settings-nav { list-style: none; padding: 0; margin: 0; background: #fff; border: 1px solid #e5e7eb; border-radius: 8px; overflow: hidden; box-shadow: 0 2px 10px rgba(0,0,0,0.02); }
.settings-nav li { border-bottom: 1px solid #e5e7eb; }
.settings-nav li:last-child { border-bottom: none; }
.settings-nav a { display: flex; align-items: center; gap: 10px; padding: 14px 18px; color: var(--text-main); text-decoration: none; font-weight: 600; font-size: 0.85rem; transition: 0.2s; border-left: 3px solid transparent; }
.settings-nav a:hover { background: #f9fafb; border-left-color: #d1d5db; }
.settings-nav a.active { background: #fef2f2; color: var(--accent-red); border-left-color: var(--accent-red); }

.card { background: var(--card-bg); padding: 30px; border: 1px solid var(--border-color); border-top: 4px solid var(--accent-red); border-radius: 6px; margin-bottom: 40px; box-shadow: 0 4px 15px rgba(0,0,0,0.03); }

/* CYBERNETIC AUTOMATION LADDER */
.ladder-container { max-width: 900px; margin: 0 auto; position: relative; padding-left: 70px; }
.ladder-container::before {
    content: ''; position: absolute; left: 24px; top: 20px; bottom: 40px; width: 2px;
    background: linear-gradient(to bottom, transparent 50%, var(--accent-red) 50%);
    background-size: 100% 12px; animation: data-flow 1s linear infinite; z-index: 0; opacity: 0.4;
}
@keyframes data-flow { 0% { background-position: 0 0; } 100% { background-position: 0 12px; } }
.ladder-step { position: relative; margin-bottom: 50px; z-index: 1; }
.ladder-node {
    position: absolute; left: -70px; top: 15px; width: 48px; height: 48px; background: var(--bg-color);
    display: flex; align-items: center; justify-content: center; font-family: monospace; font-weight: 800;
    font-size: 1.1rem; color: var(--accent-red);
    background-image: 
        linear-gradient(var(--accent-red), var(--accent-red)), linear-gradient(var(--accent-red), var(--accent-red)),
        linear-gradient(var(--accent-red), var(--accent-red)), linear-gradient(var(--accent-red), var(--accent-red)),
        linear-gradient(var(--accent-red), var(--accent-red)), linear-gradient(var(--accent-red), var(--accent-red)),
        linear-gradient(var(--accent-red), var(--accent-red)), linear-gradient(var(--accent-red), var(--accent-red));
    background-repeat: no-repeat;
    background-size: 8px 2px, 2px 8px, 8px 2px, 2px 8px, 8px 2px, 2px 8px, 8px 2px, 2px 8px;
    background-position: 0 0, 0 0, 100% 0, 100% 0, 100% 100%, 100% 100%, 0 100%, 0 100%;
    z-index: 2; box-shadow: inset 0 0 15px rgba(213,0,0,0.05);
}
.ladder-node::after {
    content: ''; position: absolute; width: 70%; height: 70%; border: 1px dashed rgba(213, 0, 0, 0.4);
    animation: scan-spin 6s linear infinite; border-radius: 2px;
}
@keyframes scan-spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }
.ladder-node.ai-core {
    color: #fff; background-color: #111827; background-image: none; border: 2px solid #374151;
    box-shadow: 0 0 15px rgba(0,0,0,0.2), inset 0 0 15px rgba(255,255,255,0.1);
}
.ladder-node.ai-core::after { border-color: rgba(255,255,255,0.5); animation: scan-spin 3s linear infinite reverse; }
.step-badge {
    display: inline-block; background: #fef2f2; color: var(--accent-red); padding: 4px 10px; border-radius: 2px;
    font-size: 0.70rem; font-weight: 800; letter-spacing: 1px; text-transform: uppercase; margin-left: 10px;
    vertical-align: middle; border: 1px solid rgba(213, 0, 0, 0.2); font-family: monospace;
}
.step-desc { color: var(--text-muted); font-size: 0.9rem; margin-bottom: 20px; line-height: 1.5; }
.token-input { font-family: monospace; letter-spacing: 2px; }

/* COMPACT FORMS & GRIDS */
.compact-form .form-group { margin-bottom: 12px; }
.compact-form label { font-size: 0.75rem; margin-bottom: 4px; color: var(--text-muted); font-weight: 700; text-transform: uppercase;}
.compact-form input[type="text"], .compact-form input[type="email"], .compact-form input[type="url"], .compact-form select, .compact-input { 
    padding: 8px 10px; font-size: 0.9rem; height: 36px; box-sizing: border-box;
}
.compact-form .compact-select { padding: 0px 6px; }

.section-split { border: 1px solid #e5e7eb; border-radius: 6px; padding: 15px; margin-bottom: 20px; background: #fafafa; }
.section-split h3 { margin-top: 0; margin-bottom: 15px; font-size: 0.95rem; color: var(--text-main); border-bottom: 2px solid #e5e7eb; padding-bottom: 8px; }

.compact-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.compact-grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; }

.address-grid { display: grid; grid-template-columns: 2fr 1fr; gap: 12px; margin-bottom: 12px; }
.address-sub-grid { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; }

/* Phone & Image Inputs */
.phone-group-wrap { display: flex; align-items: stretch; width: 100%; height: 36px; }
.phone-group-wrap .phone-input { flex: 1; min-width: 0; border-left: 1px solid #d1d5db; border-radius: 0 4px 4px 0; }

.phone-code-select {
    width: 85px;
    flex-shrink: 0;
    border-right: none;
    border-radius: 4px 0 0 4px;
    background-color: #f9fafb;
    border-color: var(--border-color);
}

.img-upload-wrapper { display: flex; align-items: center; gap: 15px; margin-bottom: 15px; }
.img-preview { width: 60px; height: 60px; border-radius: 50%; object-fit: cover; border: 2px solid #d1d5db; background: #fff; display: flex; align-items: center; justify-content: center; font-size: 1.5rem; color: #cbd5e1; overflow: hidden;}
.img-preview.square { border-radius: 4px; width: 100px; height: auto; aspect-ratio: 16/9; }
.custom-file-upload { display: inline-block; padding: 6px 12px; cursor: pointer; background: #fff; border: 1px solid var(--border-color); border-radius: 4px; font-size: 0.8rem; font-weight: 600; color: var(--text-main); transition: 0.2s;}
.custom-file-upload:hover { border-color: var(--accent-red); color: var(--accent-red); }
input[type="file"] { display: none; }

/* =========================================================
   6. CLOUD STORAGE UI
   ========================================================= */
.cloud-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 15px; margin-top: 15px; }
.cloud-card { border: 1px solid #e5e7eb; border-radius: 6px; padding: 15px; text-align: center; background: #fff; transition: 0.2s; position: relative; }
.cloud-card.active { border-color: var(--success); background: #f0fdf4; box-shadow: 0 4px 12px rgba(16, 185, 129, 0.1); }
.cloud-card.disabled { opacity: 0.5; pointer-events: none; filter: grayscale(100%); cursor: not-allowed; }
.cloud-icon { height: 35px; margin-bottom: 10px; display: flex; align-items: center; justify-content: center; }
.cloud-icon img { height: 100%; width: auto; }
.cloud-name { font-weight: 700; color: var(--text-main); margin-bottom: 15px; font-size: 0.95rem; }

.btn-google { background: #fff; color: #3c4043; border: 1px solid #dadce0; box-shadow: 0 1px 2px 0 rgba(60,64,67,0.3); font-weight: 600; padding: 8px 12px; border-radius: 4px; cursor: pointer; display: inline-flex; align-items: center; gap: 8px; width: 100%; box-sizing: border-box; justify-content: center; transition: 0.2s; font-family: var(--font-main); font-size: 0.85rem;}
.btn-google:hover { background: #f8f9fa; box-shadow: 0 1px 3px 1px rgba(60,64,67,0.15), 0 1px 2px 0 rgba(60,64,67,0.3); }

.btn-onedrive { background: #0078D4; color: #fff; border: 1px solid #0078D4; font-weight: 600; padding: 8px 12px; border-radius: 4px; cursor: pointer; display: inline-flex; align-items: center; gap: 8px; width: 100%; box-sizing: border-box; justify-content: center; transition: 0.2s; font-family: var(--font-main); box-shadow: 0 1px 2px 0 rgba(0,0,0,0.2); font-size: 0.85rem;}
.btn-onedrive:hover { background: #006abc; }

.btn-disconnect { background: #fef2f2; color: var(--accent-red); border: 1px solid #fecaca; font-weight: 700; padding: 8px 12px; border-radius: 4px; cursor: pointer; display: inline-block; width: 100%; box-sizing: border-box; transition: 0.2s; font-family: var(--font-main); font-size: 0.85rem;}
.btn-disconnect:hover { background: var(--accent-red); color: #fff; border-color: var(--accent-red); }

/* =========================================================
   7. DEAL SYNC UI
   ========================================================= */
.radio-card { flex: 1; cursor: pointer; position: relative; }
.radio-card input[type="radio"] { position: absolute; opacity: 0; cursor: pointer; height: 0; width: 0; }
.radio-content { display: block; padding: 12px 15px; border: 2px solid #e5e7eb; border-radius: 6px; background: #fff; text-align: center; transition: 0.2s; color: var(--text-muted); font-weight: 600;}
.radio-card:hover .radio-content { border-color: #d1d5db; background: #f9fafb; }
.radio-card input[type="radio"]:checked ~ .radio-content { border-color: var(--accent-red); background: #fef2f2; color: var(--accent-red); box-shadow: 0 2px 8px rgba(213,0,0,0.1); }

/* =========================================================
   8. AI INTEGRATION UI
   ========================================================= */
.ai-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 15px; margin-bottom: 20px; }
.ai-card { border: 1px solid #e5e7eb; border-radius: 6px; padding: 15px; text-align: center; background: #fff; transition: 0.2s; position: relative; cursor: pointer; }
.ai-card:hover { border-color: #d1d5db; background: #f9fafb; }
.ai-card.active { border-color: #111827; background: #f8fafc; box-shadow: 0 4px 12px rgba(17, 24, 39, 0.08); }
.ai-card.disabled { opacity: 0.5; pointer-events: none; filter: grayscale(100%); cursor: not-allowed; }
.ai-card input[type="radio"] { position: absolute; top: 15px; left: 15px; transform: scale(1.3); cursor: pointer; }
.ai-icon { height: 35px; margin-bottom: 10px; display: flex; align-items: center; justify-content: center; }
.ai-icon img { height: 100%; width: auto; object-fit: contain; }
.ai-name { font-weight: 700; color: var(--text-main); font-size: 0.95rem; }
.ai-recommended { position: absolute; top: -10px; right: 10px; background: var(--success); color: white; font-size: 0.65rem; padding: 2px 6px; border-radius: 10px; font-weight: 800; text-transform: uppercase; }
.ai-fields-container { background: #f9fafb; padding: 15px; border-radius: 6px; border: 1px solid #e5e7eb; }
.privacy-warning-red { color: #d50000; font-size: 0.85rem; font-weight: 700; margin-bottom: 15px; line-height: 1.5; padding: 12px; background: #fef2f2; border-left: 3px solid #d50000; border-radius: 4px; }

/* =========================================================
   9. ADMIN MENU UI
   ========================================================= */
.admin-nav-bar {
    background: var(--card-bg); 
    padding: 15px 30px; 
    border-bottom: 1px solid var(--border-color); 
    display: flex; 
    justify-content: space-between; 
    align-items: center; 
    margin-bottom: 30px; 
    box-shadow: 0 2px 4px rgba(0,0,0,0.02);
    position: relative;
}

.admin-nav-logo { font-weight: 800; font-size: 1.2rem; letter-spacing: 1px; }

.admin-nav-links-container { display: flex; gap: 25px; align-items: center; }

.admin-nav-item {
    text-decoration: none; 
    font-size: 0.95rem; 
    padding-bottom: 4px; 
    border-bottom: 2px solid transparent; 
    color: var(--text-muted); 
    font-weight: 600; 
    transition: all 0.2s;
}

.admin-nav-item:hover { color: var(--text-main); }
.admin-nav-item.active { color: var(--text-main); border-bottom-color: var(--accent-red); }

.admin-logout-btn { text-decoration: none; font-size: 0.85rem; padding: 8px 15px; }

.admin-hamburger {
    display: none;
    flex-direction: column;
    gap: 5px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 5px;
}

.admin-hamburger span {
    display: block;
    width: 25px;
    height: 3px;
    background-color: var(--text-main);
    border-radius: 3px;
    transition: 0.3s;
}

.admin-mobile-logout { display: none; }

/* =========================================================
   10. RESPONSIVE MEDIA QUERIES
   ========================================================= */
@media (max-width: 850px) {
    /* Settings Layout Overrides */
    .settings-wrapper { flex-direction: column; gap: 20px; }
    .settings-sidebar { width: 100%; position: static; }
    .compact-grid-2, .compact-grid-3, .address-grid, .address-sub-grid, .cloud-grid, .ai-grid { grid-template-columns: 1fr !important; gap: 10px; }
    
    .ladder-container { padding-left: 0 !important; }
    .ladder-container::before { display: none !important; }
    .ladder-node { display: none !important; }
    
    .ladder-step { margin-bottom: 25px; }
    .card { padding: 20px; } 
    
    .step-badge { display: inline-block; margin-left: 0; margin-top: 8px; }
    .card h2 { line-height: 1.4; }
}

@media (max-width: 768px) {
    /* Admin Navigation Overrides */
    .admin-nav-bar { padding: 15px 20px; }
    .admin-hamburger { display: flex; }
    .admin-desktop-logout { display: none; }
    
    .admin-nav-links-container {
        display: none; 
        flex-direction: column;
        position: absolute;
        top: 100%;
        left: 0;
        width: 100%;
        background: var(--card-bg);
        border-bottom: 1px solid var(--border-color);
        box-shadow: 0 4px 6px rgba(0,0,0,0.05);
        padding: 15px 20px;
        gap: 15px;
        z-index: 100;
        align-items: flex-start;
        box-sizing: border-box;
    }

    .admin-nav-links-container.show { display: flex; }
    
    .admin-nav-item { width: 100%; padding-bottom: 8px; border-bottom: 1px solid #f3f4f6; }
    .admin-nav-item.active { border-bottom-color: var(--accent-red); }

    .admin-mobile-logout { display: block; width: 100%; margin-top: 5px; }
    .admin-mobile-logout .btn { display: block; text-align: center; width: 100%; box-sizing: border-box; }
}
/* =========================================================
   UI COMPONENTS (Modals, Badges, Search Selectors)
   ========================================================= */
.status-badge { font-size: 0.75rem; font-weight: 700; padding: 4px 10px; border-radius: 12px; text-transform: uppercase; }
.status-pending { background: #fef3c7; color: #b45309; }
.status-received { background: #d1fae5; color: #047857; }

.new-badge { background: var(--accent-red); color: white; padding: 2px 8px; border-radius: 12px; font-size: 0.75rem; font-weight: bold; }

.modal-overlay { display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(15, 23, 42, 0.7); z-index: 9999; align-items: center; justify-content: center; backdrop-filter: blur(4px); }
.modal-overlay.active { display: flex; animation: fadeIn 0.2s ease-out; }
.modal-box { background: white; width: 90%; max-width: 650px; border-radius: 12px; overflow: hidden; display: flex; flex-direction: column; max-height: 90vh; box-shadow: 0 25px 50px -12px rgba(0,0,0,0.25); }
.modal-header { padding: 20px; border-bottom: 1px solid var(--border-color); display: flex; justify-content: space-between; align-items: center; background: #f8fafc; }
.modal-header h3 { margin: 0; font-size: 1.25rem; color: var(--text-main); }
.modal-close { background: none; border: none; font-size: 1.5rem; cursor: pointer; color: var(--text-muted); line-height: 1; }
.modal-close:hover { color: var(--accent-red); }
.modal-body { padding: 20px; overflow-y: auto; color: #334155; font-size: 0.95rem; line-height: 1.5; }
.modal-footer { padding: 15px 20px; border-top: 1px solid var(--border-color); text-align: right; background: #f8fafc; }
.modal-footer button { padding: 8px 16px; border-radius: 6px; border: none; cursor: pointer; font-weight: 600; background: #e2e8f0; color: #475569; transition: 0.2s; }
.modal-footer button:hover { background: #cbd5e1; color: var(--text-main); }
.debug-pre { background: #1e293b; color: #38bdf8; padding: 15px; border-radius: 8px; overflow-x: auto; font-family: monospace; font-size: 0.85rem; margin-top: 15px; max-height: 400px; white-space: pre-wrap;}

/* =========================================================
   DEAL EDITOR (Smart Grids & Forms)
   ========================================================= */
.editor-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; }
.section-card { background: var(--card-bg); border: 1px solid var(--border-color); border-radius: 8px; padding: 25px; margin-bottom: 25px; box-shadow: 0 1px 3px rgba(0,0,0,0.05); }
.section-title { font-size: 1.25rem; font-weight: 800; color: var(--text-main); margin-top: 0; margin-bottom: 20px; border-bottom: 2px solid #f1f5f9; padding-bottom: 10px; display: flex; justify-content: space-between; align-items: center;}
.section-subtitle { font-size: 1.05rem; font-weight: 700; color: #475569; margin: 25px 0 15px 0; border-bottom: 1px solid #e2e8f0; padding-bottom: 5px; }

.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 15px; }
.grid-4 { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 15px; }
.grid-6 { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 15px; }

.form-group { display: flex; flex-direction: column; gap: 5px; margin-bottom: 10px; }
.form-group label { font-size: 0.8rem; font-weight: 700; color: #64748b; text-transform: uppercase; letter-spacing: 0.5px; }
.form-group input, .form-group select { padding: 9px 12px; border: 1px solid #cbd5e1; border-radius: 6px; font-size: 0.95rem; width: 100%; box-sizing: border-box; background: #fdfaff; color: #1e293b; transition: 0.2s;}
.form-group input:focus, .form-group select:focus { outline: none; border-color: #3b82f6; box-shadow: 0 0 0 3px rgba(59,130,246,0.1); }

.repeater-block { background: #f8fafc; border: 1px solid #e2e8f0; border-radius: 8px; padding: 15px; margin-bottom: 15px; position: relative; }
.btn-remove-repeater { position: absolute; top: 15px; right: 15px; background: #fee2e2; color: #b91c1c; border: 1px solid #fca5a5; padding: 4px 10px; border-radius: 4px; font-size: 0.75rem; font-weight: 600; cursor: pointer; transition: 0.2s;}
.btn-remove-repeater:hover { background: #fca5a5; color: #7f1d1d; }
.btn-add-repeater { background: #f1f5f9; color: #475569; border: 1px dashed #cbd5e1; padding: 8px 15px; border-radius: 6px; font-size: 0.85rem; font-weight: 600; cursor: pointer; width: 100%; transition: 0.2s; margin-bottom: 10px;}
.btn-add-repeater:hover { background: #e2e8f0; color: #0f172a; border-color: #94a3b8;}

.btn-save { background: var(--success); color: white; border: none; padding: 12px 24px; font-weight: bold; border-radius: 6px; cursor: pointer; font-size: 1rem; transition: 0.2s; box-shadow: 0 4px 6px -1px rgba(16, 185, 129, 0.2); }
.btn-save:hover { background: #059669; transform: translateY(-1px); }

@keyframes spin { 100% { transform: rotate(360deg); } }
.spin { animation: spin 1s linear infinite; display: inline-block; }
/* =========================================================
   BROKER DASHBOARD SPECIFICS
   ========================================================= */
.app-selector-card { background: #f8fafc; border: 1px solid #cbd5e1; padding: 20px; border-radius: 8px; margin-bottom: 30px; display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 20px; }

/* Custom Searchable Select Styles */
.deal-selector-container { position: relative; flex-grow: 1; min-width: 300px;}
.deal-search-input { width: 100%; padding: 14px; font-size: 1.05rem; border-radius: 6px; border: 2px solid #cbd5e1; box-sizing: border-box; background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="%2394a3b8" viewBox="0 0 16 16"><path d="M11.742 10.344a6.5 6.5 0 1 0-1.397 1.398h-.001c.03.04.062.078.098.115l3.85 3.85a1 1 0 0 0 1.415-1.414l-3.85-3.85a1.007 1.007 0 0 0-.115-.1zM12 6.5a5.5 5.5 0 1 1-11 0 5.5 5.5 0 0 1 11 0z"/></svg>'); background-repeat: no-repeat; background-position: 15px center; padding-left: 45px; transition: 0.2s; }
.deal-search-input:focus { outline: none; border-color: #3b82f6; box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2); }
.deal-list-dropdown { display: none; position: absolute; top: 100%; left: 0; width: 100%; max-height: 400px; overflow-y: auto; background: white; border: 1px solid #cbd5e1; border-top: none; border-radius: 0 0 8px 8px; box-shadow: 0 10px 15px -3px rgba(0,0,0,0.1); z-index: 100; }
.deal-item { padding: 12px 15px; border-bottom: 1px solid #f1f5f9; cursor: pointer; display: flex; flex-direction: column; gap: 4px; transition: background 0.15s; }
.deal-item:hover { background: #f8fafc; }
.deal-item strong { color: #0f172a; font-size: 1rem; display: flex; align-items: center; justify-content: space-between; }
.deal-item span { color: #64748b; font-size: 0.85rem; }

.ai-selector-container { flex-basis: 250px; }
.ai-selector-container select { width: 100%; padding: 12px; font-size: 0.95rem; border-radius: 6px; border: 1px solid #cbd5e1; background-color: #fdfaff; color: #475569; }

/* Document Rows */
.doc-row { border: 1px solid #e2e8f0; background: #fff; border-radius: 8px; padding: 15px 20px; margin-bottom: 16px; display: flex; flex-direction: column; gap: 10px; }
.doc-main { display: flex; justify-content: space-between; align-items: center; width: 100%; flex-wrap: wrap; gap: 10px; }
.doc-name { font-weight: bold; color: #0f172a; }
.doc-category { font-size: 0.8rem; color: #64748b; text-transform: uppercase; }
.doc-actions { display: flex; align-items: center; gap: 10px; }

/* File Lists */
.file-list { padding-top: 15px; border-top: 1px solid #e2e8f0; display: flex; flex-direction: column; gap: 8px; width: 100%; }
.file-item { display: flex; justify-content: space-between; align-items: center; background: #f8fafc; padding: 10px 14px; border-radius: 6px; font-size: 0.85rem; border: 1px solid #e2e8f0; }
.file-meta { display: flex; align-items: center; gap: 10px; }
.file-uploader { font-size: 0.7rem; color: white; background: #475569; padding: 3px 8px; border-radius: 12px; font-weight:600;}
.file-actions { display: flex; gap: 8px; align-items: center; }
.file-actions a, .file-actions button.btn-icon { background: none; border: none; cursor: pointer; font-size: 1.1rem; color: #4b5563; transition: 0.2s; text-decoration: none; padding: 0 4px;}
.file-actions a:hover { color: var(--text-main); }
.file-actions button.btn-icon:hover { color: var(--accent-red); }

/* Buttons */
.btn-analyze { background: #e0e7ff; color: #3730a3; border: 1px solid #c7d2fe; padding: 4px 10px; border-radius: 6px; font-size: 0.75rem; font-weight: 700; cursor: pointer; transition: 0.2s; display: flex; align-items: center; gap: 5px; box-shadow: 0 1px 2px rgba(0,0,0,0.05); }
.btn-analyze:hover { background: #c7d2fe; color: #312e81; }
.btn-analyze.success { background: #d1fae5; color: #047857; border-color: #34d399; }
.btn-analyze.success:hover { background: #a7f3d0; }
.btn-analyze.danger { background: #fee2e2; color: #b91c1c; border-color: #fca5a5; }
.btn-analyze.danger:hover { background: #fecaca; }
.btn-analyze:disabled { opacity: 0.6; cursor: not-allowed; }

.btn-upload-ajax { background: #fef2f2; color: var(--accent-red); border: 1px dashed var(--accent-red); padding: 6px 12px; border-radius: 4px; font-size: 0.75rem; font-weight: 700; cursor: pointer; transition: 0.2s; }
.btn-upload-ajax:hover { background: var(--accent-red); color: white; }
.upload-loading { font-size: 0.8rem; color: var(--text-muted); font-weight: 600; display: none; }
.upload-error { color: var(--accent-red); font-size: 0.75rem; font-weight: 600; display: none; margin-left: 10px; }

.btn-zip { background: #111827; color: white; padding: 13px 20px; border-radius: 6px; font-weight: 600; border: none; cursor: pointer; transition: 0.2s; white-space: nowrap; height: 100%;}
.btn-zip:hover { background: #374151; }

/* =========================================================
   11. ACCOUNTING & SETTINGS SPECIFICS
   ========================================================= */
.acct-container { padding: 20px; max-width: 1200px; margin: 0 auto; }
.inline-form { display: inline-block; margin: 0; }

/* Tabs */
.tabs { display: flex; border-bottom: 2px solid #e5e7eb; margin-bottom: 25px; gap: 5px; flex-wrap: wrap; }
.tab-btn { padding: 12px 20px; cursor: pointer; background: transparent; border: none; border-bottom: 3px solid transparent; font-weight: 600; color: var(--text-muted); font-size: 0.95rem; transition: 0.2s; }
.tab-btn:hover { color: var(--text-main); background: #f9fafb; }
.tab-btn.active { color: var(--accent-red); border-bottom-color: var(--accent-red); background: #fef2f2; }
.tab-content { display: none; animation: fadeIn 0.3s; }
.tab-content.active { display: block; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

/* Drag and Drop */
.drag-handle { cursor: grab; font-size: 1.2rem; color: #9ca3af; padding-right: 15px; user-select: none; display: flex; align-items: center; }
.drag-handle:active { cursor: grabbing; }
.sortable-row.dragging { opacity: 0.5; background-color: #f3f4f6; }
.sortable-row.drag-over { border-top: 2px solid var(--accent-red); }

/* Row Buttons & Elements */
.default-star { color: #f59e0b; font-size: 1.1rem; margin-right: 5px; display: inline-flex; align-items: center; }
.btn-outline { background: #fff; color: #4b5563; border: 1px solid #d1d5db; padding: 4px 10px; border-radius: 6px; font-size: 0.75rem; font-weight: 700; cursor: pointer; transition: 0.2s; display: inline-flex; align-items: center; gap: 5px; box-shadow: 0 1px 2px rgba(0,0,0,0.05); text-decoration: none; }
.btn-outline:hover { background: #f3f4f6; color: #111827; border-color: #9ca3af; }
a.btn-analyze, a.btn-outline { text-decoration: none; }

/* =========================================================
   CHECKBOX GRIDS (For Accounting Corp Routing)
   ========================================================= */
.checkbox-container {
    width: 100%;
    margin-top: 10px;
    grid-column: 1 / -1; /* Spans full width if inside a grid */
}
.checkbox-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    background: #fff;
    padding: 15px;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    margin-top: 5px;
}
.checkbox-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.9rem;
    color: var(--text-main);
    cursor: pointer;
    background: #f9fafb;
    padding: 6px 12px;
    border-radius: 4px;
    border: 1px solid #e5e7eb;
    transition: 0.2s;
}
.checkbox-item:hover {
    background: #f3f4f6;
    border-color: #d1d5db;
}
.checkbox-item input[type="checkbox"] {
    width: 16px;
    height: 16px;
    cursor: pointer;
    accent-color: var(--accent-red);
}

/* =========================================================
   12. AI AUTOMATION SPECIFICS (Refactored from inline)
   ========================================================= */
.text-muted-title { color: var(--text-muted); }
.template-active-box { text-align: center; padding: 20px; background: #f9fafb; border: 1px solid #e5e7eb; border-radius: 6px; }
.flex-center-gap { display: flex; justify-content: center; align-items: center; gap: 15px; margin-bottom: 15px; }
.m-0 { margin: 0 !important; }
.badge-blue { background: #e0e7ff; color: #1e40af; border-color: #bfdbfe; font-size: 0.75rem; }

/* Manual Override UI */
.manual-override-box { text-align: center; padding: 20px; background: #fffbeb; border: 1px solid #fcd34d; border-radius: 6px; margin-bottom: 15px; }
.manual-override-title { color: #d97706; margin-bottom: 10px; }
.manual-override-desc { color: #92400e; font-size: 0.95rem; margin-bottom: 20px; }
.text-left { text-align: left; }
.mb-20 { margin-bottom: 20px; }
.prompt-label { font-weight: 600; color: #451a03; display: flex; justify-content: space-between; align-items: center; margin-bottom: 5px;}
.prompt-textarea-wrapper { position: relative; margin-top: 5px; }
.prompt-textarea { width: 100%; box-sizing: border-box; font-family: monospace; font-size: 13px; background: #f8fafc; border: 1px solid #cbd5e1; border-radius: 6px; padding: 12px; color: #334155; resize: vertical; }
.json-textarea { background: #ffffff; }

.copy-btn { position: absolute; top: 8px; right: 8px; background: #e2e8f0; color: #475569; border: 1px solid #cbd5e1; border-radius: 4px; padding: 4px 10px; font-size: 0.75rem; font-weight: 600; cursor: pointer; transition: 0.2s; z-index: 10; }
.copy-btn:hover { background: #cbd5e1; color: #1e293b; }

.upload-dropzone { width: 100%; text-align: center; padding: 40px; border: 2px dashed #ddd; display: block; box-sizing: border-box; margin-bottom: 15px; cursor: pointer; transition: 0.3s; }
.file-label-text { font-weight: bold; color: #475569; }
.ai-model-select { width: 100%; border: 1px solid #cbd5e1; border-radius: 6px; padding: 10px; background-color: #f8fafc; color: #475569; font-size: 0.95rem; }
.w-100 { width: 100%; }

/* AI Mapping Tables */
.mapping-table-wrapper { padding: 0; }
.mapping-header { cursor: pointer; display: flex; align-items: center; justify-content: space-between; padding: 20px; background: #f8fafc; border-bottom: 1px solid #e5e7eb; border-radius: 8px 8px 0 0; }
.mapping-header h2 { margin: 0; font-size: 1.25rem; }
.mapping-header-blue h2 span { background: #dbeafe; color: #1e3a8a; border-color: #bfdbfe; }
.mapping-content { display: none; padding: 20px; }
.mapping-table { width: 100%; border-collapse: collapse; table-layout: fixed; }
.mapping-th { text-align: left; border-bottom: 2px solid #e5e7eb; padding-bottom: 10px; }
.mapping-th-30 { width: 30%; }
.mapping-th-40 { width: 40%; }
.mapping-td { padding: 12px 10px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mapping-code { background: #f1f5f9; padding: 2px 4px; border: 1px solid #cbd5e1; border-radius: 3px; }
.mapping-row { border-bottom: 1px solid #e5e7eb; }

/* Custom Questions Preview */
.cq-ladder-node { background: #8b5cf6; color: white; border-color: #8b5cf6 !important; }
.cq-card-top { border-top-color: #8b5cf6 !important; padding: 0 !important; }
.cq-header-bg { background: #fdfaff; }
.cq-header-title { color: #6d28d9; margin: 0; font-size: 1.25rem; }
.cq-badge { background: #ede9fe; color: #6d28d9; border-color: #ddd6fe; }
.cq-btn-expand { background: #8b5cf6; border-color: #8b5cf6; color: white; padding: 6px 12px; font-size: 0.8rem; }
.cq-btn-expand:hover { background: #7c3aed; }
.cq-content-wrap { display: none; padding: 30px; background: #ffffff; }
.cq-desc-box { margin-top: 0; margin-bottom: 30px; padding: 10px; background: #f8fafc; border-radius: 6px; border-left: 4px solid #8b5cf6; }
.cq-empty { text-align: center; padding: 30px; color: #94a3b8; }
.cq-label-main { font-size: 1.1rem; font-weight: 600; color: #1e293b; display: block; margin-bottom: 15px; }
.cq-options-wrap { display: flex; flex-wrap: wrap; gap: 15px; }
.cq-radio-label { background: #f1f5f9; padding: 10px 20px; border-radius: 50px; font-size: 0.95rem; color: #475569; border: 1px solid #cbd5e1; cursor: pointer; }
.cq-text-input { width: 100%; padding: 12px; border: 1px solid #cbd5e1; border-radius: 6px; box-sizing: border-box; }
.cq-admin-controls { margin-top: 20px; padding-top: 15px; border-top: 1px solid #cbd5e1; display: flex; gap: 10px; justify-content: flex-end; }
.cq-btn-tech { background: #f1f5f9; color: #475569; border: 1px solid #cbd5e1; font-size: 0.8rem; }
.cq-tech-details { display: none; margin-top: 15px; background: #1e293b; color: #cbd5e1; padding: 15px; border-radius: 8px; font-family: monospace; font-size: 0.85rem; }
.cq-tech-comment { color: #10b981; margin-bottom: 10px; }
.cq-tech-input-group { margin-top: 10px; }
.cq-tech-label { color: #fff; display: block; margin-bottom: 4px; }
.cq-tech-input { width: 100%; background: #334155; color: #fff; border: 1px solid #475569; padding: 5px; box-sizing: border-box; }
.cq-tech-select { background: #334155; color: #fff; border: 1px solid #475569; padding: 5px; }
.cq-tech-flex { display: flex; gap: 10px; align-items: center; margin-top: 10px; }
.cq-tech-flex-1 { flex: 1; background: #334155; color: #fff; border: 1px solid #475569; padding: 5px; box-sizing: border-box; }
.cq-tech-flex-short { width: 100px; background: #0f172a; color: #10b981; border: 1px solid #475569; padding: 5px; box-sizing: border-box; }

/* Action Buttons */
.btn-finalize { margin-top: 30px; width: 100%; font-size: 1.1rem; padding: 15px; border: 2px solid var(--success); color: var(--success); font-weight: bold; background: white; }
.btn-finalize:hover { background: var(--success); color: white; }
.btn-action-small { padding: 6px 12px; font-size: 0.8rem; }

/* Test PDF Generation */
.test-pdf-card { text-align: center; margin-top: 25px; background: #ecfdf5; border-color: #10b981; }
.test-pdf-title { color: #065f46; margin-bottom: 10px;}
.test-pdf-desc { color: #047857; }
.btn-test-pdf { width: auto; padding: 14px 40px; font-size: 1.05rem; }
.test-pdf-status { color: #065f46; font-weight: bold; margin-top: 15px; display: none; }

/* =========================================================
   13. AI PROCESSING & LOADING STATES
   ========================================================= */

/* Fixes buttons breaking when the spinner div is injected via JS */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    /* Added to keep the spinner and text aligned perfectly */
}

/* The "Cool Background" for the AI analyzing state */
.inline-loader-card {
    background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
    border: 2px dashed #cbd5e1;
    border-radius: 12px;
    padding: 50px 30px;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    margin: 20px 0;
    box-shadow: inset 0 0 30px rgba(0,0,0,0.02);
    animation: pulse-bg 3s infinite alternate;
}

@keyframes pulse-bg {
    0% { background-color: #f8fafc; border-color: #cbd5e1; }
    100% { background-color: #f1f5f9; border-color: #94a3b8; }
}

/* The spinning loader used inside the card and buttons */
.processing-pulse {
    border-style: solid;
    border-color: rgba(16, 185, 129, 0.2); /* Muted green track */
    border-top-color: #10b981; /* Bright green leading edge (overridden to #fff in buttons) */
    border-radius: 50%;
    box-sizing: border-box;
    animation: spin-pulse 1s linear infinite;
    display: block; /* Required to respect JS width/height injections */
}

@keyframes spin-pulse {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Ensure the AI model select dropdown doesn't look squished */
.ai-model-select {
    font-weight: 600;
    cursor: pointer;
}
/* =========================================================
   14. ADDITIONAL DOCUMENT REQUEST UI
   ========================================================= */

/* The nice '+' button next to the category/customer name */
.btn-add-doc-header {
    background: #e0e7ff;
    color: #3730a3;
    border: 1px solid #c7d2fe;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 700;
    cursor: pointer;
    transition: 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    margin-left: 15px;
    vertical-align: middle;
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}
.btn-add-doc-header:hover {
    background: #c7d2fe;
    color: #312e81;
}

/* The footer that contains the dropdown (Hidden by default) */
.add-doc-footer {
    padding: 15px 20px; 
    border-top: 1px solid #e2e8f0; 
    background: #f8fafc; 
    display: none; /* Hidden until button is pressed */
    gap: 15px; 
    align-items: center; 
    border-radius: 0 0 8px 8px;
    margin: 0 -25px -25px -25px; /* Pulls it flush with the edges of the section-card padding */
}
.add-doc-footer.active {
    display: flex;
    animation: slideDown 0.2s ease-out forwards;
}

/* Sizing the dropdown properly */
.add-doc-select {
    flex: 1;
    padding: 10px 14px;
    font-size: 0.95rem;
    border-radius: 6px;
    border: 1px solid #cbd5e1;
    background-color: #fff;
    color: #1e293b;
    height: 42px; /* Fixed height to match button */
    box-sizing: border-box;
}
.add-doc-select:focus {
    border-color: #3b82f6; 
    box-shadow: 0 0 0 3px rgba(59,130,246,0.1);
    outline: none;
}

/* Sizing the request button properly */
.btn-request-doc {
    padding: 0 20px;
    height: 42px; /* Fixed height to match dropdown */
    font-size: 0.95rem;
    font-weight: 600;
    border-radius: 6px;
    border: none;
    background: #10b981;
    color: white;
    cursor: pointer;
    transition: 0.2s;
    white-space: nowrap;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}
.btn-request-doc:hover {
    background: #059669;
}

@keyframes slideDown {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}