/* ===========================
   ISOLATERP V3 — SOVEREIGN CSS
   =========================== */
:root {
    --bg-dark: #f1f5f9;
    --bg-panel: #ffffff;
    --bg-card: #ffffff;
    --bg-hover: #f8fafc;
    --bg-input: #ffffff;
    --border: rgba(0,0,0,0.08);
    --neon-cyan: #2563eb;
    --neon-magenta: #7c3aed;
    --neon-green: #10b981;
    --neon-amber: #f59e0b;
    --danger: #ef4444;
    --text-primary: #1e293b;
    --text-secondary: #475569;
    --text-muted: #64748b;
    --sidebar-w: 260px;
    --topbar-h: 64px;
    --radius: 12px;
    --radius-sm: 8px;
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.1), 0 2px 4px -1px rgba(0,0,0,0.06);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; overflow: hidden; }
body { font-family: 'Inter', sans-serif; background: var(--bg-dark); color: var(--text-primary); font-size: 14px; }

/* === APP SHELL === */
.app-shell { display: flex; height: 100vh; overflow: hidden; }

/* === SIDEBAR === */
.sidebar {
    width: var(--sidebar-w);
    min-width: var(--sidebar-w);
    background: var(--bg-panel);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    overflow-x: hidden;
    transition: width 0.3s ease, min-width 0.3s ease;
    scrollbar-width: thin;
    scrollbar-color: var(--bg-hover) transparent;
}
.sidebar.collapsed { width: 60px; min-width: 60px; }
.sidebar.collapsed .brand-tag,
.sidebar.collapsed .brand-name,
.sidebar.collapsed span:not(.nav-icon):not(.pulse-dot),
.sidebar.collapsed .sub-arrow,
.sidebar.collapsed .sidebar-section-label { display: none; }
.sidebar.collapsed .sidebar-brand { padding: 16px 12px; justify-content: center; }
.sidebar.collapsed .nav-item { justify-content: center; padding: 10px; }

.sidebar-brand {
    display: flex; align-items: center; gap: 10px;
    padding: 18px 16px; border-bottom: 1px solid var(--border);
    min-height: 64px;
}
.brand-icon { font-size: 22px; }
.brand-name { font-size: 13px; font-weight: 700; color: var(--neon-cyan); letter-spacing: 1px; }
.brand-tag { font-size: 9px; color: var(--text-muted); letter-spacing: 0.5px; margin-top: 2px; }

.sidebar-section-label {
    font-size: 9px; font-weight: 700; color: var(--text-muted);
    letter-spacing: 1.5px; padding: 14px 16px 4px;
}
.sidebar-nav { list-style: none; padding: 4px 8px; }
.nav-item {
    display: flex; align-items: center; gap: 10px;
    padding: 9px 10px; border-radius: var(--radius-sm);
    cursor: pointer; color: var(--text-secondary);
    transition: all 0.2s; position: relative;
    font-size: 13px; font-weight: 500;
    user-select: none;
}
.nav-item:hover { background: var(--bg-hover); color: var(--neon-cyan); }
.nav-item.active { background: #f0f9ff; color: var(--neon-cyan); font-weight: 600; }
.nav-icon { font-size: 16px; min-width: 20px; text-align: center; }
.sub-arrow { margin-left: auto; font-size: 16px; transition: transform 0.2s; }
.nav-item.open .sub-arrow { transform: rotate(90deg); }
.has-sub { flex-wrap: wrap; }
.sub-menu {
    display: none; list-style: none; width: 100%;
    padding: 4px 0 4px 30px; background: #ffffff;
    border-radius: var(--radius-sm); margin-top: 4px;
}
.nav-item.open .sub-menu { display: block; }
.sub-menu li {
    padding: 7px 10px; border-radius: var(--radius-sm);
    cursor: pointer; color: var(--text-muted); font-size: 12px;
    transition: all 0.15s;
}
.sub-menu li:hover { color: var(--neon-cyan); background: var(--bg-hover); }
.sub-menu li.active-sub { color: var(--neon-cyan); }

/* === MAIN AREA === */
.main-area { flex: 1; display: flex; flex-direction: column; overflow: hidden; }

/* === TOPBAR === */
.topbar {
    height: var(--topbar-h); background: var(--bg-panel);
    border-bottom: 1px solid var(--border);
    display: flex; align-items: center; gap: 12px;
    padding: 0 20px; position: relative; z-index: 100;
}
.menu-toggle { background: none; border: none; color: var(--text-secondary); font-size: 20px; cursor: pointer; padding: 4px; }
.search-wrap { flex: 1; position: relative; max-width: 480px; }
.search-icon { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--text-muted); font-size: 14px; }
.form-control {
    width: 100%; padding: 10px 14px; background: var(--bg-input);
    border: 1px solid #d1d5db; border-radius: var(--radius-sm);
    color: var(--text-primary); font-size: 13px; transition: all 0.2s;
}
.form-control:focus { border-color: var(--neon-cyan); outline: none; box-shadow: 0 0 0 3px rgba(37,99,235,0.1); }
/* === SEARCH RESULTS (PREMIUM GLASS) === */
.search-results {
    position: absolute;
    top: calc(100% + 12px);
    left: 0;
    right: 0;
    background: #ffffff;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: 0 10px 25px rgba(0,0,0,0.1);
    overflow: hidden;
    z-index: 1000;
    display: none;
    max-height: 450px;
    animation: searchReveal 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}
@keyframes searchReveal {
    from { opacity: 0; transform: translateY(-10px) scale(0.98); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

.search-results-list {
    display: flex;
    flex-direction: column;
}

.search-result-item {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 12px 16px;
    cursor: pointer;
    border-bottom: 1px solid var(--border);
    transition: all 0.2s;
}

.search-result-item:hover {
    background: var(--bg-hover);
    padding-left: 20px;
}

.search-result-icon {
    width: 36px;
    height: 36px;
    background: var(--bg-dark);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    flex-shrink: 0;
    transition: transform 0.2s;
}
.search-result-item:hover .search-result-icon {
    transform: scale(1.1);
}

.search-result-info {
    flex: 1;
    min-width: 0;
}

.search-result-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.search-result-module {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 2px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.search-result-arrow {
    color: var(--text-muted);
    font-size: 18px;
    opacity: 0;
    transition: all 0.2s;
}
.search-result-item:hover .search-result-arrow {
    opacity: 1;
    transform: translateX(4px);
    color: var(--neon-cyan);
}

.search-no-results {
    padding: 24px;
    text-align: center;
    color: var(--text-secondary);
    font-size: 13px;
    font-style: italic;
}

.topbar-right { display: flex; align-items: center; gap: 12px; margin-left: auto; }
.pulse-indicator { display: flex; align-items: center; gap: 6px; font-size: 11px; font-weight: 600; color: var(--neon-green); background: rgba(16,185,129,0.1); padding: 5px 12px; border-radius: 20px; border: 1px solid rgba(16,185,129,0.2); }
.pulse-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--neon-green); animation: pulse-anim 1.5s infinite; }
@keyframes pulse-anim { 0%,100%{opacity:1;transform:scale(1)} 50%{opacity:0.4;transform:scale(0.8)} }
.icon-btn { background: none; border: none; font-size: 18px; cursor: pointer; padding: 4px; opacity: 0.7; }
.icon-btn:hover { opacity: 1; }
.avatar-btn { width: 34px; height: 34px; border-radius: 50%; background: linear-gradient(135deg, var(--neon-cyan), var(--neon-magenta)); display: flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 700; color: #fff; cursor: pointer; }

/* === CONTENT AREA === */
.content-area { flex: 1; overflow-y: auto; padding: 24px; scrollbar-width: thin; scrollbar-color: var(--bg-hover) transparent; }

/* === PAGE HEADER === */
.page-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 24px; flex-wrap: gap; }
.page-title h1 { font-size: 22px; font-weight: 700; color: var(--text-primary); }
.page-title p { font-size: 13px; color: var(--text-secondary); margin-top: 2px; }
.page-actions { display: flex; gap: 10px; flex-wrap: wrap; }

/* === BUTTONS === */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 8px 16px; border-radius: var(--radius-sm); border: none; cursor: pointer; font-size: 13px; font-weight: 600; transition: all 0.2s; text-transform: uppercase; letter-spacing: 0.5px; }
.btn-primary { background: var(--neon-cyan); color: #fff; }
.btn-primary:hover { opacity: 0.9; transform: translateY(-1px); }
.btn-secondary { background: #fff; color: var(--text-secondary); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--bg-hover); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { opacity: 0.9; }
.btn-success { background: var(--neon-green); color: #fff; }
.btn-sm { padding: 5px 10px; font-size: 11px; }
.btn-icon { padding: 6px; min-width: 30px; justify-content: center; }

/* === KPI CARDS === */
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 16px; margin-bottom: 24px; }
.kpi-card {
    background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius);
    padding: 20px; position: relative; overflow: hidden; cursor: pointer; transition: all 0.2s;
    box-shadow: var(--shadow-sm);
}
.kpi-card:hover { border-color: var(--neon-cyan); transform: translateY(-2px); box-shadow: var(--shadow-md); }
.kpi-icon { font-size: 28px; margin-bottom: 10px; }
.kpi-value { font-size: 26px; font-weight: 700; color: var(--text-primary); }
.kpi-label { font-size: 12px; color: var(--text-secondary); margin-top: 4px; }
.kpi-change { font-size: 11px; margin-top: 8px; }
.kpi-change.up { color: var(--neon-green); }
.kpi-change.down { color: var(--danger); }

/* === CARDS === */
.card {
    background: var(--bg-card);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
    margin-bottom: 20px;
    transition: transform 0.2s, box-shadow 0.2s;
}
.card:hover { box-shadow: var(--shadow-md); }
.card-header { padding: 16px 20px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; }
.card-title { font-size: 14px; font-weight: 600; color: var(--text-primary); }
.card-body { padding: 20px; }

/* === DATA TABLE === */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
thead tr { background: var(--bg-hover); }
thead th { padding: 10px 14px; text-align: left; font-size: 11px; font-weight: 700; color: var(--text-secondary); text-transform: uppercase; letter-spacing: 1px; border-bottom: 1px solid var(--border); }
tbody tr { border-bottom: 1px solid var(--border); transition: background 0.15s; }
tbody tr:hover { background: var(--bg-hover); }
tbody td { padding: 11px 14px; color: var(--text-primary); vertical-align: middle; }
tbody td:last-child { text-align: right; }
.table-empty { padding: 40px; text-align: center; color: var(--text-muted); font-size: 13px; }

/* === BADGES === */
.badge { display: inline-flex; align-items: center; padding: 3px 9px; border-radius: 20px; font-size: 11px; font-weight: 600; }
.badge-green { background: #dcfce7; color: #166534; }
.badge-cyan { background: #dbeafe; color: #1e40af; }
.badge-amber { background: #fef3c7; color: #92400e; }
.badge-red { background: #fee2e2; color: #991b1b; }
.badge-grey { background: #f1f5f9; color: #475569; }

/* === FORM GRID === */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-grid.cols-3 { grid-template-columns: 1fr 1fr 1fr; }
.form-grid.cols-1 { grid-template-columns: 1fr; }
.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-group.span-2 { grid-column: span 2; }
label { font-size: 12px; font-weight: 600; color: var(--text-secondary); text-transform: uppercase; letter-spacing: 0.5px; }
input, select, textarea {
    background: var(--bg-input); border: 1px solid #d1d5db;
    border-radius: var(--radius-sm); padding: 9px 12px;
    color: var(--text-primary); font-size: 13px; font-family: inherit;
    outline: none; transition: border-color 0.2s;
}
input:focus, select:focus, textarea:focus { border-color: var(--neon-cyan); box-shadow: 0 0 0 3px rgba(37,99,235,0.1); }
select option { background: var(--bg-panel); }
textarea { resize: vertical; min-height: 80px; }
.form-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--border); }

/* === MODAL === */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.4); backdrop-filter: blur(4px); z-index: 1000; display: none; align-items: center; justify-content: center; }
.modal-overlay.show { display: flex; }
.modal-box { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); width: 90%; max-width: 700px; max-height: 90vh; overflow-y: auto; animation: modalIn 0.2s ease; box-shadow: 0 20px 25px -5px rgba(0,0,0,0.1); }
@keyframes modalIn { from{opacity:0;transform:scale(0.96)translateY(10px)} to{opacity:1;transform:scale(1)translateY(0)} }
.modal-header { padding: 16px 20px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; }
.modal-header h3 { font-size: 15px; font-weight: 700; }
.modal-close { background: none; border: none; color: var(--text-secondary); font-size: 20px; cursor: pointer; }
.modal-body { padding: 20px; }

/* === TOAST === */
.toast-container { position: fixed; bottom: 24px; right: 24px; z-index: 2000; display: flex; flex-direction: column; gap: 10px; }
.toast {
    background: #fff; border: 1px solid var(--border);
    border-radius: var(--radius); padding: 12px 20px;
    font-size: 13px; min-width: 260px; max-width: 360px;
    animation: toastIn 0.3s ease; display: flex; align-items: center; gap: 10px;
    box-shadow: 0 10px 15px -3px rgba(0,0,0,0.1);
}
@keyframes toastIn { from{opacity:0;transform:translateY(20px)} to{opacity:1;transform:translateY(0)} }
.toast.success { border-left: 3px solid var(--neon-green); }
.toast.error { border-left: 3px solid var(--danger); }
.toast.info { border-left: 3px solid var(--neon-cyan); }

/* === CHART PLACEHOLDER === */
.chart-bar-wrap { display: flex; align-items: flex-end; gap: 8px; height: 120px; padding: 10px 0; }
.chart-bar { flex: 1; background: var(--neon-cyan); opacity: 0.7; border-radius: 4px 4px 0 0; transition: opacity 0.2s; cursor: pointer; min-width: 24px; }
.chart-bar:hover { opacity: 1; }
.chart-labels { display: flex; gap: 8px; margin-top: 4px; }
.chart-label { flex: 1; text-align: center; font-size: 10px; color: var(--text-muted); }

/* === TABS === */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 20px; }
.tab { padding: 9px 16px; font-size: 13px; font-weight: 500; color: var(--text-secondary); cursor: pointer; border-bottom: 2px solid transparent; transition: all 0.2s; }
.tab.active { color: var(--neon-cyan); border-bottom-color: var(--neon-cyan); }
.tab:hover { color: var(--text-primary); }

/* === LEDGER SPECIFIC === */
.ledger-entry { display: grid; grid-template-columns: 1fr 140px 140px; gap: 10px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--border); }
.amount-credit { color: var(--neon-green); font-weight: 600; text-align: right; }
.amount-debit { color: var(--danger); font-weight: 600; text-align: right; }
.amount-neutral { color: var(--text-primary); font-weight: 600; text-align: right; }

/* === PIPELINE COLUMNS === */
.pipeline { display: flex; gap: 16px; overflow-x: auto; padding-bottom: 16px; }
.pipeline-col { min-width: 220px; background: #f8fafc; border-radius: var(--radius); border: 1px solid var(--border); }
.pipeline-col-header { padding: 12px 14px; border-bottom: 1px solid var(--border); font-size: 12px; font-weight: 700; color: var(--text-secondary); text-transform: uppercase; letter-spacing: 1px; }
.pipeline-cards { padding: 10px; display: flex; flex-direction: column; gap: 8px; min-height: 100px; }
.pipeline-card { background: #fff; border-radius: var(--radius-sm); padding: 12px; cursor: pointer; transition: all 0.2s; border: 1px solid var(--border); }
.pipeline-card:hover { border: 1px solid var(--neon-cyan); box-shadow: var(--shadow-sm); }
.pipeline-card-title { font-size: 13px; font-weight: 600; }
.pipeline-card-meta { font-size: 11px; color: var(--text-muted); margin-top: 4px; }

/* === GRID LAYOUTS === */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }
.mb-20 { margin-bottom: 20px; }
.mb-16 { margin-bottom: 16px; }
.text-right { text-align: right; }
.text-center { text-align: center; }
.fw-700 { font-weight: 700; }
.color-cyan { color: var(--neon-cyan); }
.color-green { color: var(--neon-green); }
.color-red { color: var(--danger); }
.color-amber { color: var(--neon-amber); }
.color-muted { color: var(--text-muted); }

/* === RESPONSIVE === */
@media (max-width: 768px) {
    .sidebar { position: fixed; z-index: 500; height: 100vh; left: -240px; transition: left 0.3s; }
    .sidebar.mobile-open { left: 0; }
    .form-grid, .grid-2 { grid-template-columns: 1fr; }
    .form-grid.span-2 { grid-column: span 1; }
    .kpi-grid { grid-template-columns: 1fr 1fr; }
}

/* === ANIMATIONS === */
.animate-fade {
    animation: fadeIn 0.4s ease-out forwards;
}
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

/* === GLASSMORPISM CARDS === */
.glass-card {
    background: rgba(255, 255, 255, 0.03);
    backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: var(--radius);
    padding: 24px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.2);
}

.glass-card p {
    color: var(--text-secondary);
    line-height: 1.6;
}

/* === SHSS & HUD OVERLAYS === */
.hud-overlay {
    position: fixed; top: 80px; left: 50%; transform: translateX(-50%);
    width: 90%; max-width: 600px; background: rgba(37, 99, 235, 0.95);
    backdrop-filter: blur(12px); border: 1px solid rgba(255,255,255,0.2);
    border-radius: var(--radius); padding: 20px; color: #fff;
    z-index: 2000; box-shadow: 0 20px 40px rgba(0,0,0,0.3);
    animation: hudIn 0.4s cubic-bezier(0.18, 0.89, 0.32, 1.28);
}
@keyframes hudIn { from{opacity:0;transform:translateX(-50%)translateY(-40px)} to{opacity:1;transform:translateX(-50%)translateY(0)} }
.hud-step { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; opacity: 0.8; transition: opacity 0.3s; }
.hud-step.active { opacity: 1; font-weight: 600; }
.hud-step-num { width: 24px; height: 24px; background: rgba(255,255,255,0.2); border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 11px; }
.hud-step.active .hud-step-num { background: #fff; color: var(--neon-cyan); }

.bell-notice {
    position: relative; animation: ring 4s infinite;
}
@keyframes ring { 0%,100%{transform:rotate(0)} 10%,30%,50%,70%,90%{transform:rotate(10deg)} 20%,40%,60%,80%{transform:rotate(-10deg)} }

/* DYNAMIC BANK REGISTRY DROPDOWN */
.bank-option { display: flex; align-items: center; gap: 10px; padding: 8px; border-bottom: 1px solid var(--border); }
.bank-region { font-size: 10px; padding: 2px 6px; background: var(--bg-dark); border-radius: 4px; color: var(--text-muted); }

/* UNIVERSAL CLIP BUTTONS */
.clip-btn {
    display: inline-flex; align-items: center; justify-content: center;
    width: 20px; height: 20px; font-size: 12px; cursor: pointer;
    background: rgba(37, 99, 235, 0.1); color: var(--neon-cyan);
    border-radius: 4px; margin-left: 6px; transition: all 0.2s;
    vertical-align: middle;
}
.clip-btn:hover { background: var(--neon-cyan); color: #fff; transform: scale(1.1); }
.clip-btn.attached { background: var(--neon-green); color: #fff; }

.qr-code-display {
    padding: 15px; background: #fff; border-radius: var(--radius);
    text-align: center; border: 1px solid var(--border);
}
.qr-code-display img { max-width: 150px; }
.doc-id-badge {
    font-family: 'Courier New', monospace; font-weight: 700;
    padding: 4px 10px; background: var(--bg-dark); color: var(--neon-green);
    border-radius: 4px; border: 1px solid var(--neon-green);
}
