:root { --ink: #1f2a33; --muted: #6b7680; --line: #d7dde2; --accent: #1f4e8c; --bg: #ffffff; --soft: #f3f5f7;
        --ok: #1e6b3a; --bad: #9b2226; --warn: #7a5a00; }
* { box-sizing: border-box; }
body { margin: 0; font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; color: var(--ink); background: var(--bg); }
a { color: var(--accent); }
main { max-width: 1060px; margin: 0 auto; padding: 20px 20px 80px; }
h1 { font-size: 22px; margin: 8px 0 16px; font-weight: 650; }
h2 { font-size: 17px; margin: 32px 0 8px; }
h3 { font-size: 15px; margin: 0 0 6px; }
.bar { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 10px 20px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.brand { font-weight: 700; color: var(--ink); text-decoration: none; font-size: 17px; }
.bar nav { display: flex; gap: 18px; align-items: center; flex-wrap: wrap; }
.inline { display: inline; }
input, select, textarea, button, .button { font: inherit; color: inherit; }
input, select, textarea { width: 100%; padding: 7px 9px; border: 1px solid var(--line); border-radius: 4px; background: #fff; }
textarea { resize: vertical; line-height: 1.4; }
input:focus, select:focus, textarea:focus, button:focus-visible, a:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 10px; }
label input, label select, label textarea { margin-top: 3px; font-size: 15px; color: var(--ink); }
label.check { display: flex; gap: 8px; align-items: flex-start; color: var(--ink); font-size: 14px; }
label.check input { width: auto; margin-top: 3px; }
label.short { max-width: 280px; }
button, .button { display: inline-block; padding: 7px 14px; border: 1px solid var(--line); border-radius: 4px; background: var(--soft); cursor: pointer; text-decoration: none; color: var(--ink); }
button.primary, .button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
button.danger { color: var(--bad); }
button.link { background: none; border: none; padding: 0; color: var(--accent); }
button.link.danger { color: var(--bad); }
fieldset { border: none; border-top: 1px solid var(--line); margin: 18px 0 0; padding: 12px 0 0; }
legend { font-weight: 650; padding-right: 8px; }
.grid2 { display: grid; grid-template-columns: 160px 200px; gap: 12px; }
.grid3 { display: grid; grid-template-columns: 180px 160px 1fr; gap: 12px; }
.hint { color: var(--muted); font-size: 13px; margin: 4px 0 10px; }
.err { background: #fbeceb; color: var(--bad); padding: 10px 14px; border-radius: 4px; margin: 10px 0; }
.err p { margin: 0 0 4px; font-weight: 600; }
.err ul { margin: 0; padding-left: 20px; }
.notice { background: #eaf4ed; color: var(--ok); padding: 8px 14px; border-radius: 4px; }
.warn { background: #fff6dd; color: var(--warn); padding: 8px 14px; border-radius: 4px; }
.empty { color: var(--muted); margin-top: 30px; }
.actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin: 16px 0; }
.actions.sticky { position: sticky; bottom: 0; background: var(--bg); padding: 12px 0; border-top: 1px solid var(--line); }
.delform { margin-top: 8px; }

.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
.filters input[name=q] { width: 260px; }
.filters select, .filters input[type=date] { width: auto; }
.filters label { display: flex; align-items: center; gap: 6px; margin: 0; }
.filters label input { margin: 0; }

table.list { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
table.list th { text-align: center; font-weight: 600; font-size: 13px; color: var(--muted); border-bottom: 1px solid var(--line); padding: 6px 8px; }
table.list td { border-bottom: 1px solid var(--soft); padding: 7px 16px 7px 8px; text-align: left; }
table.list td.num { text-align: right; padding-left: 16px; padding-right: 8px; }
table.list td.c { text-align: center; }
table.list tfoot td { font-weight: 600; border-bottom: none; }
table.compact td { padding-top: 4px; padding-bottom: 4px; }
.badge { display: inline-block; font-size: 12px; padding: 1px 8px; border-radius: 10px; background: var(--soft); vertical-align: middle; font-weight: 500; }
.st-issued .badge, .badge.st-issued { background: #e3ecf8; color: var(--accent); }
.st-paid .badge, .badge.st-paid { background: #e2f1e6; color: var(--ok); }
.st-cancelled td { color: var(--muted); }
.st-cancelled .num { text-decoration: line-through; }
.badge.st-cancelled { color: var(--bad); }
.badge.tax-only { background: #e2f1e6; color: var(--ok); }
.badge.tax-check { background: #fbeceb; color: var(--bad); }

table.items-edit { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; table-layout: fixed; }
table.items-edit th:nth-child(2) { width: 90px; }
table.items-edit th:nth-child(3) { width: 64px; }
table.items-edit th:nth-child(4) { width: 130px; }
table.items-edit th:nth-child(5) { width: 110px; }
table.items-edit th:nth-child(6) { width: 120px; }
table.items-edit th:nth-child(7) { width: 28px; }
table.items-edit tfoot td.lbl { text-align: right; padding-right: 12px; }
table.items-edit tfoot tr.sub td { font-weight: normal; color: var(--muted); padding-top: 2px; }
table.items-edit th { font-size: 13px; color: var(--muted); font-weight: 600; text-align: center; padding: 4px; }
table.items-edit td { padding: 3px 4px; vertical-align: top; }
table.items-edit input.n { text-align: right; }
table.items-edit input.u { text-align: center; }
table.items-edit td.num { text-align: right; padding-top: 10px; }
table.items-edit tfoot td { padding-top: 8px; font-weight: 650; }
.ac-wrap { position: relative; }
ul.ac { position: absolute; z-index: 5; left: 0; right: 0; top: 100%; margin: 2px 0 0; padding: 4px 0; list-style: none; background: #fff; border: 1px solid var(--line); border-radius: 4px; box-shadow: 0 4px 14px rgba(20,30,40,.12); max-height: 280px; overflow: auto; }
ul.ac li { padding: 6px 10px; cursor: pointer; font-size: 14px; }
ul.ac li:hover, ul.ac li.on { background: var(--soft); }

dl.facts { display: grid; grid-template-columns: 170px 1fr; gap: 6px 14px; margin: 0 0 16px; }
dl.facts dt { color: var(--muted); }
dl.facts dd { margin: 0; word-break: break-all; }
.num-inline { font-variant-numeric: tabular-nums; font-weight: 600; }

.assets { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 16px; }
.asset { border: 1px solid var(--line); border-radius: 4px; padding: 10px; }
.asset img { max-width: 100%; max-height: 120px; display: block; margin: 8px 0; background: repeating-conic-gradient(#eee 0 25%, #fff 0 50%) 0 0 / 16px 16px; }
.asset input[type=file] { border: none; padding: 4px 0; }
.memo { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }
.memo-row { display: flex; gap: 10px; align-items: center; border-bottom: 1px solid var(--soft); padding: 4px 0; }
.memo-row span:first-child { flex: 1; }
.memo-row .num { font-variant-numeric: tabular-nums; }

body.login { display: grid; place-items: center; min-height: 100vh; background: var(--soft); }
.loginbox { background: #fff; padding: 28px; border-radius: 6px; width: 320px; border: 1px solid var(--line); }
.loginbox h1 { margin-top: 0; }
.loginbox button { width: 100%; margin-top: 6px; }

@media (max-width: 720px) {
  .grid2, .grid3, .memo { grid-template-columns: 1fr; }
  dl.facts { grid-template-columns: 1fr; }
}
