[hidden] { display: none !important; }
:root {
  --bg: #f3f5f8; --card: #fff; --ink: #1b2430; --muted: #6b7684; --line: #dde2e8;
  --brand: #1f4e8c; --brand-ink: #fff; --decl: #eef1f5; --fact: #fff;
  --ok: #1d7a46; --warn: #b26a00; --warn-bg: #fff4e0; --bad: #c0362c; --bad-bg: #fdecea; --diff-bg: #fde7f0; --diff: #a3195b;
  --radius: 10px;
  font-family: -apple-system, "PingFang SC", "Noto Sans CJK SC", "Microsoft YaHei", "WenQuanYi Zen Hei", sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font-size: 16px; }
body { padding-bottom: 96px; }
a { color: var(--brand); }
input, select, textarea, button { font: inherit; color: inherit; }
input, select, textarea { width: 100%; padding: 9px 10px; border: 1px solid var(--line); border-radius: 8px; background: #fff; min-height: 42px; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--brand); outline-offset: -1px; border-color: var(--brand); }
input:disabled, select:disabled, textarea:disabled { background: #f6f7f9; color: var(--ink); }
label { display: block; font-size: 14px; color: var(--muted); }
label > input, label > select { margin-top: 4px; color: var(--ink); }

.top { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 12px; padding: 8px 12px;
  background: var(--brand); color: var(--brand-ink); }
.top a { color: var(--brand-ink); text-decoration: none; }
.brand { font-weight: 700; font-size: 18px; white-space: nowrap; }
.top nav { display: flex; gap: 4px; overflow-x: auto; }
.top nav a { padding: 6px 10px; border-radius: 8px; opacity: .85; white-space: nowrap; }
.top nav a.on { background: rgba(255,255,255,.18); opacity: 1; }
.net { margin-left: auto; font-size: 13px; white-space: nowrap; }
.user { background: transparent; border: 1px solid rgba(255,255,255,.4); color: #fff; border-radius: 8px; padding: 5px 9px; }
.banner { background: var(--warn-bg); color: var(--warn); padding: 8px 12px; font-size: 14px; }

main { max-width: 1100px; margin: 0 auto; padding: 12px; }
h2 { font-size: 20px; margin: 4px 0 12px; }
h3 { font-size: 16px; margin: 0 0 8px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.grow { flex: 1 1 auto; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; margin-bottom: 12px; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 42px; padding: 8px 14px;
  border: 1px solid var(--line); border-radius: 8px; background: #fff; cursor: pointer; text-decoration: none; color: var(--ink); }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.danger { color: var(--bad); border-color: #f0c4c0; }
.btn.big { min-height: 50px; font-size: 17px; width: 100%; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.sm { min-height: 34px; padding: 4px 10px; font-size: 14px; }

.tabs { display: flex; gap: 6px; margin-bottom: 10px; overflow-x: auto; }
.tabs button { border: 1px solid var(--line); background: #fff; border-radius: 20px; padding: 6px 14px; white-space: nowrap; }
.tabs button.on { background: var(--brand); border-color: var(--brand); color: #fff; }

.list-item { display: block; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 12px;
  margin-bottom: 8px; text-decoration: none; color: var(--ink); }
.list-item .t { display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; }
.list-item .no { font-weight: 700; }
.badge { display: inline-block; font-size: 12px; padding: 2px 8px; border-radius: 10px; background: #e9edf2; color: var(--muted); white-space: nowrap; }
.badge.draft { background: #e9edf2; }
.badge.confirmed { background: #e2f3e9; color: var(--ok); }
.badge.dirty { background: var(--warn-bg); color: var(--warn); }
.badge.err { background: var(--bad-bg); color: var(--bad); }
.badge.calc { background: #e8eefb; color: var(--brand); }

/* receipt editor */
.head-grid { display: grid; grid-template-columns: 1fr; gap: 10px; }
@media (min-width: 760px) { .head-grid { grid-template-columns: 2fr 1fr 1fr; } }
.client-box { position: relative; }
.suggest { position: absolute; left: 0; right: 0; top: 100%; z-index: 15; background: #fff; border: 1px solid var(--line);
  border-radius: 8px; box-shadow: 0 6px 20px rgba(0,0,0,.12); max-height: 280px; overflow: auto; }
.suggest div { padding: 10px 12px; border-bottom: 1px solid #f0f2f5; cursor: pointer; }
.suggest div:hover, .suggest div.on { background: #eef3fb; }
.client-state { font-size: 14px; margin-top: 4px; }
.client-state.ok { color: var(--ok); }
.client-state.new { color: var(--warn); }

.switch { display: flex; align-items: center; gap: 10px; font-size: 15px; color: var(--ink); }
.switch input { width: 22px; height: 22px; min-height: 0; }

.line-card { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 12px; overflow: hidden; }
.line-card.has-missing { border-left: 4px solid var(--bad); }
.line-head { display: flex; gap: 8px; align-items: center; padding: 10px 12px; border-bottom: 1px solid var(--line); background: #fafbfc; }
.line-no { font-weight: 700; color: var(--muted); min-width: 28px; }
.line-head input { font-weight: 600; }
.mtable { width: 100%; border-collapse: collapse; }
.mtable th, .mtable td { padding: 6px 8px; border-bottom: 1px solid #eef0f3; vertical-align: middle; }
.mtable th { font-size: 13px; color: var(--muted); font-weight: 500; text-align: left; white-space: nowrap; }
.mtable thead th { background: #fafbfc; }
.mtable thead th.decl { color: #7a8594; }
.mtable thead th.fact { color: var(--brand); font-weight: 700; }
.mtable td.decl input { background: var(--decl); border-color: transparent; color: #4a5562; }
.mtable td.fact input { border-color: #b9c7da; font-weight: 600; }
.mtable td.calc { font-weight: 600; }
.mtable .dims { display: flex; gap: 4px; }
.mtable .dims input { min-width: 0; padding-left: 6px; padding-right: 6px; }
.mtable col.c-label { width: 26%; }
.mtable col.c-decl, .mtable col.c-fact { width: 37%; }
.d-chip { display: inline-block; font-size: 12px; margin-left: 6px; padding: 1px 6px; border-radius: 8px; background: #eef0f3; color: var(--muted); font-weight: 500; }
.d-chip.hl { background: var(--diff-bg); color: var(--diff); font-weight: 700; }
.line-foot { padding: 8px 12px 12px; }
.warns { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0; }
.w { font-size: 13px; padding: 3px 8px; border-radius: 8px; }
.w.missing { background: var(--bad-bg); color: var(--bad); }
.w.warn { background: var(--warn-bg); color: var(--warn); }
.w.diff { background: var(--diff-bg); color: var(--diff); }
.photos { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.thumb { position: relative; width: 84px; height: 84px; border-radius: 8px; overflow: hidden; background: #e9edf2; border: 1px solid var(--line); }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb .x { position: absolute; top: 2px; right: 2px; width: 26px; height: 26px; border-radius: 13px; border: 0; background: rgba(0,0,0,.55); color: #fff; font-size: 15px; line-height: 26px; padding: 0; }
.thumb .pending { position: absolute; left: 0; right: 0; bottom: 0; background: rgba(0,0,0,.55); color: #fff; font-size: 11px; text-align: center; }
.file-btn { position: relative; overflow: hidden; }
.file-btn input { position: absolute; inset: 0; opacity: 0; cursor: pointer; min-height: 0; }

.bottom { position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; background: #fff; border-top: 1px solid var(--line);
  padding: 8px 12px calc(8px + env(safe-area-inset-bottom)); box-shadow: 0 -4px 16px rgba(0,0,0,.06); }
.bottom .inner { max-width: 1100px; margin: 0 auto; display: flex; gap: 10px; align-items: center; }
.tot { font-size: 15px; line-height: 1.3; }
.tot b { font-size: 17px; }
.bottom .btn { min-width: 120px; }
.why { font-size: 12px; color: var(--bad); }

.import-row { display: flex; gap: 8px; flex-wrap: wrap; }
.import-row .btn { flex: 1 1 140px; }

table.plain { width: 100%; border-collapse: collapse; background: #fff; font-size: 14px; }
table.plain th, table.plain td { padding: 7px 8px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
table.plain th { background: #fafbfc; color: var(--muted); font-weight: 500; white-space: nowrap; }
.scroll-x { overflow-x: auto; }

.modal { position: fixed; inset: 0; z-index: 50; background: rgba(15,25,40,.45); display: flex; align-items: flex-end; justify-content: center; }
@media (min-width: 640px) { .modal { align-items: center; } }
.modal-box { background: #fff; width: 100%; max-width: 520px; border-radius: 14px 14px 0 0; padding: 16px; max-height: 90vh; overflow: auto; }
@media (min-width: 640px) { .modal-box { border-radius: 14px; } }
.modal-box .actions { display: flex; flex-direction: column; gap: 8px; margin-top: 14px; }
.toast { position: fixed; left: 50%; bottom: 100px; transform: translateX(-50%); z-index: 60; background: #1b2430; color: #fff;
  padding: 10px 16px; border-radius: 10px; font-size: 15px; max-width: 90vw; }

.login-body { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 16px; }
.login-card { width: 100%; max-width: 360px; background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: 22px; display: grid; gap: 14px; }
.login-card h1 { margin: 0; color: var(--brand); font-size: 22px; }
.login-card .sub { margin: -8px 0 4px; color: var(--muted); }
.err { color: var(--bad); min-height: 1.2em; margin: 0; }
@media (max-width: 600px) {
  .top { flex-wrap: wrap; row-gap: 4px; padding-bottom: 4px; }
  .top nav { order: 3; width: 100%; }
  .top nav a { flex: 1; text-align: center; }
  .mtable th, .mtable td { padding: 5px 4px; }
}
