/* Tema claro (default) */
:root,
html[data-theme="light"] {
    --bg: #eef2f7;
    --bg-elevated: #ffffff;
    --bg-soft: #f7f9fc;
    --ink: #0f172a;
    --muted: #64748b;
    --line: rgba(15, 23, 42, 0.08);
    --line-strong: rgba(15, 23, 42, 0.14);
    --accent: #0f766e;
    --accent-hover: #0d9488;
    --accent-soft: rgba(15, 118, 110, 0.12);
    --cash: #059669;
    --card-pay: #2563eb;
    --danger: #dc2626;
    --danger-soft: rgba(220, 38, 38, 0.1);
    --shadow: 0 8px 30px rgba(15, 23, 42, 0.06);
    --shadow-lg: 0 20px 50px rgba(15, 23, 42, 0.1);
    --glow-a: rgba(45, 212, 191, 0.22);
    --glow-b: rgba(96, 165, 250, 0.18);
    --overlay: rgba(15, 23, 42, 0.45);
    --input-bg: #ffffff;
    --radius: 16px;
    --radius-sm: 10px;
    --font: "Manrope", system-ui, sans-serif;
    --display: "Sora", system-ui, sans-serif;
}

html[data-theme="dark"] {
    --bg: #0b1220;
    --bg-elevated: #121a2b;
    --bg-soft: #162033;
    --ink: #e8eef8;
    --muted: #94a3b8;
    --line: rgba(148, 163, 184, 0.14);
    --line-strong: rgba(148, 163, 184, 0.22);
    --accent: #2dd4bf;
    --accent-hover: #5eead4;
    --accent-soft: rgba(45, 212, 191, 0.14);
    --cash: #34d399;
    --card-pay: #60a5fa;
    --danger: #f87171;
    --danger-soft: rgba(248, 113, 113, 0.12);
    --shadow: 0 8px 30px rgba(0, 0, 0, 0.35);
    --shadow-lg: 0 24px 60px rgba(0, 0, 0, 0.45);
    --glow-a: rgba(45, 212, 191, 0.12);
    --glow-b: rgba(59, 130, 246, 0.1);
    --overlay: rgba(2, 6, 23, 0.7);
    --input-bg: #0f172a;
}

* { box-sizing: border-box; }

html { color-scheme: light; }
html[data-theme="dark"] { color-scheme: dark; }

body {
    margin: 0;
    min-height: 100vh;
    font-family: var(--font);
    color: var(--ink);
    background:
        radial-gradient(900px 420px at 8% -8%, var(--glow-a), transparent 55%),
        radial-gradient(800px 380px at 100% 0%, var(--glow-b), transparent 50%),
        var(--bg);
    transition: background-color 0.25s ease, color 0.2s ease;
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); }

.topbar {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.75rem 1.25rem;
    background: color-mix(in srgb, var(--bg-elevated) 82%, transparent);
    border-bottom: 1px solid var(--line);
    backdrop-filter: blur(16px) saturate(1.2);
    -webkit-backdrop-filter: blur(16px) saturate(1.2);
    position: sticky;
    top: 0;
    z-index: 20;
}

.brand-link {
    font-family: var(--display);
    font-weight: 700;
    font-size: 1.2rem;
    letter-spacing: -0.02em;
    color: var(--ink);
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
}
.brand-mark {
    width: 1.7rem;
    height: 1.7rem;
    border-radius: 9px;
    display: grid;
    place-items: center;
    overflow: hidden;
    background: transparent;
}
.brand-mark img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}
.brand-mark i { width: 0.95rem; height: 0.95rem; }

.topbar nav {
    display: flex;
    gap: 0.35rem;
    flex: 1;
}

.topbar nav a {
    color: var(--muted);
    font-weight: 600;
    font-size: 0.92rem;
    padding: 0.45rem 0.75rem;
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    transition: background 0.15s, color 0.15s;
}
.topbar nav a:hover {
    background: var(--accent-soft);
    color: var(--accent);
}

.user-chip {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    color: var(--muted);
    font-size: 0.9rem;
}
.user-chip span {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
}
.user-link {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    color: var(--ink);
    font-weight: 650;
    padding: 0.3rem 0.55rem;
    border-radius: 999px;
}
.user-link:hover {
    background: var(--accent-soft);
    color: var(--accent);
}

.theme-btn {
    width: 2.35rem;
    height: 2.35rem;
    border-radius: 999px;
    border: 1px solid var(--line);
    background: var(--bg-soft);
    color: var(--ink);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    position: relative;
    transition: border-color 0.15s, background 0.15s, transform 0.15s;
}
.theme-btn:hover {
    border-color: var(--line-strong);
    background: var(--accent-soft);
    transform: scale(1.04);
}
.theme-btn i { width: 1.05rem; height: 1.05rem; }

.notif-wrap { position: relative; }
.notif-badge {
    position: absolute;
    top: -2px;
    right: -2px;
    min-width: 1.05rem;
    height: 1.05rem;
    padding: 0 0.28rem;
    border-radius: 999px;
    background: #ef4444;
    color: #fff;
    font-size: 0.65rem;
    font-weight: 800;
    display: grid;
    place-items: center;
    line-height: 1;
    border: 2px solid var(--bg-elevated);
}
.notif-badge.hidden, .hidden { display: none !important; }
.notif-panel {
    position: absolute;
    top: calc(100% + 0.5rem);
    right: 0;
    width: min(340px, calc(100vw - 1.5rem));
    background: var(--bg-elevated);
    border: 1px solid var(--line);
    border-radius: 14px;
    box-shadow: var(--shadow-lg);
    z-index: 40;
    overflow: hidden;
}
.notif-head {
    padding: 0.75rem 1rem;
    font-weight: 750;
    font-family: var(--display);
    border-bottom: 1px solid var(--line);
    font-size: 0.95rem;
}
.notif-list { max-height: 320px; overflow: auto; }
.notif-item {
    padding: 0.85rem 1rem;
    border-bottom: 1px solid var(--line);
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
}
.notif-item:last-child { border-bottom: none; }
.notif-actions { display: flex; gap: 0.4rem; }

.container {
    width: min(1120px, calc(100% - 2rem));
    margin: 1.75rem auto 3.5rem;
}

.page-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    gap: 1rem;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
}

.page-head h1 {
    font-family: var(--display);
    font-size: clamp(1.55rem, 3vw, 2rem);
    letter-spacing: -0.03em;
    margin: 0.25rem 0 0.3rem;
    font-weight: 700;
}

.muted { color: var(--muted); }
.tiny { font-size: 0.82rem; }
.back { color: var(--muted); font-size: 0.9rem; font-weight: 600; }

.btn {
    border: 1px solid var(--line);
    background: var(--bg-elevated);
    color: var(--ink);
    border-radius: 12px;
    padding: 0.6rem 1.05rem;
    font: inherit;
    font-weight: 650;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    transition: transform 0.12s, background 0.15s, border-color 0.15s, box-shadow 0.15s;
}
.btn:hover {
    border-color: var(--line-strong);
    transform: translateY(-1px);
}
.btn-primary {
    background: linear-gradient(135deg, var(--accent), #0ea5e9);
    border-color: transparent;
    color: #fff;
    box-shadow: 0 8px 20px rgba(14, 165, 233, 0.22);
}
.btn-primary:hover {
    filter: brightness(1.05);
    background: linear-gradient(135deg, var(--accent-hover), #38bdf8);
}
.btn-ghost {
    background: transparent;
    border-color: transparent;
    color: var(--muted);
}
.btn-ghost:hover { background: var(--accent-soft); color: var(--accent); }
.btn-sm { padding: 0.35rem 0.7rem; font-size: 0.85rem; }

.actions { display: flex; gap: 0.5rem; flex-wrap: wrap; }

.grid-cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 1rem;
}

.list-card {
    display: block;
    background: var(--bg-elevated);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 1.2rem 2.6rem 1.2rem 1.25rem;
    box-shadow: var(--shadow);
    color: inherit;
    transition: transform 0.18s ease, border-color 0.18s, box-shadow 0.18s;
}
.list-card-wrap {
    position: relative;
}
.list-card-wrap:hover .list-card {
    transform: translateY(-3px);
    border-color: color-mix(in srgb, var(--accent) 40%, var(--line));
    box-shadow: var(--shadow-lg);
}
.list-card-delete {
    position: absolute;
    top: 0.65rem;
    right: 0.65rem;
    z-index: 2;
    background: var(--bg-elevated);
    border: 1px solid var(--line);
    opacity: 0.85;
}
.list-card-wrap:hover .list-card-delete { opacity: 1; }
.list-card:hover {
    transform: none;
    border-color: var(--line);
    box-shadow: var(--shadow);
}
.list-card-top {
    display: flex;
    justify-content: space-between;
    gap: 0.5rem;
    align-items: start;
}
.list-card h3 {
    margin: 0 0 0.55rem;
    font-size: 1.05rem;
    font-family: var(--display);
    letter-spacing: -0.02em;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
}
.list-card h3 i, .list-card p i, .side-panel h2 i, .compra-panel h2 i, .badge i {
    width: 1rem;
    height: 1rem;
    flex-shrink: 0;
}
.side-panel h2, .compra-panel h2 {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
}

.badge {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    font-size: 0.72rem;
    font-weight: 700;
    padding: 0.25rem 0.55rem;
    border-radius: 999px;
    background: var(--accent-soft);
    color: var(--accent);
    text-transform: capitalize;
}
.badge-cash { background: rgba(5, 150, 105, 0.14); color: var(--cash); }
.badge-card { background: rgba(37, 99, 235, 0.14); color: var(--card-pay); }

.layout-2 {
    display: grid;
    grid-template-columns: 1.65fr 0.9fr;
    gap: 1.25rem;
}

@media (max-width: 860px) {
    .layout-2 { grid-template-columns: 1fr; }
    .topbar { flex-wrap: wrap; }
}

.side-panel, .items-list, .stack-list, .table-wrap {
    background: var(--bg-elevated);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.side-panel { padding: 1.25rem; }
.side-panel h2 { font-size: 0.98rem; margin: 0 0 0.75rem; font-family: var(--display); }

.toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
}

.check-inline {
    display: inline-flex;
    flex-direction: row;
    align-items: center;
    gap: 0.45rem;
    color: var(--muted);
    font-size: 0.92rem;
    font-weight: 600;
    cursor: pointer;
}
.check-inline input { width: auto; margin: 0; flex-shrink: 0; accent-color: var(--accent); }

.items-list {
    list-style: none;
    margin: 0;
    padding: 0.45rem;
}

.item-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto auto auto;
    gap: 0.65rem;
    align-items: center;
    padding: 0.75rem 0.8rem;
    border-radius: 12px;
    transition: background 0.12s;
}
.buy-mode .item-row { grid-template-columns: minmax(0, 1fr) auto; }
.item-row:hover { background: var(--bg-soft); }
.item-row.done .item-name { text-decoration: line-through; color: var(--muted); }

.item-check {
    display: inline-flex;
    flex-direction: row;
    align-items: center;
    gap: 0.7rem;
    min-width: 0;
    font-weight: 600;
    cursor: pointer;
}
.item-check input[type="checkbox"] {
    width: 1.15rem;
    height: 1.15rem;
    margin: 0;
    flex-shrink: 0;
    accent-color: var(--accent);
}
.item-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item-meta {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    color: var(--muted);
    font-size: 0.85rem;
    white-space: nowrap;
}
.item-meta i, .btn i, .icon-btn i, .topbar nav a i, .user-chip i {
    width: 1rem;
    height: 1rem;
    stroke-width: 2;
}
.price-wrap {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    color: var(--muted);
}
.price-wrap .price-input { width: 5rem; }

.price-input {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 0.4rem 0.5rem;
    font: inherit;
    background: var(--input-bg);
    color: var(--ink);
}

.icon-btn {
    border: none;
    background: transparent;
    color: var(--muted);
    cursor: pointer;
    line-height: 1;
    padding: 0.4rem;
    border-radius: 8px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.icon-btn:hover { color: var(--danger); background: var(--danger-soft); }

.plain-list { list-style: none; margin: 0; padding: 0; }
.plain-list li {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--line);
    flex-wrap: wrap;
}
.detail-items li { font-size: 0.95rem; }

.total-box {
    margin-top: 0.75rem;
    padding: 1rem 1.1rem;
    border-radius: 14px;
    background: linear-gradient(135deg, var(--accent), #0284c7);
    color: #fff;
    font-weight: 750;
    font-size: 1.15rem;
    letter-spacing: -0.01em;
}

.stack { display: flex; flex-direction: column; gap: 0.9rem; }
label {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    font-size: 0.88rem;
    font-weight: 650;
    color: var(--muted);
}
input[type="text"], input[type="password"], input[type="email"], input[type="number"], input[type="tel"], select, textarea {
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 0.7rem 0.85rem;
    font: inherit;
    font-weight: 500;
    background: var(--input-bg);
    color: var(--ink);
    transition: border-color 0.15s, box-shadow 0.15s;
}
input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: color-mix(in srgb, var(--accent) 55%, var(--line));
    box-shadow: 0 0 0 3px var(--accent-soft);
}

.empty {
    padding: 2.25rem 1rem;
    text-align: center;
    color: var(--muted);
    border: 1px dashed var(--line-strong);
    border-radius: var(--radius);
    background: var(--bg-soft);
}

.alert {
    padding: 0.8rem 1rem;
    border-radius: 12px;
    margin-bottom: 1rem;
    font-weight: 600;
    font-size: 0.92rem;
}
.alert-error { background: var(--danger-soft); color: var(--danger); }
.alert-ok { background: var(--accent-soft); color: var(--accent); }

.hist-row {
    width: 100%;
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    align-items: center;
    text-align: left;
    border: none;
    border-bottom: 1px solid var(--line);
    background: transparent;
    padding: 1rem 1.15rem;
    font: inherit;
    color: inherit;
    cursor: pointer;
    transition: background 0.12s;
}
.hist-row:hover { background: var(--bg-soft); }
.hist-row strong {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
}
.hist-row strong i { width: 1rem; height: 1rem; }
.hist-right { display: flex; flex-direction: column; align-items: flex-end; gap: 0.35rem; }
.stack-list { padding: 0.25rem 0; overflow: hidden; }

.data-table { width: 100%; border-collapse: collapse; }
.data-table th, .data-table td {
    padding: 0.8rem 1rem;
    text-align: left;
    border-bottom: 1px solid var(--line);
    font-size: 0.92rem;
}
.data-table th { color: var(--muted); font-weight: 700; }

/* Auth */
.auth-page {
    display: grid;
    place-items: center;
    padding: 2rem 1rem;
    min-height: 100vh;
    position: relative;
}
.auth-theme {
    position: absolute;
    top: 1rem;
    right: 1rem;
}
.auth-card {
    width: min(420px, 100%);
    background: color-mix(in srgb, var(--bg-elevated) 92%, transparent);
    border: 1px solid var(--line);
    border-radius: 22px;
    padding: 2rem 1.75rem;
    box-shadow: var(--shadow-lg);
    backdrop-filter: blur(12px);
}
.auth-card .brand {
    font-family: var(--display);
    font-size: 1.35rem;
    font-weight: 700;
    margin: 0 0 0.35rem;
    letter-spacing: -0.02em;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}
.auth-card h1 {
    margin: 0.75rem 0 0.35rem;
    font-size: 1.45rem;
    font-family: var(--display);
    letter-spacing: -0.03em;
}
.auth-links {
    margin-top: 1.25rem;
    text-align: center;
    color: var(--muted);
    font-size: 0.92rem;
}
.auth-links a { font-weight: 700; }

/* Modo compra */
.compra-overlay {
    position: fixed;
    inset: 0;
    background: var(--overlay);
    z-index: 50;
    display: grid;
    place-items: end center;
    padding: 0;
}
.compra-overlay.hidden { display: none; }
.compra-panel {
    width: min(560px, 100%);
    max-height: 92vh;
    background: var(--bg-elevated);
    border-radius: 20px 20px 0 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border: 1px solid var(--line);
    box-shadow: var(--shadow-lg);
}
.compra-panel > header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.15rem;
    border-bottom: 1px solid var(--line);
}
.compra-panel > header h2 { margin: 0; font-size: 1.1rem; font-family: var(--display); }
.quick-add {
    display: grid;
    grid-template-columns: 1fr 4rem 5rem auto;
    gap: 0.45rem;
    padding: 0.8rem 1rem;
    border-bottom: 1px solid var(--line);
    background: var(--bg-soft);
}
.buy-mode {
    flex: 1;
    overflow: auto;
    border: none;
    box-shadow: none;
    border-radius: 0;
}
.compra-footer {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.95rem 1rem;
    border-top: 1px solid var(--line);
    background: var(--bg-soft);
}
.compra-footer strong { display: block; font-size: 1.2rem; }

@media (max-width: 520px) {
    .item-row { grid-template-columns: minmax(0, 1fr) auto auto; }
    .item-meta { display: none; }
    .quick-add { grid-template-columns: 1fr 1fr auto; }
    .quick-add #quickCant { display: none; }
    .user-chip > span { display: none; }
}
