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

:root {
    --bg: #0f0f1a;
    --surface: #1a1a2e;
    --surface-2: #22223a;
    --gold: #d4af37;
    --gold-light: #f0d878;
    --text: #fff8e7;
    --text-muted: #a09880;
    --border: #2e2e4a;
    --error: #e74c3c;
    --radius: 12px;
    --shadow: 0 4px 24px rgba(0, 0, 0, 0.4);
}

html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
}

body {
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    line-height: 1.6;
}

.page {
    max-width: 720px;
    margin: 0 auto;
    padding: 1.5rem 1rem 3rem;
}

/* Header */
.header {
    text-align: center;
    padding: 2rem 0 1.5rem;
}

.logo {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
}

.logo-icon {
    font-size: 2.5rem;
    color: var(--gold);
    line-height: 1;
}

.header h1 {
    font-size: 2rem;
    font-weight: 700;
    color: var(--gold);
    letter-spacing: 0.05em;
}

.tagline {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-top: 0.15rem;
}

/* Cards */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
    margin-bottom: 1.25rem;
    box-shadow: var(--shadow);
}

.card h2 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--gold-light);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin-bottom: 1rem;
}

.section-header {
    margin-bottom: 1rem;
}

.hint {
    color: var(--text-muted);
    font-size: 0.85rem;
    margin-top: 0.25rem;
}

/* Mode & Wallet toggles */
.mode-toggle,
.wallet-toggle {
    display: flex;
    gap: 0.75rem;
}

.mode-option,
.wallet-option {
    flex: 1;
    cursor: pointer;
}

.mode-option input,
.wallet-option input {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.mode-label,
.wallet-label {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.85rem 1rem;
    border: 2px solid var(--border);
    border-radius: var(--radius);
    text-align: center;
    font-weight: 500;
    transition: border-color 0.2s, background 0.2s;
    cursor: pointer;
}

.mode-option input:checked + .mode-label,
.wallet-option input:checked + .wallet-label {
    border-color: var(--gold);
    background: rgba(212, 175, 55, 0.1);
    color: var(--gold-light);
}

/* Form fields */
.field-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

@media (max-width: 540px) {
    .field-grid {
        grid-template-columns: 1fr;
    }
}

.field label {
    display: block;
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-muted);
    margin-bottom: 0.35rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.req {
    color: var(--gold);
}

.field input,
.field select {
    width: 100%;
    padding: 0.7rem 0.85rem;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    font-size: 0.95rem;
    transition: border-color 0.2s;
    appearance: none;
}

.field select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%23a09880' d='M1 1l5 5 5-5'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.85rem center;
    padding-right: 2rem;
}

.field input:focus,
.field select:focus {
    outline: none;
    border-color: var(--gold);
}

.field input::placeholder {
    color: #5a5670;
}

/* Family member rows */
.member-row {
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem;
    margin-bottom: 0.75rem;
    position: relative;
}

.member-row-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
}

.member-row-title {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--gold);
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.btn-remove {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 0.8rem;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    transition: color 0.2s, background 0.2s;
}

.btn-remove:hover {
    color: var(--error);
    background: rgba(231, 76, 60, 0.1);
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.85rem 1.5rem;
    border: none;
    border-radius: var(--radius);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: opacity 0.2s, transform 0.1s;
    width: 100%;
}

.btn:active {
    transform: scale(0.98);
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-primary {
    background: linear-gradient(135deg, var(--gold) 0%, #b8942e 100%);
    color: #1a1a2e;
    margin-top: 0.5rem;
}

.btn-primary:hover:not(:disabled) {
    opacity: 0.9;
}

.btn-secondary {
    background: transparent;
    border: 2px dashed var(--border);
    color: var(--text-muted);
    margin-top: 0.5rem;
}

.btn-secondary:hover:not(:disabled) {
    border-color: var(--gold);
    color: var(--gold);
}

/* Error banner */
.error-banner {
    background: rgba(231, 76, 60, 0.15);
    border: 1px solid var(--error);
    border-radius: var(--radius);
    color: #ff8a7a;
    padding: 0.85rem 1rem;
    margin-bottom: 1rem;
    font-size: 0.9rem;
}

/* Utilities */
.hidden {
    display: none !important;
}

/* Footer */
.footer {
    text-align: center;
    padding: 2rem 0 1rem;
    color: var(--text-muted);
    font-size: 0.8rem;
}

/* Loading state */
.btn-primary.loading {
    position: relative;
    color: transparent;
}

.btn-primary.loading::after {
    content: '';
    position: absolute;
    width: 20px;
    height: 20px;
    border: 2px solid #1a1a2e;
    border-top-color: transparent;
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}
