/* ── Reset ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    background: #EBE5DD;
    color: #1a1a1a;
    font-size: 16px;
    line-height: 1.5;
    min-height: 100dvh;
}

/* ── Header ── */
.app-header {
    background: #293A6A;
    color: white;
    padding: 0.9rem 1.25rem env(safe-area-inset-top, 0px) 1.25rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 10;
}
.app-title { font-size: 1.05rem; font-weight: 700; letter-spacing: 0.01em; }
.app-sub   { font-size: 0.7rem; opacity: 0.65; margin-top: 1px; }
.sign-out-btn {
    background: none;
    border: 1px solid rgba(255,255,255,0.35);
    color: rgba(255,255,255,0.8);
    font-size: 0.78rem;
    padding: 0.3rem 0.7rem;
    border-radius: 6px;
    cursor: pointer;
    font-family: inherit;
}
.sign-out-btn:active { opacity: 0.7; }

/* ── Main layout ── */
main { padding: 0 0 2rem; }

/* ── Cards ── */
.card {
    background: white;
    border-radius: 14px;
    padding: 1.1rem 1.1rem;
    margin: 0.75rem 0.9rem;
    box-shadow: 0 1px 4px rgba(0,0,0,0.07), 0 0 0 1px rgba(0,0,0,0.04);
}

/* ── Section labels ── */
.section-label {
    font-size: 0.68rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.09em;
    color: #666D5A;
    margin-bottom: 0.65rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* ── Form controls ── */
input[type="text"],
input[type="password"],
input[type="number"],
select,
textarea {
    width: 100%;
    padding: 0.7rem 0.85rem;
    border: 1.5px solid #d9d3cc;
    border-radius: 9px;
    font-size: 1rem;
    font-family: inherit;
    background: white;
    color: #1a1a1a;
    -webkit-appearance: none;
    appearance: none;
}
input:focus, select:focus { outline: none; border-color: #293A6A; box-shadow: 0 0 0 3px rgba(41,58,106,0.12); }

select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23666' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    padding-right: 2.5rem;
}

label, .field label {
    display: block;
    font-size: 0.82rem;
    font-weight: 600;
    margin-bottom: 0.35rem;
    color: #444;
}

.field { margin-bottom: 1rem; }

/* ── Buttons ── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    padding: 0.75rem 1.4rem;
    border-radius: 10px;
    font-size: 1rem;
    font-weight: 600;
    font-family: inherit;
    border: none;
    cursor: pointer;
    -webkit-appearance: none;
    transition: opacity 0.12s, transform 0.08s;
    text-decoration: none;
    line-height: 1.2;
}
.btn:active { opacity: 0.82; transform: scale(0.98); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; transform: none; }

.btn-primary { background: #293A6A; color: white; }
.btn-amber   { background: #AD6C2D; color: white; }
.btn-full    { width: 100%; }
.btn-lg      { padding: 1rem 1.4rem; font-size: 1.05rem; }

/* ── Add photo button ── */
.add-photo-btn {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 1rem;
    border: 2px dashed #AD6C2D;
    border-radius: 12px;
    background: #fdf9f5;
    color: #AD6C2D;
    font-size: 1rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    -webkit-appearance: none;
    transition: background 0.1s;
}
.add-photo-btn:active { background: #f7efe4; }

/* ── Photo grid ── */
#photo-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.65rem;
    margin-bottom: 0.75rem;
}
#photo-grid:empty { display: none; }

.photo-item {
    background: #f5f3f0;
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    position: relative;
}
.photo-item img {
    width: 100%;
    aspect-ratio: 4/3;
    object-fit: cover;
    display: block;
}
.photo-item .photo-footer {
    padding: 0.45rem 0.45rem 0.5rem;
}
.photo-item input[type="text"] {
    font-size: 0.82rem;
    padding: 0.35rem 0.5rem;
    border-radius: 6px;
}
.photo-remove-btn {
    position: absolute;
    top: 5px;
    right: 5px;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: rgba(0,0,0,0.55);
    color: white;
    border: none;
    font-size: 13px;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    -webkit-appearance: none;
}
.photo-remove-btn:active { background: rgba(180,30,30,0.8); }

/* Photo count chip */
.photo-count {
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: none;
    letter-spacing: 0;
    background: #EBE5DD;
    color: #666D5A;
    padding: 0.1rem 0.5rem;
    border-radius: 20px;
}

/* Processing placeholder */
.photo-processing {
    aspect-ratio: 4/3;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f0ede8;
    color: #aaa;
    font-size: 0.8rem;
}

/* ── Selected job label ── */
.selected-job-label {
    margin-top: 0.5rem;
    padding: 0.5rem 0.75rem;
    background: #f0f3fa;
    border-left: 3px solid #293A6A;
    border-radius: 0 8px 8px 0;
    font-size: 0.875rem;
    font-weight: 600;
    color: #293A6A;
}

/* ── Alerts ── */
.alert {
    padding: 0.7rem 0.9rem;
    border-radius: 9px;
    font-size: 0.875rem;
    margin-bottom: 0.9rem;
}
.alert-error   { background: #fee2e2; color: #991b1b; border: 1px solid #fca5a5; }
.alert-success { background: #d1fae5; color: #065f46; border: 1px solid #6ee7b7; }

/* ── Sync status ── */
.sync-summary {
    font-size: 0.82rem;
    font-weight: 700;
    color: #666D5A;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-bottom: 0.5rem;
}
.sync-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.45rem 0;
    border-bottom: 1px solid #f0ede8;
    font-size: 0.875rem;
}
.sync-item:last-child { border-bottom: none; }

/* ── Badges ── */
.badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    font-size: 0.7rem;
    font-weight: 700;
    flex-shrink: 0;
}
.badge-ok  { background: #d1fae5; color: #065f46; }
.badge-err { background: #fee2e2; color: #991b1b; }

/* ── Login ── */
.login-wrap { min-height: 100dvh; display: flex; flex-direction: column; }
.login-hero {
    background: #293A6A;
    padding: calc(env(safe-area-inset-top, 0px) + 3rem) 2rem 2.5rem;
    text-align: center;
    color: white;
}
.login-logo { margin-bottom: 1rem; }
.login-hero h1 { font-size: 1.6rem; font-weight: 700; }
.login-hero p  { font-size: 0.85rem; opacity: 0.65; margin-top: 0.3rem; }
.login-body    { padding: 1.75rem 1.25rem; flex: 1; }
.login-body h2 { font-size: 1rem; font-weight: 600; margin-bottom: 1.25rem; color: #293A6A; }

/* ── Utilities ── */
.hidden { display: none !important; }
.muted  { color: #888; font-size: 0.875rem; }
.hint   { color: #aaa; font-size: 0.78rem; text-align: center; }
.mt-1   { margin-top: 0.5rem; }
.mt-2   { margin-top: 1rem; }
.mt-3   { margin-top: 1.5rem; }

/* ── Admin header links ── */
.admin-link {
    color: rgba(255,255,255,0.8);
    font-size: 0.82rem;
    font-weight: 600;
    text-decoration: none;
    border: 1px solid rgba(255,255,255,0.3);
    padding: 0.28rem 0.65rem;
    border-radius: 6px;
}
.admin-link:active { opacity: 0.7; }

/* ── Danger button ── */
.btn-danger {
    background: #b91c1c;
    color: white;
}
.btn-danger:active { opacity: 0.82; }

/* ── Small outline button ── */
.btn-outline-sm {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.3rem 0.8rem;
    border-radius: 7px;
    font-size: 0.8rem;
    font-weight: 600;
    font-family: inherit;
    border: 1.5px solid #293A6A;
    color: #293A6A;
    background: transparent;
    cursor: pointer;
    text-decoration: none;
}
.btn-outline-sm:active { background: #f0f3fa; }

/* ── Admin table ── */
.admin-table-wrap { overflow-x: auto; }
.admin-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
}
.admin-table th {
    text-align: left;
    padding: 0.5rem 0.75rem;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    color: #666D5A;
    border-bottom: 2px solid #EBE5DD;
    white-space: nowrap;
}
.admin-table td {
    padding: 0.75rem;
    border-bottom: 1px solid #f5f2ee;
    vertical-align: middle;
}
.admin-table tr:last-child td { border-bottom: none; }
.row-inactive td { opacity: 0.45; }
.mono {
    font-family: 'Menlo', 'Consolas', 'Courier New', monospace;
    font-size: 0.78rem;
}
.action-cell { text-align: right; white-space: nowrap; }

/* ── Status pills ── */
.status-pill {
    display: inline-block;
    padding: 0.18rem 0.6rem;
    border-radius: 20px;
    font-size: 0.72rem;
    font-weight: 700;
    white-space: nowrap;
}
.pill-active   { background: #d1fae5; color: #065f46; }
.pill-inactive { background: #f3f4f6; color: #6b7280; }
