:root {
  --bg: #f4f3f0; --card: #ffffff; --ink: #14161a; --muted: #6b6f78; --line: #e4e2dc;
  --accent: #14161a; --accent-ink: #ffffff; --soft: #ecebe6;
  --red: #c4372b; --red-soft: #fbe9e7; --amber: #a86a00; --amber-soft: #fdf3e1; --green: #22804a; --green-soft: #e6f4ec;
  --r: 14px; --gap: 12px;
  font: 16px/1.4 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #0f1013; --card: #1a1c21; --ink: #f1f0ec; --muted: #9a9ea8; --line: #2a2d34; --soft: #23262c;
    --accent: #f1f0ec; --accent-ink: #14161a; --red: #ff6b5e; --red-soft: #3a1d1a; --amber: #f0b44c; --amber-soft: #3a2c12;
    --green: #5fd08e; --green-soft: #15301f; color-scheme: dark; }
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); -webkit-tap-highlight-color: transparent; }
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }

.top { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; justify-content: space-between;
  padding: calc(env(safe-area-inset-top) + 12px) 16px 12px; background: var(--bg); border-bottom: 1px solid var(--line); }
.top__title { font-weight: 650; font-size: 18px; letter-spacing: -.01em; }
.top__user { border: 1px solid var(--line); background: var(--card); border-radius: 999px; padding: 6px 12px; font-size: 14px; color: var(--muted); }

.view { padding: 12px 16px calc(env(safe-area-inset-bottom) + 96px); max-width: 720px; margin: 0 auto; }
.tabs { position: fixed; left: 0; right: 0; bottom: 0; z-index: 5; display: flex; justify-content: center; gap: 4px;
  padding: 8px 8px calc(env(safe-area-inset-bottom) + 8px); background: var(--card); border-top: 1px solid var(--line); }
.tabs button { flex: 1; max-width: 160px; border: 0; background: none; padding: 8px 4px; border-radius: 10px; font-size: 13px; color: var(--muted); display: grid; gap: 2px; justify-items: center; }
.tabs button svg { width: 22px; height: 22px; }
.tabs button[aria-current] { color: var(--ink); background: var(--soft); font-weight: 600; }

h2 { font-size: 13px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin: 22px 2px 8px; display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.count { display: inline-block; background: var(--soft); color: var(--ink); border-radius: 999px; padding: 1px 8px; font-size: 12px; font-weight: 600; margin-left: 4px; vertical-align: 1px; }
.empty { color: var(--muted); padding: 14px 2px; font-size: 15px; }
.hint { color: var(--muted); font-size: 14px; margin: 4px 2px 0; }

.group { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; margin-bottom: var(--gap); }
.group__head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 10px 12px; border-bottom: 1px solid var(--line); font-weight: 600; font-size: 15px; }
.card { display: grid; grid-template-columns: 56px 1fr; gap: 12px; padding: 12px; border-bottom: 1px solid var(--line); align-items: start; }
.card:last-child { border-bottom: 0; }
.card--overdue { background: var(--red-soft); }
.thumb { position: relative; overflow: hidden; width: 56px; height: 56px; border-radius: 10px; background: var(--soft); display: grid; place-items: center; color: var(--muted); font-weight: 700; font-size: 18px; border: 0; padding: 0; }
.thumb__img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.card__title { font-size: 15px; font-weight: 550; line-height: 1.3; background: none; border: 0; padding: 0; text-align: left; }
.card__meta { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; align-items: center; font-size: 13px; color: var(--muted); }
.id { font-variant-numeric: tabular-nums; font-weight: 650; color: var(--ink); background: var(--soft); border-radius: 6px; padding: 1px 6px; }
.badge { border-radius: 6px; padding: 1px 6px; font-weight: 600; }
.badge--red { background: var(--red); color: #fff; }
.badge--amber { background: var(--amber-soft); color: var(--amber); }
.badge--green { background: var(--green-soft); color: var(--green); }
.card__actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }

.btn { border: 0; border-radius: 10px; padding: 10px 14px; font-weight: 600; font-size: 15px; background: var(--accent); color: var(--accent-ink); min-height: 42px; }
.btn--ghost { background: var(--soft); color: var(--ink); }
.btn--small { padding: 6px 10px; min-height: 34px; font-size: 14px; }
.btn--icon { padding: 0; width: 42px; display: grid; place-items: center; background: var(--soft); color: var(--ink); }
.btn--icon svg { width: 20px; height: 20px; }
.btn:disabled { opacity: .5; }
.btn--wide { width: 100%; }

.field { display: flex; gap: 8px; }
.field input, textarea { flex: 1; min-width: 0; border: 1px solid var(--line); background: var(--card); border-radius: 10px; padding: 10px 12px; font-size: 16px; }
textarea { width: 100%; min-height: 96px; resize: vertical; }
input:focus, textarea:focus { outline: 2px solid var(--ink); outline-offset: -1px; }

.seg { display: flex; background: var(--soft); border-radius: 10px; padding: 3px; gap: 3px; margin: 4px 0 6px; }
.seg button { flex: 1; border: 0; background: none; border-radius: 8px; padding: 7px 4px; font-size: 14px; color: var(--muted); }
.seg button[aria-pressed="true"] { background: var(--card); color: var(--ink); font-weight: 600; box-shadow: 0 1px 2px rgb(0 0 0 / .08); }

.tiles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 8px; }
.tile { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 12px; }
.tile b { display: block; font-size: 26px; font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.tile span { color: var(--muted); font-size: 13px; }
.tile--red { background: var(--red); border-color: var(--red); color: #fff; }
.tile--red span { color: rgb(255 255 255 / .85); }
.alert { display: flex; gap: 12px; align-items: center; background: var(--red-soft); color: var(--red); border-radius: var(--r); padding: 12px 14px; margin-top: 8px; font-weight: 600; }
.alert b { font-size: 26px; }
table.offices { width: 100%; border-collapse: collapse; background: var(--card); border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; font-size: 15px; }
.offices th, .offices td { padding: 10px; text-align: right; border-bottom: 1px solid var(--line); font-variant-numeric: tabular-nums; }
.offices th:first-child, .offices td:first-child { text-align: left; }
.offices th { font-size: 12px; color: var(--muted); font-weight: 600; }
.offices tr:last-child td { border-bottom: 0; }
.red { color: var(--red); font-weight: 700; }

.users { display: grid; gap: 8px; margin-top: 12px; }
.users button { text-align: left; background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 14px; font-size: 16px; font-weight: 600; display: flex; justify-content: space-between; }
.users button span { color: var(--muted); font-weight: 400; font-size: 14px; }

.sheet { position: fixed; inset: 0; z-index: 10; }
.sheet__bg { position: absolute; inset: 0; background: rgb(0 0 0 / .4); }
.sheet__body { position: absolute; left: 0; right: 0; bottom: 0; max-height: 88vh; overflow: auto; background: var(--bg); border-radius: 18px 18px 0 0;
  padding: 16px 16px calc(env(safe-area-inset-bottom) + 20px); max-width: 720px; margin: 0 auto; animation: up .2s ease-out; }
@keyframes up { from { transform: translateY(24px); opacity: .6; } }
.photo { display: block; width: 100%; aspect-ratio: 4/3; object-fit: contain; border-radius: var(--r); background: #fff; margin-bottom: 12px; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 12px; font-size: 15px; margin: 10px 0; }
.kv dt { color: var(--muted); } .kv dd { margin: 0; font-weight: 550; }
.timeline { list-style: none; padding: 0; margin: 0; border-left: 2px solid var(--line); margin-left: 6px; }
.timeline li { position: relative; padding: 0 0 14px 16px; font-size: 14px; }
.timeline li::before { content: ""; position: absolute; left: -6px; top: 5px; width: 10px; height: 10px; border-radius: 50%; background: var(--ink); }
.timeline time { color: var(--muted); font-size: 13px; }
.timeline img { width: 72px; height: 72px; object-fit: cover; border-radius: 8px; margin-top: 6px; display: block; }

.toast { position: fixed; left: 16px; right: 16px; bottom: calc(env(safe-area-inset-bottom) + 84px); z-index: 20; max-width: 560px; margin: 0 auto;
  background: var(--ink); color: var(--bg); border-radius: 12px; padding: 12px 14px; font-size: 15px; white-space: pre-line; box-shadow: 0 6px 24px rgb(0 0 0 / .2); }
.toast--err { background: var(--red); color: #fff; }
.scan video { width: 100%; border-radius: var(--r); background: #000; }
@media (prefers-reduced-motion: reduce) { .sheet__body { animation: none; } }
