:root {
    --bg: #0f1117;
    --bg-alt: #161923;
    --card: #1b1f2b;
    --card-hover: #232838;
    --border: #2a2f3d;
    --text: #eef0f5;
    --text-dim: #9aa1b2;
    --accent: #6c8cff;
    --accent-soft: rgba(108, 140, 255, 0.15);
    --green: #2ecc71;
    --red: #e74c3c;
    --orange: #f39c12;
    --radius: 14px;
    --shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
}

@media (prefers-color-scheme: light) {
    :root {
        --bg: #f4f6fb;
        --bg-alt: #ffffff;
        --card: #ffffff;
        --card-hover: #f0f2fa;
        --border: #e3e6ef;
        --text: #1c1f2a;
        --text-dim: #6b7280;
        --accent: #4a63d6;
        --accent-soft: rgba(74, 99, 214, 0.12);
        --shadow: 0 10px 30px rgba(30, 40, 80, 0.08);
    }
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    background: var(--bg);
    color: var(--text);
}

a { color: inherit; text-decoration: none; }

.app-shell {
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    width: 230px;
    flex-shrink: 0;
    background: var(--bg-alt);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    padding: 24px 16px;
    position: sticky;
    top: 0;
    height: 100vh;
}

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0 8px 24px;
    font-size: 20px;
    font-weight: 700;
}

.nav {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 11px 12px;
    border-radius: 10px;
    color: var(--text-dim);
    font-weight: 500;
    transition: background 0.15s, color 0.15s;
}

.nav-item:hover { background: var(--card-hover); color: var(--text); }

.nav-item.active {
    background: var(--accent-soft);
    color: var(--accent);
}

.sidebar-footer {
    margin-top: auto;
    font-size: 11px;
    color: var(--text-dim);
    padding: 8px;
}

/* Content */
.content {
    flex: 1;
    padding: 32px 40px;
    max-width: 1400px;
}

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    margin-bottom: 28px;
}

.page-header h1 {
    margin: 0 0 4px;
    font-size: 26px;
}

.subtitle {
    margin: 0;
    color: var(--text-dim);
    font-size: 14px;
}

/* Buttons */
.btn {
    border: none;
    border-radius: 10px;
    padding: 10px 18px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.1s, opacity 0.15s;
}

.btn:hover { opacity: 0.9; }
.btn:active { transform: scale(0.97); }

.btn-primary {
    background: var(--accent);
    color: white;
}

.btn-secondary {
    background: var(--card-hover);
    color: var(--text);
    border: 1px solid var(--border);
}

/* Stat cards */
.cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
    gap: 18px;
    margin-bottom: 28px;
}

.stat-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow);
    border-left: 4px solid var(--border);
}

.stat-card.positive { border-left-color: var(--green); }
.stat-card.warning { border-left-color: var(--orange); }
.stat-card.info { border-left-color: var(--accent); }
.stat-card.neutral { border-left-color: var(--text-dim); }

.stat-label {
    font-size: 13px;
    color: var(--text-dim);
    margin-bottom: 8px;
}

.stat-value {
    font-size: 26px;
    font-weight: 700;
}

.stat-hint {
    font-size: 12px;
    color: var(--text-dim);
    margin-top: 6px;
}

/* Panels */
.panel-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

.panel {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 22px;
    box-shadow: var(--shadow);
    margin-bottom: 20px;
}

.panel h2 {
    margin: 0 0 16px;
    font-size: 16px;
}

.panel-header-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.panel-header-row h2 { margin: 0; }

.bar-row {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 14px;
}

.bar-label { width: 60px; font-size: 13px; color: var(--text-dim); }

.bar-track {
    flex: 1;
    background: var(--bg);
    border-radius: 6px;
    height: 10px;
    overflow: hidden;
}

.bar-fill { height: 100%; border-radius: 6px; }
.bar-fill.ganho { background: var(--green); }
.bar-fill.gasto { background: var(--red); }

.bar-value { font-size: 13px; font-weight: 600; width: 110px; text-align: right; }

.mini-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.mini-list li {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 13px;
    padding: 8px 0;
    border-bottom: 1px solid var(--border);
}

.mini-list li:last-child { border-bottom: none; }

.mini-desc { flex: 1; }
.mini-cat { color: var(--text-dim); font-size: 12px; }

.mini-amount { font-weight: 700; }
.mini-amount.ganho { color: var(--green); }
.mini-amount.gasto { color: var(--red); }

.empty { color: var(--text-dim); font-size: 13px; }

/* Badges */
.badge {
    font-size: 11px;
    padding: 3px 8px;
    border-radius: 20px;
    font-weight: 600;
}
.badge.status-pendente { background: rgba(243, 156, 18, 0.15); color: var(--orange); }
.badge.status-pago { background: rgba(46, 204, 113, 0.15); color: var(--green); }
.badge.status-parado { background: rgba(231, 76, 60, 0.15); color: var(--red); }

/* Kanban */
.kanban {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
    align-items: start;
}

.kanban-col {
    background: var(--bg-alt);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px;
}

.kanban-col-header {
    display: flex;
    justify-content: space-between;
    font-weight: 700;
    font-size: 14px;
    padding: 6px 6px 14px;
    color: var(--text-dim);
}

.kanban-count {
    background: var(--card-hover);
    border-radius: 10px;
    padding: 2px 9px;
    font-size: 12px;
}

.kanban-drop {
    display: flex;
    flex-direction: column;
    gap: 10px;
    min-height: 80px;
}

.kanban-drop.drag-over {
    background: var(--accent-soft);
    border-radius: 10px;
}

.kanban-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 12px;
    cursor: grab;
    box-shadow: var(--shadow);
}

.kanban-card:active { cursor: grabbing; }
.kanban-card.dragging { opacity: 0.4; }

.kanban-card-top {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}

.kanban-cat {
    font-size: 11px;
    color: var(--text-dim);
    flex: 1;
}

.kanban-desc { font-size: 14px; margin-bottom: 10px; }

.kanban-card-bottom {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.kanban-amount { font-weight: 700; font-size: 14px; }
.kanban-amount.ganho { color: var(--green); }
.kanban-amount.gasto { color: var(--red); }

.kanban-date { font-size: 12px; color: var(--text-dim); }

.kanban-recurring {
    margin-top: 8px;
    font-size: 11px;
    color: var(--accent);
}

.card-del {
    background: none;
    border: none;
    color: var(--text-dim);
    cursor: pointer;
    font-size: 13px;
    line-height: 1;
    padding: 2px 4px;
    border-radius: 6px;
}
.card-del:hover { background: rgba(231, 76, 60, 0.15); color: var(--red); }

.dot {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    display: inline-block;
    flex-shrink: 0;
}

/* Categories page */
.cat-columns {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

.cat-col {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow);
}

.cat-col h2 { margin: 0 0 14px; font-size: 16px; }

.cat-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.cat-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    background: var(--bg-alt);
    border: 1px solid var(--border);
    border-radius: 10px;
}

.cat-name { flex: 1; font-size: 14px; }

/* Modal */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    align-items: center;
    justify-content: center;
    z-index: 100;
}

.modal-overlay.open { display: flex; }

.modal {
    background: var(--bg-alt);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 26px;
    width: 420px;
    max-width: 92vw;
    box-shadow: var(--shadow);
}

.modal h2 { margin: 0 0 18px; font-size: 18px; }

.modal form, .inline-form {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.modal label, .inline-form label {
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-size: 13px;
    color: var(--text-dim);
}

.modal input, .modal select, .inline-form input, .inline-form select {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 9px 10px;
    color: var(--text);
    font-size: 14px;
}

.modal input[type="color"] { padding: 3px; height: 38px; }

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.checkbox-row {
    flex-direction: row !important;
    align-items: center;
    gap: 8px !important;
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 8px;
}

.inline-form {
    flex-direction: row;
    align-items: flex-end;
    flex-wrap: wrap;
}

/* Lock screen */
.lock-screen {
    display: flex;
    justify-content: center;
    padding-top: 60px;
}

.lock-box {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 40px;
    width: 360px;
    text-align: center;
    box-shadow: var(--shadow);
}

.lock-box h2 { margin: 0 0 8px; }
.lock-box p { color: var(--text-dim); font-size: 13px; margin-bottom: 20px; }

.lock-box form {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.lock-box input {
    background: var(--bg-alt);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 10px;
    color: var(--text);
    text-align: center;
}

.alert-error {
    background: rgba(231, 76, 60, 0.15);
    color: var(--red);
    padding: 8px;
    border-radius: 8px;
    font-size: 13px;
    margin-bottom: 12px;
}

/* Table */
.table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

.table th, .table td {
    text-align: left;
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
}

.table th {
    color: var(--text-dim);
    font-weight: 600;
    font-size: 12px;
    text-transform: uppercase;
}

/* Switch */
.switch {
    position: relative;
    display: inline-block;
    width: 40px;
    height: 22px;
}

.switch input { opacity: 0; width: 0; height: 0; }

.slider {
    position: absolute;
    cursor: pointer;
    inset: 0;
    background: var(--border);
    border-radius: 22px;
    transition: 0.2s;
}

.slider::before {
    content: "";
    position: absolute;
    height: 16px;
    width: 16px;
    left: 3px;
    bottom: 3px;
    background: white;
    border-radius: 50%;
    transition: 0.2s;
}

.switch input:checked + .slider { background: var(--green); }
.switch input:checked + .slider::before { transform: translateX(18px); }

@media (max-width: 900px) {
    .app-shell { flex-direction: column; }
    .sidebar { width: 100%; height: auto; position: static; }
    .content { padding: 20px; }
    .kanban, .panel-grid, .cat-columns { grid-template-columns: 1fr; }
}
