[hidden] { display: none !important; }
/* RMJ-Health 管理画面・共有端末 共通スタイル（明るい配色のみ） */
:root {
  --text-xs: clamp(0.75rem, 0.7rem + 0.25vw, 0.875rem);
  --text-sm: clamp(0.875rem, 0.8rem + 0.35vw, 1rem);
  --text-base: clamp(1rem, 0.95rem + 0.25vw, 1.125rem);
  --text-lg: clamp(1.125rem, 1rem + 0.75vw, 1.5rem);
  --text-xl: clamp(1.5rem, 1.2rem + 1.25vw, 2.25rem);
  --space-1: 0.25rem; --space-2: 0.5rem; --space-3: 0.75rem; --space-4: 1rem; --space-5: 1.25rem; --space-6: 1.5rem; --space-8: 2rem; --space-10: 2.5rem; --space-12: 3rem;
  --bg: #f5f6f4; --surface: #ffffff; --surface-2: #eef1ee; --border: #d9ded9; --border-strong: #b8c1b9;
  --text: #1c2420; --muted: #5a6660; --faint: #7d8882;
  --primary: #0e6b53; --primary-hover: #0a5843; --primary-soft: #e3f1ec; --on-primary: #ffffff;
  --caution: #9a5b00; --caution-soft: #fff3dc; --caution-border: #f0c773;
  --danger: #b42318; --danger-soft: #fdecea;
  --info: #1d5fa8; --info-soft: #e7f0fb;
  --radius: 10px; --radius-sm: 6px;
  --shadow: 0 1px 2px rgba(20, 30, 25, 0.06), 0 2px 8px rgba(20, 30, 25, 0.05);
  --font: "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Noto Sans JP", "Noto Sans CJK JP", "Yu Gothic UI", "Meiryo", system-ui, sans-serif;
  --mono: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
}
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font-family: var(--font); font-size: var(--text-base); line-height: 1.6; color: var(--text); background: var(--bg); }
h1, h2, h3 { line-height: 1.3; margin: 0; }
h1 { font-size: var(--text-lg); font-weight: 700; }
h2 { font-size: var(--text-lg); font-weight: 700; }
h3 { font-size: var(--text-base); font-weight: 700; }
p { margin: 0; }
a { color: var(--primary); }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid color-mix(in srgb, var(--primary) 55%, transparent); outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2); min-height: 40px; padding: var(--space-2) var(--space-4); border-radius: var(--radius-sm); border: 1px solid var(--border-strong); background: var(--surface); font-size: var(--text-sm); font-weight: 600; cursor: pointer; white-space: nowrap; transition: background 0.15s, border-color 0.15s; }
.btn:hover { background: var(--surface-2); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
.btn.primary:hover { background: var(--primary-hover); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.small { min-height: 32px; padding: var(--space-1) var(--space-3); font-size: var(--text-xs); }
.btn.danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 45%, white); }

/* form */
label.field { display: grid; gap: var(--space-1); font-size: var(--text-sm); color: var(--muted); }
label.field > span { font-weight: 600; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=date], input[type=month], select, textarea {
  width: 100%; min-height: 40px; padding: var(--space-2) var(--space-3); border: 1px solid var(--border-strong); border-radius: var(--radius-sm); background: var(--surface); color: var(--text); font-size: var(--text-sm); }
input[type=number] { font-variant-numeric: tabular-nums; }
label.check { display: flex; gap: var(--space-2); align-items: flex-start; font-size: var(--text-sm); color: var(--text); cursor: pointer; }
label.check input { width: 18px; height: 18px; margin-top: 3px; accent-color: var(--primary); flex: none; }
.form-grid { display: grid; gap: var(--space-4); grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }

/* layout */
.topbar { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: var(--space-4); padding: var(--space-3) var(--space-6); background: var(--surface); border-bottom: 1px solid var(--border); }
.brand { display: flex; align-items: center; gap: var(--space-2); font-weight: 700; font-size: var(--text-base); color: var(--text); text-decoration: none; white-space: nowrap; }
.brand svg { flex: none; }
.topbar .spacer { flex: 1; }
.who { font-size: var(--text-xs); color: var(--muted); text-align: right; line-height: 1.4; }
.tabs { display: flex; gap: var(--space-1); overflow-x: auto; padding: 0 var(--space-6); background: var(--surface); border-bottom: 1px solid var(--border); scrollbar-width: thin; }
.tabs button { flex: none; padding: var(--space-3) var(--space-4); border: 0; border-bottom: 3px solid transparent; background: none; font-size: var(--text-sm); font-weight: 600; color: var(--muted); cursor: pointer; }
.tabs button[aria-selected=true] { color: var(--primary); border-bottom-color: var(--primary); }
main { max-width: 1240px; margin: 0 auto; padding: var(--space-6); display: grid; gap: var(--space-6); }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: var(--space-5); min-width: 0; }
.card > header { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-3); margin-bottom: var(--space-4); }
.card > header .spacer { flex: 1; }
.toolbar { display: flex; flex-wrap: wrap; gap: var(--space-3); align-items: end; }
.toolbar label.field { min-width: 180px; }
.muted { color: var(--muted); }
.small { font-size: var(--text-xs); }
.stack { display: grid; gap: var(--space-3); }
.row { display: flex; flex-wrap: wrap; gap: var(--space-3); align-items: center; }

/* notes */
.note { padding: var(--space-3) var(--space-4); border-radius: var(--radius-sm); font-size: var(--text-sm); background: var(--info-soft); color: #173f6d; border: 1px solid #c6d9f0; }
.note.caution { background: var(--caution-soft); color: #6a4000; border-color: var(--caution-border); }
.note.danger { background: var(--danger-soft); color: #7a1a12; border-color: #f2b8b2; }
.demo-banner { padding: var(--space-2) var(--space-6); background: #fff7d6; border-bottom: 1px solid #ecd98a; color: #5c4a00; font-size: var(--text-xs); }

/* kpis */
.kpis { display: grid; gap: var(--space-3); grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.kpi { padding: var(--space-3) var(--space-4); border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); }
.kpi b { display: block; font-size: var(--text-lg); font-variant-numeric: tabular-nums; }
.kpi span { font-size: var(--text-xs); color: var(--muted); }
.kpi.caution { background: var(--caution-soft); border-color: var(--caution-border); }

/* tables */
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius-sm); }
table { width: 100%; border-collapse: collapse; font-size: var(--text-sm); }
th, td { padding: var(--space-2) var(--space-3); border-bottom: 1px solid var(--border); text-align: left; vertical-align: middle; }
th { background: var(--surface-2); font-weight: 600; color: var(--muted); font-size: var(--text-xs); white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
td input[type=number] { min-height: 32px; padding: var(--space-1) var(--space-2); width: 5.5em; text-align: right; }
tr.weekend td { background: #fafbfa; }
tr.caution td { background: #fffaf0; }

/* badges */
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 1px var(--space-2); border-radius: 999px; font-size: var(--text-xs); font-weight: 600; white-space: nowrap; border: 1px solid transparent; }
.badge.ok { background: var(--primary-soft); color: var(--primary); }
.badge.caution { background: var(--caution-soft); color: var(--caution); border-color: var(--caution-border); }
.badge.none { background: var(--surface-2); color: var(--muted); }
.badge.info { background: var(--info-soft); color: var(--info); }
.badge.danger { background: var(--danger-soft); color: var(--danger); }
.badge.draft { background: #f1ecfb; color: #5b3a9e; }

/* bars */
.bar { position: relative; height: 10px; border-radius: 999px; background: var(--surface-2); overflow: hidden; }
.bar > i { position: absolute; inset: 0 auto 0 0; background: var(--primary); }
.bar > i.draft { background: #a58ad8; }

/* dialog */
dialog { border: 0; border-radius: var(--radius); padding: 0; width: min(560px, calc(100vw - 2rem)); box-shadow: 0 10px 40px rgba(0,0,0,.2); }
dialog::backdrop { background: rgba(20, 30, 25, 0.35); }
dialog .dlg { padding: var(--space-5); display: grid; gap: var(--space-4); }
dialog .actions { display: flex; justify-content: flex-end; gap: var(--space-2); }

/* toast */
#toast { position: fixed; left: 50%; bottom: var(--space-6); transform: translateX(-50%); z-index: 50; display: grid; gap: var(--space-2); }
#toast div { padding: var(--space-3) var(--space-5); background: #1c2420; color: #fff; border-radius: var(--radius-sm); font-size: var(--text-sm); box-shadow: var(--shadow); max-width: min(90vw, 560px); }
#toast div.err { background: var(--danger); }

.empty { padding: var(--space-8); text-align: center; color: var(--muted); font-size: var(--text-sm); }
.loading { color: var(--muted); font-size: var(--text-sm); padding: var(--space-4); }

@media (max-width: 640px) {
  .topbar, .tabs { padding-inline: var(--space-4); }
  main { padding: var(--space-4); gap: var(--space-4); }
  .card { padding: var(--space-4); }
  .who { display: none; }
}
a.btn { text-decoration: none; color: inherit; }
a.btn.primary { color: var(--on-primary); }
.table-wrap table { min-width: 640px; }
td:first-child { min-width: 9em; }
@media (max-width: 640px) {
  .topbar { gap: var(--space-2); }
  .topbar .btn.small { padding-inline: var(--space-2); }
  .brand span { font-size: var(--text-sm); }
}

/* 在留カード */
.idc-format { border: 1px solid var(--border); border-radius: var(--radius); padding: var(--space-3) var(--space-4); margin-bottom: var(--space-4); display: grid; gap: var(--space-2); }
.idc-format legend { font-weight: 700; padding: 0 var(--space-2); }
.idc-grid { display: grid; grid-template-columns: minmax(260px, 420px) 1fr; gap: var(--space-5); align-items: start; }
@media (max-width: 820px) { .idc-grid { grid-template-columns: 1fr; } }
.idc-images { display: grid; gap: var(--space-4); position: sticky; top: var(--space-4); }
.idc-img { display: grid; gap: var(--space-2); }
.idc-prev { aspect-ratio: 85.6 / 54; background: var(--surface-2); border: 1px dashed var(--border); border-radius: 10px; display: grid; place-items: center; overflow: hidden; }
.idc-prev img { width: 100%; height: 100%; object-fit: contain; background: #fff; }
.idc-form { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: var(--space-3) var(--space-4); }
.idc-form h2 { grid-column: 1 / -1; margin-top: var(--space-2); color: var(--muted); }
.idc-form .field[data-f=address], .idc-form .field[data-f=name_on_card], .idc-form .field[data-f=permit_type], .idc-form .field[data-f=address_updates], .idc-form .field[data-f=extra_activity] { grid-column: 1 / -1; }
.idc-form .ic-only { opacity: .75; }
.fmsg:empty { display: none; }
.fmsg.error { color: var(--danger); font-weight: 600; }
.fmsg.warn { color: var(--caution); }
.idc-checks { margin-top: var(--space-4); border-top: 1px solid var(--border); padding-top: var(--space-3); }
.idc-checks ul { list-style: none; padding: 0; margin: var(--space-2) 0 0; display: grid; gap: 6px; font-size: var(--text-sm); }

.idc-ocr { display: grid; gap: var(--space-1); margin: var(--space-2) 0; }
.field.ocr-high input, .field.ocr-high select { background: #eef7f1; border-color: #6aa884; }
.field.ocr-low input, .field.ocr-low select { background: #fff6e0; border-color: #c9962b; }
.ocr-tag { display: block; font-size: .78rem; font-weight: 600; color: #2e6b47; }
.field.ocr-low .ocr-tag { color: #8a5a00; }

/* 法人 → 現場 */
.company-group { border-left: 3px solid var(--primary, #1f6feb); padding-left: var(--space-4); }
.company-head { display: flex; align-items: center; gap: var(--space-3); flex-wrap: wrap; }
.company-title { display: flex; align-items: baseline; gap: var(--space-2); }
.company-title > .small { white-space: nowrap; flex: none; }
.company-title b, .company-title input { font-size: var(--text-lg, 1.125rem); font-weight: 700; }
.company-title input { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 4px 8px; min-width: 16em; background: var(--surface, #fff); color: inherit; }
.add-site > summary { list-style: none; display: inline-flex; cursor: pointer; }
.add-site > summary::-webkit-details-marker { display: none; }
.add-site[open] > summary { margin-bottom: var(--space-3); }

/* 日付・月・時刻：日本の並び（西暦/月/日、24時間）の文字欄＋カレンダー。元の date/month/time 欄は隠して値だけ持つ */
.jpd { position: relative; display: flex; gap: var(--space-2); align-items: center; min-width: 0; }
.jpd .jpd-text { flex: 1 1 auto; min-width: 7.5em; font-variant-numeric: tabular-nums; }
.jpd .jpd-pick { flex: none; }
.jpd input.jpd-native { position: absolute; left: 0; bottom: 0; width: 1px; height: 1px; min-height: 0; padding: 0; border: 0; opacity: 0; pointer-events: none; }
