:root {
  --bg: #f4f6f9; --panel: #ffffff; --ink: #1c2330; --muted: #6b7686; --line: #e2e6ec;
  --brand: #0f5a8f; --brand-ink: #ffffff; --brand-soft: #e6f0f8; --accent: #c8102e;
  --ok: #1a7f4b; --ok-soft: #e4f4ea; --warn: #b26a00; --warn-soft: #fff4e0; --bad: #b3261e; --bad-soft: #fdeceb;
  --radius: 10px; --shadow: 0 1px 2px rgba(16,24,40,.06), 0 1px 3px rgba(16,24,40,.1);
  font-family: "Segoe UI", "Hiragino Sans", "Noto Sans JP", "Noto Sans", system-ui, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font-size: 14px; }
a { color: var(--brand); text-decoration: none; } a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; color: inherit; }

.app { display: grid; grid-template-columns: 240px 1fr; min-height: 100vh; }
.side { background: #12304d; color: #dfe8f1; display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; }
.side .brand { padding: 18px 18px 12px; border-bottom: 1px solid rgba(255,255,255,.1); }
.side .brand b { display: block; font-size: 15px; color: #fff; }
.side .brand small { color: #a9bccd; font-size: 11px; }
.side nav { padding: 10px 8px; display: flex; flex-direction: column; gap: 2px; overflow: auto; }
.side nav a { color: #dfe8f1; padding: 9px 12px; border-radius: 8px; display: flex; align-items: center; gap: 10px; font-size: 13.5px; }
.side nav a:hover { background: rgba(255,255,255,.08); text-decoration: none; }
.side nav a.active { background: #fff; color: var(--brand); font-weight: 600; }
.side nav .sep { height: 1px; background: rgba(255,255,255,.1); margin: 8px 10px; }
.side .foot { margin-top: auto; padding: 12px 16px; font-size: 11px; color: #a9bccd; border-top: 1px solid rgba(255,255,255,.1); }

.main { min-width: 0; display: flex; flex-direction: column; }
.top { display: flex; align-items: center; justify-content: space-between; padding: 12px 24px; background: var(--panel); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; }
.top h1 { font-size: 18px; margin: 0; font-weight: 650; }
.top .right { display: flex; align-items: center; gap: 10px; }
.lang { border: 1px solid var(--line); background: #fff; border-radius: 999px; padding: 6px 14px; cursor: pointer; font-weight: 600; color: var(--brand); }
.lang:hover { background: var(--brand-soft); }
.mode { font-size: 12px; padding: 4px 10px; border-radius: 999px; background: var(--ok-soft); color: var(--ok); }
.mode.demo { background: var(--warn-soft); color: var(--warn); }
.banner { background: var(--warn-soft); color: var(--warn); padding: 8px 24px; font-size: 12.5px; border-bottom: 1px solid #f3dfb5; }
.content { padding: 22px 24px 60px; max-width: 1280px; width: 100%; }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px 20px; margin-bottom: 18px; }
.card h2 { margin: 0 0 14px; font-size: 15px; font-weight: 650; display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.card h2 .sub { font-weight: 400; color: var(--muted); font-size: 12.5px; }
.grid { display: grid; gap: 14px; }
.grid.c2 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .grid.c3 { grid-template-columns: repeat(3, minmax(0, 1fr)); } .grid.c4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 1000px) { .grid.c3, .grid.c4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 760px) { .app { grid-template-columns: 1fr; } .side { position: static; height: auto; } .side nav { flex-direction: row; flex-wrap: wrap; } .grid.c2, .grid.c3, .grid.c4 { grid-template-columns: 1fr; } .content { padding: 16px; } }

.field { display: flex; flex-direction: column; gap: 5px; }
.field label { font-size: 12px; color: var(--muted); font-weight: 600; }
.field label .req { color: var(--accent); margin-left: 4px; }
.field input, .field select, .field textarea { border: 1px solid #cfd6df; border-radius: 8px; padding: 8px 10px; background: #fff; width: 100%; }
.field input:focus, .field select:focus, .field textarea:focus { outline: 2px solid var(--brand-soft); border-color: var(--brand); }
.field textarea { min-height: 72px; resize: vertical; }
.field .hint { font-size: 11.5px; color: var(--muted); }
.field.full { grid-column: 1 / -1; }
.inline { display: flex; gap: 8px; align-items: center; }
.inline > * { flex: 1; } .inline > .btn, .inline > button { flex: 0 0 auto; }

.btn { border: 1px solid var(--line); background: #fff; border-radius: 8px; padding: 8px 14px; cursor: pointer; font-weight: 600; display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.btn:hover { background: #f6f8fb; } .btn:disabled { opacity: .5; cursor: default; }
.btn.primary { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); } .btn.primary:hover { background: #0c4b78; }
.btn.danger { color: var(--bad); border-color: #f0c7c4; } .btn.danger:hover { background: var(--bad-soft); }
.btn.sm { padding: 5px 10px; font-size: 12.5px; }
.btn.link { border: none; background: none; color: var(--brand); padding: 0; }
.actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-top: 16px; }
.actions .spacer { flex: 1; }

table.tbl { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.tbl th, .tbl td { padding: 9px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
.tbl th { font-size: 12px; color: var(--muted); font-weight: 600; background: #fafbfd; white-space: nowrap; }
.tbl td.num, .tbl th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.tbl tr.click { cursor: pointer; } .tbl tr.click:hover td { background: #f6f9fc; }
.tbl tfoot td { font-weight: 700; background: #fafbfd; }
.tbl .sub td { color: var(--muted); }
.tbl td .pill { margin-right: 0; }
.scroll { overflow-x: auto; }

.pill { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 11.5px; font-weight: 600; background: #eef1f5; color: #475467; }
.pill.ok { background: var(--ok-soft); color: var(--ok); } .pill.warn { background: var(--warn-soft); color: var(--warn); } .pill.bad { background: var(--bad-soft); color: var(--bad); } .pill.brand { background: var(--brand-soft); color: var(--brand); }

.kv { display: grid; grid-template-columns: 200px 1fr; gap: 8px 16px; font-size: 13.5px; }
.kv dt { color: var(--muted); } .kv dd { margin: 0; }
.stat { background: var(--brand-soft); border-radius: var(--radius); padding: 14px 16px; }
.stat .l { font-size: 12px; color: var(--muted); } .stat .v { font-size: 22px; font-weight: 700; margin-top: 4px; font-variant-numeric: tabular-nums; } .stat .v.neg { color: var(--bad); }
.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 14px; }
.toolbar input[type=search], .toolbar select, .toolbar input[type=date], .toolbar input[type=month] { border: 1px solid #cfd6df; border-radius: 8px; padding: 8px 10px; background: #fff; }
.toolbar .spacer { flex: 1; }
.empty { color: var(--muted); padding: 24px; text-align: center; }
.muted { color: var(--muted); } .small { font-size: 12px; } .right { text-align: right; } .num { font-variant-numeric: tabular-nums; }
.neg { color: var(--bad); }
.filechip { display: inline-flex; gap: 8px; align-items: center; padding: 6px 10px; border: 1px dashed #cfd6df; border-radius: 8px; background: #fafbfd; font-size: 12.5px; }
.filechip.has { border-style: solid; background: var(--ok-soft); border-color: #bfe3cc; }
.filechip input[type=file] { display: none; }
.toast { position: fixed; right: 20px; bottom: 20px; background: #1c2330; color: #fff; padding: 10px 16px; border-radius: 10px; font-size: 13px; opacity: 0; transform: translateY(8px); transition: .2s; z-index: 50; pointer-events: none; }
.toast.show { opacity: 1; transform: none; } .toast.err { background: var(--bad); }
.modal-bg { position: fixed; inset: 0; background: rgba(16,24,40,.45); display: flex; align-items: center; justify-content: center; z-index: 40; padding: 20px; }
.modal { background: #fff; border-radius: 14px; width: min(760px, 100%); max-height: 92vh; overflow: auto; padding: 22px 24px; box-shadow: 0 20px 60px rgba(0,0,0,.3); }
.modal h3 { margin: 0 0 14px; font-size: 16px; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 16px; }
.tabs button { border: none; background: none; padding: 10px 14px; cursor: pointer; font-weight: 600; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs button.active { color: var(--brand); border-bottom-color: var(--brand); }
.pl .sec td { font-weight: 700; background: #f3f6fa; } .pl .total td { font-weight: 700; border-top: 2px solid #c9d2dd; } .pl .ind td:first-child { padding-left: 28px; }
.bars { display: flex; gap: 6px; align-items: flex-end; height: 140px; padding: 10px 0; }
.bars .b { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px; font-size: 10.5px; color: var(--muted); }
.bars .b i { display: block; width: 100%; background: var(--brand); border-radius: 4px 4px 0 0; min-height: 2px; } .bars .b i.neg { background: var(--bad); }
.radio-row { display: flex; gap: 8px; flex-wrap: wrap; }
.radio-row label { border: 1px solid #cfd6df; border-radius: 999px; padding: 7px 14px; cursor: pointer; font-weight: 600; background: #fff; }
.radio-row label.on { background: var(--brand); color: #fff; border-color: var(--brand); }
.radio-row input { display: none; }
.items .tbl input, .items .tbl select { border: 1px solid #cfd6df; border-radius: 6px; padding: 6px 8px; width: 100%; background: #fff; }
.items .tbl td { padding: 6px 6px; }

/* ---------- invoice document ---------- */
.doc { background: #fff; color: #111; width: 210mm; min-height: 280mm; margin: 0 auto; padding: 18mm 16mm; box-shadow: var(--shadow); border: 1px solid var(--line); font-size: 12.5px; }
.doc .head { display: flex; justify-content: space-between; align-items: flex-start; border-bottom: 3px solid var(--brand); padding-bottom: 10px; margin-bottom: 18px; }
.doc .head h1 { margin: 0; font-size: 26px; letter-spacing: 1px; color: var(--brand); }
.doc .co b { font-size: 15px; display: block; } .doc .co { text-align: right; line-height: 1.45; }
.doc .meta { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 18px; }
.doc .meta .box h4 { margin: 0 0 6px; font-size: 11px; color: #666; text-transform: uppercase; letter-spacing: .5px; }
.doc .meta .box .big { font-size: 15px; font-weight: 700; }
.doc table { width: 100%; border-collapse: collapse; margin-top: 8px; }
.doc th { background: var(--brand); color: #fff; padding: 8px; text-align: left; font-size: 11.5px; } .doc th.num { text-align: right; }
.doc td { padding: 8px; border-bottom: 1px solid #e5e5e5; vertical-align: top; } .doc td.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.doc tfoot td { border: none; font-weight: 700; } .doc tfoot tr.gt td { font-size: 15px; border-top: 2px solid var(--brand); padding-top: 10px; }
.doc .notes { margin-top: 20px; white-space: pre-wrap; }
.doc .bank { margin-top: 24px; padding: 10px 12px; background: #f6f8fb; border-radius: 6px; }
.doc .sign { margin-top: 48px; display: flex; justify-content: flex-end; } .doc .sign div { text-align: center; width: 220px; } .doc .sign .line { border-top: 1px solid #333; margin-top: 60px; padding-top: 4px; }
@media print {
  body { background: #fff; } .side, .top, .banner, .no-print, .toast { display: none !important; }
  .app { display: block; } .content { padding: 0; max-width: none; } .doc { box-shadow: none; border: none; width: auto; min-height: auto; margin: 0; padding: 0; }
  @page { size: A4; margin: 14mm; }
}
