:root {
    --ink: #1c1c1e;
    --muted: #6b7280;
    --line: #e5e7eb;
    --bg: #fafafa;
    --card: #ffffff;
    --accent: #2563eb;
    --accent-ink: #ffffff;
    --danger: #dc2626;
    --good: #16a34a;
    --radius: 14px;
}
[data-theme="dark"] {
    --ink: #f4f4f5;
    --muted: #9ca3af;
    --line: #2e2e33;
    --bg: #17171a;
    --card: #212126;
    --accent: #3b82f6;
    --accent-ink: #ffffff;
    --danger: #f87171;
    --good: #4ade80;
}
[data-theme="dark"] .photo-placeholder { background: #2a2a2f; color: #4b4b52; }
[data-theme="dark"] .location-photo, [data-theme="dark"] .item-photo { background: #2a2a2f; }
[data-theme="dark"] .badge { background: #1e2a4a; }
[data-theme="dark"] .drop-target { background: #26262b; }
[data-theme="dark"] .budget-bar { background: #2a2a2f; }
[data-theme="dark"] .summary-card { background: #16233d; border-color: #1e3a5f; }
* { box-sizing: border-box; }
body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: var(--bg);
    color: var(--ink);
}
a { color: inherit; text-decoration: none; }

/* ---------- Top bar ---------- */
.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 20px;
    background: var(--card);
    border-bottom: 1px solid var(--line);
    position: sticky;
    top: 0;
    z-index: 10;
}
.brand { font-weight: 700; font-size: 1.1rem; }
.tabs { display: flex; gap: 6px; overflow-x: auto; }
.tabs a { white-space: nowrap; }
@media (max-width: 720px) {
    .topbar { flex-wrap: wrap; gap: 10px; }
    .tabs { order: 3; width: 100%; }
}
.tabs a { padding: 8px 14px; border-radius: 999px; font-weight: 500; color: var(--muted); }
.tabs a.active { background: var(--accent); color: var(--accent-ink); }

.topbar-actions { display: flex; align-items: center; gap: 8px; }
.topbar-actions .icon-btn { width: 40px; height: 40px; font-size: 1rem; }
.bell-btn { position: relative; display: inline-flex; align-items: center; justify-content: center; }
.notif-count {
    position: absolute;
    top: -4px; right: -4px;
    background: var(--danger);
    color: #fff;
    font-size: .65rem;
    font-weight: 700;
    border-radius: 999px;
    min-width: 16px;
    height: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 3px;
}

body, .topbar, .card, .panel, dialog { transition: background-color .15s ease, color .15s ease, border-color .15s ease; }

.container { max-width: 960px; margin: 0 auto; padding: 20px; }

/* ---------- Hero / dashboard ---------- */
.hero { margin-bottom: 24px; }
.hero h1 { margin-bottom: 4px; }
.hero p { color: var(--muted); }

.card-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 640px) { .card-grid { grid-template-columns: 1fr; } }

.big-card {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 24px;
    transition: transform .15s ease, box-shadow .15s ease;
}
.big-card:hover { transform: translateY(-2px); box-shadow: 0 8px 20px rgba(0,0,0,.06); }
.big-card-icon { font-size: 2rem; margin-bottom: 8px; }
.big-card p { color: var(--muted); margin: 4px 0 0; }

/* ---------- Search bar ---------- */
.search-bar {
    display: flex;
    gap: 8px;
    margin-bottom: 20px;
}
.search-bar input[type="search"] {
    flex: 1;
    padding: 12px 14px;
    border-radius: 999px;
    border: 1px solid var(--line);
    font-size: 1rem;
}
.icon-btn {
    border: 1px solid var(--line);
    background: var(--card);
    border-radius: 999px;
    width: 46px;
    height: 46px;
    font-size: 1.1rem;
    cursor: pointer;
}
.icon-btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }

/* ---------- Section headings & buttons ---------- */
.section-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
    flex-wrap: wrap;
    gap: 10px;
}
.header-actions { display: flex; gap: 10px; align-items: center; }
.btn {
    padding: 10px 16px;
    border-radius: 10px;
    border: 1px solid var(--line);
    background: var(--card);
    cursor: pointer;
    font-size: .95rem;
}
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.small { padding: 6px 10px; font-size: .85rem; }

/* ---------- Location / item grids ---------- */
.location-grid, .item-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 14px;
}
.location-card, .item-card {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    overflow: hidden;
    cursor: grab;
}
.location-photo, .item-photo { aspect-ratio: 4/3; background: #f1f1f3; }
.location-photo img, .item-photo img { width: 100%; height: 100%; object-fit: cover; }
.photo-placeholder {
    width: 100%; height: 100%;
    display: flex; align-items: center; justify-content: center;
    font-size: 2rem; color: #c7c7cc;
}
.location-info, .item-info { padding: 10px 12px; }
.location-info h3, .item-info h3 { margin: 0 0 4px; font-size: 1rem; }
.muted { color: var(--muted); font-size: .85rem; }
.badge {
    display: inline-block;
    margin-top: 6px;
    background: #eef2ff;
    color: var(--accent);
    padding: 2px 8px;
    border-radius: 999px;
    font-size: .75rem;
}
.item-actions { display: flex; gap: 6px; margin-top: 8px; }
.item-card.dragging { opacity: .4; }

.empty-state { color: var(--muted); padding: 20px 0; }

/* ---------- Location detail layout (items + drop sidebar) ---------- */
.location-layout { display: grid; grid-template-columns: 1fr 220px; gap: 20px; align-items: start; }
@media (max-width: 720px) { .location-layout { grid-template-columns: 1fr; } }
.drop-sidebar {
    background: var(--card);
    border: 1px dashed var(--line);
    border-radius: var(--radius);
    padding: 14px;
    position: sticky;
    top: 80px;
}
.drop-sidebar h4 { margin-top: 0; font-size: .9rem; color: var(--muted); }
.drop-target {
    padding: 10px;
    border-radius: 8px;
    background: #f5f5f7;
    margin-bottom: 8px;
    font-size: .9rem;
    text-align: center;
    transition: background .15s ease;
}
.drop-target.drag-over { background: #dbeafe; outline: 2px dashed var(--accent); }

.breadcrumb { margin-bottom: 6px; }

/* ---------- Modals ---------- */
dialog {
    border: none;
    border-radius: var(--radius);
    padding: 0;
    width: min(480px, 92vw);
}
dialog::backdrop { background: rgba(0,0,0,.4); }
.modal-form { padding: 22px; display: flex; flex-direction: column; gap: 14px; }
.modal-form h2 { margin: 0 0 4px; }
.modal-form label { display: flex; flex-direction: column; gap: 6px; font-size: .9rem; color: var(--muted); }
.modal-form input, .modal-form select, .modal-form textarea {
    padding: 10px 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    font-size: 1rem;
    font-family: inherit;
    color: var(--ink);
}
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 6px; }
.type-toggle { display: flex; gap: 16px; font-size: .95rem; color: var(--ink); }
.voice-controls { display: flex; align-items: center; gap: 10px; }

/* ---------- Timeline (item history) ---------- */
.timeline { padding-left: 20px; }
.timeline li { margin-bottom: 10px; }

/* ---------- Finance ---------- */
.month-picker input { padding: 8px 10px; border-radius: 8px; border: 1px solid var(--line); }
.summary-card {
    background: #eff6ff;
    border: 1px solid #dbeafe;
    border-radius: var(--radius);
    padding: 18px 20px;
    margin-bottom: 20px;
}
.summary-card h2 { margin-top: 0; font-size: 1rem; }
.summary-card p { margin-bottom: 0; line-height: 1.6; }

.finance-grid { display: grid; grid-template-columns: 1.4fr 1fr; gap: 20px; }
@media (max-width: 800px) { .finance-grid { grid-template-columns: 1fr; } }
.panel { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; }
.panel h2 { margin-top: 0; font-size: 1.05rem; }

.txn-table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.txn-table th, .txn-table td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--line); }
.txn-table .right { text-align: right; }
.txn-table tr.income td:last-child { color: var(--good); }
.txn-table tr.expense td:last-child { color: var(--danger); }

.budget-row { margin-bottom: 14px; }
.budget-label { display: flex; justify-content: space-between; font-size: .9rem; margin-bottom: 6px; }
.budget-label .over { color: var(--danger); font-weight: 600; }
.budget-bar { background: #f1f1f3; border-radius: 999px; height: 8px; overflow: hidden; }
.budget-fill { background: var(--accent); height: 100%; }
.budget-fill.over { background: var(--danger); }

.budget-form { display: flex; flex-direction: column; gap: 10px; max-width: 420px; }
.budget-input-row { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.budget-input-row input { width: 120px; padding: 8px 10px; border-radius: 8px; border: 1px solid var(--line); }

/* ---------- Dashboard ---------- */
.dash-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}
@media (max-width: 720px) { .dash-grid { grid-template-columns: 1fr; } }
.dash-grid .notif-teaser { grid-column: 1 / -1; }
.panel-header { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 10px; }
.panel-header h2 { margin: 0; font-size: 1.05rem; }
.panel-header a { font-size: .85rem; }

.recent-items-strip { display: flex; gap: 10px; overflow-x: auto; padding-bottom: 4px; }
.recent-item { flex: 0 0 90px; text-align: center; font-size: .8rem; }
.recent-item .item-photo { width: 90px; height: 68px; border-radius: 10px; overflow: hidden; margin-bottom: 4px; }

.snapshot-numbers { display: flex; gap: 20px; margin-bottom: 10px; }
.snapshot-numbers > div { display: flex; flex-direction: column; gap: 2px; }
.snapshot-numbers strong { font-size: 1.2rem; }
.good { color: var(--good); }
.danger-text { color: var(--danger); }

/* ---------- Reminders / Bills lists ---------- */
.reminder-list { list-style: none; padding: 0; margin: 0; }
.reminder-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    padding: 12px 4px;
    border-bottom: 1px solid var(--line);
}
.reminder-row:last-child { border-bottom: none; }
.reminder-row.overdue strong { color: var(--danger); }
.reminder-row form { display: flex; gap: 6px; }
.reminder-row.done-row { opacity: .6; }
.reminder-list.compact .reminder-row { padding: 8px 4px; }

/* ---------- Notifications center ---------- */
.notif-list { display: flex; flex-direction: column; gap: 10px; }
.notif-row {
    display: flex;
    align-items: center;
    gap: 12px;
    background: var(--card);
    border: 1px solid var(--line);
    border-left: 4px solid var(--line);
    border-radius: 10px;
    padding: 12px 14px;
}
.notif-row.severity-overdue { border-left-color: var(--danger); }
.notif-row.severity-today { border-left-color: #f59e0b; }
.notif-row.severity-upcoming { border-left-color: var(--accent); }
.notif-icon { font-size: 1.4rem; }
.notif-body { flex: 1; }
.notif-actions form { display: flex; gap: 6px; }

/* ---------- Expiry badges on item cards ---------- */
.badge.badge-warn { background: #fef3c7; color: #b45309; }
.badge.badge-danger { background: #fee2e2; color: var(--danger); }
