:root {
  --bg: #f4f6f7;
  --surface: #ffffff;
  --surface-2: #eef2f3;
  --text: #15232a;
  --muted: #5f7079;
  --line: #d9e1e4;
  --brand: #0f4c5c;
  --brand-ink: #ffffff;
  --brand-soft: #dceef1;
  --accent: #f2a541;
  --ok: #1f7a4d;
  --ok-soft: #dff3e8;
  --bad: #b3261e;
  --bad-soft: #fbe3e1;
  --warn: #8a5a00;
  --warn-soft: #fdf0d5;
  --radius: 14px;
  --shadow: 0 1px 2px rgb(16 40 48 / 6%), 0 4px 14px rgb(16 40 48 / 6%);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0d1518;
    --surface: #152126;
    --surface-2: #1c2b31;
    --text: #e6eef0;
    --muted: #93a6ad;
    --line: #2a3b42;
    --brand: #5fb3c4;
    --brand-ink: #062027;
    --brand-soft: #173840;
    --ok: #6fd3a0;
    --ok-soft: #173a2a;
    --bad: #ff8a80;
    --bad-soft: #3d1c1a;
    --warn: #f5c56b;
    --warn-soft: #3a2e14;
    --shadow: none;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
html { scroll-padding-bottom: calc(96px + var(--safe-b)); }
body {
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  min-height: 100dvh;
}
body.noscroll { overflow: hidden; }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2 { margin: 0; line-height: 1.2; }
h2, .h2 { font-size: 1.15rem; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.ico { width: 22px; height: 22px; flex: none; }
.ico.inline { width: 1.15em; height: 1.15em; vertical-align: -0.2em; color: var(--brand); }
.muted { color: var(--muted); }
.hint { color: var(--muted); font-size: 0.875rem; margin: 0; }
.center { text-align: center; }
[hidden] { display: none !important; }

.splash { min-height: 100dvh; display: grid; place-items: center; }
.spinner { width: 36px; height: 36px; border: 3px solid var(--line); border-top-color: var(--brand); border-radius: 50%; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }

/* buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 0 18px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--surface); font-weight: 600; cursor: pointer; text-decoration: none; color: var(--text);
}
.btn.primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.btn.ghost { background: transparent; }
.btn.block { width: 100%; }
.btn.small { min-height: 38px; padding: 0 14px; font-size: 0.9rem; }
.btn:disabled { opacity: 0.65; cursor: progress; }
.btn:focus-visible, .icon-btn:focus-visible, .pick:focus-within, .chip:focus-visible, .row:focus-visible { outline: 3px solid color-mix(in srgb, var(--brand) 45%, transparent); outline-offset: 2px; }
.icon-btn {
  display: inline-grid; place-items: center; width: 42px; height: 42px; border-radius: 12px;
  border: 1px solid var(--line); background: var(--surface); cursor: pointer; color: var(--text);
}

/* language picker */
.langs { display: inline-flex; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: var(--surface); }
.lang { border: 0; background: transparent; padding: 0 10px; height: 34px; font-size: 0.8rem; font-weight: 700; color: var(--muted); cursor: pointer; }
.lang.on { background: var(--brand); color: var(--brand-ink); }

/* login */
.login { max-width: 420px; margin: 0 auto; padding: calc(16px + var(--safe-t)) 16px calc(24px + var(--safe-b)); min-height: 100dvh; display: flex; flex-direction: column; }
.login-top { display: flex; justify-content: flex-end; }
.brand { text-align: center; margin: 28px 0 22px; }
.brand .logo { width: 72px; height: 72px; margin: 0 auto 14px; border-radius: 20px; background: var(--brand); color: var(--brand-ink); display: grid; place-items: center; }
.brand .logo .ico { width: 38px; height: 38px; }
.brand h1 { font-size: 1.6rem; }
.brand p { color: var(--muted); margin: 6px 0 0; }
.login form { padding: 20px; display: grid; gap: 14px; }
.login-install { margin-top: 18px; text-align: center; }

/* fields */
.field { display: grid; gap: 6px; min-width: 0; }
.field input[type=date] { min-width: 0; padding-left: 8px; padding-right: 8px; -webkit-appearance: none; appearance: none; }
.field > span { font-size: 0.85rem; font-weight: 600; color: var(--muted); }
.field input, .field select, .field textarea {
  width: 100%; min-height: 48px; padding: 10px 12px; border: 1px solid var(--line);
  border-radius: 12px; background: var(--surface); font-size: 16px; /* 16px stops iOS zoom */
}
.field textarea { resize: vertical; min-height: 84px; }
.field select { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 20px) 21px, calc(100% - 14px) 21px; background-size: 6px 6px; background-repeat: no-repeat; padding-right: 36px; }
.field input:focus, .field select:focus, .field textarea:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 22%, transparent); }
.field input[readonly] { background: var(--surface-2); }
.err { color: var(--bad); margin: 0; min-height: 0; font-size: 0.9rem; }
.err:empty { display: none; }

/* shell */
.top {
  position: sticky; top: 0; z-index: 5; display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: calc(10px + var(--safe-t)) 16px 10px; background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px); border-bottom: 1px solid var(--line);
}
.who { display: grid; min-width: 0; }
.who strong, .who small { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.who small { color: var(--muted); font-size: 0.8rem; }
.top-actions { display: flex; align-items: center; gap: 8px; }
.view { max-width: 640px; margin: 0 auto; padding: 16px 16px calc(96px + var(--safe-b)); }
.tabs {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 5; display: grid; grid-template-columns: 1fr 1fr;
  background: var(--surface); border-top: 1px solid var(--line); padding-bottom: var(--safe-b);
}
.tabs button { border: 0; background: none; padding: 10px 0 8px; display: grid; justify-items: center; gap: 2px; font-size: 0.78rem; font-weight: 600; color: var(--muted); cursor: pointer; }
.tabs button.on { color: var(--brand); }

/* form */
.form { padding: 18px; display: grid; gap: 16px; grid-template-columns: minmax(0, 1fr); }
.pickers { display: grid; gap: 10px; }
.pick-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.pick {
  position: relative; display: grid; justify-items: center; align-content: center; gap: 8px; text-align: center;
  min-height: 96px; padding: 12px 6px; border: 1.5px dashed var(--line); border-radius: 14px; background: var(--surface-2);
  font-size: 0.82rem; font-weight: 600; cursor: pointer; color: var(--text);
}
.pick .ico { width: 28px; height: 28px; color: var(--brand); }
.pick:active { background: var(--brand-soft); }
.pick input { position: absolute; inset: 0; opacity: 0; width: 100%; height: 100%; cursor: pointer; }
.pickers.has-file .pick { min-height: 64px; }
.pickers.has-file .pick span { font-size: 0.75rem; }
.preview { display: flex; align-items: center; gap: 12px; padding: 10px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }
.preview img, .preview .doc { width: 64px; height: 64px; border-radius: 10px; object-fit: cover; flex: none; background: var(--surface-2); }
.preview .doc { display: grid; place-items: center; color: var(--brand); }
.preview .meta { display: grid; min-width: 0; flex: 1; }
.preview .meta strong { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 0.92rem; }
.preview .meta small { color: var(--muted); }
.progress { height: 6px; border-radius: 6px; background: var(--surface-2); overflow: hidden; }
.progress > div { height: 100%; width: 0; background: var(--brand); transition: width 0.2s; }

.two { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 12px; }

/* list */
.list { display: grid; gap: 12px; grid-template-columns: minmax(0, 1fr); }
.filters { padding: 12px; display: grid; gap: 12px; }
.range { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto; gap: 10px; align-items: end; }
.range .icon-btn { height: 48px; width: 48px; }
.chips { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; }
.chip { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; border: 1px solid var(--line); background: var(--surface); border-radius: 999px; height: 36px; padding: 0 12px; font-size: 0.85rem; font-weight: 600; cursor: pointer; color: var(--text); }
.chip b { font-weight: 700; font-size: 0.75rem; background: var(--surface-2); border-radius: 999px; padding: 1px 7px; }
.chip.on { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.chip.on b { background: color-mix(in srgb, var(--brand-ink) 22%, transparent); }
#rows { display: grid; gap: 10px; }
.row { display: flex; gap: 12px; justify-content: space-between; text-align: left; padding: 14px; width: 100%; cursor: pointer; color: var(--text); }
.row-main { min-width: 0; display: grid; gap: 2px; }
.row-main > span { display: block; }
.row-title { font-weight: 700; }
.row-sub { color: var(--muted); font-size: 0.88rem; }
.row-rem { font-size: 0.88rem; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.row-side { display: grid; justify-items: end; align-content: start; gap: 4px; flex: none; }
.row-side .amt { font-size: 0.95rem; font-variant-numeric: tabular-nums; }
.row-side small { font-size: 0.78rem; display: inline-flex; align-items: center; gap: 2px; }
.row-side .ico { width: 14px; height: 14px; }
.empty { text-align: center; color: var(--muted); padding: 32px 0; }
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 3px 9px 3px 7px; border-radius: 999px; font-size: 0.78rem; font-weight: 700; }
.badge .ico { width: 14px; height: 14px; }
.badge.pending { background: var(--warn-soft); color: var(--warn); }
.badge.accepted { background: var(--ok-soft); color: var(--ok); }
.badge.rejected { background: var(--bad-soft); color: var(--bad); }

/* sheet (native <dialog>) */
dialog.sheet {
  position: fixed; inset: auto 0 0 0; margin: 0 auto; padding: 0; border: 0; color: var(--text);
  background: var(--bg); width: 100%; max-width: 640px; max-height: 92dvh; border-radius: 20px 20px 0 0;
  display: flex; flex-direction: column; overflow: hidden;
}
dialog.sheet:not([open]) { display: none; }
dialog.sheet[open] { animation: up 0.2s ease-out; }
dialog.sheet::backdrop { background: rgb(0 0 0 / 45%); }
dialog.sheet:focus { outline: none; }
.sheet.small { max-width: 460px; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 16px 8px; }
.sheet-body { overflow-y: auto; padding: 8px 16px calc(20px + var(--safe-b)); display: grid; gap: 14px; }
.sheet-body .form { box-shadow: none; }
@media (min-width: 700px) { dialog.sheet { inset: 0; margin: auto; border-radius: 20px; height: fit-content; } }
@keyframes up { from { transform: translateY(40px); opacity: 0.4; } }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 10px 16px; margin: 0; padding: 14px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.kv dt { color: var(--muted); font-size: 0.85rem; font-weight: 600; }
.kv dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.pre { white-space: pre-wrap; }
img.full { width: 100%; max-height: 45dvh; object-fit: contain; background: var(--surface-2); border-radius: 12px; border: 1px solid var(--line); display: block; }
.lock { display: flex; gap: 10px; align-items: flex-start; margin: 0; padding: 12px 14px; border-radius: 12px; background: var(--surface-2); color: var(--muted); font-size: 0.92rem; }
.install-msg { margin: 0 0 6px; font-size: 1rem; }

/* toast + banner */
.toast {
  position: fixed; left: 50%; bottom: calc(84px + var(--safe-b)); transform: translate(-50%, 20px); z-index: 30;
  max-width: calc(100% - 32px); padding: 12px 16px; border-radius: 12px; background: var(--text); color: var(--bg);
  font-weight: 600; font-size: 0.92rem; opacity: 0; pointer-events: none; transition: 0.2s;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.bad { background: var(--bad); color: #fff; }
.toast.warn { background: var(--warn-soft); color: var(--warn); border: 1px solid var(--warn); }
.install-banner {
  max-width: 608px; margin: 12px auto 0; width: calc(100% - 32px);
  display: grid; gap: 10px; padding: 14px; border-radius: 14px; background: var(--brand-soft); border: 1px solid var(--line);
}
.install-banner p { margin: 0; font-size: 0.92rem; }
.install-banner div { display: flex; justify-content: flex-end; gap: 8px; }

@media (max-width: 360px) {
  .pick { font-size: 0.74rem; min-height: 84px; }
  .top-actions .langs .lang { padding: 0 7px; }
}
.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
