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

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: #f5f5f5;
    color: #333;
    padding: 16px;
    max-width: 900px;
    margin: 0 auto;
}

h1 {
    text-align: center;
    margin-bottom: 24px;
    color: #1a1a2e;
}

/* Header bar with logout */
.header-bar {
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
    margin-bottom: 8px;
}

.header-bar h1 {
    margin-bottom: 0;
}

.btn-logout {
    position: absolute;
    right: 0;
    background: #888;
    color: white;
    padding: 6px 14px;
    font-size: 0.8rem;
    text-decoration: none;
    border-radius: 6px;
}

/* ── Login ── */
.login-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 80vh;
}

.login-card {
    max-width: 360px;
    width: 100%;
    text-align: center;
}

.pin-input-group {
    margin: 20px 0;
}

.pin-input-group input {
    width: 180px;
    font-size: 2rem;
    text-align: center;
    padding: 12px;
    border: 2px solid #ccc;
    border-radius: 8px;
    letter-spacing: 12px;
}

.pin-input-group input:focus {
    border-color: #4a90d9;
    outline: none;
}

.attempts-info {
    margin-top: 12px;
    color: #888;
    font-size: 0.85rem;
}

/* ── Cards ── */
.card {
    background: white;
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 16px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}

.card h2 {
    margin-bottom: 16px;
    font-size: 1.1rem;
    color: #444;
}

/* ── Form rows ── */
.form-row {
    display: flex;
    gap: 12px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.form-group {
    flex: 1;
    min-width: 140px;
}

.form-group label {
    display: block;
    font-weight: 600;
    margin-bottom: 4px;
    font-size: 0.9rem;
}

.form-group input,
.form-group select {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #ccc;
    border-radius: 6px;
    font-size: 0.95rem;
}

/* ── Photo sections (two-sided card) ── */
.photo-sections {
    display: flex;
    gap: 12px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.photo-section {
    flex: 1;
    min-width: 140px;
}

.photo-label {
    display: block;
    font-weight: 600;
    margin-bottom: 6px;
    font-size: 0.9rem;
    color: #555;
}

.upload-area {
    border: 2px dashed #ccc;
    border-radius: 8px;
    padding: 24px 12px;
    text-align: center;
    cursor: pointer;
    transition: border-color 0.2s, background 0.2s;
}

.upload-area:hover {
    border-color: #4a90d9;
    background: #f0f7ff;
}

.upload-area.dragover {
    border-color: #4a90d9;
    background: #e8f0fe;
}

.upload-area input[type="file"] {
    display: none;
}

.upload-area p {
    color: #888;
    font-size: 0.85rem;
    margin: 0;
}

.preview-images {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-top: 8px;
}

.preview-images img {
    max-height: 100px;
    border-radius: 6px;
    border: 1px solid #ddd;
}

/* ── Buttons ── */
.btn {
    display: inline-block;
    padding: 10px 24px;
    border: none;
    border-radius: 6px;
    font-size: 0.95rem;
    cursor: pointer;
    transition: opacity 0.2s;
}

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

.btn-primary { background: #4a90d9; color: white; }
.btn-success { background: #27ae60; color: white; }
.btn-danger { background: #e74c3c; color: white; }
.btn-full { width: 100%; display: block; text-align: center; }
.btn-small { padding: 6px 14px; font-size: 0.8rem; }

.btn + .btn { margin-left: 8px; }

/* ── Results table ── */
.results-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 12px;
    font-size: 0.85rem;
}

.results-table th,
.results-table td {
    border: 1px solid #ddd;
    padding: 6px 8px;
    text-align: center;
}

.results-table th {
    background: #f0f0f0;
    font-weight: 600;
    font-size: 0.8rem;
}

.results-table td input {
    width: 55px;
    text-align: center;
    border: 1px solid transparent;
    padding: 2px 4px;
    border-radius: 4px;
    font-size: 0.85rem;
}

.results-table td input:focus {
    border-color: #4a90d9;
    outline: none;
}

/* ── Sheet selector ── */
.sheet-selector {
    margin-bottom: 16px;
}

.sheet-selector select {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #ccc;
    border-radius: 6px;
    font-size: 0.95rem;
}

/* ── Status messages ── */
.status {
    padding: 12px 16px;
    border-radius: 6px;
    margin-top: 12px;
    display: none;
    word-break: break-word;
}

.status.show { display: block; }
.status.success { background: #d4edda; color: #155724; border: 1px solid #c3e6cb; }
.status.error { background: #f8d7da; color: #721c24; border: 1px solid #f5c6cb; }
.status.info { background: #d1ecf1; color: #0c5460; border: 1px solid #bee5eb; }

/* ── Spinner ── */
.spinner {
    display: inline-block;
    width: 18px;
    height: 18px;
    border: 3px solid #ddd;
    border-top-color: #4a90d9;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    vertical-align: middle;
    margin-right: 6px;
}

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

/* ── Engine selector ── */
.engine-selector {
    margin-bottom: 16px;
}

.engine-selector > label {
    display: block;
    margin-bottom: 8px;
}

.engine-options {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.engine-radio {
    display: flex;
    align-items: flex-start;
    gap: 6px;
    cursor: pointer;
}

.engine-radio input[type="radio"] {
    margin-top: 6px;
}

.engine-badge {
    display: inline-block;
    padding: 8px 12px;
    border-radius: 8px;
    border: 2px solid #ddd;
    transition: border-color 0.2s, background 0.2s;
    min-width: 140px;
    font-size: 0.9rem;
}

.engine-radio input[type="radio"]:checked + .engine-badge {
    border-color: #4a90d9;
    background: #f0f7ff;
}

.engine-badge small { color: #777; }
.engine-badge.engine-claude { border-left: 3px solid #d97706; }
.engine-badge.engine-gemini { border-left: 3px solid #4285f4; }
.engine-loading { color: #888; font-style: italic; }

/* ── Performance stats ── */
.perf-stats {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 16px;
    padding: 10px 14px;
    background: #fafafa;
    border-radius: 8px;
    border: 1px solid #eee;
}

.perf-stats:empty { display: none; }

.stat { display: flex; flex-direction: column; gap: 2px; }
.stat-label { font-size: 0.7rem; text-transform: uppercase; color: #888; letter-spacing: 0.5px; }
.stat-value { font-size: 0.9rem; font-weight: 600; color: #333; }
.stat-value.engine-tag-claude { color: #d97706; }
.stat-value.engine-tag-gemini { color: #4285f4; }

/* ── Meta info ── */
.meta-info {
    display: flex;
    gap: 16px;
    margin-bottom: 12px;
    font-size: 0.9rem;
    flex-wrap: wrap;
}

.meta-info label { font-weight: 600; }
.meta-info span { color: #555; }
