:root {
  --bg: #f3f4f6;
  --surface: #ffffff;
  --text: #1c2230;
  --muted: #5d6677;
  --line: #d9dde4;
  --head: #1c2230;
  --accent: #1f5fae;
  --accent-soft: #e8f0fb;
  --accent-ink: #ffffff;
  --danger: #b42318;
  --ok: #1e7b45;
  --warn: #a15c00;
  --ext: #7a3fb0;
  --radius: 8px;
  --mode: #1f5fae;
  --side-w: 236px;
  --top-h: 52px;
  font-family: "Hiragino Sans", "Noto Sans JP", "Yu Gothic UI", Meiryo, system-ui, sans-serif;
  color: var(--text);
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); line-height: 1.6; }
a { color: var(--accent); }
code { background: #eef0f4; padding: 0 4px; border-radius: 4px; font-size: .9em; }

/* ---------- ヘッダー・サイドメニュー ---------- */
body[data-mode="machines"] { --mode: #0f766e; }
.topbar {
  position: sticky; top: 0; z-index: 30; height: var(--top-h);
  display: flex; align-items: center; gap: 12px; padding: 0 16px; background: var(--head); color: #fff;
}
.menu-btn { display: none; background: none; border: 0; color: #fff; padding: 6px; margin-left: -6px; border-radius: 6px; cursor: pointer; }
.menu-btn:hover { background: rgba(255,255,255,.1); }
.brand { color: #fff; font-weight: 700; text-decoration: none; font-size: 1.02rem; letter-spacing: .02em; display: flex; align-items: center; gap: 10px; white-space: nowrap; }
.brand-mode:not(:empty) { font-size: .8rem; font-weight: 700; padding: 2px 10px; border-radius: 999px; background: var(--mode); color: #fff; }
.userbox { margin-left: auto; display: flex; gap: 14px; align-items: center; font-size: .88rem; }
.userbox a { color: #cfd7e6; text-decoration: none; }
.userbox a:hover { color: #fff; text-decoration: underline; }
.linkbtn { background: none; border: 0; cursor: pointer; padding: 0; font: inherit; color: var(--accent); }
.linkbtn:hover { text-decoration: underline; }
body.is-login .topbar, body.is-login .side { display: none; }

.shell { display: flex; align-items: flex-start; }
.side {
  position: sticky; top: var(--top-h); flex: none; width: var(--side-w); height: calc(100vh - var(--top-h)); overflow-y: auto;
  background: var(--surface); border-right: 1px solid var(--line); padding: 14px 10px 20px; display: flex; flex-direction: column; gap: 16px;
}
.side-label { font-size: .72rem; font-weight: 700; color: var(--muted); letter-spacing: .06em; padding: 0 8px 6px; }
.mode-switch { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 4px; background: #eef0f4; padding: 4px; border-radius: 10px; }
.mode-switch a { white-space: nowrap; letter-spacing: -.02em; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 4px; border-radius: 7px; text-decoration: none; color: var(--muted); font-size: .8rem; font-weight: 700; }
.mode-switch a:hover { color: var(--text); }
.mode-switch a.on { background: var(--surface); color: var(--mode); box-shadow: 0 1px 3px rgba(0,0,0,.12); }
.side-nav a, .side-nav button {
  display: flex; align-items: center; gap: 10px; width: 100%; padding: 9px 10px; border-radius: 7px; border: 0; background: none;
  color: var(--text); text-decoration: none; font: inherit; font-size: .93rem; cursor: pointer; text-align: left;
}
.side-nav a:hover, .side-nav button:hover { background: #f1f3f6; }
.side-nav a.on { background: color-mix(in srgb, var(--mode) 12%, transparent); color: var(--mode); font-weight: 700; }
.side-nav .ic { flex: none; opacity: .85; }
.side-foot { margin-top: auto; border-top: 1px solid var(--line); padding-top: 12px; }
.scrim { position: fixed; inset: 0; background: rgba(20,24,33,.4); z-index: 39; }
.ic { vertical-align: -3px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

main { flex: 1; min-width: 0; max-width: 1280px; padding: 18px 24px 40px; }
body.is-login main { max-width: none; padding: 16px; }
h1 { font-size: 1.3rem; margin: 4px 0 16px; }
h1 .h1-sub { display: block; font-size: .85rem; color: var(--muted); font-weight: 600; margin-top: 2px; }
h2 { font-size: 1rem; margin: 0 0 10px; }
.page-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 16px; margin-bottom: 14px; }
.page-head h1 { margin: 0; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.card.narrow { max-width: 460px; }
.sec { margin-bottom: 14px; }
.sec > h2 { padding-bottom: 8px; border-bottom: 2px solid var(--accent-soft); }
.muted { color: var(--muted); font-size: .9rem; }
.small { font-size: .8rem; }
.note { background: #f6effc; border-left: 3px solid var(--ext); padding: 8px 12px; margin: 0 0 12px; font-size: .9rem; }

/* ---------- 機能の選択 ---------- */
.home { max-width: 920px; margin: 10px auto; }
.home h1 { font-size: 1.35rem; margin-bottom: 18px; }
.home-cards { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 14px; }
.home-card {
  --c: #1f5fae; display: flex; gap: 16px; padding: 22px; border-radius: 12px; background: var(--surface); border: 1px solid var(--line);
  border-top: 5px solid var(--c); color: var(--text); text-decoration: none; transition: box-shadow .15s, transform .15s;
}
.home-card.machine { --c: #0f766e; }
.home-card:hover { box-shadow: 0 8px 24px rgba(20,30,50,.12); transform: translateY(-2px); }
.hc-icon { flex: none; width: 60px; height: 60px; border-radius: 14px; display: grid; place-items: center; color: var(--c); background: color-mix(in srgb, var(--c) 10%, #fff); }
.hc-title { font-size: 1.2rem; font-weight: 700; color: var(--c); }
.home-card p { margin: 4px 0 12px; color: var(--muted); font-size: .9rem; }
.hc-stats { display: flex; flex-wrap: wrap; gap: 8px; }
.hs { display: flex; flex-direction: column; min-width: 76px; padding: 6px 10px; border-radius: 8px; background: #f3f4f6; font-size: .75rem; color: var(--muted); }
.hs strong { font-size: 1.25rem; color: var(--text); font-variant-numeric: tabular-nums; }
.hs.bad strong { color: var(--danger); }
.hs.warn strong { color: var(--ext); }

/* ---------- フォーム ---------- */
label { display: block; font-size: .88rem; font-weight: 600; margin-bottom: 4px; }
input, select, textarea {
  width: 100%; padding: 9px 10px; font: inherit; font-size: 16px;
  border: 1px solid var(--line); border-radius: 6px; background: #fff; color: var(--text);
}
input[readonly] { background: #f3f4f6; color: var(--muted); }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 0; border-color: var(--accent); }
textarea { min-height: 90px; resize: vertical; }
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 14px 16px; }
.full { grid-column: 1 / -1; }
.fld { margin-bottom: 12px; }
.grid .fld { margin-bottom: 0; }
.fld.dim label { color: var(--muted); }
.req::after { content: " *"; color: var(--danger); }
.hint { font-size: .78rem; color: var(--muted); margin-top: 3px; }
.chk { display: flex; gap: 8px; align-items: center; font-weight: 400; margin: 8px 0; }
.chk input { width: auto; }
.pw { display: flex; gap: 6px; }
.pw input { flex: 1; }
.pw-toggle { flex: none; border: 1px solid var(--line); background: #fff; border-radius: 6px; padding: 0 12px; font: inherit; font-size: .85rem; cursor: pointer; color: var(--muted); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 9px 16px; border-radius: 6px; border: 1px solid var(--line);
  background: #fff; color: var(--text); font: inherit; font-weight: 600; cursor: pointer;
  text-decoration: none; min-height: 42px;
}
.btn:hover { border-color: #b7bfcc; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { background: #194f92; }
.btn.danger { color: var(--danger); border-color: #e7b9b5; }
.btn.danger-fill { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.sm { min-height: 32px; padding: 4px 10px; font-size: .82rem; }
.btn.wide { width: 100%; }
.btn:disabled { opacity: .5; cursor: default; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
.actions.tight { margin-top: 0; }
.actions.sticky { position: sticky; bottom: 0; background: var(--bg); padding: 10px 0; border-top: 1px solid var(--line); }
.error { color: var(--danger); font-size: .9rem; margin: 8px 0; min-height: 1em; }
.info { color: var(--ok); font-size: .9rem; margin: 8px 0; }

/* ---------- 一覧 ---------- */
.cat-tabs { display: flex; flex-wrap: wrap; gap: 4px; margin: 0 0 12px; border-bottom: 2px solid var(--line); }
.cat-tabs button {
  border: 0; background: none; font: inherit; font-weight: 600; color: var(--muted); cursor: pointer;
  padding: 8px 14px; margin-bottom: -2px; border-bottom: 3px solid transparent;
}
.cat-tabs button:hover { color: var(--text); }
.cat-tabs button.on { color: var(--accent); border-bottom-color: var(--accent); }
.cat-tabs .n { font-size: .75rem; font-weight: 600; margin-left: 6px; background: #e6e9ee; color: var(--muted); border-radius: 999px; padding: 0 7px; }
.cat-tabs button.on .n { background: var(--accent-soft); color: var(--accent); }
.filters { display: grid; grid-template-columns: 2fr 1fr 1fr 1fr; gap: 10px; margin-bottom: 10px; }
.adv { margin: 0 0 12px; }
.adv summary { cursor: pointer; color: var(--accent); font-size: .9rem; margin-bottom: 8px; }
.adv-grid { grid-template-columns: repeat(4, 1fr); }
.summary { display: flex; flex-wrap: wrap; gap: 6px 14px; margin: 0 0 10px; font-size: .9rem; color: var(--muted); }
table.list { width: 100%; border-collapse: collapse; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
table.list th, table.list td { padding: 9px 10px; text-align: left; border-bottom: 1px solid var(--line); font-size: .92rem; vertical-align: top; }
table.list th { background: #eef0f4; font-size: .8rem; color: var(--muted); white-space: nowrap; }
table.list tbody tr { cursor: pointer; }
table.list tbody tr:hover { background: #f3f7fd; }
table.users tbody tr { cursor: default; }
table.users td.ops { display: flex; flex-wrap: wrap; gap: 4px; }
.sub { font-size: .8rem; color: var(--muted); }
.id { font-family: ui-monospace, Menlo, Consolas, monospace; font-weight: 700; white-space: nowrap; }

.badge { display: inline-block; padding: 0 8px; border-radius: 999px; font-size: .78rem; font-weight: 600; border: 1px solid currentColor; white-space: nowrap; line-height: 1.6; }
.st-使用可 { color: var(--ok); }
.st-使用中 { color: var(--accent); }
.st-修理中 { color: var(--warn); }
.st-休止 { color: var(--muted); }
.st-廃棄 { color: var(--danger); }
.st-稼働中 { color: var(--accent); }
.st-待機 { color: var(--ok); }
.st-故障停止 { color: #fff; background: var(--danger); border-color: var(--danger); }
.badge.due-over { color: #fff; background: var(--danger); border-color: var(--danger); }
.badge.due-soon { color: var(--warn); background: #fff6e5; }
.badge.mt { color: var(--head); border-color: #c4cad4; background: #f3f4f6; }
.res { font-size: .82rem; font-weight: 600; white-space: nowrap; }
.res-異常なし, .res-完了 { color: var(--ok); }
.res-要観察 { color: var(--warn); }
.res-要修理 { color: var(--danger); }
.badge.ext { color: #fff; background: var(--ext); border-color: var(--ext); }
.badge.int { color: var(--muted); }
.badge.adm { color: #fff; background: var(--head); border-color: var(--head); }
.cat { font-size: .8rem; color: var(--muted); }

/* ---------- 詳細 ---------- */
.detail { display: grid; grid-template-columns: 1fr 300px; gap: 14px; align-items: start; }
.detail-side { display: flex; flex-direction: column; gap: 14px; }
dl.props { display: grid; grid-template-columns: 11em 1fr; margin: 0; }
dl.props dt, dl.props dd { padding: 7px 0; border-bottom: 1px solid #eceef2; margin: 0; }
dl.props dt { color: var(--muted); font-size: .88rem; }
dl.props dd { white-space: pre-wrap; word-break: break-word; }
.qrbox { text-align: center; }
.qrbox svg { width: 100%; max-width: 180px; height: auto; }
.quick h2 { font-size: .95rem; }
.quick p { margin: 0 0 10px; font-size: .9rem; }
.tbl-scroll { overflow-x: auto; }
.sec-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 6px 12px; padding-bottom: 8px; border-bottom: 2px solid var(--accent-soft); margin-bottom: 10px; }
.sec-head h2 { margin: 0; }
.stack { display: flex; flex-direction: column; gap: 8px; }
.btn.warn { color: var(--danger); border-color: #e7b9b5; }
.alert { background: #fdecea; border: 1px solid #f1b8b2; color: var(--danger); border-radius: var(--radius); padding: 10px 14px; margin: 0 0 14px; font-weight: 600; }
table.hist td.pre { white-space: pre-wrap; word-break: break-word; min-width: 12em; }
table.hist td.num { text-align: right; white-space: nowrap; }
table.hist td.ops { white-space: nowrap; text-align: right; }
table.hist td.ops .btn + .btn { margin-left: 4px; }
table.hist tr.open td { background: #fff5f4; }
table.hist.link tbody tr { cursor: pointer; }
table.hist.link tbody tr:hover td { background: #f3f7fd; }
.nowrap { white-space: nowrap; }
.inline-sel { width: auto; padding: 4px 8px; font-size: .9rem; }

/* ---------- 保全 ---------- */
.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-bottom: 14px; }
.kpi { display: block; background: var(--surface); border: 1px solid var(--line); border-left: 4px solid var(--line); border-radius: var(--radius); padding: 10px 14px; color: var(--text); text-decoration: none; }
a.kpi:hover { border-color: #b7bfcc; }
.kpi .kl { font-size: .8rem; color: var(--muted); font-weight: 600; }
.kpi .kv { font-size: 1.7rem; font-weight: 700; line-height: 1.3; font-variant-numeric: tabular-nums; }
.kpi .kv small { font-size: .85rem; font-weight: 600; margin-left: 3px; color: var(--muted); }
.kpi .ks { font-size: .8rem; color: var(--muted); }
.kpi.bad { border-left-color: var(--danger); }
.kpi.bad .kv { color: var(--danger); }
.kpi.warn { border-left-color: var(--warn); }
.kpi.warn .kv { color: var(--warn); }
table.hist { width: 100%; min-width: 560px; border-collapse: collapse; font-size: .88rem; }
table.hist th, table.hist td { text-align: left; padding: 7px 8px; border-bottom: 1px solid #eceef2; vertical-align: top; }
table.hist th { color: var(--muted); font-size: .8rem; font-weight: 600; }

/* ---------- ダイアログ ---------- */
dialog.modal { border: 0; border-radius: 10px; padding: 20px; width: min(460px, calc(100% - 32px)); box-shadow: 0 12px 40px rgba(0,0,0,.25); }
dialog.modal.wide { width: min(680px, calc(100% - 24px)); max-height: calc(100vh - 24px); }
dialog.modal .grid.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 14px; }
dialog.modal textarea { min-height: 70px; }
dialog.modal textarea.short { min-height: 54px; }
dialog.modal::backdrop { background: rgba(20,24,33,.45); }
dialog.modal h2 { font-size: 1.1rem; margin-bottom: 14px; }
.pwshow { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 1.6rem; letter-spacing: .08em; text-align: center; background: #f3f4f6; border-radius: 8px; padding: 10px; margin: 10px 0; user-select: all; }

/* ---------- ログイン ---------- */
body.is-login { background: linear-gradient(160deg, #1c2230 0%, #2b3550 45%, #f3f4f6 45.1%); min-height: 100vh; }
.login-wrap { max-width: 400px; margin: 0 auto; padding: 48px 0 24px; }
.login-brand { text-align: center; color: #fff; margin-bottom: 22px; }
.login-mark { display: inline-flex; color: #9fc0ef; margin-bottom: 6px; }
.login-title { font-size: 1.5rem; font-weight: 700; letter-spacing: .06em; }
.login-sub { font-size: .8rem; color: #b8c3d8; letter-spacing: .12em; }
.login { padding: 26px 24px; box-shadow: 0 10px 30px rgba(0,0,0,.15); }
.login h1 { font-size: 1.15rem; margin-top: 0; }
.login-foot { text-align: center; font-size: .82rem; color: var(--muted); margin-top: 16px; }
.login-demo { background: #fff8e1; border: 1px solid #ecd9a0; border-radius: 8px; padding: 10px 14px; font-size: .85rem; line-height: 1.8; }

/* ---------- ラベル ---------- */
.labels-tools { display: flex; flex-wrap: wrap; gap: 10px; align-items: end; margin-bottom: 12px; }
.labels-tools > div { min-width: 160px; }
.pick { max-height: 50vh; overflow: auto; }
.pick label { display: flex; gap: 8px; align-items: center; font-weight: 400; padding: 6px 4px; border-bottom: 1px solid var(--line); margin: 0; }
.pick input { width: auto; }
.sheet { display: grid; gap: 4mm; margin-top: 16px; }
.sheet.small { grid-template-columns: repeat(3, 1fr); }
.sheet.large { grid-template-columns: repeat(2, 1fr); }
.label {
  display: flex; gap: 3mm; align-items: center; border: 1px dashed #999; padding: 3mm;
  background: #fff; break-inside: avoid; page-break-inside: avoid;
}
.label svg { flex: none; }
.sheet.small .label svg { width: 22mm; height: 22mm; }
.sheet.large .label svg { width: 34mm; height: 34mm; }
.label .lid { font-family: ui-monospace, Menlo, Consolas, monospace; font-weight: 700; font-size: 13pt; }
.label .lname { font-size: 9pt; line-height: 1.3; word-break: break-all; }
.label .lcat { font-size: 8pt; color: #444; }

.preview-bar { background: #fff4d6; color: #5c4300; padding: 6px 16px; font-size: .85rem; border-bottom: 1px solid #e8d49a; }
.preview-bar .linkbtn { color: var(--accent); text-decoration: underline; }

.toast {
  position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); z-index: 50;
  background: var(--head); color: #fff; padding: 10px 18px; border-radius: 8px; box-shadow: 0 4px 14px rgba(0,0,0,.2);
  max-width: calc(100% - 32px);
}
.toast.err { background: var(--danger); }
.loading { padding: 40px; text-align: center; color: var(--muted); }

/* ---------- 一覧の写真・カード ---------- */
.thumb { width: 48px; height: 48px; border-radius: 6px; object-fit: cover; display: block; background: #eef0f4; }
.thumb.noimg, .mc-img.noimg, .pop-img.noimg { display: grid; place-items: center; color: #a3abb8; }
table.list td.ph, table.list th.ph { width: 60px; padding-right: 0; }
.maplink { display: inline-flex; align-items: center; gap: 3px; text-decoration: none; }
.maplink:hover { text-decoration: underline; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: #fff; }
.seg button { border: 0; background: none; font: inherit; font-size: .88rem; font-weight: 600; padding: 8px 12px; cursor: pointer; color: var(--muted); display: inline-flex; align-items: center; gap: 4px; min-height: 42px; }
.seg button + button { border-left: 1px solid var(--line); }
.seg button.on { background: var(--accent-soft); color: var(--accent); }
.more { text-align: center; margin: 14px 0; }
.mcards { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px; }
.mcard { display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; color: var(--text); text-decoration: none; }
.mcard:hover { border-color: #b7bfcc; box-shadow: 0 4px 14px rgba(20,30,50,.08); }
.mc-ph { position: relative; aspect-ratio: 4 / 3; background: #eef0f4; }
.mc-img { width: 100%; height: 100%; object-fit: cover; display: block; }
.mc-st { position: absolute; top: 6px; right: 6px; }
.mc-st .badge { background: #fff; }
.mc-st .st-故障停止 { background: var(--danger); }
.mc-body { padding: 8px 10px 10px; }
.mc-name { font-weight: 700; line-height: 1.35; }

/* ---------- 写真 ---------- */
.filebtn { position: relative; overflow: hidden; }
.filebtn input { position: absolute; inset: 0; opacity: 0; cursor: pointer; font-size: 0; }
.gal { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); gap: 8px; }
.gal button { border: 0; padding: 0; background: #eef0f4; border-radius: 6px; overflow: hidden; cursor: zoom-in; display: block; width: 100%; }
.gal img { width: 100%; height: 100%; object-fit: cover; display: block; }
.gal-main { aspect-ratio: 4 / 3; }
.gal-main:only-child { grid-column: 1 / -1; aspect-ratio: 16 / 9; }
.gal-main:only-child img { object-fit: contain; }
.gal-thumbs { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; align-content: start; }
.gal-thumbs button { aspect-ratio: 1; }
.gal-empty { display: flex; gap: 12px; align-items: center; padding: 18px; border: 2px dashed var(--line); border-radius: 8px; color: var(--muted); font-weight: 400; cursor: pointer; margin: 0; }
.gal-empty:hover { border-color: var(--accent); color: var(--accent); }
dialog.lightbox { border: 0; padding: 0; background: #111; color: #fff; width: min(1100px, 100vw); max-width: 100vw; max-height: 100vh; border-radius: 10px; }
dialog.lightbox::backdrop { background: rgba(0,0,0,.75); }
.lb-top { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 8px; padding: 10px 12px; font-size: .88rem; }
.lb-top .muted { color: #b8c0cc; }
.lb-ops { display: flex; gap: 6px; align-items: center; }
.lb-main { position: relative; display: flex; justify-content: center; background: #000; }
.lb-main img { max-width: 100%; max-height: calc(100vh - 80px); object-fit: contain; display: block; }
.lb-nav { position: absolute; top: 50%; transform: translateY(-50%); width: 44px; height: 64px; border: 0; border-radius: 8px; background: rgba(255,255,255,.15); color: #fff; font-size: 2rem; cursor: pointer; }
.lb-nav:hover { background: rgba(255,255,255,.3); }
.lb-nav.prev { left: 8px; } .lb-nav.next { right: 8px; }

/* ---------- 配置図 ---------- */
.pin {
  position: absolute; width: 22px; height: 22px; margin: -11px 0 0 -11px; border-radius: 50%; padding: 0;
  border: 2.5px solid var(--pc, var(--accent)); background: transparent; cursor: pointer;
  box-shadow: 0 0 0 1.5px rgba(255,255,255,.95), inset 0 0 0 1px rgba(255,255,255,.6);
}
.legend .pin { position: relative; display: inline-block; margin: 0 4px -5px 0; width: 16px; height: 16px; cursor: default; }
.p-run { --pc: #1f5fae; } .p-idle { --pc: #1e7b45; } .p-down { --pc: #c81e1e; } .p-fix { --pc: #c26a00; } .p-off { --pc: #7a8494; }
.pin.p-down { background: color-mix(in srgb, #c81e1e 25%, transparent); }
.pin .pl { position: absolute; left: 50%; top: 100%; transform: translate(-50%, 1px); font-size: 10px; font-weight: 700; line-height: 1.2; white-space: nowrap;
  background: rgba(255,255,255,.92); color: #1c2230; padding: 0 3px; border-radius: 3px; pointer-events: none; }
.pin.dim { opacity: .18; }
.pin.focus { z-index: 3; width: 30px; height: 30px; margin: -15px 0 0 -15px; animation: pulse 1.4s ease-out infinite; }
.pin.big { width: 30px; height: 30px; margin: -15px 0 0 -15px; animation: pulse 1.4s ease-out infinite; pointer-events: none; }
@keyframes pulse { 0% { box-shadow: 0 0 0 2px #fff, 0 0 0 2px var(--pc); } 100% { box-shadow: 0 0 0 2px #fff, 0 0 0 16px transparent; } }
@media (prefers-reduced-motion: reduce) { .pin.focus, .pin.big { animation: none; } }
.map-tabs { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 4px; margin-bottom: 12px; }
.map-tabs a { flex: none; padding: 7px 12px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); color: var(--text); text-decoration: none; font-size: .88rem; font-weight: 600; }
.map-tabs a.on { background: var(--mode); border-color: var(--mode); color: #fff; }
.map-tabs .n { font-size: .75rem; margin-left: 6px; opacity: .75; }
.placebar { display: flex; align-items: center; gap: 10px; background: #fff6e5; border: 1px solid #f0c98a; color: #6b4300; padding: 10px 14px; border-radius: var(--radius); margin-bottom: 12px; position: sticky; top: calc(var(--top-h) + 6px); z-index: 5; }
.placebar span { flex: 1; }
.placebar[hidden], .menu-btn[hidden], .side[hidden] { display: none; }
.map-layout { display: grid; grid-template-columns: minmax(0, 1fr) 280px; gap: 14px; align-items: start; }
.map-main { padding: 10px; }
.map-tools { display: flex; flex-wrap: wrap; gap: 8px 14px; align-items: center; margin-bottom: 8px; }
.map-tools input[type=search] { flex: 1; min-width: 180px; padding: 7px 10px; }
.map-tools .chk { margin: 0; font-size: .85rem; }
.zoom { display: flex; align-items: center; gap: 4px; }
.zoom span { min-width: 3.4em; text-align: center; font-size: .85rem; font-variant-numeric: tabular-nums; }
.map-view { position: relative; overflow: auto; height: min(72vh, 760px); border: 1px solid var(--line); border-radius: 6px; background: #f8f9fb; overscroll-behavior: contain; }
.map-canvas { position: relative; width: 100%; min-width: 100%; }
.map-canvas > img { width: 100%; height: 100%; display: block; user-select: none; -webkit-user-drag: none; }
.map-canvas.placing { cursor: crosshair; }
.map-canvas.placing .pin { pointer-events: none; }
.legend { display: flex; flex-wrap: wrap; gap: 4px 14px; align-items: center; font-size: .82rem; margin-top: 8px; }
.pop { position: absolute; z-index: 10; width: 280px; transform: translate(14px, -50%); background: #fff; border: 1px solid var(--line); border-radius: 10px;
  box-shadow: 0 10px 30px rgba(20,30,50,.22); padding: 10px; display: flex; gap: 10px; cursor: default; }
.pop.left { transform: translate(calc(-100% - 14px), -50%); }
.pop.up { transform: translate(14px, -85%); } .pop.left.up { transform: translate(calc(-100% - 14px), -85%); }
.pop-x { position: absolute; top: 2px; right: 4px; border: 0; background: none; font-size: 1.2rem; cursor: pointer; color: var(--muted); }
.pop-ph { flex: none; }
.pop-img { width: 84px; height: 84px; border-radius: 6px; object-fit: cover; display: block; background: #eef0f4; }
.pop-b { min-width: 0; font-size: .88rem; }
.pop-name { font-weight: 700; margin-top: 2px; }
.pop-act { display: flex; gap: 6px; margin-top: 6px; }
.map-side { padding: 12px; max-height: calc(72vh + 90px); overflow: auto; }
.map-side h2 { font-size: .95rem; }
.mlist { list-style: none; margin: 0; padding: 0; }
.mlist li { display: flex; gap: 8px; align-items: center; padding: 6px 4px; border-bottom: 1px solid #eceef2; font-size: .88rem; cursor: pointer; }
.mlist li:hover { background: #f3f7fd; }
.mlist .thumb { width: 40px; height: 40px; }
.mlist .sub { line-height: 1.35; }
#ulist li { cursor: default; justify-content: space-between; flex-wrap: wrap; }
.unplaced { margin-top: 12px; }
.unplaced summary { cursor: pointer; font-weight: 700; font-size: .9rem; }
.minimap { position: relative; height: 190px; overflow: hidden; border-radius: 6px; border: 1px solid var(--line); background: #f8f9fb; }
.minimap img { position: absolute; max-width: none; }
.locbox h2 { display: flex; align-items: center; gap: 6px; }
.locbox .locname { margin: 8px 0; }

/* ---------- 契約書 ---------- */
body[data-mode="contracts"] { --mode: #8a4b0f; }
.home-card.contract { --c: #8a4b0f; }
.home-cards { grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.badge.ct-有効 { color: var(--ok); }
.badge.ct-締結手続中 { color: var(--accent); }
.badge.ct-終了・解約 { color: var(--muted); }
.badge.ct-未確認 { color: #8a8f99; border-style: dashed; }
.badge.al-bad { color: #fff; background: var(--danger); border-color: var(--danger); }
.badge.al-warn { color: var(--warn); background: #fff6e5; }
.badge.al-info { color: var(--muted); background: #f3f4f6; }
.badge.al-ok { color: var(--ok); background: #eaf6ef; }
.alert.al-box-warn { background: #fff6e5; border-color: #f0d3a0; color: var(--warn); }
.alert.al-box-info { background: #f3f4f6; border-color: var(--line); color: var(--muted); }
.alert-link { display: block; background: #fff6e5; border: 1px solid #f0d3a0; color: var(--warn); border-radius: var(--radius); padding: 10px 14px; margin: 0 0 12px; text-decoration: none; }
.alert-link:hover { border-color: var(--warn); }
table.list.contracts td.nm .ttl { font-weight: 600; }
table.list.contracts td.nm { min-width: 16em; }
table.list.contracts td[data-k="signed"], table.list.contracts td[data-k="end"] { white-space: nowrap; font-variant-numeric: tabular-nums; }
table.list th.ck, table.list td.ck { width: 34px; padding-right: 0; }
table.list td.ck input, table.list th.ck input { width: 18px; height: 18px; cursor: pointer; }
.pdfmark { display: inline-flex; align-items: center; gap: 1px; color: var(--accent); font-size: .78rem; font-weight: 700; }
.bulkbar { position: sticky; top: calc(var(--top-h) + 6px); z-index: 5; display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; background: var(--head); color: #fff; border-radius: var(--radius); padding: 8px 12px; margin-bottom: 10px; }
.bulkbar[hidden] { display: none; }
.bulkbar .linkbtn { color: #cfe0f7; }
ul.files { list-style: none; margin: 0 0 10px; padding: 0; }
ul.files li { display: flex; align-items: center; gap: 6px; border-bottom: 1px solid #eceef2; padding: 6px 0; }
.file-open { flex: 1; min-width: 0; display: flex; align-items: flex-start; gap: 6px; background: none; border: 0; padding: 4px; text-align: left; font: inherit; cursor: pointer; color: var(--accent); border-radius: 6px; }
.file-open:hover { background: var(--accent-soft); }
.file-open strong { display: block; word-break: break-all; font-size: .88rem; }
.file-open .sub { display: block; }
.file-open .ic { flex: none; margin-top: 2px; }
.file-ops { display: flex; gap: 4px; flex: none; }
.dropzone { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; text-align: center; border: 2px dashed #b9c2d0; border-radius: var(--radius); padding: 16px; color: var(--muted); font-size: .88rem; cursor: pointer; font-weight: 400; margin: 0; }
.dropzone.big { padding: 34px 16px; font-size: 1rem; }
.dropzone:hover, .dropzone.over { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
.dropzone input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
tr.nomatch td { background: #fffaf0; }
.err-t { color: var(--danger); font-size: .82rem; }
.no-in { max-width: 12em; padding: 4px 8px; }
.inline2 { display: flex; gap: 8px; }
.inline2 input { max-width: 8em; }
.inline2 select { width: auto; }
details.share { margin-top: 6px; }
details.share summary { cursor: pointer; font-size: .85rem; color: var(--accent); }
.chks { display: flex; flex-wrap: wrap; gap: 4px 14px; margin-top: 6px; }
.chks .chk { margin: 0; font-weight: 400; }
.deprow { display: flex; gap: 6px; margin-bottom: 6px; }
.prevbox { margin-top: 10px; }
.prevbox .scroll { max-height: 32vh; overflow: auto; }
.prevbox table.hist { min-width: 0; }
dialog.modal .grid.g3 { grid-template-columns: 2fr 1fr 1fr; gap: 10px; }
ul.plain { margin: 0; padding-left: 1.2em; }
ul.plain li { margin: 4px 0; }
@media (max-width: 720px) {
  table.list.contracts tr { padding-left: 4px; min-height: 0; }
  table.list.contracts td.ck, table.list.contracts th.ck { display: none; }
  table.list.contracts td.nm { min-width: 0; padding-right: 110px; }
  table.list.contracts td.id .sub { display: inline; margin-left: 6px; }
  .bulkbar { display: none; }
  dialog.modal .grid.g3 { grid-template-columns: 1fr 1fr; }
}

/* ---------- スマホ ---------- */
@media (max-width: 1000px) {
  .menu-btn { display: inline-flex; }
  .side { position: fixed; top: var(--top-h); left: 0; bottom: 0; height: auto; z-index: 40; transform: translateX(-100%); transition: transform .2s ease; box-shadow: none; }
  body.side-open .side { transform: none; box-shadow: 8px 0 30px rgba(0,0,0,.2); }
  .map-layout { grid-template-columns: minmax(0, 1fr) 240px; }
}
@media (max-width: 860px) {
  .detail { grid-template-columns: 1fr; }
  .detail-side { order: -1; }
  .qrbox svg { max-width: 140px; }
}
@media (max-width: 720px) {
  .filters { grid-template-columns: 1fr 1fr; }
  .kpis { grid-template-columns: 1fr 1fr; }
  dialog.modal .grid.g2 { grid-template-columns: 1fr; }
  dialog.modal.wide { padding: 16px; }
  .cat-tabs { flex-wrap: nowrap; overflow-x: auto; }
  .cat-tabs button { white-space: nowrap; padding: 8px 10px; }
  .filters .search { grid-column: 1 / -1; }
  .adv-grid { grid-template-columns: 1fr 1fr; }
  table.list thead { display: none; }
  table.list, table.list tbody, table.list tr, table.list td { display: block; width: 100%; }
  table.list tr { border-bottom: 1px solid var(--line); padding: 8px 4px; position: relative; }
  table.list td { border: 0; padding: 2px 8px; }
  table.list td.id, table.list td.cat { display: inline-block; width: auto; }
  table.list td[data-k] { display: inline-block; width: auto; font-size: .82rem; color: var(--muted); padding-top: 0; }
  table.list td[data-k]:empty { display: none; }
  table.list td.st { position: absolute; top: 10px; right: 8px; width: auto; }
  table.users td.ops { display: flex; }
  dl.props { grid-template-columns: 1fr; }
  dl.props dt { border-bottom: 0; padding-bottom: 0; font-size: .78rem; }
  dl.props dd { padding-top: 0; }
  main { padding: 14px 12px 32px; }
  .home-cards { grid-template-columns: 1fr; }
  .home-card { padding: 16px; }
  .hc-icon { width: 48px; height: 48px; }
  .map-layout { grid-template-columns: 1fr; }
  .map-side { max-height: none; }
  .map-view { height: 62vh; }
  .userbox #who { max-width: 9em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  table.list td.ph { position: absolute; left: 4px; top: 10px; width: auto; padding: 0; }
  table.list.machines tr, table.list tr { padding-left: 64px; min-height: 64px; }
  body.is-login { background: linear-gradient(170deg, #1c2230 0%, #2b3550 38%, #f3f4f6 38.1%); }
  .login-wrap { padding-top: 32px; }
}

/* ---------- 印刷 ---------- */

/* ---------- 契約書の紐づけ・保管料 ---------- */
:root { --pay: #b4471f; --recv: #1e6f8a; }
a.ctlink { display: inline-flex; flex-wrap: wrap; align-items: baseline; gap: 4px; text-decoration: none; }
a.ctlink:hover { text-decoration: underline; }
a.ctlink .ic { align-self: center; flex: none; }
.ctlist { list-style: none; margin: 0; padding: 0; }
.ctlist li { display: flex; align-items: flex-start; gap: 10px; padding: 8px 0; border-bottom: 1px solid #eceef2; }
.ctlist li:last-child { border-bottom: 0; }
.ctl-main { flex: 1; min-width: 0; }
.ctl-main .sub { display: block; }
.ctl-ops { display: flex; gap: 4px; flex: none; }
.badge.ctp { color: #445; background: #eef0f4; border-color: #d9dde4; }
.badge.fee-pay { color: #fff; background: var(--pay); border-color: var(--pay); }
.badge.fee-recv { color: #fff; background: var(--recv); border-color: var(--recv); }
.ctsel { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-right: 6px; }
.ctpick { max-height: 46vh; overflow: auto; border: 1px solid var(--line); border-radius: 8px; }
.ctpick button { display: grid; grid-template-columns: 6.5em 1fr auto; gap: 8px; align-items: center; width: 100%; text-align: left; background: #fff; border: 0; border-bottom: 1px solid #eceef2; padding: 8px 10px; font: inherit; cursor: pointer; color: var(--text); }
.ctpick button:hover { background: #f3f7fd; }
.ctpick button.on { background: var(--accent-soft); box-shadow: inset 3px 0 0 var(--accent); }
.ctpick .ctp-t { min-width: 0; }
.ctpick .ctp-t strong { font-weight: 600; }
.ctpick .ctp-t .sub { display: block; }
.ctpick > p { padding: 8px 10px; margin: 0; }
.inl { display: flex; align-items: center; gap: 6px; }
.inl input[type="month"] { width: auto; }
.inl select { width: auto; }
.seg .segopt { display: inline-flex; align-items: center; gap: 6px; margin: 0; padding: 8px 12px; font-weight: 600; font-size: .88rem; cursor: pointer; color: var(--muted); }
.seg .segopt + .segopt { border-left: 1px solid var(--line); }
.seg .segopt input { width: auto; margin: 0; }
.seg .segopt:has(input:checked) { background: var(--accent-soft); color: var(--accent); }
table.fees td.num, table.fees-all td.num, table.fees-all th.num, table.fees th.num { text-align: right; white-space: nowrap; }
.kpi.pay { border-left-color: var(--pay); }
.kpi.pay .kv { color: var(--pay); }
.kpi.recv { border-left-color: var(--recv); }
.kpi.recv .kv { color: var(--recv); }
.feebars { display: grid; grid-template-columns: repeat(12, 1fr); gap: 4px; align-items: end; }
.feebars button { display: flex; flex-direction: column; align-items: center; gap: 2px; background: none; border: 1px solid transparent; border-radius: 6px; padding: 6px 2px 4px; cursor: pointer; font: inherit; color: var(--text); min-width: 0; }
.feebars button:hover { background: #f3f7fd; }
.feebars button.on { border-color: var(--accent); background: var(--accent-soft); }
.fb-bars { display: flex; align-items: flex-end; justify-content: center; gap: 2px; height: 90px; width: 100%; }
.fb { width: 38%; max-width: 14px; min-height: 0; border-radius: 3px 3px 0 0; }
.fb.pay { background: var(--pay); }
.fb.recv { background: var(--recv); }
.fb-m { font-size: .8rem; font-weight: 600; }
.fb-v { font-size: .68rem; line-height: 1.2; font-variant-numeric: tabular-nums; white-space: nowrap; }
.fb-v.pay { color: var(--pay); }
.fb-v.recv { color: var(--recv); }
.legend { font-size: .8rem; color: var(--muted); display: flex; align-items: center; gap: 6px; margin: 8px 0 0; }
.legend .lg { display: inline-block; width: 10px; height: 10px; border-radius: 2px; }
.legend .lg.pay { background: var(--pay); }
.legend .lg.recv { background: var(--recv); margin-left: 8px; }
ul.linked li { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
@media (max-width: 720px) {
  .ctlist li { flex-wrap: wrap; }
  .ctl-ops { width: 100%; justify-content: flex-end; }
  .ctpick button { grid-template-columns: 1fr auto; }
  .ctpick .ctp-no { grid-column: 1 / -1; }
  .fb-v { display: none; }
  .fb-bars { height: 70px; }
}

@media print {
  @page { size: A4; margin: 10mm; }
  body { background: #fff; }
  .no-print, .topbar, .side, .labels-tools, .pick, .print-hide, .preview-bar { display: none !important; }
  main { padding: 0; max-width: none; }
  .label { border-color: #bbb; }
}
table.fees-all { min-width: 820px; }
table.fees-all td:nth-child(3), table.fees-all td:nth-child(6), table.fees td:nth-child(5) { white-space: nowrap; }
.fb-m { white-space: nowrap; }
@media (max-width: 720px) { .fb-m { font-size: .66rem; } .feebars { gap: 1px; } }
