* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
    --bg: #0f172a;
    --surface: #1e293b;
    --surface2: #334155;
    --text: #f1f5f9;
    --text2: #94a3b8;
    --accent: #22d3ee;
    --accent2: #06b6d4;
    --danger: #ef4444;
    --success: #22c55e;
    --radius: 12px;
}

html, body {
    height: 100%;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
    background: var(--bg);
    color: var(--text);
    -webkit-font-smoothing: antialiased;
    overflow: hidden;
}

/* Screens */
.screen {
    display: none;
    flex-direction: column;
    height: 100%;
    padding: 16px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}
.screen.active { display: flex; }

/* Landing */
.landing {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex: 1;
    gap: 12px;
    text-align: center;
}
.logo { font-size: 64px; margin-bottom: 8px; }
h1 { font-size: 36px; font-weight: 800; letter-spacing: -1px; }
h1 .accent { color: var(--accent); }
.tagline { color: var(--text2); font-size: 18px; margin-bottom: 20px; }

/* Buttons */
.btn-primary {
    width: 100%;
    max-width: 360px;
    padding: 16px 24px;
    background: var(--accent);
    color: var(--bg);
    border: none;
    border-radius: var(--radius);
    font-size: 17px;
    font-weight: 700;
    cursor: pointer;
    transition: opacity 0.15s;
}
.btn-primary:hover { opacity: 0.9; }
.btn-primary:disabled { opacity: 0.4; cursor: not-allowed; }

.btn-secondary {
    background: var(--surface);
    color: var(--text);
    border: 1px solid var(--surface2);
    padding: 12px 24px;
    border-radius: var(--radius);
    font-size: 15px;
    cursor: pointer;
    transition: background 0.15s;
}
.btn-secondary:hover { background: var(--surface2); }

.btn-text {
    background: none;
    border: none;
    color: var(--accent);
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
}

.btn-back {
    background: none;
    border: none;
    color: var(--text);
    font-size: 24px;
    cursor: pointer;
    padding: 4px 8px;
}

.btn-add {
    background: var(--accent);
    color: var(--bg);
    border: none;
    border-radius: 8px;
    padding: 10px 16px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
}

.hint { color: var(--text2); font-size: 14px; margin-top: 8px; }

/* Screen Header */
.screen-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 0 16px;
    min-height: 48px;
}
.screen-header h2 { font-size: 20px; font-weight: 700; flex: 1; text-align: center; }

/* Scanning */
.scanning {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex: 1;
    gap: 16px;
}
.spinner {
    width: 48px;
    height: 48px;
    border: 4px solid var(--surface2);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Error State */
.error-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex: 1;
    gap: 12px;
    text-align: center;
    padding: 32px 16px;
}
.error-icon { font-size: 64px; margin-bottom: 8px; }
.error-state h2 { font-size: 22px; font-weight: 700; }
.error-actions {
    display: flex;
    flex-direction: column;
    gap: 8px;
    width: 100%;
    max-width: 320px;
    margin-top: 16px;
}

/* Items List */
.items-list {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 12px;
}

.item-row {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--surface);
    padding: 12px;
    border-radius: 8px;
}
.item-row input[type="text"] {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--text);
    font-size: 15px;
    outline: none;
}
.item-row input[type="number"] {
    width: 80px;
    background: var(--surface2);
    border: none;
    color: var(--text);
    font-size: 15px;
    padding: 6px 8px;
    border-radius: 6px;
    text-align: right;
    outline: none;
}
.item-row .btn-remove {
    background: none;
    border: none;
    color: var(--danger);
    font-size: 18px;
    cursor: pointer;
    padding: 4px;
}

.fees-section {
    border-top: 1px solid var(--surface2);
    padding-top: 8px;
    margin-bottom: 8px;
}
.fees-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}
.fees-label { color: var(--text2); font-size: 14px; font-weight: 600; }
.fee-row { background: var(--surface); opacity: 0.85; }

.currency-row label {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text2);
    font-size: 14px;
    flex: 1;
}
.currency-row input {
    flex: 1;
    background: var(--surface);
    border: 1px solid var(--surface2);
    color: var(--text);
    padding: 8px 12px;
    border-radius: 8px;
    font-size: 15px;
    outline: none;
}
.currency-row { margin-bottom: 8px; }

.total-check {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--surface);
    padding: 10px 14px;
    border-radius: 8px;
    font-size: 14px;
    margin-bottom: 16px;
    flex-wrap: wrap;
    gap: 4px;
}
.total-match { color: var(--success); }
.total-mismatch { color: #f59e0b; }

/* People */
.people-input {
    display: flex;
    gap: 8px;
    margin-bottom: 12px;
}
.people-input input {
    flex: 1;
    background: var(--surface);
    border: 1px solid var(--surface2);
    color: var(--text);
    padding: 12px 16px;
    border-radius: 8px;
    font-size: 15px;
    outline: none;
}

.chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 12px;
}
.chip {
    display: flex;
    align-items: center;
    gap: 6px;
    background: var(--surface);
    border: 1px solid var(--surface2);
    padding: 8px 12px;
    border-radius: 20px;
    font-size: 14px;
    cursor: default;
}
.chip .remove {
    cursor: pointer;
    color: var(--text2);
    font-size: 16px;
    line-height: 1;
}
.chip .remove:hover { color: var(--danger); }

/* Assign */
.assign-list {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 16px;
}

.assign-item {
    background: var(--surface);
    border-radius: 8px;
    padding: 12px;
}
.assign-item-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 8px;
}
.assign-item-name { font-weight: 600; }
.assign-item-price { color: var(--accent); font-weight: 600; }

.assign-people {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}
.assign-chip {
    padding: 6px 12px;
    border-radius: 16px;
    font-size: 13px;
    font-weight: 500;
    border: 1px solid var(--surface2);
    background: var(--surface2);
    color: var(--text2);
    cursor: pointer;
    transition: all 0.15s;
    user-select: none;
}
.assign-chip.selected {
    background: var(--accent);
    color: var(--bg);
    border-color: var(--accent);
}

/* Summary */
.summary-content {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 16px;
}

.person-summary {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 16px;
}
.person-summary-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}
.person-name { font-size: 17px; font-weight: 700; }
.person-total { font-size: 20px; font-weight: 800; color: var(--accent); }

.person-items {
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.person-item {
    display: flex;
    justify-content: space-between;
    font-size: 14px;
    color: var(--text2);
}
.person-extras {
    margin-top: 6px;
    padding-top: 6px;
    border-top: 1px solid var(--surface2);
    font-size: 13px;
    color: var(--text2);
}

.summary-actions {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

/* Usage Badge */
.usage-badge {
    position: fixed;
    bottom: 16px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--surface);
    border: 1px solid var(--surface2);
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 13px;
    color: var(--text2);
}

/* Modal */
.modal {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    padding: 16px;
}
.modal-content {
    background: var(--surface);
    border-radius: 16px;
    padding: 32px 24px;
    max-width: 400px;
    width: 100%;
    text-align: center;
    position: relative;
}
.modal-close {
    position: absolute;
    top: 12px;
    right: 16px;
    background: none;
    border: none;
    color: var(--text2);
    font-size: 24px;
    cursor: pointer;
}
.price {
    font-size: 36px;
    font-weight: 800;
    color: var(--accent);
    margin: 16px 0;
}
.price span {
    font-size: 16px;
    font-weight: 400;
    color: var(--text2);
}

.input-email {
    width: 100%;
    padding: 12px 16px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: var(--bg);
    color: var(--text);
    font-size: 16px;
    box-sizing: border-box;
}

/* Responsive */
@media (min-width: 640px) {
    .screen { max-width: 480px; margin: 0 auto; }
}
