/* SAFE & SMART GOLD – design system */
:root {
  --brand-red: #C8102E; --brand-blue: #2E6FD8; --brand-gold: #C9A227; --brand-gold-soft: #FBF3DC;
  --ink: #1B2333; --ink-2: #4A5468; --ink-3: #8A94A6; --line: #E6EAF1; --bg: #F4F6FA; --card: #FFFFFF;
  --nav: #0E1A2F; --nav-2: #16243F; --nav-ink: #AEB8CC;
  --ok: #138A5B; --ok-bg: #E6F6EF; --warn: #B7791F; --warn-bg: #FFF5E0; --bad: #C8102E; --bad-bg: #FDECEE; --info: #2E6FD8; --info-bg: #EAF1FD;
  --radius: 14px; --shadow: 0 1px 2px rgba(16,24,40,.04), 0 4px 16px rgba(16,24,40,.06);
  --bs-primary: #2E6FD8; --bs-primary-rgb: 46,111,216; --bs-body-font-family: 'Inter', 'Segoe UI', system-ui, sans-serif; --bs-body-color: #1B2333;
}
html, body { background: var(--bg); color: var(--ink); font-family: var(--bs-body-font-family); font-size: 14px; }
a { color: var(--brand-blue); text-decoration: none; } a:hover { text-decoration: underline; }
.btn-primary { --bs-btn-bg: var(--brand-blue); --bs-btn-border-color: var(--brand-blue); --bs-btn-hover-bg: #2259B5; --bs-btn-hover-border-color: #2259B5; }
.btn-gold { background: linear-gradient(135deg, #E3BC4E, #B98A12); color: #fff; border: 0; font-weight: 600; }
.btn-gold:hover { color: #fff; filter: brightness(1.05); }
.btn { border-radius: 9px; font-weight: 500; }
.form-control, .form-select { border-radius: 9px; border-color: #D9DFEA; }
.form-control:focus, .form-select:focus { border-color: var(--brand-blue); box-shadow: 0 0 0 3px rgba(46,111,216,.15); }
.form-label { font-weight: 600; color: var(--ink-2); font-size: 12.5px; margin-bottom: 4px; }

/* ---------- shell */
.shell { display: flex; min-height: 100vh; }
.sidebar { width: 252px; background: var(--nav); color: var(--nav-ink); position: fixed; inset: 0 auto 0 0; display: flex; flex-direction: column; z-index: 1030; transition: transform .2s; }
.sidebar .brand { padding: 18px 18px 14px; border-bottom: 1px solid rgba(255,255,255,.06); }
.sidebar .brand img { height: 42px; max-width: 100%; }
.sidebar nav { overflow-y: auto; padding: 10px 10px 30px; flex: 1; }
.nav-section { font-size: 10.5px; letter-spacing: 1.4px; text-transform: uppercase; color: #6E7A93; padding: 14px 12px 6px; font-weight: 700; }
.nav-link-x { display: flex; align-items: center; gap: 11px; color: var(--nav-ink); padding: 8px 12px; border-radius: 9px; font-weight: 500; margin: 1px 0; }
.nav-link-x i { font-size: 16px; width: 18px; text-align: center; opacity: .9; }
.nav-link-x:hover { background: var(--nav-2); color: #fff; text-decoration: none; }
.nav-link-x.active { background: linear-gradient(90deg, rgba(201,162,39,.22), rgba(201,162,39,.04)); color: #fff; box-shadow: inset 3px 0 0 var(--brand-gold); }
.nav-link-x .badge { margin-left: auto; }
.main { margin-left: 252px; flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar { height: 62px; background: #fff; border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 14px; padding: 0 22px; position: sticky; top: 0; z-index: 1020; }
.topbar .search { flex: 1; max-width: 560px; position: relative; }
.topbar .search input { padding-left: 36px; background: #F3F5F9; border-color: transparent; height: 38px; }
.topbar .search i { position: absolute; left: 12px; top: 10px; color: var(--ink-3); }
.search-results { position: absolute; top: 44px; left: 0; right: 0; background: #fff; border-radius: 12px; box-shadow: 0 12px 40px rgba(16,24,40,.18); z-index: 2000; max-height: 420px; overflow-y: auto; }
.search-results a { display: flex; gap: 10px; padding: 10px 14px; color: var(--ink); border-bottom: 1px solid var(--line); }
.search-results a:hover { background: #F6F8FC; text-decoration: none; }
.chip-date { background: var(--brand-gold-soft); color: #7A5A00; border-radius: 999px; padding: 5px 12px; font-weight: 600; font-size: 12.5px; white-space: nowrap; }
.chip-date.sim { background: #FFE8EB; color: var(--brand-red); }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: linear-gradient(135deg, var(--brand-blue), #6FA3FF); color: #fff; display: grid; place-items: center; font-weight: 700; }
.content { padding: 22px 26px 60px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.page-head h1 { font-size: 22px; font-weight: 750; margin: 0; letter-spacing: -.2px; }
.page-head .sub { color: var(--ink-3); margin-top: 3px; }
.mobile-toggle { display: none; }
@media (max-width: 991px) {
  .sidebar { transform: translateX(-100%); } .sidebar.open { transform: none; }
  .main { margin-left: 0; } .mobile-toggle { display: inline-flex; } .content { padding: 16px; }
}

/* ---------- cards & stats */
.card-x { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); border: 1px solid #EEF1F6; }
.card-x > .hd { padding: 14px 18px; border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.card-x > .hd h3 { font-size: 14.5px; font-weight: 700; margin: 0; }
.card-x > .bd { padding: 16px 18px; }
.kpi { padding: 16px 18px; position: relative; overflow: hidden; height: 100%; }
.kpi .lbl { color: var(--ink-3); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .5px; }
.kpi .val { font-size: 25px; font-weight: 800; margin-top: 6px; letter-spacing: -.4px; }
.kpi .sub { color: var(--ink-2); font-size: 12.5px; margin-top: 2px; }
.kpi::after { content: ""; position: absolute; right: -18px; top: -18px; width: 80px; height: 80px; border-radius: 50%; opacity: .12; background: var(--info); }
.kpi.good::after { background: var(--ok); } .kpi.warn::after { background: var(--warn); } .kpi.bad::after { background: var(--bad); }
.kpi.bad .val { color: var(--bad); } .kpi.warn .val { color: var(--warn); }
.tone-good { color: var(--ok); } .tone-warn { color: var(--warn); } .tone-bad { color: var(--bad); }
.pill { display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: 999px; font-size: 11.5px; font-weight: 650; }
.pill-ok { background: var(--ok-bg); color: var(--ok); } .pill-warn { background: var(--warn-bg); color: var(--warn); }
.pill-bad { background: var(--bad-bg); color: var(--bad); } .pill-info { background: var(--info-bg); color: var(--info); } .pill-gray { background: #EEF1F6; color: var(--ink-2); }
.pill-gold { background: var(--brand-gold-soft); color: #7A5A00; }
.scheme { font-weight: 800; letter-spacing: .5px; border-radius: 8px; padding: 3px 10px; color: #fff; display: inline-block; }
.scheme-SE { background: #138A5B; } .scheme-SC { background: #2E6FD8; } .scheme-SA { background: #3B82A0; } .scheme-SF { background: #B7791F; } .scheme-SB { background: #D9480F; } .scheme-SD { background: #C8102E; }
.staff-only { font-size: 10.5px; color: var(--ink-3); text-transform: uppercase; letter-spacing: .6px; }

/* ---------- tables */
.table-x { width: 100%; border-collapse: separate; border-spacing: 0; }
.table-x th { background: #F7F9FC; color: var(--ink-2); font-weight: 650; font-size: 12px; text-transform: uppercase; letter-spacing: .4px; padding: 10px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; position: sticky; top: 0; z-index: 1; }
.table-x td { padding: 10px 12px; border-bottom: 1px solid #F0F2F6; vertical-align: middle; }
.table-x tbody tr:hover td { background: #FAFBFE; }
.table-x tfoot td { font-weight: 700; background: #FFFBEF; border-top: 2px solid #F1E2B3; }
.table-wrap { overflow: auto; max-height: 640px; border-radius: 0 0 var(--radius) var(--radius); }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }

/* ---------- counter screen */
.cust-hero { background: linear-gradient(120deg, #0E1A2F 0%, #1D3561 60%, #2E6FD8 140%); color: #fff; border-radius: var(--radius); padding: 20px 22px; display: flex; gap: 22px; flex-wrap: wrap; align-items: center; }
.cust-hero .name { font-size: 21px; font-weight: 800; }
.cust-hero .meta { color: #B8C4DC; font-size: 13px; }
.cust-hero .box { background: rgba(255,255,255,.08); border-radius: 12px; padding: 10px 14px; min-width: 150px; }
.cust-hero .box .k { font-size: 11px; color: #9FB0CF; text-transform: uppercase; letter-spacing: .6px; } .cust-hero .box .v { font-weight: 750; font-size: 16px; }
.loan-card { border-left: 4px solid var(--brand-blue); }
.loan-card.counting { border-left-color: var(--brand-gold); }
.loan-card.overdue { border-left-color: var(--warn); } .loan-card.npa { border-left-color: var(--bad); }
.metric-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px 18px; }
.metric-grid .k { color: var(--ink-3); font-size: 11.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .4px; }
.metric-grid .v { font-weight: 700; font-size: 15px; }
.action-btn { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; border: 1px solid var(--line); background: #fff; border-radius: 12px; padding: 12px 8px; min-width: 110px; font-weight: 600; color: var(--ink); }
.action-btn i { font-size: 20px; color: var(--brand-blue); }
.action-btn:hover:not(:disabled) { border-color: var(--brand-blue); background: var(--info-bg); }
.action-btn:disabled { opacity: .45; cursor: not-allowed; }
.reason { font-size: 11.5px; color: var(--bad); }
.counter-dots { display: inline-flex; gap: 4px; } .counter-dots span { width: 12px; height: 12px; border-radius: 50%; background: #E3E7EF; } .counter-dots span.on { background: var(--brand-gold); }
.quote-line { display: flex; justify-content: space-between; padding: 7px 0; border-bottom: 1px dashed var(--line); }
.quote-line.pay { font-weight: 800; font-size: 16px; border-bottom: 0; padding-top: 12px; color: var(--brand-blue); }
.quote-line.info { color: var(--ink-3); } .quote-line.deduct span:last-child { color: var(--bad); }
.callout { border-radius: 12px; padding: 12px 14px; display: flex; gap: 10px; align-items: flex-start; }
.callout i { font-size: 18px; } .callout.warn { background: var(--warn-bg); color: #7A4E00; } .callout.bad { background: var(--bad-bg); color: #8E0B21; }
.callout.info { background: var(--info-bg); color: #1A4B9C; } .callout.ok { background: var(--ok-bg); color: #0C5E3D; } .callout.gold { background: var(--brand-gold-soft); color: #6B4E00; }

/* ---------- modal & toasts */
.modal-x-backdrop { position: fixed; inset: 0; background: rgba(14,26,47,.45); z-index: 1050; display: flex; align-items: flex-start; justify-content: center; padding: 40px 16px; overflow-y: auto; }
.modal-x { background: #fff; border-radius: 16px; width: 100%; max-width: 760px; box-shadow: 0 24px 64px rgba(0,0,0,.25); animation: pop .15s ease-out; }
.modal-x.lg { max-width: 1100px; } .modal-x.sm { max-width: 480px; }
.modal-x .hd { padding: 16px 20px; border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; }
.modal-x .hd h3 { margin: 0; font-size: 17px; font-weight: 750; }
.modal-x .bd { padding: 18px 20px; } .modal-x .ft { padding: 14px 20px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 10px; background: #FAFBFD; border-radius: 0 0 16px 16px; }
@keyframes pop { from { transform: translateY(8px); opacity: 0; } to { transform: none; opacity: 1; } }
.toasts { position: fixed; right: 18px; bottom: 18px; z-index: 3000; display: flex; flex-direction: column; gap: 10px; max-width: 440px; }
.toast-x { background: #fff; border-radius: 12px; box-shadow: 0 10px 30px rgba(16,24,40,.2); padding: 12px 14px; display: flex; gap: 10px; border-left: 4px solid var(--ok); animation: pop .2s; }
.toast-x.err { border-left-color: var(--bad); } .toast-x.warn { border-left-color: var(--warn); }

/* ---------- builders */
.palette-item { border: 1px dashed #CDD5E3; border-radius: 10px; padding: 8px 10px; margin-bottom: 8px; cursor: pointer; background: #fff; display: flex; gap: 8px; align-items: center; }
.palette-item:hover { border-color: var(--brand-blue); background: var(--info-bg); }
.widget-grid { display: grid; grid-template-columns: repeat(12, 1fr); gap: 16px; }
.w-3 { grid-column: span 3; } .w-4 { grid-column: span 4; } .w-6 { grid-column: span 6; } .w-8 { grid-column: span 8; } .w-12 { grid-column: span 12; }
@media (max-width: 1200px) { .w-3 { grid-column: span 6; } .w-4 { grid-column: span 6; } .w-8 { grid-column: span 12; } }
@media (max-width: 700px) { .w-3, .w-4, .w-6, .w-8 { grid-column: span 12; } }
.widget-edit { outline: 2px dashed transparent; } .widget-edit.sel { outline-color: var(--brand-blue); }
.chart-box { position: relative; height: 260px; }
.narrative { font-size: 15px; line-height: 1.6; color: var(--ink); }
textarea.code-editor, .code-editor { font-family: 'Cascadia Code', Consolas, monospace; font-size: 12.5px; min-height: 520px; background: #0F172A; color: #E2E8F0; border-radius: 10px; border: 0; line-height: 1.5; tab-size: 2; }
.code-editor:focus { background: #0F172A; color: #E2E8F0; }
.preview-frame { width: 100%; height: 620px; border: 1px solid var(--line); border-radius: 10px; background: #fff; }
.placeholder-chip { display: inline-block; background: #EEF3FC; color: #1A4B9C; border-radius: 7px; padding: 3px 8px; margin: 2px; font-family: Consolas, monospace; font-size: 11.5px; cursor: pointer; }
.placeholder-chip:hover { background: var(--brand-blue); color: #fff; }

/* ---------- workflow designer */
.wf-wrap { display: grid; grid-template-columns: 190px 1fr 290px; gap: 14px; }
@media (max-width: 1200px) { .wf-wrap { grid-template-columns: 1fr; } }
.wf-canvas { position: relative; height: 620px; background-color: #FBFCFE; background-image: radial-gradient(#DCE2EC 1px, transparent 1px); background-size: 18px 18px; border-radius: 12px; border: 1px solid var(--line); overflow: auto; }
.wf-canvas svg { position: absolute; inset: 0; width: 2400px; height: 1400px; }
.wf-node { cursor: move; } .wf-node rect, .wf-node polygon, .wf-node circle { stroke-width: 2; filter: drop-shadow(0 2px 4px rgba(16,24,40,.12)); }
.wf-node.sel rect, .wf-node.sel polygon, .wf-node.sel circle { stroke: var(--brand-gold) !important; stroke-width: 3; }
.wf-node.active rect, .wf-node.active polygon, .wf-node.active circle { stroke: var(--brand-red) !important; stroke-width: 3.5; }
.wf-node.done rect, .wf-node.done polygon, .wf-node.done circle { fill: #E6F6EF !important; }
.wf-port { fill: #fff; stroke: var(--brand-blue); stroke-width: 2; cursor: crosshair; }
.wf-port:hover { fill: var(--brand-blue); }
.wf-edge { stroke: #7C8AA5; stroke-width: 2; fill: none; } .wf-edge.sel { stroke: var(--brand-gold); stroke-width: 3; }
.wf-edge-hit { stroke: transparent; stroke-width: 14; fill: none; cursor: pointer; }
.wf-label { font-size: 11px; fill: var(--ink-2); font-weight: 600; }

/* ---------- misc */
.empty { text-align: center; color: var(--ink-3); padding: 34px 10px; } .empty i { font-size: 34px; display: block; margin-bottom: 8px; opacity: .6; }
.tabs-x { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 16px; flex-wrap: wrap; }
.tabs-x button { background: none; border: 0; padding: 9px 14px; font-weight: 600; color: var(--ink-3); border-bottom: 2px solid transparent; }
.tabs-x button.on { color: var(--ink); border-bottom-color: var(--brand-gold); }
.steps { display: flex; gap: 8px; margin-bottom: 16px; } .steps div { flex: 1; text-align: center; padding: 8px; border-radius: 9px; background: #EEF1F6; color: var(--ink-3); font-weight: 600; font-size: 12.5px; }
.steps div.on { background: var(--brand-blue); color: #fff; } .steps div.done { background: var(--ok-bg); color: var(--ok); }
.spinner-x { width: 18px; height: 18px; border: 2px solid #D6DCE7; border-top-color: var(--brand-blue); border-radius: 50%; animation: spin .7s linear infinite; display: inline-block; vertical-align: middle; }
@keyframes spin { to { transform: rotate(360deg); } }
.ai-badge { background: linear-gradient(135deg, #7C3AED, #2E6FD8); color: #fff; border-radius: 999px; font-size: 10.5px; padding: 2px 8px; font-weight: 700; letter-spacing: .5px; }
.ask-box { background: linear-gradient(135deg, #0E1A2F, #1D3561); border-radius: var(--radius); padding: 22px; color: #fff; }
.ask-box input { background: rgba(255,255,255,.1); border: 1px solid rgba(255,255,255,.2); color: #fff; height: 48px; font-size: 15px; }
.ask-box input::placeholder { color: #9FB0CF; } .ask-box input:focus { background: rgba(255,255,255,.14); color: #fff; }
.suggest { background: rgba(255,255,255,.1); color: #DCE6F7; border-radius: 999px; padding: 5px 12px; font-size: 12.5px; border: 0; margin: 4px 4px 0 0; }
.suggest:hover { background: rgba(255,255,255,.2); color: #fff; }
.footer-x { color: var(--ink-3); font-size: 12px; text-align: center; padding: 18px; }
.blazor-error-boundary { background: var(--bad-bg); color: var(--bad); padding: 1rem; border-radius: 10px; }
.blazor-error-boundary::after { content: "Something went wrong on this screen. Please reload."; }
#blazor-error-ui { background: #FFF5E0; bottom: 0; box-shadow: 0 -1px 2px rgba(0,0,0,.2); display: none; left: 0; padding: .6rem 1.25rem; position: fixed; width: 100%; z-index: 4000; }
#blazor-error-ui .dismiss { cursor: pointer; position: absolute; right: .75rem; top: .5rem; }

/* ---------- auth pages */
.auth-bg { min-height: 100vh; display: grid; grid-template-columns: 1.1fr 1fr; }
.auth-art { background: radial-gradient(circle at 20% 20%, #1D3561, #0E1A2F 70%); color: #fff; padding: 56px; display: flex; flex-direction: column; justify-content: space-between; }
.auth-art h2 { font-size: 34px; font-weight: 800; line-height: 1.2; } .auth-art p { color: #B8C4DC; font-size: 15px; max-width: 460px; }
.auth-art .feat { display: flex; gap: 10px; align-items: center; color: #DCE6F7; margin: 10px 0; } .auth-art .feat i { color: #E6C25A; font-size: 18px; }
.auth-form { display: flex; align-items: center; justify-content: center; padding: 40px; background: #fff; }
.auth-card { width: 100%; max-width: 400px; }
@media (max-width: 900px) { .auth-bg { grid-template-columns: 1fr; } .auth-art { display: none; } }
@media print { .sidebar, .topbar, .no-print { display: none !important; } .main { margin: 0; } }
