:root {
    --bg: #0f1419;
    --surface: #1a2332;
    --surface2: #243044;
    --border: #2d3a4f;
    --text: #e8edf4;
    --muted: #8b9cb3;
    --primary: #3b82f6;
    --primary-hover: #2563eb;
    --success: #22c55e;
    --danger: #ef4444;
    --warning: #f59e0b;
    --radius: 10px;
    --shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
    --font: 'Segoe UI', system-ui, -apple-system, sans-serif;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    min-height: 100vh;
}

/* Login */
.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    background: radial-gradient(ellipse at top, #1e3a5f 0%, var(--bg) 60%);
}

.login-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 2.5rem;
    width: 100%;
    max-width: 380px;
    box-shadow: var(--shadow);
}

.login-logo {
    font-size: 2rem;
    font-weight: 800;
    color: var(--primary);
    text-align: center;
    margin-bottom: 0.5rem;
    letter-spacing: 2px;
}

.login-card h1 {
    font-size: 1.25rem;
    text-align: center;
    margin-bottom: 0.25rem;
}

.login-sub {
    text-align: center;
    color: var(--muted);
    font-size: 0.9rem;
    margin-bottom: 1.5rem;
}

.login-form label {
    display: block;
    font-size: 0.85rem;
    color: var(--muted);
    margin-bottom: 0.35rem;
}

.login-form input {
    width: 100%;
    padding: 0.75rem 1rem;
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    font-size: 1rem;
    margin-bottom: 1rem;
}

.login-form input:focus {
    outline: none;
    border-color: var(--primary);
}

/* App layout */
.app {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: 220px;
    background: var(--surface);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    padding: 1.5rem 0;
    flex-shrink: 0;
}

.sidebar-brand {
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--primary);
    padding: 0 1.25rem 1.5rem;
    letter-spacing: 2px;
}

.sidebar-nav {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    padding: 0 0.75rem;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.7rem 1rem;
    background: none;
    border: none;
    border-radius: var(--radius);
    color: var(--muted);
    font-size: 0.95rem;
    cursor: pointer;
    text-align: left;
    width: 100%;
    transition: background 0.15s, color 0.15s;
}

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

.nav-item.active {
    background: var(--primary);
    color: #fff;
}

.nav-icon {
    font-size: 1.1rem;
}

.sidebar-logout {
    margin: 1rem 1.25rem 0;
    padding: 0.6rem;
    text-align: center;
    color: var(--muted);
    text-decoration: none;
    font-size: 0.85rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    transition: color 0.15s, border-color 0.15s;
}

.sidebar-logout:hover {
    color: var(--danger);
    border-color: var(--danger);
}

.main {
    flex: 1;
    padding: 1.5rem 2rem;
    overflow: auto;
}

.main-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.5rem;
    gap: 1rem;
    flex-wrap: wrap;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.search-input {
    padding: 0.55rem 0.85rem;
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    font-size: 0.9rem;
    min-width: 200px;
}

.search-input:focus {
    outline: none;
    border-color: var(--primary);
}

.search-input::placeholder {
    color: var(--muted);
}

.main-header h1 {
    font-size: 1.5rem;
}

.section {
    display: none;
}

.section.active {
    display: block;
}

/* Stats */
.stats-row {
    display: flex;
    gap: 1rem;
    margin-bottom: 1.25rem;
    flex-wrap: wrap;
}

.stat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem 1.25rem;
    min-width: 140px;
}

.stat-card .label {
    font-size: 0.8rem;
    color: var(--muted);
    margin-bottom: 0.25rem;
}

.stat-card .value {
    font-size: 1.4rem;
    font-weight: 700;
}

.stat-card.income .value { color: var(--success); }
.stat-card.expense .value { color: var(--danger); }
.stat-card.balance .value { color: var(--primary); }

/* Table */
.table-wrap {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
}

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

.data-table th {
    background: var(--surface2);
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--muted);
    font-weight: 600;
}

.data-table tr:last-child td {
    border-bottom: none;
}

.data-table tr:hover td {
    background: rgba(59, 130, 246, 0.05);
}

.data-table .empty {
    text-align: center;
    color: var(--muted);
    padding: 2rem;
}

/* Badges */
.badge {
    display: inline-block;
    padding: 0.2rem 0.55rem;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
}

.badge-active { background: rgba(34, 197, 94, 0.2); color: var(--success); }
.badge-done { background: rgba(139, 156, 179, 0.2); color: var(--muted); }
.badge-pause { background: rgba(245, 158, 11, 0.2); color: var(--warning); }
.badge-income { background: rgba(34, 197, 94, 0.2); color: var(--success); }
.badge-expense { background: rgba(239, 68, 68, 0.2); color: var(--danger); }

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.55rem 1rem;
    border: none;
    border-radius: var(--radius);
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s, opacity 0.15s;
}

.btn-primary {
    background: var(--primary);
    color: #fff;
}

.btn-primary:hover {
    background: var(--primary-hover);
}

.btn-ghost {
    background: transparent;
    color: var(--muted);
    border: 1px solid var(--border);
}

.btn-ghost:hover {
    color: var(--text);
    border-color: var(--muted);
}

.btn-sm {
    padding: 0.3rem 0.6rem;
    font-size: 0.8rem;
}

.btn-danger {
    background: transparent;
    color: var(--danger);
    border: 1px solid transparent;
}

.btn-danger:hover {
    background: rgba(239, 68, 68, 0.15);
}

.btn-block {
    width: 100%;
    padding: 0.75rem;
}

.actions {
    display: flex;
    gap: 0.35rem;
    flex-wrap: wrap;
}

.actions-wide {
    min-width: 11rem;
    justify-content: flex-end;
}

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

.modal-overlay[hidden] {
    display: none;
}

.modal {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 14px;
    width: 100%;
    max-width: 480px;
    box-shadow: var(--shadow);
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--border);
}

.modal-header h2 {
    font-size: 1.1rem;
}

.modal-close {
    background: none;
    border: none;
    color: var(--muted);
    font-size: 1.5rem;
    cursor: pointer;
    line-height: 1;
}

.modal-body {
    padding: 1.25rem 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--border);
}

.form-group label {
    display: block;
    font-size: 0.8rem;
    color: var(--muted);
    margin-bottom: 0.3rem;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 0.6rem 0.75rem;
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    font-size: 0.9rem;
    font-family: inherit;
}

.form-group textarea {
    min-height: 80px;
    resize: vertical;
}

.form-hint {
    font-size: 0.75rem;
    color: var(--muted);
    margin-top: 0.25rem;
}

.modal.modal-wide {
    max-width: 560px;
}

.cell-service {
    max-width: 280px;
    line-height: 1.35;
    font-size: 0.85rem;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary);
}

.alert {
    padding: 0.65rem 0.85rem;
    border-radius: var(--radius);
    font-size: 0.85rem;
    margin-bottom: 1rem;
}

.alert-error {
    background: rgba(239, 68, 68, 0.15);
    color: var(--danger);
    border: 1px solid rgba(239, 68, 68, 0.3);
}

@media (max-width: 768px) {
    .app {
        flex-direction: column;
    }

    .sidebar {
        width: 100%;
        flex-direction: row;
        flex-wrap: wrap;
        padding: 1rem;
    }

    .sidebar-brand {
        padding: 0;
        margin-right: auto;
    }

    .sidebar-nav {
        flex-direction: row;
        width: 100%;
        order: 3;
        margin-top: 0.75rem;
    }

    .sidebar-logout {
        margin: 0;
    }

    .main {
        padding: 1rem;
    }
}
