:root {
  --blue: #2563eb;
  --bg: #f8fafc;
  --border: #e2e8f0;
  --text: #0f172a;
  --muted: #64748b;
}
* { box-sizing: border-box; }
body { margin: 0; font-family: system-ui, -apple-system, sans-serif; background: var(--bg); color: var(--text); }
main { max-width: 720px; margin: 0 auto; padding: 16px; }
section { background: #fff; border: 1px solid var(--border); border-radius: 12px; padding: 16px; margin-bottom: 16px; }
h2 { margin: 0 0 12px; font-size: 16px; }
input, select, button { font: inherit; }
input[type="text"], input[type="number"], input:not([type]) {
  border: 1px solid var(--border); border-radius: 8px; padding: 10px; min-height: 44px; width: 100%;
}
a { color: var(--blue); }

/* Header */
.app-header { display: flex; justify-content: space-between; align-items: center; padding: 12px 16px; background: var(--blue); color: #fff; }
.app-title { color: #fff; text-decoration: none; font-weight: 700; font-size: 18px; }
.identity-btn { background: rgba(255,255,255,.15); color: #fff; border: 0; border-radius: 999px; padding: 8px 14px; min-height: 44px; cursor: pointer; }

/* Buttons */
.btn { min-height: 44px; padding: 10px 16px; border: 1px solid var(--border); background: #fff; border-radius: 8px; cursor: pointer; }
.btn-primary { background: var(--blue); border-color: var(--blue); color: #fff; }
.btn-big { width: 100%; font-size: 18px; padding: 18px; }
.btn-small { min-height: 44px; min-width: 44px; padding: 6px; }

/* Home */
.home .btn-big { margin: 24px 0; }
.recent-list { list-style: none; padding: 0; margin: 0; }
.recent-list li { border-bottom: 1px solid var(--border); }
.recent-list a { display: block; padding: 12px 4px; text-decoration: none; min-height: 44px; }

/* Bill top bar */
.top-bar { display: flex; gap: 8px; align-items: center; margin-bottom: 16px; }
.bill-name { font-size: 18px; font-weight: 600; flex: 1; }
.save-indicator { color: var(--muted); font-size: 13px; white-space: nowrap; }

/* People chips */
.chips { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.chip { display: inline-flex; align-items: center; background: #eff6ff; border: 1px solid #bfdbfe; border-radius: 999px; padding: 2px 2px 2px 12px; }
.chip-name { border: 0; background: none; min-height: 40px; cursor: pointer; }
.chip-edit { max-width: 120px; min-height: 40px; }
.chip-remove { border: 0; background: none; min-width: 40px; min-height: 40px; cursor: pointer; color: var(--muted); }
.chip-add { max-width: 160px; }

/* Items table */
.table-wrap { overflow-x: auto; margin-bottom: 12px; }
table.items { border-collapse: collapse; min-width: 100%; }
table.items th, table.items td { padding: 6px; border-bottom: 1px solid var(--border); text-align: left; white-space: nowrap; background: #fff; }
table.items th:first-child, table.items td:first-child { position: sticky; left: 0; width: 140px; min-width: 140px; z-index: 1; }
table.items th:nth-child(2), table.items td:nth-child(2) { position: sticky; left: 140px; width: 100px; min-width: 100px; z-index: 1; }
table.items input[type="checkbox"] { width: 24px; height: 24px; }
table.items td input { min-width: 90px; }
.num { text-align: right; font-variant-numeric: tabular-nums; }

/* Charges */
.money-field { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.money-field input { max-width: 140px; }
.fee-row { display: flex; gap: 8px; margin-bottom: 8px; }
.fee-row select { min-height: 44px; border: 1px solid var(--border); border-radius: 8px; }

/* Summary */
.summary-list { margin-bottom: 8px; }
.summary-row { display: flex; justify-content: space-between; padding: 8px 0; border-bottom: 1px solid var(--border); }
.summary-row.grand { font-weight: 700; border-bottom: 0; }
.warning { color: #b45309; background: #fffbeb; border: 1px solid #fde68a; border-radius: 8px; padding: 8px 12px; }
.reconcile { font-size: 13px; }
.reconcile.ok { color: #15803d; }

/* Modal */
.modal-overlay { position: fixed; inset: 0; background: rgba(15,23,42,.5); display: flex; align-items: center; justify-content: center; padding: 16px; z-index: 10; }
.modal { background: #fff; border-radius: 12px; padding: 20px; max-width: 360px; width: 100%; }
.modal h2 { font-size: 18px; }
.modal-actions { display: flex; gap: 8px; margin-top: 12px; justify-content: flex-end; }
.field-error { color: #b91c1c; font-size: 13px; }
