:root { color-scheme: light dark; }
* { box-sizing: border-box; }
body { font-family: -apple-system, Segoe UI, Roboto, sans-serif; margin: 0; background: #0f1115; color: #e8e8e8; }

/* ---- layout: collapsible left rail + content area ---- */
.app-shell { display: flex; min-height: 100vh; }

.sidebar { width: 220px; background: #14161c; border-right: 1px solid #2c2f38; flex-shrink: 0; transition: width .15s ease; display: flex; flex-direction: column; }
.sidebar.collapsed { width: 56px; }
.sidebar-header { display: flex; align-items: center; justify-content: space-between; padding: 14px 12px; border-bottom: 1px solid #2c2f38; }
.sidebar-brand { display: flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 700; color: #e8e8e8; white-space: nowrap; overflow: hidden; }
.sidebar-brand img { width: 20px; height: 20px; flex-shrink: 0; }
.sidebar.collapsed .sidebar-brand span { display: none; }
.sidebar-toggle { background: none; border: none; color: #9aa0a6; cursor: pointer; font-size: 14px; padding: 4px 6px; }
.sidebar-toggle:hover { color: #e8e8e8; }

.sidebar-nav { flex: 1; padding: 10px 8px; overflow-y: auto; }
.sidebar-section-label { font-size: 10px; text-transform: uppercase; letter-spacing: .07em; color: #6b7078; padding: 12px 8px 4px; white-space: nowrap; overflow: hidden; }
.sidebar.collapsed .sidebar-section-label { visibility: hidden; height: 4px; padding: 8px 0 0; }
.sidebar-link { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 6px; color: #c7cad1; text-decoration: none; font-size: 13px; margin-bottom: 2px; white-space: nowrap; overflow: hidden; }
.sidebar-link:hover { background: #1b1e26; color: #e8e8e8; }
.sidebar-link.active { background: #1c2432; color: #6ec6ff; }
.sidebar-link .icon { width: 16px; flex-shrink: 0; text-align: center; }
.sidebar.collapsed .sidebar-link span.label { display: none; }

.sidebar-footer { padding: 10px; border-top: 1px solid #2c2f38; }
.sidebar-user { font-size: 12px; color: #9aa0a6; white-space: nowrap; overflow: hidden; margin-bottom: 6px; }
.sidebar.collapsed .sidebar-user, .sidebar.collapsed .sidebar-footer-btns span { display: none; }
.sidebar-footer-btns { display: flex; flex-direction: column; gap: 4px; }

.content { flex: 1; padding: 24px 28px; min-width: 0; }
.content h1 { font-size: 20px; margin: 0 0 4px 0; }
.sub { color: #9aa0a6; font-size: 13px; margin-bottom: 20px; }

/* ---- common components ---- */
.panel { background: #171a21; border: 1px solid #2c2f38; border-radius: 8px; padding: 14px 16px; margin-bottom: 16px; }
.panel-title { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: #9aa0a6; margin-bottom: 10px; }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; margin-bottom: 10px; }
.row:last-child { margin-bottom: 0; }
label { font-size: 13px; color: #9aa0a6; display: flex; align-items: center; gap: 6px; }
select, input, textarea, button { background: #1b1e26; color: #e8e8e8; border: 1px solid #2c2f38; border-radius: 6px; padding: 6px 10px; font-size: 13px; font-family: inherit; }
input[type="checkbox"] { width: 15px; height: 15px; }
button { cursor: pointer; }
button:hover:not(:disabled) { border-color: #4a90e2; }
button:disabled { opacity: .4; cursor: not-allowed; }
button.primary { background: #2563eb; border-color: #2563eb; color: white; }
button.danger:hover { border-color: #e5636b; color: #e5636b; }

table { border-collapse: collapse; width: 100%; font-size: 13px; }
th, td { padding: 7px 9px; text-align: right; border-bottom: 1px solid #2c2f38; white-space: nowrap; }
th:first-child, td:first-child, th:nth-child(2), td:nth-child(2) { text-align: left; }
th { color: #9aa0a6; font-weight: 600; position: sticky; top: 0; background: #0f1115; }
tr:hover { background: #171a21; }
.pos { color: #4caf7d; }
.neg { color: #e5636b; }
.group-tag { display: inline-block; font-size: 11px; padding: 1px 7px; border-radius: 10px; background: #22262f; border: 1px solid #2c2f38; color: #9aa0a6; }
.empty { color: #9aa0a6; padding: 40px 0; text-align: center; }
.table-wrap { max-height: 70vh; overflow: auto; border: 1px solid #2c2f38; border-radius: 8px; }
.icon-btn { padding: 3px 7px; font-size: 12px; margin-left: 4px; }

.modal-backdrop { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.6); align-items: center; justify-content: center; z-index: 50; }
.modal-backdrop.open { display: flex; }
.modal { background: #171a21; border: 1px solid #2c2f38; border-radius: 10px; padding: 20px; width: 420px; max-width: 90vw; max-height: 85vh; overflow-y: auto; }
.modal h3 { margin: 0 0 14px 0; font-size: 15px; }
.modal .field { display: flex; flex-direction: column; gap: 4px; margin-bottom: 12px; }
.modal .field label { font-size: 12px; }
.modal .field input, .modal .field select, .modal .field textarea { width: 100%; box-sizing: border-box; }
.modal .buttons { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }

.auth-overlay { position: fixed; inset: 0; background: #0f1115; display: flex; align-items: center; justify-content: center; z-index: 100; }
.auth-box { background: #171a21; border: 1px solid #2c2f38; border-radius: 10px; padding: 32px; width: 340px; max-width: 90vw; }
.auth-box h2 { margin: 0 0 4px 0; font-size: 18px; }
.auth-box .sub { margin-bottom: 18px; }
.auth-box .field { display: flex; flex-direction: column; gap: 4px; margin-bottom: 12px; }
.auth-box .field input { width: 100%; box-sizing: border-box; }
.auth-box button.primary { width: 100%; padding: 8px; margin-top: 6px; }
.auth-error { color: #e5636b; font-size: 12px; margin-top: 8px; min-height: 14px; }
.auth-link { color: #4a90e2; font-size: 12px; cursor: pointer; text-align: center; margin-top: 12px; }
.auth-link:hover { text-decoration: underline; }

.badge { display: inline-block; padding: 2px 8px; border-radius: 10px; font-size: 11px; font-weight: 700; color: white; }

/* ---- Sidebar footer version + copyright ---- */
.sidebar-version { font-size: 11px; color: #4a90e2; margin-top: 8px; letter-spacing: .04em; }
.sidebar-copyright { font-size: 10px; color: #4a5060; margin-top: 3px; line-height: 1.4; }
.sidebar.collapsed .sidebar-version, .sidebar.collapsed .sidebar-copyright { display: none; }

/* ---- Debt Eliminator specific ---- */
.stat-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; margin-bottom: 16px; }
.stat-card { background: #171a21; border: 1px solid #2c2f38; border-radius: 8px; padding: 14px 16px; }
.stat-card .stat-label { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: #9aa0a6; margin-bottom: 6px; }
.stat-card .stat-value { font-size: 22px; font-weight: 700; color: #e8e8e8; }
.stat-card .stat-value.warn { color: #f0b429; }
.stat-card .stat-value.bad { color: #e5636b; }
.stat-card .stat-value.good { color: #4caf7d; }
.stat-card .stat-sub { font-size: 11px; color: #6b7078; margin-top: 4px; }

.debt-card { background: #171a21; border: 1px solid #2c2f38; border-radius: 8px; padding: 16px 18px; margin-bottom: 12px; }
.debt-card.paid-off { opacity: .55; }
.debt-card-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; flex-wrap: wrap; }
.debt-card-title { font-size: 15px; font-weight: 700; }
.debt-card-type { font-size: 11px; color: #9aa0a6; margin-top: 2px; }
.debt-card-actions { display: flex; gap: 6px; }
.debt-card-metrics { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 10px; margin-top: 12px; }
.debt-metric-label { font-size: 10px; text-transform: uppercase; letter-spacing: .05em; color: #6b7078; }
.debt-metric-value { font-size: 14px; font-weight: 600; margin-top: 2px; }
.debt-progress-wrap { margin-top: 12px; }
.debt-progress-bar { height: 8px; background: #22262f; border-radius: 4px; overflow: hidden; }
.debt-progress-fill { height: 100%; background: #4a90e2; border-radius: 4px; }
.debt-warning { margin-top: 10px; padding: 8px 12px; background: #2a1e13; border: 1px solid #6b4a1f; border-radius: 6px; color: #f0b429; font-size: 12px; }
.debt-link-btn { color: #4a90e2; text-decoration: none; font-size: 12px; }
.debt-link-btn:hover { text-decoration: underline; }
