/* Qortex Maia look (06_UI_Rules.md, sections 1–3 and 9) */
@font-face { font-family: "Cabin"; src: url("fonts/Cabin.ttf") format("truetype"); font-weight: 400 700; font-display: swap; }
@font-face { font-family: "Cairo"; src: url("fonts/Cairo.ttf") format("truetype"); font-weight: 200 1000; font-display: swap; }

:root {
  --deep-blue: #052945;
  --orange-light: #F79421;
  --orange: #F15C2C;
  --gradient: linear-gradient(90deg, #F79421, #F15C2C);
  --text: #1A1A1A;
  --caption: #6B6560;
  --placeholder: #9A938D;
  --icon-grey: #8C857F;
  --tan: #EFEDEB;
  --section: #E6DBD4;
  --soft: #F3EEEA;
  --card: #FFFFFF;
  --border: #E2DCD6;
  --green: #1D9E75; --green-text: #157A5A; --green-tint: #E1F3EC;
  --amber: #EF9F27; --amber-tint: #FDF1DE;
  --red: #E24B4A; --red-text: #C8403F; --red-tint: #FCE9E9;
  --blue: #378ADD; --blue-tint: #EAF2FB;
  --orange-tint: #FEEBDD;
  --shadow: 0 1px 3px rgba(0, 0, 0, .06);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body {
  font-family: "Cabin", system-ui, sans-serif; font-size: 15px; line-height: 1.4;
  color: var(--text); background: var(--tan);
}
[lang="ar"], .ar { font-family: "Cairo", system-ui, sans-serif; }
button, input, select { font: inherit; color: inherit; }
img { display: block; max-width: 100%; }
.hidden { display: none !important; }

/* ------------------------------------------------ screens */
.screen { display: none; min-height: 100vh; min-height: 100dvh; flex-direction: column; }
.screen.active { display: flex; }
.content { flex: 1; padding: 20px 24px 120px; display: flex; flex-direction: column; gap: 12px; }

/* ------------------------------------------------ header (deep blue) */
.header {
  background: var(--deep-blue); color: #fff; padding: 14px 16px; min-height: 60px;
  display: flex; align-items: center; gap: 8px; position: sticky; top: 0; z-index: 5;
}
.header .lockup { height: 34px; width: auto; }
.header h1 { font-size: 18px; font-weight: 600; margin: 0; flex: 1; }
.header .spacer { flex: 1; }
.icon-btn {
  background: none; border: 0; color: #fff; width: 44px; height: 44px; border-radius: 8px;
  display: inline-flex; align-items: center; justify-content: center; cursor: pointer;
}
.icon-btn svg { width: 24px; height: 24px; }

/* ------------------------------------------------ login / splash */
#login { background: var(--deep-blue); color: #fff; align-items: center; justify-content: center; }
#login .box { width: 100%; max-width: 360px; padding: 24px; display: flex; flex-direction: column; gap: 16px; }
#login .lockup-a { width: 220px; margin: 0 auto 24px; }
#login .tag { text-align: center; color: rgba(255, 255, 255, .7); font-size: 14px; margin: -16px 0 16px; }
#login .field input { background: #fff; }
#login .error { color: #FFB4A8; min-height: 20px; font-size: 14px; }

/* ------------------------------------------------ cards, text */
.card { background: var(--card); border: 1px solid var(--border); border-radius: 12px; padding: 16px; box-shadow: var(--shadow); }
h2 { color: var(--deep-blue); font-size: 18px; font-weight: 700; margin: 0; }
h3 { color: var(--deep-blue); font-size: 16px; font-weight: 600; margin: 0; }
.caption { color: var(--caption); font-size: 13px; }
.muted { color: var(--caption); }
p { margin: 0; }

/* ------------------------------------------------ buttons */
.btn {
  min-height: 48px; border-radius: 8px; padding: 0 20px; border: 0; cursor: pointer;
  font-weight: 600; font-size: 16px; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%;
}
.btn-primary { background: var(--gradient); color: #fff; }
.btn-primary:disabled { background: var(--section); color: var(--placeholder); }
.btn-secondary { background: #fff; color: var(--orange); border: 1.5px solid var(--orange); }
.btn-text { background: none; color: var(--deep-blue); text-decoration: underline; min-height: 44px; width: auto; padding: 0 8px; font-weight: 500; }
.btn svg { width: 22px; height: 22px; }
.row { display: flex; gap: 12px; }
.row > * { flex: 1; }
.links { display: flex; justify-content: center; gap: 8px; flex-wrap: wrap; }

.action-bar {
  position: fixed; left: 0; right: 0; bottom: 0; background: #fff; border-top: 1px solid var(--border);
  padding: 12px 24px calc(12px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 4px; z-index: 6;
}

/* ------------------------------------------------ fields */
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-weight: 600; font-size: 14px; color: var(--deep-blue); display: flex; align-items: center; gap: 8px; }
.field .hint { color: var(--caption); font-size: 12px; font-weight: 400; }
.field input, .field select {
  min-height: 48px; border: 1px solid var(--border); border-radius: 8px; background: #fff; padding: 0 12px; width: 100%;
}
.field input::placeholder { color: var(--placeholder); }
.field input:focus, .field select:focus { outline: 2px solid var(--blue); outline-offset: -1px; }
.field .readonly { min-height: 48px; border-radius: 8px; background: var(--section); padding: 12px; font-variant-numeric: tabular-nums; }
.size-row { display: flex; gap: 8px; }
.size-row input { flex: 2; }
.size-row select { flex: 1; }

/* "Suggested — check" (Maia flows 1.7; decision 15) */
.field.suggested input, .field.suggested select { background: var(--blue-tint); border-color: var(--blue); }
.sugg-tag {
  display: none; font-size: 12px; font-weight: 600; color: #1F5FA0; background: var(--blue-tint);
  border: 1px solid #B7D3F2; border-radius: 4px; padding: 1px 6px;
}
.field.suggested .sugg-tag { display: inline-block; }
.sugg-alt { font-size: 13px; color: var(--caption); }
.sugg-alt button { background: none; border: 0; color: #1F5FA0; font-weight: 600; text-decoration: underline; padding: 0 4px; cursor: pointer; }

.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip { border: 1px solid var(--border); background: var(--section); border-radius: 999px; padding: 6px 14px; min-height: 36px; cursor: pointer; }

/* ------------------------------------------------ banners and badges */
.banner { border-radius: 12px; padding: 12px 14px; display: flex; gap: 10px; align-items: flex-start; font-size: 14px; }
.banner.info { background: var(--blue-tint); color: #1F4E7F; }
.banner.ok { background: var(--green-tint); color: var(--green-text); }
.banner.warn { background: var(--amber-tint); color: #7A4C05; }
.banner.err { background: var(--red-tint); color: var(--red-text); }
.banner .grow { flex: 1; }
.spinner { width: 18px; height: 18px; border: 2.5px solid #B7D3F2; border-top-color: var(--blue); border-radius: 50%; animation: spin .8s linear infinite; flex: none; margin-top: 1px; }
@keyframes spin { to { transform: rotate(360deg); } }

.badge { display: inline-block; font-size: 12px; font-weight: 600; border-radius: 4px; padding: 2px 8px; white-space: nowrap; }
.badge.reading { background: var(--blue-tint); color: #1F5FA0; }
.badge.suggested { background: var(--amber-tint); color: #7A4C05; }
.badge.confirmed { background: var(--green-tint); color: var(--green-text); }
.badge.failed { background: var(--red-tint); color: var(--red-text); }
.badge.kept { background: var(--green-tint); color: var(--green-text); }
.badge.changed { background: var(--amber-tint); color: #7A4C05; }
.badge.typed, .badge.empty, .badge.cleared { background: var(--section); color: var(--caption); }

/* ------------------------------------------------ home list */
.mode-pill { align-self: flex-start; background: var(--section); border-radius: 999px; padding: 4px 12px; font-size: 13px; color: var(--deep-blue); }
.mode-pill.mock { background: var(--amber-tint); color: #7A4C05; }
.list { display: flex; flex-direction: column; gap: 8px; }
.item { display: flex; gap: 12px; align-items: center; background: #fff; border: 1px solid var(--border); border-radius: 12px; padding: 10px; box-shadow: var(--shadow); cursor: pointer; }
.item img, .item .noimg { width: 56px; height: 56px; border-radius: 8px; object-fit: cover; background: var(--soft); flex: none; }
.item .body { flex: 1; min-width: 0; }
.item .name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.empty { text-align: center; color: var(--caption); padding: 24px 8px; }

/* ------------------------------------------------ scanner */
.scanner { position: relative; background: #000; border-radius: 12px; overflow: hidden; aspect-ratio: 3 / 4; }
.scanner video { width: 100%; height: 100%; object-fit: cover; display: block; }
.scanner .frame { position: absolute; left: 10%; right: 10%; top: 35%; height: 30%; border: 3px solid rgba(255, 255, 255, .9); border-radius: 12px; box-shadow: 0 0 0 999px rgba(0, 0, 0, .35); }
.scanner .msg { position: absolute; left: 0; right: 0; bottom: 12px; text-align: center; color: #fff; font-size: 14px; padding: 0 16px; }

/* ------------------------------------------------ photos */
.thumbs { display: flex; gap: 8px; }
.thumbs .t { position: relative; width: 84px; height: 84px; border-radius: 8px; overflow: hidden; background: var(--soft); border: 1px solid var(--border); }
.thumbs .t img { width: 100%; height: 100%; object-fit: cover; }
.thumbs .t span { position: absolute; left: 4px; top: 4px; background: rgba(5, 41, 69, .85); color: #fff; font-size: 11px; border-radius: 4px; padding: 0 5px; }
.step-title { color: var(--deep-blue); font-size: 18px; font-weight: 700; }
.photo-guide { border: 2px dashed var(--border); border-radius: 12px; background: var(--orange-tint); padding: 24px 16px; text-align: center; color: var(--deep-blue); display: flex; flex-direction: column; gap: 8px; align-items: center; }
.photo-guide svg { width: 40px; height: 40px; color: var(--orange); }

/* ------------------------------------------------ sheet */
.sheet-bg { position: fixed; inset: 0; background: rgba(0, 0, 0, .4); z-index: 20; display: flex; align-items: flex-end; }
.sheet { background: #fff; border-radius: 20px 20px 0 0; padding: 20px 24px calc(20px + env(safe-area-inset-bottom)); width: 100%; display: flex; flex-direction: column; gap: 12px; }
.sheet img { border-radius: 8px; max-height: 40vh; object-fit: contain; background: var(--soft); }

/* ------------------------------------------------ stats and compare tables */
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; color: var(--caption); font-weight: 500; font-size: 12px; padding: 6px 4px; border-bottom: 1px solid var(--border); }
td { padding: 8px 4px; border-bottom: 1px solid var(--border); vertical-align: top; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.big { font-size: 28px; font-weight: 700; color: var(--deep-blue); }
.kpis { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.kpis .card { padding: 12px; }

.toast { position: fixed; left: 24px; right: 24px; bottom: 100px; background: var(--deep-blue); color: #fff; border-radius: 12px; padding: 12px 16px; z-index: 30; text-align: center; }
.photo-full { width: 100%; border-radius: 8px; }
