* { box-sizing: border-box; }
body {
    margin: 0;
    font-family: Arial, sans-serif;
    background: #f4f7fb;
    color: #18212f;
}
.app-shell { min-height: 100vh; }
.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    padding: 16px 20px;
    background: #0f172a;
    color: #fff;
}
.app-title { font-size: 22px; font-weight: 700; }
.app-subtitle { opacity: 0.8; font-size: 13px; margin-top: 4px; }
.top-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.main-content { padding: 20px; max-width: 1280px; margin: 0 auto; }

.card {
    background: #fff;
    border-radius: 16px;
    padding: 18px;
    box-shadow: 0 10px 25px rgba(15, 23, 42, 0.08);
    margin-bottom: 18px;
}
.hero-card { min-height: 220px; display: flex; flex-direction: column; justify-content: center; }
.hero-label { font-size: 14px; color: #64748b; }
.hero-balance { font-size: 42px; font-weight: 800; margin: 10px 0 18px; }
.hero-actions { display: flex; gap: 10px; flex-wrap: wrap; }

.primary-btn, .secondary-btn, .danger-btn, .link-btn, .segment-btn {
    border: none;
    text-decoration: none;
    display: inline-flex;
    justify-content: center;
    align-items: center;
    border-radius: 12px;
    padding: 12px 16px;
    cursor: pointer;
    font-weight: 700;
}
.primary-btn { background: #2563eb; color: #fff; }
.secondary-btn, .link-btn { background: #e2e8f0; color: #0f172a; }
.danger-btn, .link-btn.danger { background: #dc2626; color: #fff; }
.small-btn { padding: 8px 10px; font-size: 13px; }

.login-card {
    max-width: 420px;
    margin: 60px auto;
    background: #fff;
    border-radius: 18px;
    padding: 24px;
    box-shadow: 0 10px 25px rgba(15, 23, 42, 0.08);
}
.stack { display: grid; gap: 12px; }
.stack-inline { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
label span { display: block; font-size: 13px; color: #475569; margin-bottom: 6px; }
input, select {
    width: 100%;
    border: 1px solid #cbd5e1;
    border-radius: 12px;
    padding: 12px;
    font-size: 16px;
    background: #fff;
}
.alert { padding: 12px 14px; border-radius: 12px; margin-bottom: 12px; }
.alert.success { background: #dcfce7; color: #166534; }
.alert.error { background: #fee2e2; color: #991b1b; }
.muted { color: #64748b; }
.hidden { display: none !important; }

.grid.one-two { display: grid; grid-template-columns: 2fr 1fr; gap: 18px; }
.kv { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.kv div:nth-child(odd) { color: #64748b; }

.mobile-shortcut .mobile-grid {
    display: grid;
    grid-template-columns: 1.1fr 1.4fr 1fr auto;
    gap: 10px;
    align-items: center;
}
.table-wrap {
    overflow: auto;
    border: 1px solid #e2e8f0;
    border-radius: 14px;
}
.excel-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    min-width: 760px;
}
.excel-table th, .excel-table td {
    padding: 12px 14px;
    border-bottom: 1px solid #e2e8f0;
    background: #fff;
}
.excel-table th {
    position: sticky;
    top: 0;
    background: #eff6ff;
    text-align: left;
    font-size: 13px;
    text-transform: uppercase;
}
.excel-table tbody tr:nth-child(even) td { background: #f8fafc; }
.money-cell { text-align: right; font-variant-numeric: tabular-nums; }
.click-row { cursor: pointer; }
.click-row:hover td { background: #eaf2ff !important; }
.locked-row { opacity: 0.8; }

.table-head, .filters, .search-bar, .edit-head, .action-row {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
}
.table-head { justify-content: space-between; }
.balance-chip {
    display: inline-block;
    background: #dbeafe;
    color: #1d4ed8;
    border-radius: 999px;
    padding: 10px 14px;
    font-weight: 700;
}
.entry-switch {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
}
.segment-btn {
    background: #e5e7eb;
    color: #111827;
    min-width: 120px;
}
.segment-btn.active { background: #2563eb; color: #fff; }
.entry-pane { display: none; }
.entry-pane.active { display: block; }
.tag {
    display: inline-block;
    padding: 6px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 700;
}
.tag.income { background: #dcfce7; color: #166534; }
.tag.expense { background: #fee2e2; color: #991b1b; }

.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.45);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    z-index: 50;
}
.modal-card {
    width: min(560px, 100%);
    background: #fff;
    border-radius: 18px;
    padding: 18px;
    box-shadow: 0 20px 40px rgba(15, 23, 42, 0.18);
}

@media (max-width: 900px) {
    .grid.one-two { grid-template-columns: 1fr; }
    .mobile-shortcut .mobile-grid { grid-template-columns: 1fr; }
    .hero-balance { font-size: 34px; }
    .topbar, .table-head { align-items: flex-start; }
}

@media (max-width: 640px) {
    .main-content { padding: 12px; }
    .card { padding: 14px; border-radius: 14px; }
    .hero-actions { display: grid; grid-template-columns: 1fr; }
    .top-actions { width: 100%; }
    .top-actions a { flex: 1; }
    .filters, .search-bar, .action-row { display: grid; grid-template-columns: 1fr; }
}
