:root {
  --bg: #f4f6f7; --card: #fff; --ink: #1b2428; --muted: #5d6b72; --line: #dde3e6;
  --brand: #0f4c5c; --brand-2: #1a7f8e; --accent: #e9f4f6;
  --warn: #b3261e; --warn-bg: #fdecea; --caution: #8a5a00; --caution-bg: #fff4dc; --ok: #1e7b45;
  --radius: 14px;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 16px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; background: var(--bg); color: var(--ink);
  padding-bottom: env(safe-area-inset-bottom); }
.topbar { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: calc(env(safe-area-inset-top) + 10px) 16px 10px; background: var(--brand); color: #fff; }
.brand { display: flex; align-items: center; gap: 8px; color: #fff; text-decoration: none; font-weight: 700; font-size: 18px; }
.brand img { border-radius: 7px; }
.who { font-size: 12px; opacity: .8; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 55%; }
main { max-width: 640px; margin: 0 auto; padding: 16px; }
h1 { font-size: 22px; margin: 4px 0 14px; }
h2 { font-size: 17px; margin: 22px 0 8px; }
h3 { font-size: 15px; margin: 14px 0 6px; }
a { color: var(--brand-2); }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; margin: 12px 0; }
.big-buttons { display: grid; gap: 12px; margin-top: 8px; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 1px solid var(--brand); background: var(--brand); color: #fff;
  border-radius: 12px; padding: 12px 16px; font-size: 16px; font-weight: 600; text-decoration: none; cursor: pointer; min-height: 46px; }
.btn.big { font-size: 19px; padding: 22px; border-radius: 16px; }
.btn.secondary { background: #fff; color: var(--brand); }
.btn.danger { background: #fff; color: var(--warn); border-color: var(--warn); }
.btn.small { padding: 6px 10px; min-height: 34px; font-size: 14px; border-radius: 9px; }
.btn:disabled { opacity: .5; cursor: default; }
.links { display: flex; flex-wrap: wrap; gap: 10px 18px; justify-content: center; margin: 22px 0; }
.links a { font-weight: 600; }
.row-actions { display: flex; flex-wrap: wrap; gap: 10px; margin: 14px 0; }
form .field { margin: 14px 0; }
label, .label { display: block; font-weight: 600; font-size: 14px; margin-bottom: 6px; }
input[type=text], input[type=number], input[type=date], input:not([type]), textarea, select {
  width: 100%; font: inherit; font-size: 17px; padding: 11px 12px; border: 1px solid var(--line); border-radius: 10px; background: #fff; color: var(--ink); }
textarea { min-height: 90px; resize: vertical; }
.inline { display: flex; gap: 10px; align-items: center; }
.inline > * { flex: 1; }
.inline .sep { flex: 0; color: var(--muted); }
.unit { color: var(--muted); font-size: 14px; flex: 0 0 auto; }
.seg { display: flex; flex-wrap: wrap; gap: 6px; }
.seg button { flex: 1 1 auto; min-width: 54px; padding: 10px 8px; border: 1px solid var(--line); background: #fff; border-radius: 10px; font: inherit; font-size: 15px; cursor: pointer; color: var(--ink); }
.seg button[aria-pressed=true] { background: var(--brand); color: #fff; border-color: var(--brand); font-weight: 600; }
.invalid input, .invalid .seg { outline: 2px solid var(--warn); outline-offset: 2px; border-radius: 10px; }
.err { color: var(--warn); font-size: 13px; margin-top: 4px; }
.suggest { margin-top: 8px; padding: 10px 12px; background: var(--accent); border-radius: 10px; font-size: 14px; display: flex; gap: 10px; align-items: center; justify-content: space-between; }
.result-main { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.metric { background: var(--accent); border-radius: 12px; padding: 12px; }
.metric .v { font-size: 23px; font-weight: 800; color: var(--brand); line-height: 1.15; }
.metric .k { font-size: 13px; color: var(--muted); }
.banner { border-radius: 12px; padding: 12px 14px; margin: 10px 0; font-size: 15px; }
.banner.warn { background: var(--warn-bg); color: var(--warn); border: 1px solid #f3b8b3; }
.banner.caution { background: var(--caution-bg); color: var(--caution); border: 1px solid #f0d79a; }
.banner.ok { background: #e7f6ec; color: var(--ok); border: 1px solid #b7e2c6; }
.banner.info { background: var(--accent); color: var(--brand); }
.salt { font-weight: 600; margin-top: 10px; }
dl.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; margin: 0; }
dl.kv dt { color: var(--muted); font-size: 14px; }
dl.kv dd { margin: 0; font-weight: 600; text-align: right; }
.list { list-style: none; padding: 0; margin: 0; }
.list li a { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 13px 14px; background: #fff; border: 1px solid var(--line);
  border-radius: 12px; margin-bottom: 8px; text-decoration: none; color: var(--ink); }
.list .meta { font-size: 13px; color: var(--muted); }
.pill { font-size: 12px; padding: 3px 8px; border-radius: 99px; background: #eef1f2; color: var(--muted); white-space: nowrap; }
.pill.done { background: #e7f6ec; color: var(--ok); }
.counter { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.counter:last-child { border-bottom: 0; }
.counter .name { flex: 1; }
.counter .name small { display: block; color: var(--muted); font-size: 12px; }
.counter .ctl { display: flex; align-items: center; gap: 8px; }
.counter .ctl button { width: 40px; height: 40px; border-radius: 10px; border: 1px solid var(--line); background: #fff; font-size: 22px; line-height: 1; cursor: pointer; color: var(--brand); }
.counter .ctl output { min-width: 26px; text-align: center; font-weight: 700; font-size: 18px; }
details { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 10px 14px; margin: 12px 0; }
details summary { cursor: pointer; font-weight: 600; }
.grid-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table.grid { border-collapse: collapse; width: 100%; background: #fff; font-size: 12px; }
table.grid th, table.grid td { border: 1px solid var(--line); padding: 5px 3px; text-align: center; vertical-align: middle; }
table.grid th { background: #eef3f4; }
table.grid td.ready { background: #e9f6ee; cursor: pointer; }
table.grid td.partial { color: var(--muted); cursor: pointer; }
table.grid td .avg { font-weight: 800; font-size: 15px; color: var(--brand); }
pre { white-space: pre-wrap; word-break: break-word; background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 10px; font-size: 12px; max-height: 360px; overflow: auto; }
.toast { position: fixed; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom)); transform: translateX(-50%); background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 10px; z-index: 20; font-size: 14px; }
.prod-row { display: grid; grid-template-columns: 1fr; gap: 6px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.prod-row .nums { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.prod-row .nums input { font-size: 15px; padding: 8px; }
.archived { opacity: .55; }
.back { display: inline-block; margin-bottom: 6px; text-decoration: none; font-weight: 600; }

/* v1.1 layout fixes */
.metric .v { font-size: clamp(18px, 5.4vw, 26px); white-space: nowrap; letter-spacing: -0.01em; }
.metric .v .u { font-size: .62em; font-weight: 700; }
.row-actions.three { display: grid; grid-template-columns: 1fr 1fr auto; gap: 8px; }
.row-actions.three .btn { font-size: 15px; padding: 10px 8px; line-height: 1.2; text-align: center; }
.list-card { padding: 2px 14px; }
details.prod { border: 0; border-bottom: 1px solid var(--line); border-radius: 0; margin: 0; padding: 0; background: transparent; }
details.prod:last-child { border-bottom: 0; }
details.prod > summary { list-style: none; display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 11px 0; }
details.prod > summary::-webkit-details-marker { display: none; }
details.prod[open] > summary .pill { background: var(--brand); color: #fff; }
.pname { display: flex; flex-direction: column; }
.pname small { color: var(--muted); font-size: 12px; font-weight: 400; }
.prod-edit { padding: 0 0 12px; }
.prod-edit input { font-size: 15px; padding: 8px; }
.prod-edit .nums { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin-top: 6px; }
.sub { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 700; margin: 14px 0 4px; }
.rgrid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 10px; }
.rtable { background: #f8fafb; border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; }
.rtable.wide { grid-column: 1 / -1; }
.rt-title { font-weight: 700; font-size: 13px; margin-bottom: 4px; }
table.kv-table { width: 100%; border-collapse: collapse; font-size: 13px; }
table.kv-table th { text-align: left; color: var(--muted); font-weight: 600; font-size: 12px; padding: 2px 0; }
table.kv-table td { padding: 2px 0; border-top: 1px solid var(--line); }
table.kv-table td:last-child, table.kv-table th:last-child { text-align: right; }
dl.kv.rules { font-size: 13px; gap: 4px 10px; margin-top: 8px; }
dl.kv.rules dt { font-size: 13px; }
dl.kv.rules dd { font-weight: 600; }
.version { border-top: 1px solid var(--line); padding: 10px 0; }
.vhead { display: flex; align-items: center; gap: 8px; }
.vhead a.pill { margin-left: auto; text-decoration: none; }
.vnotes { font-size: 13px; color: var(--muted); margin: 6px 0 0; line-height: 1.45; }
.list.compact li a { padding: 9px 12px; font-size: 14px; }
@media (max-width: 560px) { .rgrid { grid-template-columns: 1fr; } }
dl.kv.rules { grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); }
dl.kv.rules dd { overflow-wrap: break-word; }
