/* Shared look of the phone pages - the same Google-Blue Material palette as the desktop app (zakat_app/theme.py) and
   the native screens of the Android app (UiKit.kt), with a dark variant that follows the phone's own setting. */
:root {
  --bg: #F8F9FA; --surface: #FFFFFF; --border: #DADCE0; --text: #202124; --muted: #5F6368;
  --primary: #1A73E8; --primary-press: #185ABC; --on-primary: #FFFFFF; --tint: #F1F6FE;
  --danger: #D93025; --danger-tint: #FCE8E6; --success: #188038; --success-tint: #E6F4EA;
  --warn: #B06000; --warn-tint: #FEF7E0;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #17191D; --surface: #202328; --border: #34383F; --text: #E8EAED; --muted: #9AA0A6;
    --primary: #6AA6F8; --primary-press: #8AB8FA; --on-primary: #0B1A30; --tint: #26303F;
    --danger: #F28B82; --danger-tint: #3C2321; --success: #81C995; --success-tint: #1E3326;
    --warn: #FDD663; --warn-tint: #3A3220;
  }
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.4 Roboto, "Segoe UI", -apple-system, sans-serif; }
body { min-height: 100vh; }
.bar { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 10px; padding: 12px 14px;
  background: var(--surface); border-bottom: 1px solid var(--border); }
.bar h1 { flex: 1; margin: 0; font-size: 18px; font-weight: 700; }
.back { border: 0; background: none; color: var(--primary); font-size: 22px; line-height: 1; padding: 4px 8px 4px 0; }
.pill { font-size: 12px; font-weight: 600; padding: 3px 10px; border-radius: 12px; background: var(--border); color: var(--muted); }
.pill.ok { background: var(--success-tint); color: var(--success); }
.pill.bad { background: var(--danger-tint); color: var(--danger); }
.wrap { max-width: 560px; margin: 0 auto; padding: 14px 14px 40px; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 14px 16px; margin-top: 12px; }
.card h2 { margin: 0 0 8px; font-size: 15px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.center { text-align: center; }

.btn { display: inline-block; border: 0; border-radius: 10px; padding: 11px 18px; font: inherit; font-weight: 600;
  background: var(--primary); color: var(--on-primary); text-decoration: none; text-align: center; }
.btn:active { background: var(--primary-press); }
.btn.secondary { background: var(--surface); color: var(--primary); border: 1px solid var(--border); }
.btn.block { display: block; width: 100%; }
.btn:disabled { opacity: .5; }
.row { display: flex; gap: 10px; align-items: center; }
.row > * { flex: 1; min-width: 0; }
.row > .btn { flex: 0 0 auto; }

label.field { display: block; margin-top: 12px; font-size: 13px; color: var(--muted); font-weight: 600; }
.field input, .field select, .field textarea, input.plain, select.plain { display: block; width: 100%; margin-top: 4px; padding: 11px 12px;
  font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--border); border-radius: 10px; }
.field input:focus, .field select:focus, input.plain:focus, select.plain:focus { outline: 2px solid var(--primary); outline-offset: -1px; }
.field input:disabled, .field select:disabled { opacity: .6; }

.camera { position: relative; margin-top: 12px; border-radius: 20px; overflow: hidden; aspect-ratio: 4 / 3;
  background: linear-gradient(160deg, #1b2330, #0d1118); }
/* The video is invisible until its first real frame (box gets .live), so the web view's own grey "play" placeholder
   can never show; a styled panel (.cam-msg, created by shared.js) covers the box until then. */
.camera video { width: 100%; height: 100%; object-fit: cover; display: block; opacity: 0; transition: opacity .25s ease; background: transparent; }
.camera.live video { opacity: 1; }
.camera:not(.live) .frame { display: none; }
video::-webkit-media-controls, video::-webkit-media-controls-start-playback-button, video::-webkit-media-controls-overlay-play-button { display: none !important; -webkit-appearance: none; }
.cam-msg { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px;
  padding: 24px; text-align: center; color: #cfd6e0; font-size: 14px; }
.cam-msg.hidden { display: none; }
.cam-msg .cam-ico { width: 40px; height: 40px; color: #8ab4f8; }
.cam-msg .cam-btn { padding: 9px 18px; font-size: 14px; }
.cam-msg .spin { width: 30px; height: 30px; border-radius: 50%; border: 3px solid rgba(255,255,255,.18); border-top-color: #8ab4f8; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.camera.live .frame::after { content: ''; position: absolute; left: 6px; right: 6px; top: 0; height: 2px; border-radius: 2px;
  background: linear-gradient(90deg, transparent, var(--primary), transparent); animation: sweep 2.2s ease-in-out infinite; }
@keyframes sweep { 0% { top: 4%; } 50% { top: 94%; } 100% { top: 4%; } }
.camera .frame { position: absolute; inset: 18%; pointer-events: none;
  background:
    linear-gradient(var(--primary), var(--primary)) top left / 26px 4px no-repeat,
    linear-gradient(var(--primary), var(--primary)) top left / 4px 26px no-repeat,
    linear-gradient(var(--primary), var(--primary)) top right / 26px 4px no-repeat,
    linear-gradient(var(--primary), var(--primary)) top right / 4px 26px no-repeat,
    linear-gradient(var(--primary), var(--primary)) bottom left / 26px 4px no-repeat,
    linear-gradient(var(--primary), var(--primary)) bottom left / 4px 26px no-repeat,
    linear-gradient(var(--primary), var(--primary)) bottom right / 26px 4px no-repeat,
    linear-gradient(var(--primary), var(--primary)) bottom right / 4px 26px no-repeat; }
.camera .off { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; padding: 20px;
  text-align: center; color: #cfd3d8; font-size: 14px; }

.status { margin-top: 12px; padding: 11px 14px; border-radius: 10px; background: var(--tint); color: var(--text); font-weight: 500; }
.status.ok { background: var(--success-tint); color: var(--success); }
.status.err { background: var(--danger-tint); color: var(--danger); }
.status.warn { background: var(--warn-tint); color: var(--warn); }

.chip { display: inline-block; padding: 3px 11px; border-radius: 12px; font-size: 12px; font-weight: 700;
  background: var(--tint); color: var(--primary); }
.chip.ok { background: var(--success-tint); color: var(--success); }
.chip.warn { background: var(--warn-tint); color: var(--warn); }
.chip.bad { background: var(--danger-tint); color: var(--danger); }
.result .head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 4px; }
.result .item { font-size: 20px; font-weight: 700; }
.result .serial { font-size: 13px; color: var(--muted); }
.rows { margin-top: 8px; }
.rows .r { display: flex; justify-content: space-between; gap: 14px; padding: 9px 0; border-top: 1px solid var(--border); }
.rows .r span:first-child { color: var(--muted); }
.rows .r span:last-child { font-weight: 600; text-align: right; }
.rows .r .empty { color: var(--muted); font-weight: 400; }
.bigcount { display: flex; align-items: baseline; justify-content: space-between; margin-top: 8px; padding-top: 10px; border-top: 1px solid var(--border); }
.bigcount b { font-size: 26px; }
.progress { height: 8px; border-radius: 4px; background: var(--border); overflow: hidden; margin-top: 8px; }
.progress > i { display: block; height: 100%; background: var(--primary); }

.menu { display: block; margin-top: 12px; padding: 16px 18px; background: var(--surface); border: 1px solid var(--border);
  border-radius: 14px; color: var(--text); text-decoration: none; }
.menu:active { background: var(--tint); border-color: var(--primary); }
.menu b { display: block; font-size: 17px; }
.menu span { color: var(--muted); font-size: 13px; }

.batch { display: flex; align-items: center; gap: 12px; }
.batch .info { flex: 1; min-width: 0; }
.batch .name { font-weight: 700; font-size: 16px; }
.log { margin-top: 12px; font-size: 13px; color: var(--muted); }
.log div { padding: 6px 0; border-top: 1px solid var(--border); }
.log .ok { color: var(--success); } .log .err { color: var(--danger); }
/* ---- packing: order picker + checklist ---- */
.order { display: block; width: 100%; text-align: left; font: inherit; color: var(--text); background: var(--surface);
  border: 1px solid var(--border); border-radius: 14px; padding: 14px 16px; margin-top: 12px; }
.order:active { background: var(--tint); border-color: var(--primary); }
.order .top { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.order .who { font-weight: 700; font-size: 16px; }
.order .meta { color: var(--muted); font-size: 13px; margin-top: 2px; }
.checklist { margin-top: 4px; }
.cl-row { display: flex; align-items: center; gap: 12px; padding: 11px 0; border-top: 1px solid var(--border); transition: background .6s ease; }
.cl-row:first-child { border-top: 0; }
.cl-row .tick { flex: 0 0 22px; height: 22px; border-radius: 50%; border: 2px solid var(--border); display: flex; align-items: center; justify-content: center;
  font-size: 13px; line-height: 1; color: transparent; }
.cl-row .name { flex: 1; min-width: 0; font-weight: 600; }
.cl-row .qty { font-weight: 700; font-variant-numeric: tabular-nums; color: var(--muted); }
.cl-row.partial .qty { color: var(--primary); }
.cl-row.done .tick { background: var(--success); border-color: var(--success); color: #fff; }
.cl-row.done .qty, .cl-row.done .name { color: var(--success); }
.cl-row.flash { background: var(--success-tint); }
.linkbtn { border: 0; background: none; color: var(--primary); font: inherit; font-weight: 600; padding: 6px 0; }
.linkbtn:disabled { opacity: .4; }

/* ---- the packing pop-up: translucent card over the page, faint until it is touched ---- */
body.has-pop .wrap { padding-bottom: 260px; }
.pop { position: fixed; z-index: 30; left: 12px; right: 12px; max-width: 536px; margin: 0 auto;
  bottom: calc(14px + env(safe-area-inset-bottom, 0px)); padding: 14px 16px 12px; border-radius: 20px; color: #fff;
  background: rgba(24, 28, 34, .5); border: 1px solid rgba(255, 255, 255, .22);
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px); box-shadow: 0 10px 34px rgba(0, 0, 0, .22);
  opacity: 1; touch-action: manipulation;
  /* slowly settles back to faint after being touched (the .touched rule below overrides this to be quick) */
  transition: background-color 1.1s ease, opacity .5s ease, transform .35s ease, box-shadow 1.1s ease; }
.pop.hidden { display: none !important; }
.pop.leaving { opacity: 0; transform: translateY(10px); pointer-events: none; }
.pop.entering { animation: popin .28s ease; }
@keyframes popin { from { opacity: 0; transform: translateY(14px) scale(.98); } to { opacity: 1; transform: none; } }
.pop.touched { background: rgba(18, 21, 26, .9); box-shadow: 0 12px 38px rgba(0, 0, 0, .35); transition-duration: .2s; }
.pop .pop-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; min-height: 28px; }
.pop .pop-title { font-weight: 800; font-size: 16px; letter-spacing: .01em; }
.pop .pop-tag { font-size: 11px; font-weight: 800; padding: 2px 9px; border-radius: 10px; background: rgba(129, 201, 149, .25); color: #A8E6BA; margin-left: 8px; }
.pop .pop-tag.undone { background: rgba(253, 214, 99, .22); color: #FDD663; }
.pop .pop-x { flex: 0 0 auto; width: 30px; height: 30px; border-radius: 50%; border: 0; font-size: 15px; line-height: 1;
  color: #fff; background: rgba(255, 255, 255, .18); opacity: 0; pointer-events: none; transition: opacity 1.1s ease; }
.pop.touched .pop-x { opacity: 1; pointer-events: auto; transition-duration: .2s; }
.pop .pop-rows { margin-top: 6px; }
.pop .pop-rows .r { display: flex; justify-content: space-between; gap: 14px; padding: 5px 0; font-size: 14px; }
.pop .pop-rows .r span:first-child { color: rgba(255, 255, 255, .72); }
.pop .pop-rows .r span:last-child { font-weight: 700; text-align: right; }
.pop .pop-actions { display: flex; align-items: center; gap: 8px; margin-top: 8px; padding-top: 10px; border-top: 1px solid rgba(255, 255, 255, .18); }
.pop .pop-nav { flex: 0 0 auto; width: 38px; height: 36px; border-radius: 10px; border: 0; font-size: 20px; line-height: 1;
  color: #fff; background: rgba(255, 255, 255, .16); }
.pop .pop-nav:disabled { opacity: .3; }
.pop .pop-pos { flex: 0 0 auto; min-width: 54px; text-align: center; font-size: 13px; color: rgba(255, 255, 255, .8); font-variant-numeric: tabular-nums; }
.pop .pop-undo { flex: 1; height: 36px; border-radius: 10px; border: 1px solid rgba(255, 255, 255, .35); font: inherit; font-weight: 700;
  color: #fff; background: rgba(217, 48, 37, .45); }
.pop .pop-undo:disabled { opacity: .45; background: rgba(255, 255, 255, .1); }

/* ---- bottom sheet (Mark Broken) ---- */
.sheet-back { position: fixed; inset: 0; z-index: 40; background: rgba(0, 0, 0, .5); display: flex; align-items: flex-end; justify-content: center;
  animation: fade .2s ease; }
.sheet { width: 100%; max-width: 560px; max-height: 94vh; overflow-y: auto; background: var(--surface); color: var(--text);
  border-radius: 22px 22px 0 0; padding: 16px 16px calc(16px + env(safe-area-inset-bottom, 0px)); animation: rise .25s ease; }
.sheet .grab { width: 40px; height: 4px; border-radius: 2px; background: var(--border); margin: 0 auto 12px; }
.sheet h2 { margin: 0; font-size: 19px; }
.photo-box { position: relative; margin-top: 12px; aspect-ratio: 4 / 3; border-radius: 16px; overflow: hidden; background: var(--tint);
  border: 1.5px dashed var(--border); display: flex; align-items: center; justify-content: center; color: var(--muted); text-align: center; padding: 12px; }
.photo-box.has { border-style: solid; padding: 0; background: #000; }
.photo-box img, .photo-box video { width: 100%; height: 100%; object-fit: cover; display: block; }
.photo-box video { opacity: 0; transition: opacity .25s ease; background: transparent; }
.photo-box.live video { opacity: 1; }
.photo-box .shutter { position: absolute; left: 50%; bottom: 12px; transform: translateX(-50%); width: 62px; height: 62px; border-radius: 50%;
  border: 4px solid #fff; background: rgba(255, 255, 255, .25); }
.photo-box .shutter:active { background: rgba(255, 255, 255, .6); }
.btn.danger { background: var(--danger); color: #fff; }
textarea.plain { display: block; width: 100%; margin-top: 4px; padding: 11px 12px; font: inherit; color: var(--text); background: var(--surface);
  border: 1px solid var(--border); border-radius: 10px; resize: vertical; min-height: 76px; }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes rise { from { transform: translateY(40px); opacity: 0; } to { transform: none; opacity: 1; } }

.hidden { display: none !important; }
