/* splitbot — shared design tokens & components */

:root {
    --bg: #0b1120;
    --surface: #161f36;
    --surface-2: #0f172a;
    --border: #253352;
    --text: #e8edf7;
    --text-dim: #94a3b8;
    --text-faint: #64748b;
    --accent: #6366f1;
    --accent-hover: #4f46e5;
    --accent-soft: rgba(99, 102, 241, 0.12);
    --green: #4ade80;
    --green-bg: #123821;
    --red: #f87171;
    --red-bg: #3a1212;
    --radius: 14px;
    --radius-sm: 9px;
    --shadow: 0 10px 40px rgba(0, 0, 0, 0.35);
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    -webkit-font-smoothing: antialiased;
}

.page {
    max-width: 780px;
    margin: 0 auto;
    padding: 1.75rem 1.25rem 3rem;
}

a { color: inherit; }

/* Header */
.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.75rem;
    gap: 1rem;
    flex-wrap: wrap;
}
.brand { display: flex; align-items: baseline; gap: .65rem; }
.brand h1 { font-size: 1.25rem; margin: 0; font-weight: 700; letter-spacing: -0.01em; }
.brand .who { color: var(--text-dim); font-size: .82rem; }
.topbar-actions { display: flex; gap: .6rem; align-items: center; }

/* Buttons */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
    padding: .55rem 1.1rem; border-radius: var(--radius-sm); border: none;
    font-size: .9rem; font-weight: 600; cursor: pointer; text-decoration: none;
    transition: background .15s ease, border-color .15s ease, transform .1s ease, opacity .15s ease;
    white-space: nowrap;
}
.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }
.btn-primary { background: var(--accent); color: white; }
.btn-primary:hover:not(:disabled) { background: var(--accent-hover); }
.btn-ghost { background: transparent; border: 1px solid var(--border); color: var(--text-dim); }
.btn-ghost:hover:not(:disabled) { border-color: #3a4a72; color: var(--text); }
.btn-danger-ghost { background: transparent; border: 1px solid var(--border); color: var(--red); }
.btn-danger-ghost:hover:not(:disabled) { background: var(--red-bg); border-color: var(--red); }
.btn-block { width: 100%; }
.btn-sm { padding: .4rem .8rem; font-size: .8rem; }

/* Cards */
.card {
    background: var(--surface); border-radius: var(--radius); padding: 1.4rem 1.5rem;
    margin-bottom: 1.25rem; border: 1px solid rgba(255,255,255,0.03);
}
.card h2 { font-size: 1rem; margin: 0 0 1rem; color: #d8deed; font-weight: 600; }
.card .sub { color: var(--text-dim); font-size: .85rem; margin: -.6rem 0 1rem; }

/* Forms */
.field { margin-bottom: 1rem; }
.field label { display: block; font-size: .82rem; color: var(--text-dim); margin-bottom: .4rem; font-weight: 500; }
input[type=text], input[type=number], input[type=password], textarea {
    width: 100%; padding: .65rem .85rem; border-radius: var(--radius-sm);
    border: 1px solid var(--border); background: var(--surface-2); color: var(--text);
    font-size: .95rem; font-family: inherit; transition: border-color .15s ease;
}
input:focus, textarea:focus { outline: none; border-color: var(--accent); }
input::placeholder { color: var(--text-faint); }

/* Banners / toasts */
.banner {
    padding: .75rem 1rem; border-radius: var(--radius-sm); margin-bottom: 1.25rem;
    font-size: .88rem; display: flex; align-items: center; gap: .5rem;
}
.banner.ok { background: var(--green-bg); color: var(--green); }
.banner.err { background: var(--red-bg); color: var(--red); }

/* Member chips */
.member-list { display: flex; flex-direction: column; gap: .4rem; }
.member-chip {
    display: flex; align-items: center; gap: .65rem; padding: .6rem .75rem;
    border-radius: var(--radius-sm); border: 1px solid var(--border); background: var(--surface-2);
    cursor: pointer; transition: border-color .15s ease, background .15s ease;
    font-size: .92rem; user-select: none;
}
.member-chip:hover { border-color: #3a4a72; }
.member-chip.selected { border-color: var(--accent); background: var(--accent-soft); }
.member-chip .dot {
    width: 18px; height: 18px; border-radius: 50%; border: 2px solid var(--border);
    flex-shrink: 0; display: flex; align-items: center; justify-content: center; font-size: .65rem;
    transition: border-color .15s ease, background .15s ease;
}
.member-chip.selected .dot { border-color: var(--accent); background: var(--accent); color: white; }

/* Per-item quantity counters (split by item) */
.qty-row {
    display: flex; align-items: center; justify-content: space-between; gap: .65rem;
    padding: .6rem .75rem; border-radius: var(--radius-sm); border: 1px solid var(--border);
    background: var(--surface-2); transition: border-color .15s ease, background .15s ease;
    font-size: .92rem;
}
.qty-row.included { border-color: var(--accent); background: var(--accent-soft); }
.qty-row .qty-name { flex: 1; cursor: pointer; user-select: none; }
.qty-row .qty-controls { display: flex; align-items: center; gap: .5rem; }
.qty-btn {
    width: 28px; height: 28px; border-radius: 50%; border: 1px solid var(--border);
    background: var(--surface); color: var(--text); font-size: 1rem; line-height: 1;
    display: flex; align-items: center; justify-content: center; cursor: pointer;
    transition: border-color .15s ease, background .15s ease;
}
.qty-btn:hover { border-color: var(--accent); }
.qty-btn:disabled { opacity: .4; cursor: not-allowed; }
.qty-value { min-width: 1.4rem; text-align: center; font-weight: 700; }

/* Balance rows (dashboard) */
.balance-row {
    display: flex; justify-content: space-between; align-items: center; padding: .55rem 0;
    border-bottom: 1px solid var(--border); font-size: .95rem;
}
.balance-row:last-child { border-bottom: none; }
.positive { color: var(--green); }
.negative { color: var(--red); }
.zero { color: var(--text-dim); }
.own-name { font-weight: 700; }

/* Expense list */
.expense-details { border-bottom: 1px solid var(--border); }
.expense-details:last-child { border-bottom: none; }
.expense-row {
    display: flex; justify-content: space-between; align-items: flex-start; gap: .75rem;
    padding: .9rem 0; cursor: pointer; list-style: none;
}
.expense-row::-webkit-details-marker { display: none; }
.expense-row::marker { content: ""; }
.expense-row:hover .expense-desc { color: #fff; }
.expense-row:focus-visible { outline: 2px solid var(--accent); outline-offset: -4px; border-radius: var(--radius-sm); }
.expense-details[open] .expense-expand-label { color: var(--accent); }
.expense-main { flex: 1; min-width: 0; }
.expense-desc { font-weight: 600; }
.expense-meta { color: var(--text-dim); font-size: .8rem; margin-top: .2rem; }
.expense-amount-col { text-align: right; flex-shrink: 0; }
.expense-amount { font-weight: 600; }
.expense-expand-label { display: block; color: var(--text-faint); font-size: .75rem; margin-top: .25rem; }
.expense-split-panel { padding: 0 0 1rem; }
.expense-split-heading { color: var(--text-dim); font-size: .78rem; font-weight: 600; margin-bottom: .35rem; }
.expense-split-row {
    display: flex; justify-content: space-between; gap: .75rem; padding: .45rem .6rem;
    background: var(--surface-2); border-radius: 7px; color: var(--text-dim); font-size: .86rem;
    margin-top: .3rem;
}
.expense-split-row span:last-child { color: var(--text); white-space: nowrap; }
.expense-delete-form { margin-top: .8rem; }

/* Insights */
.insight-grid { display: grid; grid-template-columns: 1fr 1fr; gap: .9rem; }
.insight-card { background: var(--surface-2); border-radius: var(--radius-sm); padding: .9rem 1rem; }
.insight-card .label { color: var(--text-dim); font-size: .76rem; margin-bottom: .3rem; }
.insight-card .value { font-size: 1.05rem; font-weight: 700; }
.contrib-row, .month-row { display: flex; justify-content: space-between; padding: .35rem 0; font-size: .87rem; }
@media (max-width: 480px) { .insight-grid { grid-template-columns: 1fr; } }

.empty { color: var(--text-faint); font-size: .88rem; text-align: center; padding: 1.5rem 0; }

/* Wizard-specific */
.wizard-header { text-align: center; margin-bottom: 1.5rem; }
.wizard-header .icon { font-size: 2.2rem; margin-bottom: .4rem; }
.wizard-header h1 { font-size: 1.3rem; margin: 0 0 .3rem; }
.wizard-header p { color: var(--text-dim); font-size: .88rem; margin: 0; }

.upload-actions { display: grid; grid-template-columns: 1fr 1fr; gap: .7rem; }
.upload-btn {
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .4rem;
    padding: 1.1rem .8rem; border-radius: var(--radius); border: 1px solid var(--border);
    background: var(--surface-2); color: var(--text); cursor: pointer; font-size: .88rem; font-weight: 600;
    text-align: center; transition: border-color .15s ease, background .15s ease, transform .1s ease;
    -webkit-tap-highlight-color: transparent; user-select: none;
}
.upload-btn:active { transform: scale(0.97); background: var(--accent-soft); border-color: var(--accent); }
.upload-btn:hover { border-color: var(--accent); background: var(--accent-soft); }
.upload-btn .icon { font-size: 1.9rem; line-height: 1; }
.upload-btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.upload-btn-primary:active { background: var(--accent-hover); border-color: var(--accent-hover); }
.upload-btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.upload-hint { color: var(--text-dim); font-size: .8rem; text-align: center; margin: .7rem 0 0; }
/* Drag-and-drop (desktop convenience only; mobile users tap the buttons above instead). */
.card.dragover { border-color: var(--accent); background: var(--accent-soft); }
@media (max-width: 380px) {
    .upload-actions { grid-template-columns: 1fr; }
}

.divider { display: flex; align-items: center; gap: .75rem; color: var(--text-faint); font-size: .8rem; margin: 1.25rem 0; }
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: var(--border); }

.total-display { text-align: center; padding: .5rem 0 1.25rem; }
.total-display .label { color: var(--text-dim); font-size: .82rem; }
.total-display .amount { font-size: 2rem; font-weight: 700; margin-top: .2rem; }
.total-display .title-row {
    display: flex; align-items: center; justify-content: center; gap: .5rem; margin-top: .3rem;
    color: var(--text-dim); font-size: .92rem;
}
.title-edit-btn {
    background: none; border: none; color: var(--text-faint); cursor: pointer; font-size: .85rem;
    padding: .15rem .3rem; border-radius: 6px;
}
.title-edit-btn:hover { color: var(--text); background: var(--surface-2); }

/* Custom-split "left to add" pool indicator */
.custom-remaining {
    text-align: center; padding: .65rem .8rem; border-radius: var(--radius-sm);
    background: var(--surface-2); border: 1px solid var(--border); color: var(--text);
    font-size: .95rem; font-weight: 700; margin-bottom: 1rem;
    transition: background .15s ease, border-color .15s ease, color .15s ease;
}
.custom-remaining.exact { background: var(--green-bg); border-color: var(--green); color: var(--green); }
.custom-remaining.over { background: var(--red-bg); border-color: var(--red); color: var(--red); }

.method-grid { display: grid; grid-template-columns: 1fr 1fr; gap: .6rem; margin-top: 1rem; }
.method-btn {
    padding: .9rem .7rem; border-radius: var(--radius-sm); border: 1px solid var(--border);
    background: var(--surface-2); color: var(--text); cursor: pointer; font-size: .85rem; font-weight: 600;
    display: flex; flex-direction: column; align-items: center; gap: .35rem; transition: border-color .15s, background .15s;
}
.method-btn:hover { border-color: var(--accent); background: var(--accent-soft); }
.method-btn .icon { font-size: 1.4rem; }
.method-grid .method-btn.wide { grid-column: 1 / -1; }

.progress-dots { display: flex; justify-content: center; gap: .35rem; margin-bottom: 1rem; }
.progress-dots .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--border); }
.progress-dots .dot.active { background: var(--accent); width: 18px; border-radius: 3px; }

.item-label { font-size: 1.05rem; font-weight: 600; margin-bottom: .3rem; }
.item-counter { color: var(--text-dim); font-size: .82rem; margin-bottom: 1rem; }

.payer-grid { display: grid; grid-template-columns: 1fr 1fr; gap: .6rem; }
.payer-btn {
    padding: .9rem .7rem; border-radius: var(--radius-sm); border: 1px solid var(--border);
    background: var(--surface-2); color: var(--text); cursor: pointer; font-size: .92rem; font-weight: 600;
    transition: border-color .15s, background .15s;
}
.payer-btn:hover { border-color: var(--accent); background: var(--accent-soft); }

.done-state { text-align: center; padding: 1.5rem 0; }
.done-state .icon { font-size: 3rem; margin-bottom: .75rem; }
.done-state h2 { font-size: 1.15rem; margin: 0 0 .3rem; }
.done-state p { color: var(--text-dim); font-size: .9rem; margin: 0 0 1.5rem; }

.fade-in { animation: fadeIn .2s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: translateY(0); } }

.spinner {
    width: 32px; height: 32px; border: 3px solid var(--border); border-top-color: var(--accent);
    border-radius: 50%; animation: spin .7s linear infinite; margin: 1.5rem auto;
}
@keyframes spin { to { transform: rotate(360deg); } }
