:root {
    --primary: #0f4c81;
    --primary-light: #4f7fab;
    --primary-lightest: #e4edf5;
    --accent: #2f8f68;
    --accent-light: #5cb08a;
    --accent-lightest: #e3f4ec;
    --dark: #2d3432;
    --bg: #f2f5f4;
    --surface: #ffffff;
    --text: #1f2937;
    --text-muted: #6b7280;
    --border: #eef1f0;
    --border-dark: #e2e8e6;
    --danger: #ef4444;
    --success: #2f8f68;
    --radius-lg: 16px;
    --radius-md: 12px;
    --radius-sm: 8px;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: var(--bg);
    color: var(--text);
    margin: 0;
    padding: 0;
    -webkit-font-smoothing: antialiased;
    padding-top: env(safe-area-inset-top);
    padding-bottom: env(safe-area-inset-bottom);
}

.container {
    width: 100%;
    max-width: 500px;
    margin: 0 auto;
    padding: 16px;
    box-sizing: border-box;
}

.app-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin: 12px 0 24px 0;
}

h1 {
    font-size: 28px;
    font-weight: 800;
    color: var(--primary);
    margin: 0;
    letter-spacing: -0.5px;
    flex: 1;
}

.app-header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.app-intro {
    font-size: 14px;
    color: var(--text-muted);
    line-height: 1.5;
    margin: -8px 0 20px 0;
}

.help-btn {
    background-color: var(--surface);
    color: var(--primary);
    border: 1.5px solid var(--primary-light);
    width: 34px;
    height: 34px;
    min-width: 34px;
    border-radius: 50%;
    font-size: 16px;
    font-weight: 800;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    box-shadow: 0 2px 4px rgba(15, 76, 129, 0.08);
}

    .help-btn:active {
        background-color: var(--primary-lightest);
    }

.app-icon {
    width: 38px;
    height: 38px;
    /* border-radius: 10px;
                border: 1.5px solid var(--dark);
                box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15); */
}

.user-badge {
    font-size: 12px;
    font-weight: 700;
    color: var(--primary);
    max-width: 90px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

h2 {
    font-size: 20px;
    font-weight: 700;
    margin-top: 0;
    margin-bottom: 16px;
    color: var(--text);
    border-bottom: 2px solid var(--primary-lightest);
    padding-bottom: 8px;
}

.card {
    background: var(--surface);
    padding: 20px;
    border-radius: var(--radius-lg);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.03), 0 1px 3px rgba(0, 0, 0, 0.02);
    margin-bottom: 16px;
    border: 1px solid rgba(0, 0, 0, 0.01);
}

/* Custom Touch Zone for Camera Capture */
.upload-zone {
    border: 2px dashed var(--primary-light);
    background-color: var(--primary-lightest);
    background-image: radial-gradient(var(--primary-lightest) 40%, transparent 42%);
    background-size: 8px 8px;
    border-radius: var(--radius-md);
    padding: 24px 16px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    margin-bottom: 8px;
}

    .upload-zone:active {
        transform: scale(0.98);
        background-color: #d9e6ef;
    }

.upload-icon {
    width: 48px;
    height: 48px;
    color: var(--primary);
    margin-bottom: 12px;
}

.upload-title {
    font-size: 16px;
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 4px;
}

.upload-subtitle {
    font-size: 12px;
    color: var(--text-muted);
}

.controls {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.control-group {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

    .control-group label {
        font-weight: 700;
        font-size: 15px;
    }

button.btn-action,
a.btn-action {
    background-color: var(--primary);
    color: white;
    border: none;
    padding: 14px 20px;
    border-radius: var(--radius-md);
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
    width: 100%;
    margin-top: 4px;
    box-shadow: 0 4px 6px rgba(15, 76, 129, 0.15);
    transition: all 0.2s ease;
    text-align: center;
    box-sizing: border-box;
}

    button.btn-action:active,
    a.btn-action:active {
        transform: translateY(1px);
        box-shadow: 0 2px 3px rgba(15, 76, 129, 0.15);
        opacity: 0.95;
    }

    a.btn-action:visited {
        color: white;
    }

button.btn-small {
    background-color: var(--primary);
    color: white;
    border: none;
    padding: 10px 16px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 2px 4px rgba(15, 76, 129, 0.1);
}

button.btn-outline {
    background-color: transparent;
    color: var(--primary);
    border: 1.5px solid var(--primary-light);
    padding: 10px 16px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
}

    button.btn-outline:active {
        background-color: var(--primary-lightest);
    }

button.btn-accent {
    background-color: var(--accent);
    color: white;
    border: none;
    padding: 14px 20px;
    border-radius: var(--radius-md);
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
    width: 100%;
    box-shadow: 0 4px 6px rgba(47, 143, 104, 0.2);
}

    button.btn-accent:active {
        transform: translateY(1px);
        opacity: 0.95;
    }

#peopleList {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid var(--border);
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
}

.person-badge {
    background-color: var(--primary-lightest);
    color: var(--primary);
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 700;
}

.person-chip {
    display: flex;
    align-items: center;
    gap: 2px;
    background-color: var(--primary-lightest);
    border-radius: 20px;
    padding: 4px 4px 4px 12px;
}

.person-name-input {
    border: none;
    background: transparent;
    color: var(--primary);
    font-size: 13px;
    font-weight: 700;
    padding: 4px 2px;
    outline: none;
    min-width: 50px;
    max-width: 140px;
}

.person-remove-btn {
    background: none;
    border: none;
    color: var(--primary);
    font-size: 15px;
    font-weight: 700;
    cursor: pointer;
    width: 22px;
    height: 22px;
    min-width: 22px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    padding: 0;
}

    .person-remove-btn:active {
        background-color: rgba(15, 76, 129, 0.15);
    }

/* Stacked responsive design patterns for line items */
.item-row-card {
    background: var(--surface);
    border: 1px solid var(--border-dark);
    border-radius: var(--radius-md);
    padding: 14px;
    margin-bottom: 12px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.item-row-header {
    display: flex;
    gap: 8px;
    align-items: flex-start;
}

.item-badge-index {
    background-color: #f3f4f6;
    color: var(--text-muted);
    font-size: 11px;
    font-weight: 700;
    padding: 3px 6px;
    border-radius: var(--radius-sm);
    min-width: 20px;
    text-align: center;
}

.item-name-text {
    font-size: 15px;
    font-weight: 600;
    color: var(--text);
    word-break: break-word;
    line-height: 1.3;
}

.item-row-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-top: 1px dashed var(--border-dark);
    padding-top: 10px;
}

.item-price-val {
    font-size: 16px;
    font-weight: 800;
    color: var(--text);
}

input[type="number"],
input[type="text"] {
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-dark);
    font-size: 15px;
    font-weight: 600;
    box-sizing: border-box;
}

#status {
    text-align: center;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-muted);
    margin-top: 12px;
    padding: 12px;
    border-radius: var(--radius-md);
    background-color: #f9fafb;
    line-height: 1.4;
}

.status-warning {
    background-color: #fffbeb !important;
    color: #b45309 !important;
    border: 1px solid #fef3c7;
}

.status-error {
    background-color: #fef2f2 !important;
    color: #b91c1c !important;
    border: 1px solid #fee2e2;
}

.result-card-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 0;
    border-bottom: 1px solid var(--border);
}

    .result-card-row:last-child {
        border-bottom: none;
    }

.result-person {
    font-size: 16px;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 8px;
}

.result-person-initial {
    width: 28px;
    height: 28px;
    background-color: var(--primary);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 800;
}

.result-amounts {
    text-align: right;
}

.result-grandtotal {
    font-size: 18px;
    font-weight: 800;
    color: var(--accent);
}

.result-breakdown {
    font-size: 11px;
    font-weight: 500;
    color: var(--text-muted);
    display: block;
    margin-top: 2px;
}

/* Shared modal overlay used by Help and the multi-receipt prompt */
.modal-overlay {
    position: fixed;
    inset: 0;
    background-color: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    z-index: 100;
    box-sizing: border-box;
}

.modal-card {
    background: var(--surface);
    border-radius: var(--radius-lg);
    padding: 20px;
    width: 100%;
    max-width: 440px;
    max-height: 85vh;
    overflow-y: auto;
    box-sizing: border-box;
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.2);
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}

    .modal-header h2 {
        border-bottom: none;
        padding-bottom: 0;
        margin-bottom: 0;
    }

.modal-close-btn {
    background: none;
    border: none;
    font-size: 22px;
    line-height: 1;
    color: var(--text-muted);
    cursor: pointer;
    padding: 0 4px;
}

.modal-body {
    font-size: 14px;
    line-height: 1.55;
    color: var(--text);
}

    .modal-body h3 {
        font-size: 14px;
        color: var(--primary);
        margin: 16px 0 4px 0;
    }

        .modal-body h3:first-child {
            margin-top: 0;
        }

    .modal-body ul,
    .modal-body ol {
        margin: 4px 0 0 0;
        padding-left: 20px;
    }

    .modal-body li {
        margin-bottom: 6px;
    }

    .modal-body p {
        margin: 4px 0 0 0;
    }

.modal-actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 16px;
}

/* Per-item "who shares this?" toggle chips - allow any subset of people */
.item-people-label {
    font-size: 11px;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.03em;
    margin-bottom: 2px;
}

.item-people-row {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.person-toggle-chip {
    border: 1.5px solid var(--border-dark);
    background-color: var(--surface);
    color: var(--text-muted);
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
}

    .person-toggle-chip.active {
        background-color: var(--primary);
        border-color: var(--primary);
        color: white;
    }

.item-ignore-toggle {
    border: 1.5px solid var(--border-dark);
    background-color: var(--surface);
    color: var(--text-muted);
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
}

    .item-ignore-toggle.active {
        background-color: var(--danger);
        border-color: var(--danger);
        color: white;
    }

.item-split-all-btn {
    border: none;
    background: none;
    color: var(--accent);
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
    text-decoration: underline;
    padding: 4px 0;
    align-self: flex-start;
}

.status-success {
    background-color: var(--accent-lightest) !important;
    color: var(--success) !important;
    border: 1px solid var(--accent-light);
}

.item-unassigned-note {
    font-size: 11px;
    color: var(--danger);
    font-weight: 600;
}

.data-buttons-row {
    display: flex;
    gap: 10px;
}

    .data-buttons-row button {
        flex: 1;
    }

