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

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: #f5f5f7;
    color: #1d1d1f;
    line-height: 1.5;
}

.hidden { display: none !important; }
.error { color: #d32f2f; }
.muted { color: #86868b; font-style: italic; }
.success { color: #2e7d32; }

/* Login */
.login-box {
    max-width: 320px;
    margin: 120px auto;
    padding: 32px;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 2px 12px rgba(0,0,0,0.08);
    text-align: center;
}

.login-box h1 {
    margin-bottom: 24px;
    font-size: 22px;
}

.login-box input {
    width: 100%;
    padding: 10px 12px;
    margin-bottom: 12px;
    border: 1px solid #d2d2d7;
    border-radius: 8px;
    font-size: 16px;
}

.login-box button {
    width: 100%;
    padding: 10px;
    background: #0071e3;
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    cursor: pointer;
}

.login-box button:hover { background: #0077ed; }

/* App layout */
header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 24px;
    background: #fff;
    border-bottom: 1px solid #d2d2d7;
}

header h1 { font-size: 20px; }

nav {
    display: flex;
    gap: 8px;
    padding: 12px 24px;
    background: #fff;
    border-bottom: 1px solid #e5e5ea;
}

.nav-btn {
    padding: 8px 16px;
    border: 1px solid #d2d2d7;
    border-radius: 8px;
    background: #fff;
    cursor: pointer;
    font-size: 14px;
}

.nav-btn.active {
    background: #0071e3;
    color: #fff;
    border-color: #0071e3;
}

main {
    max-width: 1200px;
    margin: 24px auto;
    padding: 0 24px;
}

/* Table */
table {
    width: 100%;
    border-collapse: collapse;
    background: #fff;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}

th, td {
    padding: 12px 16px;
    text-align: left;
    border-bottom: 1px solid #e5e5ea;
}

th {
    background: #f5f5f7;
    font-weight: 600;
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #86868b;
}

td { font-size: 14px; }

td .url-cell {
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    display: block;
    color: #86868b;
    font-size: 12px;
}

/* Buttons */
.btn-primary {
    padding: 8px 20px;
    background: #0071e3;
    color: #fff;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
}

.btn-primary:hover { background: #0077ed; }
.btn-primary:disabled { background: #a0c4e8; cursor: not-allowed; }

.btn-secondary {
    padding: 8px 16px;
    background: #fff;
    color: #0071e3;
    border: 1px solid #0071e3;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
}

.btn-secondary:hover { background: #f0f7ff; }

.btn-danger {
    padding: 6px 12px;
    background: #fff;
    color: #d32f2f;
    border: 1px solid #d32f2f;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
}

.btn-danger:hover { background: #fef2f2; }

.btn-small {
    padding: 6px 12px;
    font-size: 13px;
    border-radius: 6px;
}

.action-btns {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

/* Form */
form {
    background: #fff;
    padding: 24px;
    border-radius: 12px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}

label {
    display: block;
    margin-bottom: 16px;
    font-size: 14px;
    font-weight: 500;
}

label input, label select {
    display: block;
    width: 100%;
    margin-top: 4px;
    padding: 8px 12px;
    border: 1px solid #d2d2d7;
    border-radius: 8px;
    font-size: 14px;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
}

.checkbox-label input {
    width: auto;
    margin: 0;
}

fieldset {
    border: 1px solid #e5e5ea;
    border-radius: 8px;
    padding: 16px;
    margin: 16px 0;
}

fieldset legend {
    font-weight: 600;
    padding: 0 8px;
}

.form-actions {
    display: flex;
    gap: 12px;
    margin-top: 20px;
}

/* Allergen rows */
.allergen-row {
    display: flex;
    gap: 8px;
    margin-bottom: 8px;
    align-items: center;
}

.allergen-row input {
    flex: 1;
    padding: 6px 10px;
    border: 1px solid #d2d2d7;
    border-radius: 6px;
    font-size: 14px;
}

.allergen-row button {
    padding: 4px 8px;
    background: none;
    border: 1px solid #d32f2f;
    color: #d32f2f;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
}

#allergens-section h4 {
    margin-bottom: 8px;
    font-size: 14px;
}

/* Badge */
.badge-active {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 600;
}

.badge-active.yes { background: #dcfce7; color: #166534; }
.badge-active.no { background: #fee2e2; color: #991b1b; }

/* ===== Wizard ===== */
.wizard-steps {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0;
    margin-bottom: 28px;
    padding: 20px 0;
}

.wizard-step {
    display: flex;
    align-items: center;
    gap: 8px;
    opacity: 0.4;
    transition: opacity 0.2s;
}

.wizard-step.active {
    opacity: 1;
}

.wizard-step.completed {
    opacity: 0.7;
}

.step-number {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: #d2d2d7;
    color: #fff;
    font-weight: 700;
    font-size: 14px;
    transition: background 0.2s;
}

.wizard-step.active .step-number {
    background: #0071e3;
}

.wizard-step.completed .step-number {
    background: #2e7d32;
}

.step-label {
    font-size: 14px;
    font-weight: 500;
    color: #86868b;
}

.wizard-step.active .step-label {
    color: #1d1d1f;
    font-weight: 600;
}

.wizard-step-line {
    width: 40px;
    height: 2px;
    background: #d2d2d7;
    margin: 0 12px;
}

/* ===== Split layout (Step 2) ===== */
.split-layout {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
    align-items: start;
}

.split-left h2,
.split-right h2 {
    font-size: 18px;
    margin-bottom: 16px;
}

.split-left form {
    max-height: calc(100vh - 280px);
    overflow-y: auto;
}

.iframe-container {
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.06);
    overflow: hidden;
    height: calc(100vh - 280px);
    position: relative;
}

.iframe-container iframe {
    width: 100%;
    height: 100%;
    border: none;
}

/* ===== Modal (scrape result popup) ===== */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    backdrop-filter: blur(4px);
}

.modal-content {
    background: #f5f5f7;
    border-radius: 16px;
    width: 420px;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 8px 40px rgba(0,0,0,0.15);
    overflow: hidden;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    background: #fff;
    border-bottom: 1px solid #e5e5ea;
}

.modal-header h2 {
    font-size: 17px;
    font-weight: 600;
}

.modal-close {
    background: none;
    border: none;
    font-size: 24px;
    color: #86868b;
    cursor: pointer;
    padding: 0 4px;
    line-height: 1;
}

.modal-close:hover { color: #1d1d1f; }

.modal-body {
    overflow-y: auto;
    padding: 12px 16px;
    flex: 1;
}

.modal-footer {
    padding: 12px 20px;
    background: #fff;
    border-top: 1px solid #e5e5ea;
}

/* ===== App-styled day cards inside modal ===== */
.app-day-card {
    background: rgba(0, 0, 0, 0.04);
    border-radius: 14px;
    padding: 12px;
    margin-bottom: 10px;
    border: 1px solid rgba(0, 0, 0, 0.10);
}

.app-day-card.is-today {
    background: rgba(185, 224, 246, 0.3);
    border-color: rgba(0, 0, 0, 0.18);
}

.app-day-header {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-bottom: 8px;
}

.app-day-name {
    font-size: 16px;
    font-weight: 600;
}

.app-day-card.is-today .app-day-name {
    font-weight: 700;
}

.app-today-badge {
    font-size: 11px;
    font-weight: 700;
    padding: 3px 10px;
    background: rgba(0, 0, 0, 0.06);
    border-radius: 100px;
    letter-spacing: 0.5px;
}

.app-dish-row {
    display: flex;
    align-items: baseline;
    gap: 8px;
    padding: 3px 0;
    font-size: 14px;
    line-height: 1.4;
}

.app-dish-text {
    flex: 1;
}

.app-allergen-ring {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    border: 1px solid rgba(0, 0, 0, 0.35);
    font-size: 10px;
    font-weight: 700;
    flex-shrink: 0;
}

.app-allergen-rings {
    display: flex;
    gap: 4px;
    flex-shrink: 0;
}

.app-no-dishes {
    color: #86868b;
    font-size: 14px;
    font-style: italic;
}

.app-legend {
    display: flex;
    gap: 16px;
    justify-content: center;
    padding: 8px 0 4px;
}

.app-legend-item {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 11px;
    color: #86868b;
}

/* Scrape stats in modal */
.modal-footer .scrape-stats {
    font-size: 13px;
    color: #86868b;
    text-align: center;
    margin: 0;
    padding: 0;
    border: none;
}

/* Scrape error inside step 3 */
.scrape-error {
    background: #fef2f2;
    padding: 12px;
    border-radius: 8px;
    border: 1px solid #fecaca;
    margin-top: 12px;
}

.scrape-error pre {
    margin-top: 8px;
    font-size: 12px;
    background: #fff;
    padding: 8px;
    border-radius: 4px;
    overflow-x: auto;
    max-height: 200px;
}

/* Spinner */
.spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid #d2d2d7;
    border-top-color: #0071e3;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    vertical-align: middle;
    margin-right: 8px;
}

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

/* Responsive: stack split layout on narrow screens */
@media (max-width: 900px) {
    .split-layout {
        grid-template-columns: 1fr;
    }
    .iframe-container {
        height: 400px;
    }
    .modal-content {
        width: 95vw;
    }
}
