@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@400;500;600;700&display=swap');

:root {
    --bg: #f9fafb;
    --panel: rgba(18, 52, 25, 0.05);
    --panel-strong: rgba(18, 52, 25, 0.12);
    --text: #0f172a;
    --muted: #475467;
    --accent: #22c55e;
    --accent-strong: #16a34a;
    --success: #16a34a;
    --danger: #ef4444;
    --shadow: 0 16px 32px rgba(15, 23, 42, 0.12);
    --radius: 18px;
}

* { box-sizing: border-box; }
body {
    margin: 0;
    font-family: 'Space Grotesk', 'SF Pro Display', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--bg);
    color: var(--text);
}

a { color: inherit; }

#app {
    position: relative;
    min-height: 100vh;
    padding: 18px 18px 120px;
    overflow-x: hidden;
    transition: background 0.25s ease, color 0.25s ease, border-color 0.25s ease;
}

.gradient-bg {
    position: fixed;
    inset: -30% -40% auto auto;
    width: 90vw;
    height: 60vh;
    background: radial-gradient(circle at 30% 30%, rgba(34, 197, 94, 0.25), transparent 45%),
                radial-gradient(circle at 70% 0%, rgba(52, 211, 153, 0.2), transparent 35%),
                radial-gradient(circle at 40% 80%, rgba(22, 163, 74, 0.18), transparent 30%);
    filter: blur(22px);
    pointer-events: none;
    z-index: 0;
}

header.topbar {
    position: sticky;
    top: 0;
    z-index: 5;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 14px;
    background: #fff;
    border: 1px solid rgba(15,23,42,0.08);
    box-shadow: var(--shadow);
    border-radius: 16px;
    margin-bottom: 14px;
}

.brand { display: flex; gap: 10px; align-items: center; }
.brand .dot {
    width: 12px; height: 12px;
    background: linear-gradient(135deg, #22c55e, #16a34a);
    border-radius: 50%;
    box-shadow: 0 0 12px rgba(22,163,74,0.4);
}
.brand h1 { margin: 0; font-size: 1.1rem; letter-spacing: -0.01em; }
.eyebrow { margin: 0; color: var(--muted); font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.08em; }

.controls { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 8px;
    background: var(--panel);
    border-radius: 999px;
    border: 1px solid rgba(15,23,42,0.08);
    color: var(--text);
    font-size: 0.9rem;
    position: relative;
}
.chip input[type="month"] {
    position: absolute;
    inset: 0;
    opacity: 0;
    width: 100%;
    height: 100%;
    cursor: pointer;
    z-index: 2;
}
.chip input:focus { outline: none; }
.chip .icon { pointer-events: none; z-index: 1; }
#monthLabel { font-weight: 700; position: relative; z-index: 1; pointer-events: none; text-transform: capitalize; }

.icon-btn {
    background: #fff;
    color: var(--text);
    border: 1px solid rgba(15,23,42,0.08);
    border-radius: 12px;
    padding: 7px 8px;
    font-size: 0.92rem;
    cursor: pointer;
    transition: transform 0.15s ease, background 0.2s ease, box-shadow 0.2s ease;
    box-shadow: var(--shadow);
}
.icon-btn:active { transform: scale(0.96); }

.pill {
    background: linear-gradient(135deg, #22c55e, #16a34a);
    color: #f8fafc;
    border: none;
    border-radius: 999px;
    padding: 10px 14px;
    font-weight: 700;
    letter-spacing: 0.01em;
    cursor: pointer;
    box-shadow: 0 10px 30px rgba(22,163,74,0.35);
}

.card {
    border-radius: var(--radius);
    padding: 16px;
}
.glass {
    background: #fff;
    border: 1px solid rgba(15,23,42,0.08);
    box-shadow: var(--shadow);
}

.summary .card {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 14px;
    align-items: center;
}
.summary h2 { margin: 10px 0 6px; }
.summary { margin-bottom: 12px; }

.list { margin-top: 16px; display: flex; flex-direction: column; gap: 12px; }
.rubro-card {
    position: relative;
    padding: 14px;
    border-radius: 18px;
    border: 1px solid rgba(15,23,42,0.08);
    background: #fff;
    box-shadow: 0 10px 30px rgba(15,23,42,0.12);
    overflow: hidden;
    cursor: pointer;
}
.rubro-card .badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    border-radius: 999px;
    background: rgba(15,23,42,0.05);
    border: 1px solid rgba(15,23,42,0.08);
    font-size: 0.9rem;
}
.rubro-card h3 { margin: 10px 0 4px; font-size: 1.1rem; }
.rubro-card p { margin: 2px 0; }

.progress {
    position: relative;
    width: 100%;
    height: 10px;
    border-radius: 999px;
    background: rgba(15,23,42,0.08);
    overflow: hidden;
    margin-top: 8px;
}
.progress span {
    position: absolute;
    inset: 0;
    background: linear-gradient(90deg, #22c55e, #a3e635);
    width: 0%;
    transition: width 0.3s ease, background 0.3s ease;
}
.rubro-card.over { border-color: rgba(239,68,68,0.6); background: rgba(239,68,68,0.08); }
.rubro-card.over .badge, .rubro-card.over h3, .rubro-card.over p { color: #b91c1c; }
.rubro-card.over .progress span { background: linear-gradient(90deg, #fca5a5, #ef4444); }

.sheet, .modal {
    position: fixed;
    inset: 0;
    background: rgba(15,23,42,0.3);
    backdrop-filter: blur(12px);
    display: none;
    align-items: flex-end;
    justify-content: center;
    z-index: 20;
}
.sheet.show, .modal.show { display: flex; }
.sheet-content {
    width: 100%;
    max-width: 520px;
    background: #fff;
    border-radius: 24px 24px 0 0;
    padding: 24px;
    box-shadow: 0 -12px 40px rgba(15,23,42,0.15);
}
.sheet .logo {
    width: 54px; height: 54px;
    border-radius: 16px;
    display: grid; place-items: center;
    background: linear-gradient(135deg, #22c55e, #16a34a);
    box-shadow: 0 10px 30px rgba(22,163,74,0.35);
    font-size: 1.4rem;
}
.sheet h2 { margin: 14px 0 4px; }
.muted { color: var(--muted); margin: 0; }

.input-field, .upload-field {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 12px 0;
    padding: 12px 14px;
    border-radius: 14px;
    background: rgba(15,23,42,0.05);
    border: 1px solid rgba(15,23,42,0.08);
}
.input-field input,
.input-field select {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--text);
    font-size: 1rem;
}
.input-field input:focus,
.input-field select:focus { outline: none; }
.upload-field input[type=file] { display: none; }
.upload-field { cursor: pointer; }

button.primary {
    width: 100%;
    padding: 14px;
    border-radius: 14px;
    border: none;
    font-weight: 700;
    background: linear-gradient(135deg, #22c55e, #16a34a);
    color: #f8fafc;
    box-shadow: 0 15px 30px rgba(22,163,74,0.35);
    cursor: pointer;
}

.modal-card {
    width: 100%;
    max-width: 520px;
    background: #fff;
    border-radius: 24px;
    padding: 18px 16px;
    border: 1px solid rgba(15,23,42,0.08);
    box-shadow: var(--shadow);
}
.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 10px;
}
.inline-form {
    display: grid;
    grid-template-columns: 1.2fr 90px 90px;
    gap: 8px;
    margin-bottom: 12px;
    align-items: center;
    padding: 10px;
    border-radius: 14px;
    border: 1px dashed rgba(34,197,94,0.35);
    background: rgba(34,197,94,0.05);
}
.inline-form input, .inline-form button {
    width: 100%;
    border-radius: 12px;
    border: none;
    padding: 12px;
}
.inline-form button { background: var(--accent); color: #fff; font-weight: 700; }
.config-item {
    padding: 12px;
    background: rgba(15,23,42,0.02);
    border: 1px solid rgba(15,23,42,0.08);
    border-radius: 14px;
    margin-bottom: 10px;
    display: grid;
    gap: 10px;
    align-items: center;
}
.config-main {
    display: grid;
    gap: 8px;
}
.config-row {
    display: grid;
    grid-template-columns: 1fr 80px;
    gap: 8px;
}
.config-row input[type=\"text\"],
.config-row input[type=\"color\"],
.config-actions input {
    width: 100%;
    border-radius: 12px;
    border: 1px solid rgba(15,23,42,0.12);
    background: rgba(15,23,42,0.03);
    color: var(--text);
    padding: 10px 12px;
}
.config-actions {
    display: grid;
    grid-template-columns: 1fr 0.9fr 0.9fr;
    gap: 8px;
    align-items: center;
}
.config-actions input {
    border-radius: 12px;
}
.config-actions button { border-radius: 12px; border: none; padding: 10px 12px; cursor: pointer; }
.config-actions .save { background: #22c55e; color: #f8fafc; }
.config-actions .delete { background: #ef4444; color: #fff; }

.detail { max-height: 88vh; overflow-y: auto; }
.detail-header { display: flex; gap: 12px; align-items: center; }
.gasto-form { margin: 12px 0 16px; }
.gasto-list { display: flex; flex-direction: column; gap: 10px; }
.gasto-item {
    padding: 10px 12px;
    border-radius: 12px;
    border: 1px solid rgba(15,23,42,0.08);
    background: #fff;
}
.gasto-item .meta { display: flex; justify-content: space-between; color: var(--muted); font-size: 0.9rem; }
.gasto-item .amount { font-weight: 700; margin-top: 6px; }
.gasto-item img { width: 100%; border-radius: 10px; margin-top: 8px; }

@media (min-width: 720px) {
    #app { max-width: 520px; margin: 0 auto; }
}

.alerting { background: #fff0f0; }
.alerting .topbar {
    border-color: rgba(239,68,68,0.4);
    box-shadow: 0 16px 32px rgba(239,68,68,0.25);
}
