:root {
  --bg: #f7f4ed;
  --surface: #fffdf8;
  --surface-soft: #edf5f2;
  --primary: #0b5d55;
  --primary-dark: #07463f;
  --primary-light: #d7ebe5;
  --ink: #142b36;
  --muted: #66757c;
  --danger: #b83232;
  --danger-soft: #fbe9e7;
  --success: #13795b;
  --warning: #9a6700;
  --border: #dce4e1;
  --shadow: 0 6px 24px rgba(19, 48, 55, .07);
  --radius-sm: 10px;
  --radius: 16px;
  --radius-lg: 24px;
  --space-1: .5rem;
  --space-2: .75rem;
  --space-3: 1rem;
  --space-4: 1.5rem;
  --space-5: 2rem;
  --tap: 48px;
  font-family: "Noto Sans Arabic", "Segoe UI", Tahoma, Arial, sans-serif;
  color: var(--ink);
  background: var(--bg);
  font-synthesis: none;
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--bg); }
body { margin: 0; min-height: 100dvh; background: var(--bg); }
button, input, select, textarea { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
img { max-width: 100%; }
.app-shell { width: 100%; max-width: 480px; min-height: 100dvh; margin: 0 auto; padding: max(var(--space-3), env(safe-area-inset-top)) var(--space-3) max(var(--space-3), env(safe-area-inset-bottom)); }
.visually-hidden { position: absolute!important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
.muted, .form-hint { color: var(--muted); }
.form-hint { margin: 0; font-size: .82rem; line-height: 1.6; }
h1, h2, p { margin-top: 0; }
svg { width: 24px; height: 24px; fill: currentColor; }

.button { min-height: var(--tap); border: 0; border-radius: var(--radius-sm); padding: .75rem 1rem; display: inline-flex; align-items: center; justify-content: center; gap: .25rem; color: var(--ink); background: #e7ecea; font-weight: 700; text-decoration: none; cursor: pointer; }
.button:disabled { opacity: .58; cursor: wait; }
.button--primary, .button--approve { color: white; background: var(--primary); }
.button--primary:active, .button--approve:active { background: var(--primary-dark); }
.button--danger-quiet { color: var(--danger); background: var(--danger-soft); }
.button--reject { color: white; background: var(--danger); }
.button--quiet { background: #edf0ef; }
.button--outline { color: var(--primary); background: transparent; border: 1px solid var(--primary); }
.flash-stack { position: fixed; z-index: 20; inset: max(12px, env(safe-area-inset-top)) 16px auto; max-width: 448px; margin: auto; }
.flash { padding: .8rem 1rem; border-radius: var(--radius-sm); box-shadow: var(--shadow); background: var(--surface); }
.flash--error { color: var(--danger); border-inline-start: 4px solid var(--danger); }
.flash--success { color: var(--success); border-inline-start: 4px solid var(--success); }
.brand-mark { position: relative; width: 52px; height: 52px; border-radius: 16px; background: var(--primary); margin: 0 auto; }
.brand-mark::before { content: ""; position: absolute; width: 22px; height: 16px; border: 3px solid white; border-radius: 6px; inset: 18px 15px; }
.brand-mark::after { content: ""; position: absolute; width: 7px; height: 7px; background: white; border-radius: 50%; inset: 24px 23px; }
.brand-mark span { position: absolute; width: 13px; height: 5px; background: white; border-radius: 3px 3px 0 0; inset: 14px 20px; }
.brand-mark--small { width: 32px; height: 32px; border-radius: 10px; margin: 0; transform: scale(.72); transform-origin: center; }

.login-page .app-shell { display: grid; place-items: center; }
.auth-card { width: 100%; background: var(--surface); padding: var(--space-5) var(--space-4); border-radius: var(--radius-lg); box-shadow: var(--shadow); text-align: center; }
.auth-card h1 { margin: var(--space-3) 0 .2rem; font-size: 1.7rem; }
.stack-form { display: grid; gap: .55rem; text-align: right; margin-top: var(--space-4); }
.stack-form input, .filters input, .filters select, textarea { width: 100%; min-height: var(--tap); padding: .7rem .8rem; color: var(--ink); background: white; border: 1px solid var(--border); border-radius: var(--radius-sm); }
.stack-form .button { margin-top: var(--space-2); }

.collector-page .app-shell { display: flex; }
.collector { flex: 1; min-height: calc(100dvh - max(2rem, env(safe-area-inset-top) + env(safe-area-inset-bottom))); display: flex; flex-direction: column; position: relative; }
.collector__header { min-height: 48px; display: flex; align-items: center; justify-content: space-between; color: var(--primary); font-weight: 800; }
.collector__brand { position: absolute; left: 50%; transform: translateX(-50%); display: flex; align-items: center; gap: .15rem; }
.collector-logout { min-width: 48px; min-height: 44px; padding: .25rem .4rem; display: flex; align-items: center; gap: .25rem; border: 0; border-radius: var(--radius-sm); color: var(--muted); background: transparent; cursor: pointer; }
.collector-logout svg { width: 20px; height: 20px; }
.collector-logout span { display: flex; flex-direction: column; line-height: 1.1; }
.collector-logout strong { font-size: .76rem; }
.collector-logout small { margin-top: .15rem; font-size: .58rem; font-weight: 500; direction: ltr; }
.capture-state { flex: 1; display: grid; place-items: center; padding-bottom: 44px; }
.capture-state[hidden] { display: none; }
.capture-button { width: min(78vw, 330px); aspect-ratio: 1; border-radius: 50%; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .35rem; color: white; background: var(--primary); box-shadow: 0 12px 34px rgba(11,93,85,.2); cursor: pointer; text-align: center; }
.capture-button svg { width: 58px; height: 58px; margin-bottom: .6rem; }
.capture-button strong { font-size: 1.45rem; }
.capture-button small, .collector-actions small, .success-message small { display: block; opacity: .76; font-size: .86rem; font-weight: 500; direction: ltr; }
.preview-state { flex: 1; min-height: 0; display: flex; flex-direction: column; gap: var(--space-3); }
.preview-state[hidden] { display: none; }
.preview-frame { flex: 1; min-height: 0; display: grid; place-items: center; overflow: hidden; background: #10242a; border-radius: var(--radius); }
.preview-frame img { width: 100%; height: 100%; max-height: calc(100dvh - 245px); object-fit: contain; }
.collector-actions { display: grid; grid-template-columns: 1.35fr 1fr; gap: var(--space-2); }
.collector-actions .button { min-height: 60px; flex-direction: column; }
.upload-status { min-height: 24px; text-align: center; color: var(--muted); }
.upload-status.is-error { color: var(--danger); }
.success-message { position: absolute; z-index: 5; inset: 50% 12px auto; transform: translateY(-50%); padding: 1.4rem; border-radius: var(--radius); color: var(--success); background: var(--surface); box-shadow: var(--shadow); text-align: center; }
.success-check { display: grid; place-items: center; width: 42px; height: 42px; margin: 0 auto .7rem; border-radius: 50%; color: white; background: var(--success); font-size: 1.4rem; }

.review-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: var(--space-3); }
.review-header h1 { margin: 0; font-size: 1.42rem; }
.eyebrow { color: var(--primary); font-size: .78rem; font-weight: 800; }
.icon-button { width: var(--tap); height: var(--tap); display: grid; place-items: center; border: 0; border-radius: 50%; color: var(--muted); background: transparent; }
.filter-panel, .queue-panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: var(--space-3); overflow: hidden; }
.filter-panel summary, .queue-panel summary { min-height: var(--tap); padding: .8rem 1rem; display: flex; align-items: center; justify-content: space-between; cursor: pointer; font-weight: 800; }
.filter-panel summary span { color: var(--muted); font-size: .78rem; font-weight: 500; }
.filters { display: grid; gap: var(--space-2); padding: 0 var(--space-3) var(--space-3); border-top: 1px solid var(--border); padding-top: var(--space-3); }
.filters label { display: grid; gap: .35rem; font-size: .86rem; font-weight: 700; }
.field-pair, .filter-actions { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-2); }
.review-card { padding-bottom: calc(86px + env(safe-area-inset-bottom)); }
.photo-stage { height: min(58dvh, 520px); display: grid; place-items: center; overflow: hidden; background: #10242a; border-radius: var(--radius); box-shadow: var(--shadow); }
.photo-stage a, .photo-stage img { display: block; width: 100%; height: 100%; }
.photo-stage img { object-fit: contain; }
.photo-meta { display: flex; flex-wrap: wrap; gap: .35rem .65rem; align-items: center; padding: .8rem .15rem; color: var(--muted); font-size: .78rem; }
.status { display: inline-flex; align-items: center; min-height: 25px; padding: .15rem .5rem; border-radius: 999px; font-size: .74rem; font-weight: 800; }
.status--pending { color: var(--warning); background: #fff3cd; }
.status--approved { color: var(--success); background: #dff4e9; }
.status--rejected { color: var(--danger); background: var(--danger-soft); }
.rejection-note { padding: .7rem; color: var(--danger); background: var(--danger-soft); border-radius: var(--radius-sm); font-size: .86rem; }
.photo-nav { display: flex; justify-content: space-between; }
.review-actions { position: fixed; z-index: 10; inset: auto 0 0; width: min(100%, 480px); margin: auto; padding: .7rem max(1rem, env(safe-area-inset-right)) max(.7rem, env(safe-area-inset-bottom)) max(1rem, env(safe-area-inset-left)); display: grid; grid-template-columns: 1.2fr 1fr; gap: .7rem; background: rgba(247,244,237,.94); border-top: 1px solid var(--border); backdrop-filter: blur(10px); }
.review-actions .button { min-height: 56px; }
.empty-state { padding: 4rem 1rem; text-align: center; color: var(--muted); }
.empty-state h2 { color: var(--ink); margin: var(--space-3) 0 .4rem; }
.thumbnail-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: .6rem; padding: var(--space-3); border-top: 1px solid var(--border); }
.thumbnail-card { position: relative; height: 150px; overflow: hidden; border: 2px solid transparent; border-radius: var(--radius-sm); background: #10242a; }
.thumbnail-card.is-current { border-color: var(--primary); }
.thumbnail-card img { width: 100%; height: 100%; object-fit: cover; }
.thumbnail-card .status { position: absolute; inset: auto .4rem .4rem auto; }
.queue-pagination { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: .5rem; padding: 0 var(--space-3) var(--space-3); font-size: .82rem; text-align: center; }
.reject-dialog { width: calc(100% - 2rem); max-width: 448px; padding: var(--space-4); border: 0; border-radius: var(--radius); color: var(--ink); background: var(--surface); box-shadow: var(--shadow); }
.reject-dialog::backdrop { background: rgba(9,27,33,.55); }
.reject-dialog h2 { font-size: 1.25rem; }
.reject-dialog label { display: grid; gap: .5rem; }
.dialog-actions { display: grid; grid-template-columns: 1fr 1.3fr; gap: .7rem; margin-top: var(--space-3); }

@media (max-width: 350px) {
  .app-shell { padding-inline: .65rem; }
  .capture-button strong { font-size: 1.25rem; }
  .photo-stage { height: 52dvh; }
}

@media (prefers-reduced-motion: no-preference) {
  .success-message { animation: pop-in .18s ease-out; }
  @keyframes pop-in { from { opacity: 0; transform: translateY(-45%) scale(.96); } }
}
