:root {
  --blue-900: #0e2b52; --blue: #174a8c; --blue-600: #1f5fb0; --blue-100: #e4edf8; --blue-50: #f3f7fc;
  --yellow: #f6c343; --yellow-700: #b8860b;
  --ink: #1b2430; --muted: #5b6878; --line: #d9e0e8; --bg: #f2f4f7; --card: #ffffff;
  --red: #d8322c; --green: #1f8a4c; --amber: #e08a00;
  --radius: 10px; --shadow: 0 1px 2px rgba(16, 32, 64, .08), 0 4px 14px rgba(16, 32, 64, .06);
  --safe-b: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--ink); font: 15px/1.45 -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; -webkit-text-size-adjust: 100%; }
a { color: var(--blue-600); text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
img { display: block; max-width: 100%; }
[hidden] { display: none !important; }
h1 { font-size: 22px; margin: 0 0 4px; font-weight: 650; }
h2 { font-size: 17px; margin: 0 0 10px; font-weight: 650; }
h3 { font-size: 15px; margin: 0 0 8px; font-weight: 650; }
p { margin: 0 0 10px; }
small, .muted { color: var(--muted); }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.grow { flex: 1; }
.stack > * + * { margin-top: 12px; }

/* top bar */
.topbar { position: sticky; top: 0; z-index: 20; background: var(--blue); color: #fff; display: flex; align-items: center; gap: 18px; padding: 8px 16px; box-shadow: 0 2px 6px rgba(0,0,0,.18); }
.brand { display: flex; align-items: center; gap: 10px; color: #fff; }
.brand span { display: flex; flex-direction: column; line-height: 1.1; }
.brand strong { font-size: 15px; }
.brand small { color: #d7e3f5; font-size: 12px; }
.nav { display: flex; gap: 4px; margin-left: 12px; }
.nav a { color: #e8f0fb; padding: 7px 11px; border-radius: 7px; font-weight: 500; }
.nav a.active, .nav a:hover { background: rgba(255,255,255,.14); color: #fff; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.who { font-size: 13px; color: #d7e3f5; }
.mode-toggle { background: rgba(255,255,255,.12); border: 1px solid rgba(255,255,255,.35); color: #fff; border-radius: 999px; padding: 4px 10px; font-size: 12px; cursor: pointer; }
.mode-toggle.smart { background: var(--yellow); color: var(--blue-900); border-color: var(--yellow); font-weight: 600; }

.view { max-width: 1180px; margin: 0 auto; padding: 18px 16px calc(84px + var(--safe-b)); }
@media (min-width: 900px) { .view { padding-bottom: 40px; } .tabbar { display: none !important; } }
@media (max-width: 899px) { .nav { display: none; } .who { display: none; } }

/* bottom tabs (phone) */
.tabbar { position: fixed; bottom: 0; left: 0; right: 0; z-index: 20; display: flex; background: #fff; border-top: 1px solid var(--line); padding-bottom: var(--safe-b); }
.tabbar a { flex: 1; text-align: center; padding: 8px 0 6px; font-size: 11px; color: var(--muted); display: flex; flex-direction: column; gap: 2px; }
.tabbar a .ico { font-size: 18px; line-height: 1; }
.tabbar a.active { color: var(--blue); font-weight: 600; }

/* cards & tiles */
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; }
.card + .card { margin-top: 14px; }
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
.tile { background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px 16px; border-left: 4px solid var(--blue); }
.tile .n { font-size: 26px; font-weight: 700; line-height: 1.1; }
.tile .l { color: var(--muted); font-size: 13px; }
.tile.warn { border-left-color: var(--amber); }
.tile.bad { border-left-color: var(--red); }
.tile.good { border-left-color: var(--green); }

.actions { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; }
.action { display: flex; flex-direction: column; gap: 4px; padding: 16px; border-radius: var(--radius); background: var(--blue); color: #fff; box-shadow: var(--shadow); }
.action:hover { background: var(--blue-600); }
.action strong { font-size: 16px; }
.action small { color: #d7e3f5; }
.action.secondary { background: #fff; color: var(--ink); border: 1px solid var(--line); }
.action.secondary:hover { background: var(--blue-50); }
.action.secondary small { color: var(--muted); }

/* buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 9px 14px; border-radius: 8px; border: 1px solid var(--blue); background: var(--blue); color: #fff; font-weight: 600; cursor: pointer; white-space: nowrap; min-height: 38px; }
.btn:hover { background: var(--blue-600); }
.btn:disabled { opacity: .5; cursor: default; }
.btn.ghost { background: #fff; color: var(--blue); }
.btn.ghost:hover { background: var(--blue-50); }
.btn.plain { background: #fff; color: var(--ink); border-color: var(--line); font-weight: 500; }
.btn.plain:hover { background: var(--bg); }
.btn.danger { background: var(--red); border-color: var(--red); }
.btn.yellow { background: var(--yellow); border-color: var(--yellow); color: var(--blue-900); }
.btn.sm { padding: 5px 10px; min-height: 30px; font-size: 13px; }
.btn.lg { padding: 13px 20px; font-size: 16px; }
.btn.block { width: 100%; }
.btn.icon { width: 38px; padding: 0; }

/* chips */
.chip { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 600; background: var(--blue-100); color: var(--blue-900); white-space: nowrap; }
.chip.ok { background: #e3f3e8; color: #176a3a; }
.chip.warn { background: #fff1d6; color: #8a5a00; }
.chip.bad { background: #fde3e1; color: #9c231e; }
.chip.grey { background: #eceff3; color: var(--muted); }
.chip.major { background: #fde3e1; color: #9c231e; }
.chip.minor { background: #eceff3; color: #3b4654; }

/* forms */
.field { display: flex; flex-direction: column; gap: 4px; margin-bottom: 12px; }
.field label { font-size: 13px; font-weight: 600; color: #2d3a4a; }
input[type=text], input[type=password], input[type=number], input[type=date], select, textarea { width: 100%; padding: 9px 11px; border: 1px solid var(--line); border-radius: 8px; background: #fff; min-height: 40px; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--blue-600); outline-offset: 1px; border-color: transparent; }
textarea { min-height: 90px; resize: vertical; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: #fff; }
.seg button { border: 0; background: transparent; padding: 8px 12px; cursor: pointer; font-weight: 500; color: var(--muted); }
.seg button.active { background: var(--blue); color: #fff; }
.seg button + button { border-left: 1px solid var(--line); }

/* tables */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font-size: 12px; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); font-weight: 600; background: #fafbfd; position: sticky; top: 0; }
tr.click { cursor: pointer; }
tr.click:hover td { background: var(--blue-50); }
td img.thumb { width: 56px; height: 42px; object-fit: cover; border-radius: 4px; }

/* lists */
.list { display: flex; flex-direction: column; }
.item { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.item:last-child { border-bottom: 0; }
.item .thumb { width: 72px; height: 54px; object-fit: cover; border-radius: 6px; background: #e9edf2; flex: none; }
.item .thumb.empty { display: flex; align-items: center; justify-content: center; color: var(--muted); font-size: 11px; }
.item .body { flex: 1; min-width: 0; }
.item .title { font-weight: 600; }
.item .sub { font-size: 13px; color: var(--muted); }

.bus-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.bus-card { background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); padding: 12px 14px; color: var(--ink); display: flex; flex-direction: column; gap: 6px; border-top: 3px solid var(--line); }
.bus-card:hover { background: var(--blue-50); }
.bus-card.started { border-top-color: var(--amber); }
.bus-card.done { border-top-color: var(--green); }
.bus-card .num { font-size: 20px; font-weight: 700; }
.bar { height: 6px; border-radius: 3px; background: #e6eaf0; overflow: hidden; }
.bar > span { display: block; height: 100%; background: var(--blue); }
.bar.good > span { background: var(--green); }

/* photo frames with marks */
.frame { position: relative; background: #0d1520; border-radius: 8px; overflow: hidden; user-select: none; -webkit-user-select: none; touch-action: none; }
.frame img, .frame canvas { width: 100%; height: auto; display: block; -webkit-user-drag: none; user-select: none; pointer-events: none; }
.frame .mark { position: absolute; border: 3px solid var(--red); box-shadow: 0 0 0 1px rgba(255,255,255,.6); border-radius: 2px; }
.frame .mark .tag { position: absolute; left: -3px; top: -24px; background: var(--red); color: #fff; font-size: 11px; font-weight: 600; padding: 2px 6px; border-radius: 3px; white-space: nowrap; }
.frame .mark.suggested { border-color: var(--yellow); border-style: dashed; }
.frame .mark.suggested .tag { background: var(--yellow); color: var(--blue-900); }
.frame .mark.dismissed { opacity: .3; }
.frame .mark.selected { box-shadow: 0 0 0 3px rgba(255,255,255,.9), 0 0 0 5px var(--blue-600); }
.frame .mark.draft { border-color: #4cc3ff; }
.frame .label { position: absolute; left: 8px; top: 8px; background: rgba(13,21,32,.7); color: #fff; font-size: 12px; padding: 3px 8px; border-radius: 4px; }
.frame .label.right { left: auto; right: 8px; }
.frame.crosshair { cursor: crosshair; }

.compare { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 760px) { .compare { grid-template-columns: 1fr; } }
.compare-tools { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin: 10px 0; }
.slider-wrap { position: relative; }
.slider-wrap .top { position: absolute; inset: 0; clip-path: inset(0 50% 0 0); }
.slider-wrap .handle { position: absolute; top: 0; bottom: 0; width: 2px; background: #fff; left: 50%; box-shadow: 0 0 0 1px rgba(0,0,0,.3); }
.slider-wrap .handle::after { content: "◀ ▶"; position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); background: #fff; color: var(--ink); font-size: 11px; padding: 4px 6px; border-radius: 12px; white-space: nowrap; }

/* capture */
.capture { position: relative; background: #000; border-radius: 10px; overflow: hidden; aspect-ratio: 3 / 4; max-height: 72vh; margin: 0 auto; }
@media (min-width: 760px) { .capture { aspect-ratio: 4 / 3; } }
.capture video, .capture .ghost, .capture canvas.preview { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; }
.capture .ghost { opacity: .38; pointer-events: none; mix-blend-mode: screen; }
.capture .hud { position: absolute; left: 0; right: 0; bottom: 0; padding: 10px 12px calc(10px + var(--safe-b)); background: linear-gradient(transparent, rgba(0,0,0,.65)); color: #fff; }
.capture .hint { font-weight: 600; font-size: 15px; text-shadow: 0 1px 2px #000; }
.meter { height: 8px; border-radius: 4px; background: rgba(255,255,255,.25); overflow: hidden; margin: 6px 0 10px; }
.meter > span { display: block; height: 100%; width: 0; background: var(--yellow); transition: width .15s; }
.meter.good > span { background: #45d07a; }
.shutter { width: 66px; height: 66px; border-radius: 50%; border: 4px solid #fff; background: rgba(255,255,255,.25); cursor: pointer; }
.shutter:active { background: #fff; }
.capture-bar { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.capture .corner { position: absolute; top: 10px; left: 10px; right: 10px; display: flex; justify-content: space-between; gap: 8px; }
.pill { background: rgba(0,0,0,.55); color: #fff; padding: 4px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.pill.ok { background: rgba(31,138,76,.85); }
.pill.warn { background: rgba(224,138,0,.9); }
.pill.bad { background: rgba(216,50,44,.9); }

/* misc */
.steps { display: flex; gap: 6px; flex-wrap: wrap; }
.steps span { width: 26px; height: 26px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 600; background: #e6eaf0; color: var(--muted); }
.steps span.done { background: var(--green); color: #fff; }
.steps span.cur { background: var(--blue); color: #fff; }
.steps span.warn { background: var(--amber); color: #fff; }
.empty { padding: 28px; text-align: center; color: var(--muted); }
.notice { background: var(--blue-50); border: 1px solid var(--blue-100); border-radius: 8px; padding: 10px 12px; font-size: 14px; }
.notice.warn { background: #fff8e6; border-color: #ffe3a3; }
.notice.bad { background: #fdecea; border-color: #f7c6c2; }
.toasts { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(70px + var(--safe-b)); z-index: 60; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.toast { background: var(--blue-900); color: #fff; padding: 10px 14px; border-radius: 8px; box-shadow: var(--shadow); font-size: 14px; max-width: 90vw; }
.toast.bad { background: var(--red); }
.toast.ok { background: var(--green); }
.modal { position: fixed; inset: 0; z-index: 50; background: rgba(10,20,35,.5); display: flex; align-items: flex-end; justify-content: center; padding: 0; }
@media (min-width: 700px) { .modal { align-items: center; padding: 20px; } }
.modal .box { background: #fff; border-radius: 14px 14px 0 0; width: 100%; max-width: 560px; max-height: 92vh; overflow: auto; padding: 18px; }
@media (min-width: 700px) { .modal .box { border-radius: 14px; } }
.modal .box.wide { max-width: 1100px; }
.login { max-width: 380px; margin: 8vh auto; }
.login .brandline { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; }
.keypad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 8px 0 14px; }
.keypad button { padding: 14px; font-size: 20px; border-radius: 10px; border: 1px solid var(--line); background: #fff; cursor: pointer; }
.keypad button:active { background: var(--blue-100); }
.pin-dots { display: flex; gap: 10px; justify-content: center; margin: 10px 0; }
.pin-dots span { width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--blue); }
.pin-dots span.on { background: var(--blue); }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 4px 14px; font-size: 14px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }
.timeline { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; }
.timeline .card { padding: 10px; }
.dropzone { border: 2px dashed var(--line); border-radius: 10px; padding: 26px; text-align: center; color: var(--muted); background: #fff; cursor: pointer; }
.dropzone.over { border-color: var(--blue); background: var(--blue-50); }
.grid-photos { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.grid-photos .card { padding: 8px; }
.grid-photos img { width: 100%; aspect-ratio: 4/3; object-fit: cover; border-radius: 6px; }
.badge-num { display: inline-flex; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px; background: var(--red); color: #fff; font-size: 12px; font-weight: 700; align-items: center; justify-content: center; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.spin { display: inline-block; width: 16px; height: 16px; border: 2px solid rgba(0,0,0,.15); border-top-color: var(--blue); border-radius: 50%; animation: spin .8s linear infinite; vertical-align: -3px; }
@keyframes spin { to { transform: rotate(360deg); } }
.pulse { animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .45; } }
