:root { --ink:#1a1a1a; --muted:#666; --line:#d9d9d9; --bg:#f4f5f7; --panel:#fff; --accent:#1f5fbf; --accent-ink:#fff; --danger:#c0392b; --ok:#1e8449; --warn:#b9770e; }
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font-family: "Noto Sans JP","Hiragino Sans","Yu Gothic UI","Meiryo",system-ui,sans-serif; font-size: 13.5px; color: var(--ink); background: var(--bg); }
a { color: var(--accent); }
.topbar { display: flex; align-items: center; gap: 10px; height: 46px; padding: 0 14px; background: #1f2a44; color: #fff; }
.topbar a { color: #dfe6f3; text-decoration: none; }
.brand { font-weight: 700; margin-right: 10px; font-size: 15px; }
.nav { display: flex; gap: 2px; flex-wrap: wrap; }
.nav a { padding: 6px 10px; border-radius: 6px; }
.nav a.on, .nav a:hover { background: rgba(255,255,255,.14); color: #fff; }
.nav .sep { width: 1px; background: rgba(255,255,255,.25); margin: 6px 6px; }
.spacer { flex: 1; }
.company-sel { font-size: 13px; padding: 4px 8px; border-radius: 6px; border: 1px solid #7a86a3; background: #fff; color: var(--ink); }
.who { font-size: 12.5px; opacity: .85; }
.logout { font-size: 12.5px; }
.main { padding: 12px 14px; }
.toolbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 8px; }
.toolbar .grow { flex: 1; }
.btn { font: inherit; font-size: 13px; padding: 6px 12px; border: 1px solid var(--line); background: #fff; border-radius: 6px; cursor: pointer; color: var(--ink); white-space: nowrap; }
.btn:hover { background: #f0f3f8; }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.primary:hover { background: #184c9a; }
.btn.danger { color: var(--danger); border-color: #e7b3ad; }
.btn.sm { padding: 3px 8px; font-size: 12px; }
.btn.wide { width: 100%; margin-top: 8px; }
.btn:disabled { opacity: .5; cursor: default; }
input, select, textarea { font: inherit; font-size: 13px; padding: 5px 7px; border: 1px solid var(--line); border-radius: 5px; background: #fff; }
input:focus, select:focus, textarea:focus { outline: 2px solid #bcd1f3; border-color: var(--accent); }
.search { min-width: 260px; }
.tabs { display: flex; gap: 2px; margin-bottom: 8px; border-bottom: 1px solid var(--line); }
.tabs button { background: none; border: none; padding: 7px 12px; font: inherit; cursor: pointer; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs button.on { color: var(--ink); border-bottom-color: var(--accent); font-weight: 600; }
.tabs .cnt { display: inline-block; min-width: 18px; padding: 0 5px; margin-left: 4px; border-radius: 9px; background: #e4e8f0; font-size: 11px; }
#grid { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; }
.tabulator { font-size: 13px; border: none; }
.tabulator .tabulator-header { background: #f1f3f7; border-bottom: 1px solid var(--line); }
.tabulator .tabulator-header .tabulator-col { background: #f1f3f7; border-right: 1px solid #e6e8ee; }
.tabulator-row { border-bottom: 1px solid #eef0f4; }
.tabulator-row.tabulator-row-even { background: #fafbfc; }
.tabulator-row.tabulator-selected { background: #e6efff !important; }
.tabulator-row .tabulator-cell { border-right: 1px solid #f0f0f0; padding: 5px 7px; }
.tabulator .tabulator-header .tabulator-col .tabulator-header-filter input { font-size: 12px; padding: 3px 5px; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.tag { display: inline-block; padding: 1px 7px; border-radius: 10px; font-size: 11.5px; background: #e9ecf2; color: #333; }
.tag.sent { background: #dcefdf; color: #1e6a34; } .tag.pending { background: #fdebcf; color: #8a5a08; } .tag.draft { background: #e9ecf2; }
.tag.paid { background: #dcefdf; color: #1e6a34; } .tag.unpaid { background: #f2f2f2; } .tag.partial { background: #fdebcf; color: #8a5a08; } .tag.overdue { background: #f8d7d3; color: #922b21; }
.tag.co { background: #e3eaf7; color: #1f3f7a; }
.statusbar { display: flex; gap: 12px; align-items: center; font-size: 12.5px; color: var(--muted); margin-top: 6px; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { background: #e3eaf7; color: #1f3f7a; border-radius: 12px; padding: 2px 8px; font-size: 12px; cursor: pointer; }
.chip:hover { background: #cfdcf3; }
/* edit page */
.edit-wrap { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 14px; align-items: start; }
@media (max-width: 1000px) { .edit-wrap { grid-template-columns: 1fr; } }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 12px 14px; margin-bottom: 12px; }
.card h3 { margin: 0 0 8px; font-size: 13px; color: var(--muted); font-weight: 600; letter-spacing: .04em; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 8px 12px; }
.form-grid label, .stack label { display: flex; flex-direction: column; gap: 3px; font-size: 12px; color: var(--muted); }
.form-grid label input, .form-grid label select, .stack label input, .stack label select, .stack label textarea { color: var(--ink); }
.form-grid .span2 { grid-column: span 2; }
.lines-table { width: 100%; border-collapse: collapse; }
.lines-table th { font-size: 12px; color: var(--muted); font-weight: 600; text-align: left; padding: 4px 4px; border-bottom: 1px solid var(--line); }
.lines-table td { padding: 2px 3px; vertical-align: middle; }
.lines-table input, .lines-table select { width: 100%; }
.lines-table .amt { text-align: right; font-variant-numeric: tabular-nums; padding-right: 8px; white-space: nowrap; }
.lines-table tr.text-row td input { background: #f8f8f8; }
.lines-table .drag { color: #bbb; cursor: grab; width: 14px; text-align: center; }
.totals-box { margin-top: 10px; display: flex; justify-content: flex-end; }
.totals-box table { border-collapse: collapse; }
.totals-box td { padding: 3px 10px; }
.totals-box td:last-child { text-align: right; font-variant-numeric: tabular-nums; min-width: 120px; }
.totals-box tr.grand td { font-weight: 700; font-size: 15px; border-top: 1px solid var(--line); }
.brk { font-size: 12px; color: var(--muted); }
.side .status-row { display: flex; gap: 8px; align-items: center; margin: 4px 0; flex-wrap: wrap; }
.side .kv { display: grid; grid-template-columns: 90px 1fr; gap: 4px 8px; font-size: 12.5px; }
.side .kv b { color: var(--muted); font-weight: 500; }
.history { font-size: 12px; max-height: 260px; overflow: auto; }
.history div { padding: 4px 0; border-bottom: 1px dashed #eee; }
.history .t { color: var(--muted); margin-right: 6px; }
.linkbox { font-family: ui-monospace, Menlo, monospace; font-size: 11.5px; word-break: break-all; background: #f6f7f9; padding: 6px 8px; border-radius: 5px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.err { color: var(--danger); font-size: 12.5px; margin: 6px 0; }
.ok { color: var(--ok); }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: #1f2a44; color: #fff; padding: 8px 16px; border-radius: 8px; font-size: 13px; opacity: 0; pointer-events: none; transition: opacity .2s; z-index: 100; }
.toast.show { opacity: 1; }
.modal-bg { position: fixed; inset: 0; background: rgba(0,0,0,.35); display: none; align-items: center; justify-content: center; z-index: 50; }
.modal-bg.show { display: flex; }
.modal { background: #fff; border-radius: 10px; padding: 16px 18px; min-width: 360px; max-width: 92vw; max-height: 90vh; overflow: auto; box-shadow: 0 10px 40px rgba(0,0,0,.2); }
.modal h3 { margin: 0 0 10px; font-size: 15px; }
.modal .actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 12px; }
.stack { display: flex; flex-direction: column; gap: 8px; }
/* login */
.login-body { display: flex; align-items: center; justify-content: center; min-height: 100vh; background: #1f2a44; }
.login-box { background: #fff; padding: 28px 30px; border-radius: 12px; width: 340px; display: flex; flex-direction: column; gap: 10px; }
.login-box h1 { margin: 0 0 6px; font-size: 18px; text-align: center; }
.login-box label { display: flex; flex-direction: column; gap: 4px; font-size: 12.5px; color: var(--muted); }
/* share page */
.share-body { background: #eef0f4; }
.share-wrap { max-width: 860px; margin: 0 auto; padding: 18px 14px; }
.share-head { background: #fff; border-radius: 10px; padding: 16px 18px; margin-bottom: 12px; }
.share-head h1 { font-size: 17px; margin: 0 0 6px; }
.share-frame { width: 100%; height: 80vh; border: 1px solid var(--line); border-radius: 10px; background: #fff; }
.preview-pane { width: 100%; height: calc(100vh - 110px); border: 1px solid var(--line); border-radius: 8px; background: #fff; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.import-table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.import-table th, .import-table td { border-bottom: 1px solid #eee; padding: 4px 6px; text-align: left; }
.import-table tr.bad td { background: #fff3f2; }

.tag.warn { background: #f8d7d3; color: #922b21; }
.mailbox { margin-top: 10px; border-top: 1px solid #eee; padding-top: 8px; } .mailbox summary { cursor: pointer; padding: 4px 0; }
/* ファイルボックス */
.dropzone { position: fixed; inset: 60px 16px 16px; border: 3px dashed #1F3F8F; border-radius: 14px; background: rgba(31,63,143,.08); display: flex; align-items: center; justify-content: center; font-size: 22px; color: #1F3F8F; z-index: 40; pointer-events: none; }
.modal.wide { max-width: 96vw; width: 1240px; padding: 12px 14px; }
.fb-detail { display: grid; grid-template-columns: 1fr 460px; gap: 14px; min-height: 70vh; }
.fb-preview iframe { width: 100%; height: 82vh; border: 1px solid var(--line); border-radius: 8px; background: #f4f4f4; }
.fb-form { overflow: auto; max-height: 82vh; }
@media (max-width: 900px) { .fb-detail { grid-template-columns: 1fr; } .fb-preview iframe { height: 45vh; } }
.fb-form .kv { display: grid; grid-template-columns: 70px 1fr; gap: 3px 8px; }
.fb-form .kv b { color: #555; font-weight: 600; }
