:root {
  --bg-deep: #f4f5f7;
  --bg: #f8f9fb;
  --bg-elevated: #ffffff;
  --bg-surface: #f0f1f4;
  --bg-hover: #ecedf1;
  --border: #e2e4ea;
  --border-active: #cdd0d9;
  --text: #1a1d26;
  --text-secondary: #5a5f72;
  --text-muted: #93969f;
  --gold: #7a5c0e;
  --gold-soft: rgba(122,92,14,0.08);
  --emerald: #0f8a5c;
  --emerald-soft: rgba(15,138,92,0.06);
  --rose: #d43455;
  --rose-soft: rgba(212,52,85,0.06);
  --sky: #1578c2;
  --sky-soft: rgba(21,120,194,0.06);
  --amber: #b88407;
  --amber-soft: rgba(184,132,7,0.06);
  --radius: 12px;
  --radius-sm: 8px;
  --transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

* { margin: 0; padding: 0; box-sizing: border-box; }
body {
  font-family: 'Outfit', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}
body::before { display: none; }
.ambient-glow { display: none; }

/* Setup */
#setup-screen { display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 20px; position: relative; z-index: 1; }
.setup-box { background: var(--bg-elevated); border: 1px solid var(--border); border-radius: var(--radius); padding: 48px; max-width: 460px; width: 100%; }
.setup-box h1 { font-family: 'Playfair Display', serif; font-size: 26px; color: var(--gold); margin-bottom: 4px; }
.setup-box .sub { font-size: 11px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 2px; margin-bottom: 32px; }
.setup-box label { display: block; font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 1.5px; color: var(--text-muted); margin-bottom: 6px; }
.setup-box input { width: 100%; background: var(--bg-surface); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 12px 14px; color: var(--text); font-family: 'Outfit', monospace; font-size: 13px; margin-bottom: 18px; transition: border-color var(--transition); }
.setup-box input:focus { outline: none; border-color: var(--gold); }
.setup-box button { width: 100%; background: linear-gradient(135deg, var(--gold), #9a7520); color: var(--bg-deep); border: none; border-radius: var(--radius-sm); padding: 13px; font-weight: 700; font-size: 14px; cursor: pointer; font-family: 'Outfit', sans-serif; }
.setup-box button:hover { opacity: 0.9; }
.setup-error { color: var(--rose); font-size: 13px; margin-top: 12px; display: none; }

/* Layout */
#dashboard { display: none; }
.layout { display: flex; min-height: 100vh; position: relative; z-index: 1; }
.sidebar { width: 260px; background: var(--bg-deep); border-right: 1px solid var(--border); padding: 28px 0; display: flex; flex-direction: column; position: fixed; height: 100vh; z-index: 10; }
.sidebar-brand { padding: 0 24px; margin-bottom: 36px; }
.sidebar-brand h1 { font-family: 'Playfair Display', serif; font-size: 22px; font-weight: 700; color: var(--gold); }
.sidebar-brand span { font-size: 11px; color: var(--text-muted); font-weight: 500; letter-spacing: 2px; text-transform: uppercase; display: block; margin-top: 4px; }
.sidebar-section { padding: 0 16px; margin-bottom: 28px; }
.sidebar-section-label { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 2px; color: var(--text-muted); padding: 0 12px; margin-bottom: 8px; }
.nav-item { display: flex; align-items: center; padding: 10px 16px; border-radius: var(--radius-sm); color: var(--text-secondary); font-size: 13.5px; font-weight: 500; cursor: pointer; transition: all var(--transition); border: 1px solid transparent; }
.nav-item:hover { background: var(--bg-hover); color: var(--text); }
.nav-item.active { background: var(--gold-soft); color: var(--gold); border-color: rgba(122,92,14,0.15); font-weight: 600; }
.nav-badge { margin-left: auto; background: var(--bg-surface); color: var(--text-secondary); font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 10px; }
.nav-item.active .nav-badge { background: rgba(122,92,14,0.2); color: var(--gold); }
/* Nav Groups (collapsible dropdowns) */
.nav-group { margin-bottom: 4px; }
.nav-group-header { display: flex; align-items: center; padding: 10px 16px; border-radius: var(--radius-sm); color: var(--text); font-size: 13.5px; font-weight: 600; cursor: pointer; transition: all var(--transition); border: 1px solid transparent; user-select: none; }
.nav-group-header:hover { background: var(--bg-hover); }
.nav-group-header.has-active-child { color: var(--gold); }
.nav-chevron { margin-left: 8px; font-size: 9px; color: var(--text-muted); transition: transform 0.25s ease; display: inline-block; }
.nav-group.open .nav-chevron { transform: rotate(90deg); }
.nav-group-items { max-height: 0; overflow: hidden; transition: max-height 0.3s ease; }
.nav-group.open .nav-group-items { max-height: 300px; }
.nav-group-items .nav-item { padding: 7px 16px 7px 32px; font-size: 12.5px; color: var(--text-muted); }
.nav-group-items .nav-item:hover { color: var(--text); }
.nav-group-items .nav-item.active { color: var(--gold); }

.sidebar-footer { margin-top: auto; padding: 16px 24px; border-top: 1px solid var(--border); }
.sidebar-user { display: flex; align-items: center; gap: 10px; }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: linear-gradient(135deg, var(--gold), #9a7520); display: flex; align-items: center; justify-content: center; font-size: 13px; font-weight: 700; color: var(--bg-deep); }
.sidebar-user-info .name { font-size: 13px; font-weight: 600; }
.sidebar-user-info .role { font-size: 11px; color: var(--text-muted); }

.main { flex: 1; margin-left: 260px; min-height: 100vh; }
.topbar { display: flex; align-items: center; justify-content: space-between; padding: 18px 36px; border-bottom: 1px solid var(--border); background: rgba(248,249,251,0.88); backdrop-filter: blur(16px); position: sticky; top: 0; z-index: 5; }
.topbar-left h2 { font-size: 18px; font-weight: 700; }
.topbar-left p { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.topbar-actions { display: flex; gap: 10px; }
.btn { padding: 9px 16px; border-radius: var(--radius-sm); font-size: 12.5px; font-weight: 600; font-family: 'Outfit', sans-serif; cursor: pointer; transition: all var(--transition); border: 1px solid var(--border); background: var(--bg-surface); color: var(--text-secondary); }
.btn:hover { border-color: var(--border-active); color: var(--text); }
.btn-gold { background: linear-gradient(135deg, var(--gold), #9a7520); color: var(--bg-deep); border: none; font-weight: 700; }
.btn-gold:hover { opacity: 0.9; }
.container { padding: 32px 36px; max-width: 1280px; }

/* Stats */
.stats-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-bottom: 32px; }
/* Overview volume widget */
.overview-volume-widget { background: var(--bg-elevated); border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: 32px; overflow: hidden; }
.ovw-header { display: flex; justify-content: space-between; align-items: center; padding: 28px 32px; border-bottom: 1px solid var(--border); }
.ovw-header-left {}
.ovw-total-label { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 1.5px; color: var(--text-muted); margin-bottom: 6px; }
.ovw-total-value { font-size: 32px; font-weight: 800; color: var(--gold); letter-spacing: -0.5px; }
.ovw-header-right { display: flex; gap: 32px; }
.ovw-header-stat { display: flex; flex-direction: column; align-items: flex-end; }
.ovw-header-stat-label { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 1px; color: var(--text-muted); margin-bottom: 4px; }
.ovw-header-stat-value { font-size: 18px; font-weight: 700; color: var(--text); }
.ovw-sections { display: grid; grid-template-columns: repeat(4, 1fr); }
.ovw-section-card { padding: 20px 24px; cursor: pointer; transition: all var(--transition); border-right: 1px solid var(--border); }
.ovw-section-card:last-child { border-right: none; }
.ovw-section-card:hover { background: rgba(122,92,14,0.03); }
.ovw-section-label { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 1.2px; color: var(--text-muted); margin-bottom: 8px; }
.ovw-section-value { font-size: 22px; font-weight: 700; color: var(--text); margin-bottom: 4px; }
.ovw-section-meta { font-size: 12px; color: var(--text-secondary); margin-bottom: 10px; }
.ovw-section-bar { height: 3px; background: var(--border); border-radius: 2px; }
.ovw-section-bar-fill { height: 100%; background: var(--gold); border-radius: 2px; transition: width 0.6s ease; }
.stat-card { background: var(--bg-elevated); border: 1px solid var(--border); border-radius: var(--radius); padding: 24px; position: relative; overflow: hidden; transition: all var(--transition); animation: fadeUp 0.5s ease both; backdrop-filter: blur(8px); }
.stat-card:nth-child(1) { animation-delay: 0.05s; }
.stat-card:nth-child(2) { animation-delay: 0.1s; }
.stat-card:nth-child(3) { animation-delay: 0.15s; }
.stat-card:nth-child(4) { animation-delay: 0.2s; }
.stat-card:hover { border-color: var(--border-active); transform: translateY(-2px); box-shadow: 0 2px 8px rgba(0,0,0,0.06); }
.stat-card::after { content: ''; position: absolute; top: 0; left: 0; right: 0; height: 2px; opacity: 0.6; transition: opacity var(--transition); }
.stat-card:hover::after { opacity: 1; }
.stat-card:nth-child(1)::after { background: linear-gradient(90deg, var(--gold), transparent); }
.stat-card:nth-child(2)::after { background: linear-gradient(90deg, var(--emerald), transparent); }
.stat-card:nth-child(3)::after { background: linear-gradient(90deg, var(--sky), transparent); }
.stat-card:nth-child(4)::after { background: linear-gradient(90deg, var(--amber), transparent); }
.stat-label { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 1.5px; color: var(--text-muted); margin-bottom: 16px; }
.stat-value { font-family: 'Playfair Display', serif; font-size: 34px; font-weight: 700; line-height: 1; letter-spacing: -1px; }
.stat-value.gold { color: var(--gold); }
.stat-sub { font-size: 12px; color: var(--text-muted); margin-top: 10px; }
.stat-bar { height: 4px; border-radius: 2px; margin-top: 14px; background: var(--bg); overflow: hidden; }
.stat-bar-fill { height: 100%; border-radius: 2px; transition: width 0.8s ease; }
.stat-bar-fill.gold { background: linear-gradient(90deg, var(--gold), rgba(122,92,14,0.4)); }
.stat-bar-fill.emerald { background: linear-gradient(90deg, var(--emerald), rgba(52,211,153,0.4)); }
.stat-bar-fill.sky { background: linear-gradient(90deg, var(--sky), rgba(56,189,248,0.4)); }
.stat-bar-fill.amber { background: linear-gradient(90deg, var(--amber), rgba(251,191,36,0.4)); }

/* Charts */
.charts-row { display: grid; grid-template-columns: 1.4fr 1fr; gap: 16px; margin-bottom: 32px; }
.charts-row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 32px; }
.chart-card { background: #ffffff; border: 1px solid var(--border); border-radius: var(--radius); padding: 28px; box-shadow: 0 1px 3px rgba(0,0,0,0.03); transition: border-color var(--transition); }
.chart-card:hover { border-color: var(--border-active); }
.chart-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 24px; }
.chart-title { font-size: 14px; font-weight: 600; }
.chart-subtitle { font-size: 11px; color: var(--text-muted); margin-top: 2px; }
.chart-container { position: relative; height: 260px; }

/* Search */
.search-bar { display: flex; gap: 10px; }
.search-input { background: var(--bg-elevated); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 9px 14px 9px 36px; color: var(--text); font-size: 12.5px; font-family: 'Outfit', sans-serif; width: 280px; transition: border-color var(--transition); background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%234d5570' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='8'/%3E%3Cline x1='21' y1='21' x2='16.65' y2='16.65'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: 12px center; }
.search-input:focus { outline: none; border-color: var(--gold); }
.search-input::placeholder { color: var(--text-muted); }
.filter-select { background: var(--bg-elevated); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 9px 14px; color: var(--text); font-size: 12px; font-weight: 600; font-family: 'Outfit', sans-serif; cursor: pointer; transition: border-color var(--transition); }
.filter-select:focus { outline: none; border-color: var(--gold); }
.filter-select option { background: var(--bg-elevated); color: var(--text); }

/* Table */
.table-section { animation: fadeUp 0.5s ease both; animation-delay: 0.3s; }
.table-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.table-title-group h3 { font-size: 16px; font-weight: 700; }
.table-title-group p { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.table-wrap { background: #ffffff; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; box-shadow: 0 1px 3px rgba(0,0,0,0.03); }
.table-scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
thead th { text-align: left; padding: 14px 18px; font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: 1.5px; color: var(--text-muted); border-bottom: 1px solid var(--border); white-space: nowrap; background: var(--bg-surface); cursor: pointer; user-select: none; }
thead th:hover { color: var(--text-secondary); }
thead th.sorted { color: var(--gold); }
tbody tr { border-bottom: 1px solid #f0f1f4; transition: background var(--transition); cursor: pointer; }
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: var(--bg-hover); }
tbody td { padding: 14px 18px; font-size: 13px; white-space: nowrap; }
.cell-name { font-weight: 600; display: flex; align-items: center; gap: 10px; }
.cell-avatar { width: 30px; height: 30px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 700; flex-shrink: 0; }
.amount { font-variant-numeric: tabular-nums; font-weight: 600; }
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 4px 10px; border-radius: 20px; font-size: 11px; font-weight: 600; }
.badge-active { background: var(--emerald-soft); color: var(--emerald); }
.badge-disabled { background: var(--rose-soft); color: var(--rose); }
.badge-open { background: var(--sky-soft); color: var(--sky); }
.badge-dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.contract-select { padding: 4px 8px; border-radius: 20px; font-size: 11px; font-weight: 600; border: none; cursor: pointer; font-family: 'Outfit', sans-serif; appearance: auto; }
.contract-yes { background: var(--emerald-soft); color: var(--emerald); }
.contract-no { background: var(--rose-soft); color: var(--rose); }
.contract-unknown { background: var(--sky-soft); color: var(--sky); }
.interest-bar { display: flex; align-items: center; gap: 8px; }
.interest-track { width: 48px; height: 4px; background: var(--bg); border-radius: 2px; overflow: hidden; }
.interest-fill { height: 100%; border-radius: 2px; background: var(--gold); }

/* Upcoming */
.upcoming-split-row { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; margin-bottom: 32px; }
@media (max-width: 900px) { .upcoming-split-row { grid-template-columns: 1fr; } }
.upcoming-panel { background: #ffffff; border: 1px solid var(--border); border-radius: var(--radius); padding: 24px; margin-bottom: 0; box-shadow: 0 1px 3px rgba(0,0,0,0.03); }
.upcoming-item { display: flex; align-items: center; justify-content: space-between; padding: 14px 0; border-bottom: 1px solid #f0f1f4; }
.upcoming-item:last-child { border-bottom: none; }
.upcoming-left { display: flex; align-items: center; gap: 14px; }
.upcoming-date-box { width: 44px; height: 44px; border-radius: var(--radius-sm); display: flex; flex-direction: column; align-items: center; justify-content: center; font-weight: 700; line-height: 1; }
.upcoming-date-box .month { font-size: 9px; text-transform: uppercase; letter-spacing: 1px; }
.upcoming-date-box .day { font-size: 17px; margin-top: 1px; }
.upcoming-date-box.urgent { background: var(--rose-soft); color: var(--rose); }
.upcoming-date-box.soon { background: var(--amber-soft); color: var(--amber); }
.upcoming-date-box.ok { background: var(--emerald-soft); color: var(--emerald); }
.upcoming-info .uname { font-weight: 600; font-size: 13.5px; }
.upcoming-info .meta { font-size: 11.5px; color: var(--text-muted); margin-top: 2px; }
.upcoming-amount { font-family: 'Playfair Display', serif; font-size: 18px; font-weight: 700; color: var(--gold); }

/* Upcoming redesign */
.upcoming-grid { display: grid; gap: 10px; }
.upcoming-card { display: flex; align-items: center; gap: 16px; background: var(--bg-surface); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 16px 20px; cursor: pointer; transition: all var(--transition); position: relative; overflow: hidden; }
.upcoming-card:hover { border-color: var(--border-active); transform: translateX(4px); }
.upcoming-card::before { content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; }
.upcoming-card.urg-urgent::before { background: var(--rose); }
.upcoming-card.urg-soon::before { background: var(--amber); }
.upcoming-card.urg-ok::before { background: var(--emerald); }
.upcoming-card-date { min-width: 52px; text-align: center; }
.upcoming-card-date .day { font-family: 'Playfair Display', serif; font-size: 24px; font-weight: 700; line-height: 1; }
.upcoming-card-date .month-year { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 1px; color: var(--text-muted); margin-top: 2px; }
.upcoming-card.urg-urgent .upcoming-card-date .day { color: var(--rose); }
.upcoming-card.urg-soon .upcoming-card-date .day { color: var(--amber); }
.upcoming-card.urg-ok .upcoming-card-date .day { color: var(--emerald); }
.upcoming-card-info { flex: 1; min-width: 0; }
.upcoming-card-name { font-size: 14px; font-weight: 600; }
.upcoming-card-details { font-size: 11.5px; color: var(--text-secondary); margin-top: 3px; display: flex; gap: 12px; flex-wrap: wrap; }
.upcoming-card-detail { display: flex; align-items: center; gap: 4px; }
.upcoming-card-right { text-align: right; min-width: 100px; }
.upcoming-card-amount { font-family: 'Playfair Display', serif; font-size: 20px; font-weight: 700; }
.upcoming-card.urg-urgent .upcoming-card-amount { color: var(--rose); }
.upcoming-card.urg-soon .upcoming-card-amount { color: var(--amber); }
.upcoming-card.urg-ok .upcoming-card-amount { color: var(--emerald); }
.upcoming-card-days { font-size: 11px; font-weight: 600; margin-top: 3px; }
.upcoming-card.urg-urgent .upcoming-card-days { color: var(--rose); }
.upcoming-card.urg-soon .upcoming-card-days { color: var(--amber); }
.upcoming-card.urg-ok .upcoming-card-days { color: var(--text-muted); }
.upcoming-summary-pill { display: flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 20px; font-size: 12px; font-weight: 600; }
.upcoming-summary-pill.urgent { background: var(--rose-soft); color: var(--rose); }
.upcoming-summary-pill.soon { background: var(--amber-soft); color: var(--amber); }
.upcoming-summary-pill.ok { background: var(--emerald-soft); color: var(--emerald); }
.upcoming-summary-total { font-family: 'Playfair Display', serif; font-size: 16px; font-weight: 700; color: var(--gold); }

/* Detail panel */
.detail-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.6); z-index: 200; backdrop-filter: blur(4px); }
.detail-overlay.open { display: flex; justify-content: flex-end; }
.detail-panel { width: 540px; max-width: 90vw; background: var(--bg); border-left: 1px solid var(--border); height: 100vh; overflow-y: auto; padding: 32px; animation: slideIn 0.25s ease; }
@keyframes slideIn { from { transform: translateX(100%); } to { transform: translateX(0); } }
.detail-panel .close-btn { background: var(--bg-surface); border: 1px solid var(--border); color: var(--text-muted); width: 32px; height: 32px; border-radius: 8px; cursor: pointer; font-size: 16px; display: flex; align-items: center; justify-content: center; margin-bottom: 24px; }
.detail-panel h2 { font-family: 'Playfair Display', serif; font-size: 24px; margin-bottom: 4px; }
.detail-meta { color: var(--text-secondary); font-size: 13px; margin-bottom: 24px; }
.detail-section { margin-bottom: 24px; }
.detail-section h4 { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 1.5px; color: var(--text-muted); margin-bottom: 12px; padding-bottom: 8px; border-bottom: 1px solid var(--border); }
.detail-row { display: flex; justify-content: space-between; padding: 8px 0; font-size: 13px; }
.detail-row .dlabel { color: var(--text-secondary); }
.detail-row .dvalue { font-weight: 600; }
.loan-card { background: var(--bg-elevated); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 16px; margin-bottom: 10px; }
.loan-card-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.loan-card-header .contract-num { font-weight: 600; font-size: 14px; }
.loan-card-rows { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 16px; font-size: 12px; }
.loan-card-rows .lbl { color: var(--text-secondary); }

/* Edit mode */
.edit-btn { background: var(--bg-surface); border: 1px solid var(--border); color: var(--text-secondary); padding: 6px 14px; border-radius: var(--radius-sm); font-size: 11px; font-weight: 600; cursor: pointer; font-family: 'Outfit', sans-serif; transition: all var(--transition); }
.edit-btn:hover { border-color: var(--border-active); color: var(--text); }
.edit-btn.editing { background: var(--gold-soft); color: var(--gold); border-color: rgba(122,92,14,0.3); }
.save-btn { background: linear-gradient(135deg, var(--gold), #9a7520); color: var(--bg-deep); border: none; padding: 8px 18px; border-radius: var(--radius-sm); font-size: 12px; font-weight: 700; cursor: pointer; font-family: 'Outfit', sans-serif; transition: all var(--transition); }
.save-btn:hover { opacity: 0.9; transform: translateY(-1px); }
.cancel-btn { background: var(--bg-surface); border: 1px solid var(--border); color: var(--text-secondary); padding: 8px 18px; border-radius: var(--radius-sm); font-size: 12px; font-weight: 600; cursor: pointer; font-family: 'Outfit', sans-serif; }
.cancel-btn:hover { border-color: var(--border-active); color: var(--text); }
.delete-btn { background: var(--rose-soft); border: 1px solid transparent; color: var(--rose); padding: 8px 18px; border-radius: var(--radius-sm); font-size: 12px; font-weight: 600; cursor: pointer; font-family: 'Outfit', sans-serif; margin-left: auto; transition: all var(--transition); }
.delete-btn:hover { background: var(--rose); color: white; }
.edit-actions { display: flex; gap: 8px; margin-top: 16px; }
.edit-input { background: var(--bg-surface); border: 1px solid var(--border); border-radius: 6px; padding: 6px 10px; color: var(--text); font-size: 12px; font-family: 'Outfit', sans-serif; width: 100%; transition: border-color var(--transition); }
.edit-input:focus { outline: none; border-color: var(--gold); }
.edit-select { background: var(--bg-surface); border: 1px solid var(--border); border-radius: 6px; padding: 6px 10px; color: var(--text); font-size: 12px; font-family: 'Outfit', sans-serif; width: 100%; }
.edit-select option { background: var(--bg-surface); color: var(--text); }
.detail-header-row { display: flex; align-items: center; justify-content: space-between; margin-bottom: 4px; }
.save-toast { position: fixed; bottom: 24px; right: 24px; background: var(--emerald); color: var(--bg-deep); padding: 12px 20px; border-radius: var(--radius-sm); font-weight: 600; font-size: 13px; z-index: 300; animation: fadeUp 0.3s ease; }
.upload-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.7); z-index: 250; display: flex; align-items: center; justify-content: center; backdrop-filter: blur(8px); }
.upload-card { background: var(--bg-elevated); border: 1px solid var(--border); border-radius: var(--radius); padding: 40px; text-align: center; max-width: 400px; width: 90%; }
.upload-card h3 { font-size: 18px; font-weight: 700; margin-bottom: 8px; }
.upload-card p { font-size: 13px; color: var(--text-secondary); margin-bottom: 20px; }
.upload-spinner { width: 40px; height: 40px; border: 3px solid var(--border); border-top-color: var(--gold); border-radius: 50%; animation: spin 0.8s linear infinite; margin: 0 auto 16px; }
@keyframes spin { to { transform: rotate(360deg); } }
.upload-card .filename { font-size: 12px; color: var(--text-muted); margin-top: 8px; word-break: break-all; }

/* Chat Panel */
.chat-fab { position: fixed; bottom: 24px; right: 24px; width: 56px; height: 56px; border-radius: 50%; background: linear-gradient(135deg, var(--gold), #9a7520); border: none; color: var(--bg-deep); font-size: 24px; cursor: pointer; z-index: 199; box-shadow: 0 4px 20px rgba(122,92,14,0.4); transition: all var(--transition); display: flex; align-items: center; justify-content: center; }
.chat-fab:hover { transform: scale(1.08); box-shadow: 0 6px 28px rgba(122,92,14,0.5); }
.chat-fab.has-badge::after { content: ''; position: absolute; top: 2px; right: 2px; width: 12px; height: 12px; background: var(--rose); border-radius: 50%; border: 2px solid var(--bg-deep); }
.chat-panel { position: fixed; bottom: 96px; right: 24px; width: 420px; max-width: calc(100vw - 48px); height: 560px; max-height: calc(100vh - 140px); background: var(--bg-deep); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: 0 12px 48px rgba(0,0,0,0.5); z-index: 200; display: none; flex-direction: column; overflow: hidden; animation: chatSlideUp 0.25s ease; }
.chat-panel.open { display: flex; }
@keyframes chatSlideUp { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: translateY(0); } }
.chat-header { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--border); background: var(--bg-elevated); }
.chat-header-left { display: flex; align-items: center; gap: 10px; }
.chat-header-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--emerald); }
.chat-header h4 { font-size: 14px; font-weight: 600; }
.chat-header-actions { display: flex; gap: 6px; }
.chat-header-btn { background: var(--bg-surface); border: 1px solid var(--border); color: var(--text-muted); width: 28px; height: 28px; border-radius: 6px; cursor: pointer; font-size: 12px; display: flex; align-items: center; justify-content: center; transition: all var(--transition); }
.chat-header-btn:hover { border-color: var(--border-active); color: var(--text); }
.chat-messages { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 12px; }
.chat-msg { max-width: 85%; padding: 10px 14px; border-radius: 12px; font-size: 13px; line-height: 1.5; word-wrap: break-word; }
.chat-msg.user { align-self: flex-end; background: var(--gold-soft); color: var(--text); border-bottom-right-radius: 4px; }
.chat-msg.bot { align-self: flex-start; background: var(--bg-surface); color: var(--text); border-bottom-left-radius: 4px; border: 1px solid var(--border); }
.chat-msg.bot .msg-text { white-space: pre-wrap; }
.chat-msg .msg-time { font-size: 10px; color: var(--text-muted); margin-top: 4px; }
.chat-msg.typing .dots { display: inline-flex; gap: 4px; }
.chat-msg.typing .dots span { width: 6px; height: 6px; border-radius: 50%; background: var(--text-muted); animation: bounce 1.2s infinite; }
.chat-msg.typing .dots span:nth-child(2) { animation-delay: 0.2s; }
.chat-msg.typing .dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes bounce { 0%, 80%, 100% { transform: translateY(0); } 40% { transform: translateY(-6px); } }
.chat-action-card { background: var(--bg-elevated); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 12px; margin-top: 8px; }
.chat-action-card .action-title { font-size: 12px; font-weight: 600; margin-bottom: 8px; color: var(--gold); }
.chat-action-card .action-row { display: flex; justify-content: space-between; font-size: 12px; padding: 3px 0; }
.chat-action-card .action-row .alabel { color: var(--text-secondary); }
.chat-action-card .action-buttons { display: flex; gap: 6px; margin-top: 10px; }
.chat-action-card .action-btn { padding: 6px 12px; border-radius: 6px; font-size: 11px; font-weight: 600; cursor: pointer; border: 1px solid var(--border); background: var(--bg-surface); color: var(--text-secondary); font-family: 'Outfit', sans-serif; transition: all var(--transition); }
.chat-action-card .action-btn:hover { border-color: var(--border-active); color: var(--text); }
.chat-action-card .action-btn.primary { background: var(--gold-soft); color: var(--gold); border-color: rgba(122,92,14,0.3); }
.chat-action-card .action-btn.primary:hover { background: rgba(122,92,14,0.25); }
.chat-input-area { display: flex; gap: 8px; padding: 12px 16px; border-top: 1px solid var(--border); background: var(--bg-elevated); }
.chat-input { flex: 1; background: var(--bg-surface); border: 1px solid var(--border); border-radius: 20px; padding: 10px 16px; color: var(--text); font-size: 13px; font-family: 'Outfit', sans-serif; resize: none; outline: none; transition: border-color var(--transition); }
.chat-input:focus { border-color: var(--gold); }
.chat-input::placeholder { color: var(--text-muted); }
.chat-send { width: 38px; height: 38px; border-radius: 50%; background: var(--gold); border: none; color: var(--bg-deep); font-size: 16px; cursor: pointer; display: flex; align-items: center; justify-content: center; transition: all var(--transition); flex-shrink: 0; }
.chat-send:hover { opacity: 0.85; }
.chat-send:disabled { opacity: 0.4; cursor: default; }

.tab-content { display: none; }
.tab-content.active { display: block; }
.empty-state { text-align: center; padding: 48px; color: var(--text-muted); font-size: 14px; }

/* Drill-down sidebar */
.drilldown-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.6); z-index: 250; backdrop-filter: blur(4px); }
.drilldown-overlay.open { display: flex; justify-content: flex-end; }
.drilldown-panel { width: 600px; max-width: 90vw; background: var(--bg); border-left: 1px solid var(--border); height: 100vh; overflow-y: auto; padding: 32px; animation: slideIn 0.25s ease; }
.drilldown-panel h3 { font-family: 'Playfair Display', serif; font-size: 22px; font-weight: 700; margin-bottom: 4px; }
.drilldown-panel .drilldown-sub { font-size: 12px; color: var(--text-muted); margin-bottom: 20px; }
.drilldown-table { width: 100%; border-collapse: collapse; margin-top: 8px; }
.drilldown-table th { text-align: left; padding: 10px 14px; font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 1.2px; color: var(--text-muted); border-bottom: 1px solid var(--border); background: var(--bg-surface); position: sticky; top: 0; }
.drilldown-table td { padding: 10px 14px; font-size: 12.5px; border-bottom: 1px solid #f0f1f4; }
.drilldown-table tr { cursor: pointer; transition: background var(--transition); }
.drilldown-table tr:hover { background: var(--bg-hover); }
.drilldown-total { display: flex; justify-content: space-between; padding: 16px 0; margin-top: 8px; border-top: 1px solid var(--border); font-weight: 600; font-size: 13px; }
.drilldown-total .dt-value { color: var(--gold); font-family: 'Playfair Display', serif; font-size: 16px; }

/* Filter labels */
.ctrl-group-wrap { display: flex; flex-direction: column; gap: 4px; }
.ctrl-group-label { font-size: 9px; font-weight: 700; text-transform: uppercase; letter-spacing: 1.2px; color: var(--text-muted); }

/* Payment method badges */
.badge-transfer { background: rgba(251,191,36,0.1); color: var(--amber); }
.badge-standing { background: rgba(52,211,153,0.1); color: var(--emerald); }
.badge-debit { background: rgba(56,189,248,0.1); color: var(--sky); }

/* Interest billing section */
.interest-billing-card { background: var(--bg-surface); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 14px 18px; margin-bottom: 8px; display: flex; align-items: center; justify-content: space-between; transition: all var(--transition); cursor: pointer; }
.interest-billing-card:hover { border-color: var(--border-active); transform: translateX(4px); }
.interest-billing-left { display: flex; align-items: center; gap: 14px; }
.interest-billing-icon { width: 40px; height: 40px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 700; letter-spacing: 0.5px; }
.interest-billing-icon.soon { background: var(--amber-soft); color: var(--amber); }
.interest-billing-icon.ok { background: var(--emerald-soft); color: var(--emerald); }
.interest-billing-info .ib-name { font-weight: 600; font-size: 13px; }
.interest-billing-info .ib-meta { font-size: 11px; color: var(--text-secondary); margin-top: 2px; }
.interest-billing-right { text-align: right; }
.interest-billing-amount { font-family: 'Playfair Display', serif; font-size: 18px; font-weight: 700; color: var(--gold); }
.interest-billing-date { font-size: 11px; color: var(--text-muted); margin-top: 2px; }

/* Go-to-lender button in loan detail */
.goto-lender-btn { display: block; width: 100%; margin-top: 20px; padding: 14px; background: var(--bg-surface); border: 1px solid var(--border); border-radius: var(--radius-sm); color: var(--gold); font-weight: 600; font-size: 14px; cursor: pointer; transition: all var(--transition); text-align: center; }
.goto-lender-btn:hover { border-color: var(--gold); background: var(--gold-soft); }

/* Cost overview stats */
.cost-stats-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-bottom: 24px; }
.cost-stat { background: var(--bg-surface); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 16px; text-align: center; }
.cost-stat .cs-label { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 1.2px; color: var(--text-muted); margin-bottom: 8px; }
.cost-stat .cs-value { font-family: 'Playfair Display', serif; font-size: 22px; font-weight: 700; color: var(--gold); }
.cost-stat .cs-sub { font-size: 11px; color: var(--text-secondary); margin-top: 4px; }

@keyframes fadeUp { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: translateY(0); } }

/* Main Analytics Chart */
.top-lender-row { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid #f0f1f4; }
.top-lender-row:last-child { border-bottom: none; }
.top-lender-rank { font-size: 11px; font-weight: 700; color: var(--text-muted); width: 20px; text-align: center; }
.top-lender-rank.gold { color: var(--gold); }
.top-lender-info { flex: 1; min-width: 0; }
.top-lender-name { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.top-lender-meta { font-size: 11px; color: var(--text-muted); margin-top: 1px; }
.top-lender-bar-wrap { flex: 1; max-width: 200px; }
.top-lender-bar { height: 6px; border-radius: 3px; background: var(--bg); overflow: hidden; }
.top-lender-bar-fill { height: 100%; border-radius: 3px; background: linear-gradient(90deg, var(--gold), rgba(122,92,14,0.4)); transition: width 0.6s ease; }
.top-lender-amount { font-size: 13px; font-weight: 700; color: var(--gold); min-width: 90px; text-align: right; }
.status-stat-row { display: flex; align-items: center; justify-content: space-between; padding: 12px 0; border-bottom: 1px solid #f0f1f4; }
.status-stat-row:last-child { border-bottom: none; }
.status-stat-left { display: flex; align-items: center; gap: 10px; }
.status-stat-dot { width: 10px; height: 10px; border-radius: 3px; }
.status-stat-label { font-size: 13px; font-weight: 500; }
.status-stat-right { text-align: right; }
.status-stat-count { font-size: 18px; font-weight: 700; font-family: 'Playfair Display', serif; }
.status-stat-pct { font-size: 11px; color: var(--text-muted); }
.analytics-card { background: #ffffff; border: 1px solid var(--border); border-radius: var(--radius); padding: 28px; margin-bottom: 32px; box-shadow: 0 1px 3px rgba(0,0,0,0.03); }
.analytics-header { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 20px; flex-wrap: wrap; gap: 16px; }
.analytics-header-left h3 { font-size: 18px; font-weight: 700; letter-spacing: -0.3px; }
.analytics-header-left p { font-size: 12px; color: var(--text-muted); margin-top: 3px; }
.analytics-controls { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.ctrl-group { display: flex; gap: 2px; background: var(--bg-deep); border-radius: var(--radius-sm); padding: 3px; border: 1px solid var(--border); }
.ctrl-btn { padding: 6px 14px; border-radius: 6px; font-size: 11px; font-weight: 600; color: var(--text-muted); cursor: pointer; border: none; background: transparent; font-family: 'Outfit', sans-serif; transition: all var(--transition); white-space: nowrap; }
.ctrl-btn:hover { color: var(--text-secondary); }
.ctrl-btn.active { background: var(--gold-soft); color: var(--gold); }
.ctrl-btn.active-emerald { background: var(--emerald-soft); color: var(--emerald); }
.ctrl-btn.active-sky { background: var(--sky-soft); color: var(--sky); }
.ctrl-select { background: var(--bg-deep); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 6px 10px; color: var(--text); font-size: 11px; font-weight: 600; font-family: 'Outfit', sans-serif; cursor: pointer; }
.ctrl-select option { background: var(--bg-deep); color: var(--text); }
.analytics-row2 { display: flex; gap: 8px; align-items: center; margin-bottom: 20px; flex-wrap: wrap; }
.ctrl-label { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 1.2px; color: var(--text-muted); margin-right: 4px; }
.ctrl-date { background: var(--bg-deep); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 6px 10px; color: var(--text); font-size: 11px; font-family: 'Outfit', sans-serif; }
.ctrl-date::-webkit-calendar-picker-indicator { filter: invert(0.7); }
.analytics-summary { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-bottom: 20px; }
.analytics-summary .summary-card { background: var(--bg-surface); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 16px 20px; }
.analytics-summary .summary-label { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 1.5px; color: var(--text-muted); margin-bottom: 6px; }
.analytics-summary .summary-value { font-size: 22px; font-weight: 700; }
.analytics-summary .summary-sub { font-size: 11px; color: var(--text-muted); margin-top: 4px; }
.analytics-chart-wrap { position: relative; height: 360px; }
.analytics-legend { display: flex; gap: 20px; margin-top: 16px; flex-wrap: wrap; }
.legend-item { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--text-secondary); cursor: pointer; padding: 4px 8px; border-radius: 6px; transition: all var(--transition); }
.legend-item:hover { background: var(--bg-hover); }
.legend-item.dimmed { opacity: 0.35; }
.legend-dot { width: 10px; height: 10px; border-radius: 3px; }
.legend-value { font-weight: 600; color: var(--text); margin-left: 4px; }

/* Analytics payments list */
.ap-card { background: var(--bg-surface); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 12px 16px; margin-bottom: 6px; display: flex; align-items: center; justify-content: space-between; transition: all var(--transition); cursor: pointer; }
.ap-card:hover { border-color: var(--border-active); transform: translateX(4px); }
.ap-card:last-child { margin-bottom: 0; }
.ap-paid { border-left: 3px solid var(--emerald); opacity: 0.6; }
.ap-paid:hover { opacity: 1; }
.ap-due { border-left: 3px solid var(--amber); }
.ap-today { border-left: 3px solid var(--gold); border-color: var(--gold); background: var(--gold-soft); }
.ap-left { display: flex; align-items: center; gap: 12px; min-width: 0; }
.ap-day-box { min-width: 36px; height: 36px; border-radius: 8px; background: var(--bg-hover); display: flex; flex-direction: column; align-items: center; justify-content: center; flex-shrink: 0; padding: 2px 6px; }
.ap-day { font-weight: 700; font-size: 14px; color: var(--text); line-height: 1; }
.ap-month { font-size: 9px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; line-height: 1; margin-top: 1px; }
.ap-paid .ap-day-box { background: var(--emerald-soft); }
.ap-paid .ap-day { color: var(--emerald); }
.ap-due .ap-day-box { background: var(--amber-soft); }
.ap-due .ap-day { color: var(--amber); }
.ap-today .ap-day-box { background: var(--gold-soft); }
.ap-today .ap-day { color: var(--gold); }
.ap-info { min-width: 0; }
.ap-name { font-weight: 600; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ap-meta { display: flex; align-items: center; gap: 8px; font-size: 11px; color: var(--text-secondary); margin-top: 2px; flex-wrap: wrap; }
.ap-type { font-weight: 600; padding: 1px 6px; border-radius: 4px; font-size: 10px; text-transform: uppercase; letter-spacing: 0.5px; }
.badge-zins { background: var(--sky-soft); color: var(--sky); }
.badge-rate { background: var(--emerald-soft); color: var(--emerald); }
.badge-annuitaet { background: var(--gold-soft); color: var(--gold); }
.ap-breakdown { display: block; font-size: 10px; color: var(--text-muted); margin-top: 2px; letter-spacing: 0.3px; }
.ap-right { text-align: right; flex-shrink: 0; margin-left: 12px; }
.ap-amount { font-weight: 700; font-size: 14px; }
.ap-paid .ap-amount { color: var(--emerald); }
.ap-due .ap-amount { color: var(--amber); }
.ap-status { font-size: 11px; color: var(--text-muted); margin-top: 2px; }
.ap-today .ap-status { color: var(--gold); font-weight: 600; }
.ap-done { color: var(--emerald); font-weight: 600; }
.ap-today-dot { color: var(--gold); }

@media (max-width: 1100px) { .stats-grid { grid-template-columns: repeat(2, 1fr); } .charts-row, .charts-row-2 { grid-template-columns: 1fr; } }
@media (max-width: 768px) {
  .sidebar { display: none; position: fixed; top: 0; left: 0; bottom: 0; z-index: 1000; width: 260px; }
  .sidebar.open { display: flex; flex-direction: column; }
  #sidebar-backdrop { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: 999; }
  #sidebar-backdrop.open { display: block; }
  .hamburger { display: flex; }
  .main { margin-left: 0; }
  .stats-grid { grid-template-columns: 1fr; }
  .container { padding: 20px 16px; }
}

/* Hamburger */
.hamburger { display: none; background: none; border: 1px solid var(--border); color: var(--text); font-size: 20px; padding: 6px 10px; border-radius: var(--radius-sm); cursor: pointer; align-items: center; justify-content: center; margin-right: 12px; }
.hamburger:hover { background: var(--bg-hover); }

/* Loading spinner */
#loading-spinner { position: fixed; inset: 0; background: rgba(8,9,12,0.7); z-index: 2000; align-items: center; justify-content: center; }
.spinner-ring { width: 48px; height: 48px; border: 3px solid var(--border); border-top-color: var(--gold); border-radius: 50%; animation: spin 0.8s linear infinite; }

/* Payment form */
.payment-actions { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--border); }
.payment-record-btn { font-size: 12px; padding: 6px 14px; background: var(--emerald-soft); color: var(--emerald); border: 1px solid rgba(52,211,153,0.2); }
.payment-record-btn:hover { background: rgba(52,211,153,0.2); }
.payment-form { margin-top: 12px; padding: 16px; background: var(--bg-deep); border-radius: var(--radius-sm); border: 1px solid var(--border); }
::-webkit-scrollbar { width: 6px; } ::-webkit-scrollbar-track { background: transparent; } ::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
