:root {
  --ink: #1d1d1f; --muted: #6e6e73; --line: #e5e5ea; --bg: #fafafa; --accent: #1f5f4a;
  --new: #eef7f1; --edited: #fff6d6; --warn: #b25000; --err: #c0392b;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; font: 14px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; color: var(--ink); background: var(--bg); }
header, main { max-width: 1600px; margin: 0 auto; padding: 0 24px; }
header { padding-top: 28px; }
h1 { font-size: 24px; margin: 0 0 4px; }
h2 { font-size: 17px; margin: 28px 0 12px; display: flex; align-items: center; gap: 10px; }
.n { display: inline-grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; background: var(--accent); color: #fff; font-size: 13px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.warn { color: var(--warn); margin-top: 6px; }
.err { color: var(--err); }
section { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 4px 20px 20px; margin: 18px 0; }

#drop { border: 2px dashed #c7c7cc; border-radius: 10px; padding: 22px; text-align: center; transition: .15s; }
#drop.over { border-color: var(--accent); background: var(--new); }
#drop p { margin: 6px 0; }
#master-row { margin-top: 14px; }
#summary, #status { margin-top: 10px; }

button, .btn { font: inherit; border: 1px solid var(--accent); background: #fff; color: var(--accent); border-radius: 8px; padding: 6px 14px; cursor: pointer; display: inline-block; }
button.primary { background: var(--accent); color: #fff; padding: 9px 20px; font-weight: 600; }
button.primary:disabled { background: #c7c7cc; border-color: #c7c7cc; cursor: default; }
button.secondary { border-color: var(--line); color: var(--ink); }
.link { color: var(--accent); cursor: pointer; text-decoration: underline; background: none; border: none; padding: 0; font: inherit; }
button:focus-visible, #drop:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.toolbar { display: flex; flex-wrap: wrap; gap: 14px; align-items: center; margin-bottom: 8px; }
.toolbar input[type=search] { padding: 6px 10px; border: 1px solid var(--line); border-radius: 8px; min-width: 220px; font: inherit; }
.legend { padding: 0 6px; border-radius: 4px; }
.legend.new { background: var(--new); }
.legend.edited { background: var(--edited); }

.table-wrap { overflow: auto; max-height: 70vh; border: 1px solid var(--line); border-radius: 8px; }
table { border-collapse: separate; border-spacing: 0; width: max-content; min-width: 100%; }
th, td { border-bottom: 1px solid var(--line); border-right: 1px solid var(--line); padding: 0; text-align: left; vertical-align: middle; }
thead th { position: sticky; top: 0; z-index: 2; background: #f2f2f5; padding: 6px 8px; font-weight: 600; white-space: nowrap; }
th.obj, td.obj { position: sticky; left: 0; z-index: 1; background: #fff; padding: 6px 10px; width: 230px; min-width: 230px; max-width: 230px; }
thead th.obj { z-index: 3; background: #f2f2f5; }
td.obj .path { color: var(--muted); font-size: 11px; }
td.obj .badge { font-size: 11px; border-radius: 4px; padding: 0 5px; margin-left: 4px; background: var(--new); color: var(--accent); }
td.obj .badge.bad { background: #fdecea; color: var(--err); }
th .fill { border: none; background: none; color: var(--accent); padding: 0 0 0 6px; cursor: pointer; }
td.cell { position: relative; }
td.cell.wide { width: 150px; min-width: 150px; max-width: 150px; }
td.cell.narrow { width: 100px; min-width: 100px; max-width: 100px; }
td.cell input, td.cell select { min-width: 0; box-sizing: border-box; }
thead th { font-size: 13px; }
.table-outer { position: relative; }
.table-wrap::-webkit-scrollbar { height: 12px; width: 12px; }
.table-wrap::-webkit-scrollbar-thumb { background: #c7c7cc; border-radius: 6px; border: 3px solid #fff; }
.table-wrap::-webkit-scrollbar-track { background: #f5f5f7; }
.more-hint { display: none; z-index: 5; position: absolute; top: 1px; right: 1px; bottom: 13px; width: 120px; pointer-events: none;
  background: linear-gradient(to right, rgba(255,255,255,0), #fff 70%); border-radius: 0 8px 0 0;
  align-items: flex-start; justify-content: flex-end; padding: 8px 10px; font-size: 12px; color: var(--accent); font-weight: 600;
  text-shadow: 0 0 6px #fff, 0 0 6px #fff; }
td.cell input::placeholder { color: #d1d1d6; }
.more-right .more-hint { display: flex; }
td.cell input, td.cell select { width: 100%; border: 0; padding: 7px 8px; font: inherit; background: transparent; }
td.cell input:focus, td.cell select:focus { outline: 2px solid var(--accent); outline-offset: -2px; }
td.cell.new { background: var(--new); }
td.cell.edited { background: var(--edited); }
td.cell.disabled { background: #f5f5f7; }
td.cell.disabled input, td.cell.disabled select { color: #aeaeb2; }
td.cell .w { position: absolute; right: 4px; top: 6px; color: var(--warn); cursor: help; font-size: 12px; }
td.error { color: var(--err); padding: 6px 10px; }

.pop { position: fixed; z-index: 10; background: #fff; border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 8px 30px rgba(0,0,0,.15); padding: 12px; display: grid; gap: 8px; min-width: 240px; }
.pop-input input, .pop-input select { width: 100%; padding: 6px 8px; font: inherit; border: 1px solid var(--line); border-radius: 6px; }
.pop-title { font-weight: 600; }

details { margin-top: 18px; background: var(--bg); border-radius: 8px; padding: 10px 14px; }
details summary { cursor: pointer; font-weight: 600; }

body.login { display: grid; place-items: center; min-height: 100vh; }
.card { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 28px; display: grid; gap: 12px; min-width: 300px; }
.card input { display: block; width: 100%; margin-top: 4px; padding: 8px; font: inherit; border: 1px solid var(--line); border-radius: 8px; }
td.cell input.num { text-align: right; font-variant-numeric: tabular-nums; }
td.cell .chk { display: flex; justify-content: center; padding: 7px 0; cursor: pointer; }
td.cell .chk input { width: auto; }
td.cell.invalid { background: #fdecea; outline: 2px solid var(--err); outline-offset: -2px; }
#dock { position: fixed; left: 50%; bottom: 16px; transform: translateX(-50%); z-index: 20; display: flex; gap: 16px;
  align-items: center; background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 8px 8px 8px 18px;
  box-shadow: 0 8px 30px rgba(0,0,0,.15); }
#dock[hidden] { display: none; }
main { padding-bottom: 80px; }
#summary-row { margin-top: 10px; display: flex; gap: 14px; align-items: baseline; }
#summary-row[hidden] { display: none; }
#download-note { margin-top: 8px; }
.tpl-chip { margin-left: auto; font-size: 13px; font-weight: 400; color: var(--muted); }
.tpl-chip strong { color: var(--ink); }
h2 { flex-wrap: wrap; }
dialog#tpl-dialog { width: min(1100px, 95vw); max-height: 90vh; border: 1px solid var(--line); border-radius: 14px;
  padding: 18px 22px; box-shadow: 0 20px 60px rgba(0,0,0,.25); }
dialog#tpl-dialog::backdrop { background: rgba(0,0,0,.25); }
.dlg-head { display: flex; gap: 18px; align-items: center; flex-wrap: wrap; }
.dlg-head h2 { margin: 0; }
.dlg-head select { font: inherit; padding: 4px 6px; max-width: 420px; }
.dlg-links { margin-left: auto; font-size: 13px; }
.dlg-links a { color: var(--accent); }
.tpl-table-wrap { overflow: auto; max-height: 55vh; border: 1px solid var(--line); border-radius: 8px; margin: 10px 0; }
#tpl-table { width: 100%; border-collapse: collapse; }
#tpl-table th { position: sticky; top: 0; background: #f2f2f5; font-size: 12px; padding: 6px 8px; text-align: left; z-index: 1; }
#tpl-table td { border-bottom: 1px solid var(--line); padding: 4px 6px; vertical-align: top; }
#tpl-table input, #tpl-table select, #tpl-table textarea { width: 100%; font: inherit; padding: 5px 6px;
  border: 1px solid var(--line); border-radius: 6px; background: #fff; box-sizing: border-box; }
#tpl-table input[readonly], #tpl-table select:disabled, #tpl-table input:disabled, #tpl-table textarea:disabled { background: #f5f5f7; color: #6e6e73; }
#tpl-table textarea { resize: vertical; min-height: 30px; }
#tpl-table td.bad input, #tpl-table td.bad select, #tpl-table td.bad textarea { border-color: var(--err); background: #fdecea; }
#tpl-table .moves { white-space: nowrap; width: 44px; }
#tpl-table td:nth-child(2) { width: 170px; } #tpl-table td:nth-child(3) { width: 120px; }
#tpl-table td:nth-child(5) { width: 150px; } #tpl-table td:last-child { width: 24px; }
#tpl-banner { margin: 8px 0; }
#tpl-diff { margin: 6px 0; padding-left: 18px; }
.dlg-foot { display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap; margin-top: 12px; }
.dlg-foot label { display: grid; gap: 2px; font-size: 12px; color: var(--muted); }
.dlg-foot input { font: inherit; padding: 6px 8px; border: 1px solid var(--line); border-radius: 6px; min-width: 220px; }
.dlg-foot .spacer { flex: 1; }
#master-offer { margin-top: 8px; }
