:root {
  --fs-caption: 0.875rem;
  --fs-label: 0.9375rem;
  --fs-body: 1.0625rem;
  --fs-md: 1.1875rem;
  --fs-name: clamp(1.375rem, 1.15rem + 1vw, 1.625rem);
  --ink: #14201d;
  --muted: #545a57;
  --paper: #f4f4f1;
  --surface: #fff;
  --line: #e2e2db;
  --line-strong: #8c8c82;
  --risk: #a00000;
  --risk-bg: #fdeaea;
  --risk-line: #f7a8a8;
  --watch-bg: #fff2e0;
  --watch-line: #ffc073;
  --watch-t: #a85400;
  --ok: #00663a;
  --ok-bg: #e4f4ea;
  --ok-line: #8fd0ad;
  --risk-bg: #fdeaea;
  --risk-line: #f7a8a8;
  --sel: #14201d;
  --fs-metric: clamp(1.75rem, 1.45rem + 1.4vw, 2.125rem);
  --focus: #14201d;
  --accent: #0b5fa5;
  --r: 10px;
  --r-lg: 16px;
  --tap: 48px;
  --pad: clamp(14px, 3.5vw, 22px);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: system-ui, -apple-system, "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Noto Sans JP", "Yu Gothic UI", sans-serif;
  font-size: var(--fs-body);
  line-height: 1.6;
}

:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }

.login { min-height: 90vh; display: flex; align-items: center; justify-content: center; padding: 20px; }
.login-card { width: 100%; max-width: 420px; background: var(--surface); border-radius: var(--r-lg); padding: 32px 26px; box-shadow: 0 12px 28px rgba(20, 32, 29, .08); }
.login-title { font-size: var(--fs-md); font-weight: 700; }
.login-caption { margin-bottom: 24px; }
.step-title { font-weight: 700; margin-bottom: 6px; }

.cap { font-size: var(--fs-caption); color: var(--muted); }
.lbl { display: block; font-size: var(--fs-label); font-weight: 700; color: var(--muted); margin-bottom: 8px; letter-spacing: .02em; }
.hint { font-size: var(--fs-caption); color: var(--muted); line-height: 1.6; margin: 0 0 12px; }
.hint:last-child { margin: 12px 0 0; }

.field {
  display: block; width: 100%; min-height: var(--tap); margin-bottom: 12px; padding: 10px 14px;
  border: 1.5px solid var(--line-strong); border-radius: var(--r); background: var(--surface); color: var(--ink); font: inherit;
}

.error { color: var(--risk); font-size: var(--fs-label); font-weight: 700; margin: 7px 0 0; }
.notice { color: var(--ink); font-size: var(--fs-label); margin: 7px 0 0; }

.btn {
  min-height: var(--tap); padding: 12px 20px; border-radius: var(--r); border: 2px solid var(--line-strong);
  background: var(--surface); color: var(--ink); font: inherit; font-weight: 700; cursor: pointer;
}
.btn:hover { border-color: var(--muted); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-primary { background: var(--ink); color: #fff; border-color: var(--ink); }
.btn-ghost { border-color: transparent; background: transparent; }
.btn-block { display: block; width: 100%; margin-top: 16px; }
form + form .btn-block { margin-top: 8px; }

.btn-sm { min-height: 44px; padding: 9px 14px; font-size: var(--fs-label); border-radius: 8px; border-width: 1.5px; }
a.btn { display: inline-flex; align-items: center; justify-content: center; text-decoration: none; }

.shell { width: 100%; max-width: 1000px; margin: 0 auto; padding-inline: var(--pad); }
.appbar { background: var(--surface); border-bottom: 1px solid var(--line); }
.appbar .in { display: flex; align-items: center; gap: 8px; min-height: 60px; }
.appbar h1 {
  margin: 0; font-size: var(--fs-md); font-weight: 700; letter-spacing: -.01em; flex: 1;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.appbar .sub { font-size: var(--fs-caption); color: var(--muted); font-weight: 400; margin-left: 10px; }
.appbar-actions { display: flex; gap: 8px; margin-left: auto; }
.appbar-actions .btn { border-color: transparent; background: transparent; padding: 8px 12px; border-radius: 8px; color: var(--ink); min-width: 120px; }
.appbar-actions .btn:hover { background: var(--paper); border-color: transparent; }
@media (max-width: 1024px) { .appbar .sub { display: none; } }
@media (max-width: 480px) { .appbar h1 { font-size: var(--fs-body); } }

.maint-band { background: var(--paper); border-bottom: 1px solid var(--line-strong); }
.maint-band .in { display: flex; align-items: center; gap: 12px; min-height: 48px; font-size: var(--fs-label); }
.maint-band form { margin-left: auto; }
.idle-warn {
  position: fixed; left: 16px; right: 16px; bottom: 16px; z-index: 150; max-width: 520px; margin: 0 auto;
  border: 1.5px solid var(--watch-line); border-radius: var(--r); padding: 14px 16px; line-height: 1.7; font-size: var(--fs-label);
  background: var(--watch-bg); color: var(--watch-t); box-shadow: 0 12px 28px rgba(20, 32, 29, .16);
}
.idle-warn b { display: block; margin-bottom: 4px; font-size: var(--fs-body); }
.idle-warn .btn { margin-top: 10px; }

.page { max-width: 1000px; margin: 0 auto; padding: 24px 20px; }
.page-title { font-size: var(--fs-md); margin: 0 0 24px; }
.sec { margin-bottom: 30px; }
.sec-h { font-size: var(--fs-body); font-weight: 700; margin: 0 0 6px; }
.sum-list { display: grid; grid-template-columns: minmax(8em, auto) 1fr; margin: 10px 0 0; }
.sum-list dt, .sum-list dd { margin: 0; padding: 8px 0; border-bottom: 1px solid var(--line); }
.sum-list dt { color: var(--muted); font-size: var(--fs-label); }

.sticky { position: sticky; top: 0; z-index: 60; background: var(--paper); border-bottom: 1px solid var(--line); box-shadow: 0 1px 0 rgba(0, 0, 0, .02); }
.plate {
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 14px 16px; margin: 12px 0 10px;
}
.avatar {
  width: 54px; height: 54px; border-radius: 50%; flex-shrink: 0; color: #fff;
  display: flex; align-items: center; justify-content: center; font-size: var(--fs-md); font-weight: 700;
}
.pl-main { flex: 1 1 240px; min-width: 0; }
.pl-top { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.pl-name { font-size: var(--fs-name); font-weight: 700; letter-spacing: -.015em; line-height: 1.3; }
.pl-ids { font-size: var(--fs-label); color: var(--muted); margin-top: 4px; line-height: 1.6; }
.pl-ids .sep { color: var(--line-strong); margin: 0 7px; }
.plate-actions { display: flex; align-items: center; gap: 8px; flex-shrink: 0; flex-wrap: wrap; }
.plate-actions .btn { min-height: 44px; padding: 9px 16px; font-size: var(--fs-label); border-radius: var(--r); border-width: 2px; }
.switch { display: inline-flex; align-items: center; text-decoration: none; }
.switch {
  flex: 0 0 auto; min-height: 44px; padding: 9px 16px; border: 2px solid var(--ink); border-radius: var(--r);
  background: var(--surface); color: var(--ink); font-weight: 700; cursor: pointer; gap: 9px;
}
.switch:hover { background: var(--ink); color: #fff; }
@media (max-width: 768px) {
  .plate { gap: 10px; }
  .plate-actions { flex: 1 1 100%; display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
  .plate-actions .btn, .plate-actions .switch { width: 100%; min-width: 0; justify-content: center; font-size: var(--fs-label); white-space: nowrap; }
}

.hue-0 { background: #5b6b8c; }
.hue-1 { background: #6d7a58; }
.hue-2 { background: #8c6a5b; }
.hue-3 { background: #6b5b8c; }
.hue-4 { background: #4f7a78; }
.hue-5 { background: #8c7a4f; }
.hue-6 { background: #7a5b6b; }
.hue-7 { background: #5b7a8c; }

.navwrap { position: relative; }
.nav { display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none; }
.nav::-webkit-scrollbar { display: none; }
.nav a {
  flex: 1 0 auto; min-height: var(--tap); padding: 10px 18px; border-bottom: 3px solid transparent;
  color: var(--muted); font-weight: 700; white-space: nowrap; text-decoration: none;
  display: flex; align-items: center; justify-content: center;
}
.nav a:hover { color: var(--ink); }
.nav a[aria-current="page"] { color: var(--ink); border-bottom-color: var(--ink); }
@media (max-width: 480px) { .nav a { padding: 10px 8px; font-size: var(--fs-label); flex: 1 1 0; min-width: 0; } .nav { gap: 0; } }

.overlay { position: fixed; inset: 0; z-index: 100; display: flex; align-items: center; justify-content: center; padding: 24px; }
.overlay-close { position: absolute; inset: 0; background: rgba(20, 32, 29, .45); }
@media (max-width: 480px) { .overlay { align-items: flex-end; padding: 0; } }
.sheet { position: relative; background: var(--surface); width: 100%; max-width: 560px; max-height: 90vh; border-radius: var(--r-lg); display: flex; flex-direction: column; }
@media (max-width: 480px) { .sheet { border-radius: var(--r-lg) var(--r-lg) 0 0; } }
.sheet-h { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 18px 20px 15px; border-bottom: 1px solid var(--line); flex-shrink: 0; }
.sheet-h h2 { margin: 0; font-size: var(--fs-md); font-weight: 700; flex: 1; }
.sheet-b { padding: 20px; overflow-y: auto; flex: 1; }
.x {
  width: 44px; height: 44px; color: var(--muted); font-size: 24px; line-height: 1; flex-shrink: 0; text-decoration: none;
  display: flex; align-items: center; justify-content: center; padding: 7px; background-clip: content-box; border-radius: 15px;
}
.x:hover { background-color: var(--paper); color: var(--ink); }

.plist { display: grid; gap: 10px; }
.plist form { margin: 0; }
.pitem {
  display: flex; align-items: center; gap: 14px; width: 100%; min-height: var(--tap); padding: 13px;
  border: 2px solid var(--line); border-radius: var(--r); background: var(--surface); color: var(--ink); font: inherit; cursor: pointer; text-align: left;
}
.pitem:hover { border-color: var(--line-strong); background: var(--paper); }
.pitem[aria-current="true"] { border-color: var(--ink); background: var(--paper); }
.pitem-text { flex: 1; min-width: 0; }
.pitem .pn { display: block; font-weight: 700; font-size: var(--fs-body); line-height: 1.4; }
.pitem .pi { display: block; font-size: var(--fs-label); color: var(--muted); margin-top: 2px; }
.new {
  display: inline-flex; align-items: center; font-size: var(--fs-caption); font-weight: 700;
  background: var(--ink); color: #fff; border-radius: 5px; padding: 2px 8px; letter-spacing: .06em; flex-shrink: 0;
}
.ma { width: 42px; height: 42px; border-radius: 50%; flex-shrink: 0; color: #fff; display: flex; align-items: center; justify-content: center; }

.empty { color: var(--muted); padding: 28px 8px; text-align: center; line-height: 1.8; }
.empty b { display: block; color: var(--ink); font-size: var(--fs-md); margin-bottom: 6px; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: var(--pad); margin: 16px 0; }
.card-h {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  font-size: var(--fs-label); font-weight: 700; color: var(--muted); margin: 0 0 16px; letter-spacing: .02em;
}
.chip { display: inline-flex; align-items: center; gap: 7px; white-space: nowrap; font-size: var(--fs-label); font-weight: 700; padding: 6px 13px; border-radius: 99px; border: 1.5px solid; }
.chip.mute { color: var(--muted); background: var(--paper); border-color: var(--line); }
textarea.field { min-height: 100px; resize: vertical; line-height: 1.7; }

.composer { padding-bottom: 18px; margin-bottom: 6px; border-bottom: 2px solid var(--line); }
.composer .actions { margin-top: 22px; padding-top: 0; border-top: none; justify-content: flex-end; }
.composer-field { position: relative; }
.replying-to { display: flex; align-items: flex-start; gap: 10px; padding: 10px 12px; margin-bottom: 10px; background: var(--paper); border-radius: 8px; border-left: 3px solid var(--ink); }
.replying-to[hidden] { display: none; }
.replying-to .rt-main { flex: 1; min-width: 0; }
.replying-to .rt-label { font-size: var(--fs-caption); font-weight: 700; color: var(--ink); margin-bottom: 2px; }
.replying-to .rt-text { font-size: var(--fs-label); color: var(--muted); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.replying-to .x { width: 32px; height: 32px; font-size: 20px; flex-shrink: 0; }
.card-h-side { display: flex; align-items: center; gap: 10px; }
.file-chip { display: flex; align-items: center; gap: 10px; padding: 10px 12px; margin-top: 8px; max-width: 100%; border: 1.5px solid var(--line); border-radius: var(--r); background: var(--surface); text-decoration: none; color: var(--ink); transition: border-color .12s; }
a.file-chip:hover { border-color: var(--ink); }
.file-chip .ic { font-size: 20px; flex-shrink: 0; }
.file-chip .fmain { flex: 1; min-width: 0; }
.file-chip .fname { display: block; font-size: var(--fs-label); font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-chip .fsize { display: block; font-size: var(--fs-caption); color: var(--muted); }
.file-chip .fdel { width: 34px; height: 34px; border: none; background: none; color: var(--muted); font-size: 20px; cursor: pointer; border-radius: 8px; flex-shrink: 0; }
.file-chip .fdel:hover { background: var(--paper); color: var(--risk); }
.file-thumb { max-width: 100%; max-height: 280px; border-radius: 8px; margin-top: 8px; display: block; border: 1px solid var(--line); }
.attach-status { font-size: var(--fs-caption); color: var(--muted); margin: 6px 0 0; }
.attach-status:empty { display: none; }
.composer .attach-hint { margin-top: 22px; }
.file-list .notice.mute { margin-bottom: 16px; }
.file-row { display: flex; justify-content: space-between; align-items: flex-start; gap: 14px; padding: 14px 0; border-top: 1px solid var(--line); }
.file-row:first-child { border-top: none; }
.file-row-main { flex: 1; min-width: 0; }
.file-row-main .file-chip { margin-top: 0; }
.file-row .rt { font-size: var(--fs-caption); color: var(--muted); font-variant-numeric: tabular-nums; margin-top: 5px; }

.mention { background: #fff3a3; color: var(--ink); font-weight: 700; border-radius: 4px; padding: 1px 4px; }
.mention.me { background: var(--risk-bg); color: var(--risk); box-shadow: 0 0 0 1px var(--risk-line); }
.mention-pop {
  position: absolute; left: 0; right: 0; bottom: calc(100% + 6px); z-index: 80; background: var(--surface); border: 1.5px solid var(--line-strong);
  border-radius: var(--r); box-shadow: 0 8px 24px rgba(20, 32, 29, .16); max-height: 240px; overflow-y: auto; padding: 6px;
}
.mention-pop button {
  display: flex; align-items: center; gap: 10px; width: 100%; min-height: 44px; padding: 8px 12px; border: none; background: none;
  border-radius: 8px; cursor: pointer; text-align: left; font: inherit; font-size: var(--fs-label); font-weight: 700; color: var(--ink);
}
.mention-pop button:hover, .mention-pop button.on { background: var(--paper); }
.mention-pop .who { color: var(--muted); font-weight: 400; font-size: var(--fs-caption); }
.mention-pop .empty-hint { padding: 12px; color: var(--muted); font-size: var(--fs-label); }

.day-divider { display: flex; justify-content: center; margin: 20px 0 14px; }
.day-divider .label { background: rgba(20, 32, 29, .06); border-radius: 99px; padding: 5px 16px; font-size: var(--fs-caption); font-weight: 700; color: var(--muted); white-space: nowrap; }
.msg { display: flex; gap: 12px; margin-bottom: 14px; align-items: flex-start; border-radius: var(--r-lg); }
.msg:target { animation: msg-flash 1.2s; }
@keyframes msg-flash { from { background: var(--paper); } to { background: transparent; } }
.msg-avatar { width: 38px; height: 38px; border-radius: 50%; flex-shrink: 0; display: flex; align-items: center; justify-content: center; font-size: var(--fs-label); font-weight: 700; margin-top: 2px; }
.msg-main { min-width: 0; flex: 1; }
.msg-content { flex: 1; min-width: 0; display: flex; align-items: flex-end; gap: 8px; }
.bubble { flex: 0 1 auto; max-width: 100%; min-width: 0; background: var(--surface); border: 1.5px solid var(--line); border-radius: var(--r-lg); border-top-left-radius: 4px; padding: 12px 16px; }
.bubble > * { min-width: 0; }
.msg-head { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; margin-bottom: 5px; }
.msg-name { font-size: var(--fs-body); font-weight: 700; color: var(--ink); }
.msg-time { font-size: var(--fs-caption); color: var(--muted); }
.msg-body { white-space: pre-wrap; line-height: 1.75; font-size: var(--fs-body); word-break: break-word; }
.msg-side { flex: 0 0 auto; display: flex; align-items: center; gap: 2px; }
.msg-meta { font-size: var(--fs-caption); color: var(--muted); white-space: nowrap; }
.mtag {
  display: inline-flex; align-items: center; font-size: var(--fs-caption); font-weight: 700; border: 1.5px solid var(--line); background: var(--paper);
  color: var(--muted); border-radius: 5px; padding: 2px 8px; margin-right: 8px; vertical-align: 2px; flex-shrink: 0;
}
.quote { display: block; margin: 0 0 8px; padding: 0 0 0 10px; border-left: 2px solid var(--line-strong); opacity: .75; color: inherit; text-decoration: none; }
.quote:hover { opacity: 1; }
.quote-name { display: block; font-size: var(--fs-caption); font-weight: 700; color: var(--muted); margin-bottom: 1px; }
.quote-text { font-size: var(--fs-caption); color: var(--muted); line-height: 1.5; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

.menu-wrap { position: relative; flex-shrink: 0; }
.menu-btn {
  display: flex; align-items: center; justify-content: center; width: 44px; height: 44px; border: 1.5px solid transparent; border-radius: 8px;
  cursor: pointer; color: var(--muted); font-size: 18px; line-height: 1; list-style: none;
}
.menu-btn::-webkit-details-marker { display: none; }
.menu-btn:hover, .menu-wrap[open] .menu-btn { background: var(--paper); border-color: var(--line); color: var(--ink); }
.menu {
  position: absolute; right: 0; bottom: 46px; z-index: 70; min-width: 158px; padding: 6px; background: var(--surface);
  border: 1.5px solid var(--line); border-radius: var(--r); box-shadow: 0 8px 24px rgba(20, 32, 29, .16);
}
.menu button, .menu a {
  display: flex; align-items: center; gap: 10px; width: 100%; min-height: 44px; padding: 10px 12px; border: none; background: none;
  border-radius: 8px; cursor: pointer; text-align: left; font: inherit; font-size: var(--fs-label); font-weight: 700; color: var(--ink); text-decoration: none;
}
.menu button:hover, .menu a:hover { background: var(--paper); }

.job-doctor { background: #efeef8; color: #1b119c; box-shadow: inset 0 0 0 1.5px #a8a5d9; }
.job-nurse { background: #eff5fc; color: #176fd3; box-shadow: inset 0 0 0 1.5px #a7c8ee; }
.job-pharmacist { background: #f3eff2; color: #541c45; box-shadow: inset 0 0 0 1.5px #bea9b8; }
.job-dietitian { background: #f9f1f7; color: #b03b91; box-shadow: inset 0 0 0 1.5px #e1b5d5; }
.job-other { background: #f3f3f3; color: #545a57; box-shadow: inset 0 0 0 1.5px #bec0bf; }

.grid { display: grid; gap: 18px; }
.g2 { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.grid .field { margin-bottom: 0; }
.grid .hint { margin: 6px 0 0; }
@media (max-width: 480px) { .g2 { grid-template-columns: 1fr; } .grid { gap: 16px; } }
.field[readonly] { background: var(--paper); }
.actions { display: flex; gap: 12px; flex-wrap: wrap; justify-content: flex-end; margin-top: 22px; padding-top: 20px; border-top: 1px solid var(--line); }
.actions .btn { flex: 0 0 auto; }
@media (max-width: 768px) { .actions .btn { flex: 1 1 auto; justify-content: center; } }

.chip {
  display: inline-flex; align-items: center; gap: 7px; white-space: nowrap;
  font-size: var(--fs-label); font-weight: 700; padding: 6px 13px; border-radius: 99px; border: 1.5px solid;
}
.chip.mute { color: var(--muted); background: var(--paper); border-color: var(--line); }
.num { font-variant-numeric: tabular-nums; font-feature-settings: "tnum"; }
.sec-d { font-size: var(--fs-label); color: var(--muted); margin: 10px 0 16px; line-height: 1.7; }
.row-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-top: 12px; }
.row-actions form { margin: 0; }

.acc-h { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.acc-row { display: flex; align-items: flex-start; gap: 12px; padding: 14px 0; border-top: 1px solid var(--line); }
.acc-row:first-child { border-top: none; }
.acc-row .ar-main { flex: 1; min-width: 0; }
.acc-row .ar-name { font-weight: 700; }
.acc-row .ar-sub { font-size: var(--fs-caption); color: var(--muted); margin-top: 2px; overflow-wrap: anywhere; }
.acc-patients { max-height: 260px; overflow-y: auto; }

.checks { display: grid; gap: 10px; }
.check {
  display: flex; gap: 14px; align-items: flex-start; border: 2px solid var(--line);
  border-radius: var(--r); padding: 14px; cursor: pointer;
}
.check:hover { border-color: var(--line-strong); background: var(--paper); }
.check:has(input:checked) { border-color: var(--ink); background: var(--paper); }
.check input { width: 24px; height: 24px; margin: 3px 0 0; flex-shrink: 0; accent-color: var(--ink); }
.check .t { font-weight: 700; line-height: 1.5; }

.danger-zone { margin-top: 28px; padding-top: 20px; border-top: 2px dashed var(--line-strong); }
.result-box { border: 1.5px solid var(--line); border-radius: var(--r); padding: 14px 16px; line-height: 1.7; background: var(--paper); color: var(--muted); }
.result-box b { display: block; margin-bottom: 4px; font-size: var(--fs-body); color: var(--ink); }
.temp-pw { font-family: ui-monospace, Menlo, monospace; font-size: var(--fs-md); font-weight: 700; letter-spacing: .06em; margin: 8px 0; user-select: all; color: var(--ink); }

.team-list { margin-top: 24px; }
.member { display: flex; align-items: center; gap: 13px; padding: 13px 0; border-top: 1px solid var(--line); }
.member:first-child { border-top: none; }
.member .ma { font-weight: 700; font-size: var(--fs-label); }
.member-text { flex: 1; min-width: 0; }
.mn { display: block; font-weight: 700; line-height: 1.4; }
.mr { display: block; font-size: var(--fs-label); color: var(--muted); }
.job-doctor { background: #efeef8; color: #1b119c; box-shadow: inset 0 0 0 1.5px #a8a5d9; }
.job-nurse { background: #eff5fc; color: #176fd3; box-shadow: inset 0 0 0 1.5px #a7c8ee; }
.job-pharmacist { background: #f3eff2; color: #541c45; box-shadow: inset 0 0 0 1.5px #bea9b8; }
.job-dietitian { background: #f9f1f7; color: #b03b91; box-shadow: inset 0 0 0 1.5px #e1b5d5; }
.job-other { background: #f3f3f3; color: #545a57; box-shadow: inset 0 0 0 1.5px #bec0bf; }

nav.seg { margin-bottom: 24px; }
.seg a {
  min-height: var(--tap); padding: 10px 14px; border: 2px solid var(--line-strong); border-radius: var(--r);
  background: var(--surface); color: var(--ink); text-align: center; text-decoration: none; line-height: 1.5;
  display: flex; align-items: center; justify-content: center;
}
.seg a:hover { border-color: var(--muted); }
.seg a[aria-current="page"] { background: var(--ink); color: #fff; border-color: var(--ink); font-weight: 700; }

.g3 { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.range { display: flex; align-items: center; gap: 8px; }
.range .field { margin-bottom: 0; min-width: 0; }
.audit-filter { margin-bottom: 16px; }
.audit-row { display: flex; gap: 14px; padding: 10px 0; border-top: 1px solid var(--line); align-items: baseline; }
.audit-row:first-child { border-top: none; }
.audit-row .au-when { flex: 0 0 auto; font-size: var(--fs-caption); color: var(--muted); min-width: 11.5em; }
.audit-row .au-main { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.audit-row .au-who { font-size: var(--fs-caption); color: var(--muted); margin-top: 2px; }
.au-diff { margin-top: 6px; font-size: var(--fs-label); }
@media (max-width: 480px) { .audit-row { flex-direction: column; gap: 2px; } .g3 { grid-template-columns: 1fr; } }

.disclaimer { font-size: var(--fs-caption); color: var(--muted); text-align: center; line-height: 1.7; margin: 24px 16px; }

.num { font-variant-numeric: tabular-nums; font-feature-settings: "tnum"; }
main.shell { padding-top: 22px; padding-bottom: 80px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: var(--pad); margin-bottom: 16px; }
.card-h {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  font-size: var(--fs-label); font-weight: 700; color: var(--muted); margin: 0 0 16px; letter-spacing: .02em;
}
.chip {
  display: inline-flex; align-items: center; gap: 7px; white-space: nowrap;
  font-size: var(--fs-label); font-weight: 700; padding: 6px 13px; border-radius: 99px; border: 1.5px solid;
}
.chip.ok { color: var(--ok); background: var(--ok-bg); border-color: var(--ok-line); }
.chip.risk { color: var(--risk); background: var(--risk-bg); border-color: var(--risk-line); }
.chip.mute { color: var(--muted); background: var(--paper); border-color: var(--line); }
.checklist-note {
  border: 1.5px solid var(--line); border-radius: var(--r); padding: 14px 16px; line-height: 1.7;
  font-size: var(--fs-label); background: var(--paper); color: var(--muted); margin: 0 0 16px;
}
.notice.mute, .notice.ok, .notice.risk, .notice.judged {
  border: 1.5px solid; border-radius: var(--r); padding: 14px 16px; line-height: 1.7; font-size: var(--fs-label); margin: 0;
}
.notice.mute { background: var(--paper); border-color: var(--line); color: var(--muted); }
.notice.ok { background: var(--ok-bg); border-color: var(--ok-line); color: #0c472c; }
.notice.risk { background: var(--risk-bg); border-color: var(--risk-line); color: #7b1911; }
.notice.judged { background: transparent; border-style: dashed; border-color: var(--line-strong); color: var(--muted); }
.notice b { display: block; margin-bottom: 4px; font-size: var(--fs-body); }
.g3 { grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }
@media (min-width: 769px) { .g3 > div > .lbl { min-height: 3.4em; } }
@media (max-width: 768px) { .g2, .g3 { grid-template-columns: 1fr; } }
.lbl.light { font-weight: 400; }
.block { margin-bottom: 18px; }
.block-sm { margin-bottom: 10px; }
.block-top { margin-top: 18px; }
.block-top-sm { margin-top: 16px; }
.block-top-lg { margin-top: 24px; }
.mna-items { gap: 24px; }
.sec-h.plain { border: none; padding: 0; margin-bottom: 14px; }
.sec-h.section-gap { margin-top: 26px; }
.metric { font-size: var(--fs-metric); font-weight: 700; line-height: 1.3; }
.value { font-size: var(--fs-md); font-weight: 700; }
.f input[type=text], .f input[type=number], .f input[type=date], .f select, .f textarea {
  width: 100%; min-height: var(--tap); padding: 11px 14px; border: 2px solid var(--line-strong);
  border-radius: var(--r); background: var(--surface); font: inherit; color: var(--ink); font-variant-numeric: tabular-nums;
}
.f textarea { min-height: 100px; resize: vertical; line-height: 1.7; }
.f input[type=date], .f select { height: var(--tap); line-height: normal; }
.f input[readonly] { background: var(--paper); }
.f input:focus, .f select:focus, .f textarea:focus { border-color: var(--ink); outline: none; }
.err { color: var(--risk); font-size: var(--fs-label); font-weight: 700; margin-top: 7px; }
.f .hint { margin: 7px 0 0; }
.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 8px; }
@media (max-width: 768px) { .seg { grid-auto-flow: row; grid-auto-columns: auto; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); } }
@media (max-width: 480px) { .seg { grid-template-columns: 1fr; } }
.seg label, .seg button {
  position: relative; display: block; min-height: var(--tap); padding: 10px 14px; font: inherit; color: var(--ink);
  border: 2px solid var(--line-strong); border-radius: var(--r); background: var(--surface); cursor: pointer; text-align: center; line-height: 1.5;
}
.seg label:hover { border-color: var(--muted); }
.seg input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.seg label:has(input:checked) { background: var(--sel); color: #fff; border-color: var(--sel); font-weight: 700; }
.seg label:has(input:focus-visible) { outline: 3px solid var(--focus); outline-offset: 2px; }
.seg .pt { display: block; font-size: var(--fs-caption); opacity: .7; font-weight: 700; }
.seg.auto button { cursor: default; background: var(--paper); border-style: dashed; color: var(--muted); }
.seg.auto button:disabled { opacity: 1; }
.seg.auto button[aria-pressed="true"] { background: var(--surface); color: var(--ink); border-style: solid; border-color: var(--ink); font-weight: 700; }
.checks { display: grid; gap: 10px; }
.check { display: flex; gap: 14px; align-items: flex-start; border: 2px solid var(--line); border-radius: var(--r); padding: 14px; cursor: pointer; }
.check:hover { border-color: var(--line-strong); background: var(--paper); }
.check:has(input:checked) { border-color: var(--ink); background: var(--paper); }
.check input { width: 24px; height: 24px; margin: 3px 0 0; flex-shrink: 0; accent-color: var(--ink); }
.check .t { font-weight: 700; line-height: 1.5; }
.check .s { display: block; font-size: var(--fs-label); color: var(--muted); margin-top: 3px; line-height: 1.6; }
.btn-danger { color: var(--risk); border-color: var(--risk-line); }
.btn-danger:hover { background: var(--risk-bg); border-color: var(--risk); }
.btn-commit { min-height: 52px; padding: 12px 28px; box-shadow: 0 2px 0 rgba(20, 32, 29, .25); }
@media (max-width: 768px) { .btn-commit { min-height: 48px; padding: 11px 20px; flex: 1 1 auto; min-width: 0; } }
.save-bar {
  position: sticky; bottom: 0; z-index: 55; display: flex; justify-content: space-between; align-items: center; gap: 12px;
  margin: -16px 0 0; padding: 30px 0; background: var(--paper);
}
@media (max-width: 768px) { .save-bar { padding: 16px 0; } }
.card .save-bar { background: var(--surface); margin: 0 0 calc(var(--pad) * -1); padding: 30px 0; }
.left-count {
  font-size: var(--fs-label); color: var(--muted); font-weight: 700; display: flex; align-items: center; gap: 7px; flex: 0 0 auto; white-space: nowrap;
}
.left-count::before { content: ""; width: 10px; height: 10px; border-radius: 50%; flex: none; background: var(--surface); box-shadow: 0 0 0 1.8px var(--line-strong); }
.left-count.done { color: var(--ok); }
.left-count.done::before { background: var(--ok); box-shadow: none; }
@media (max-width: 480px) { .left-count { font-size: var(--fs-caption); } }
.left-count.saved { color: var(--accent); }
.left-count.saved::before { background: var(--accent); box-shadow: none; }
.draft-note {
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap; background: var(--surface); border: 1px solid var(--line);
  border-left: 4px solid var(--accent); border-radius: var(--r); padding: 14px 18px; margin: 0 0 18px; font-size: var(--fs-label); line-height: 1.7;
}
.draft-note .dn-t { flex: 1 1 220px; min-width: 0; color: var(--ink); }
.draft-note .dn-t b { font-weight: 700; }
.draft-note .dn-b { flex: 0 0 auto; display: flex; gap: 10px; }
.draft-note .dn-b form { display: contents; }
@media (max-width: 480px) {
  .draft-note { align-items: stretch; }
  .draft-note .dn-b { width: 100%; }
  .draft-note .dn-b .btn { flex: 1 1 0; }
}
.rec-form-h { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 16px var(--pad); margin-bottom: 16px; }
.rec-form-h .rfh-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.rec-form-h h2 { margin: 0; font-size: var(--fs-md); }
.rec-form-h .hint { margin: 4px 0 12px; }
.rec-form-h .hint:last-child { margin-bottom: 0; }
.rec-steps { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 8px; }
.rec-steps a {
  display: inline-flex; align-items: center; gap: 8px; min-height: 44px; padding: 8px 14px; border: 1px solid var(--line-strong);
  border-radius: 99px; color: var(--ink); text-decoration: none; font-size: var(--fs-label); font-weight: 700; background: var(--surface);
}
.rec-steps a:hover { background: var(--paper); }
.rec-steps .st { font-size: var(--fs-caption); font-weight: 700; color: var(--muted); }
.rec-steps li[data-s="done"] .st { color: var(--ok); }
.rec-steps li[data-s="done"] .st::before { content: "✓ "; }
.rec-steps li[data-s="todo"] .st { color: var(--watch-t); }
.prev-record { margin-bottom: 18px; }
#glim-switch[data-shown="false"] + #glim-card { display: none; }
#smi-card:has(#record_unmeasurable:checked) .smi-input-box { display: none; }
#smi-card:not(:has(#record_unmeasurable:checked)) .smi-unmeasurable-note { display: none; }
#glim-verdict { margin-top: 24px; }
.rec-row { border-top: 1px solid var(--line); }
.rec-row:first-child, .rec-row:first-of-type { border-top: none; }
.rec-row > summary { list-style: none; cursor: pointer; display: flex; gap: 12px; align-items: flex-start; padding: 14px 4px; min-height: 44px; }
.rec-row > summary::-webkit-details-marker { display: none; }
.rec-row > summary::before {
  content: ""; flex: 0 0 auto; width: 9px; height: 9px; margin-top: .55em;
  border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted); transform: rotate(-45deg); transition: transform .15s;
}
.rec-row[open] > summary::before { transform: rotate(45deg); }
.rec-row .rr-main { flex: 1; min-width: 0; }
.rec-row .rr-h { display: flex; gap: 10px; flex-wrap: wrap; align-items: baseline; }
.rec-row .rr-date { font-weight: 700; }
.rec-row .rr-by { font-size: var(--fs-caption); color: var(--muted); }
.rec-row .rr-vals { margin-top: 4px; line-height: 1.8; font-variant-numeric: tabular-nums; }
.rec-row .rr-vals .dl { font-size: var(--fs-caption); color: var(--muted); margin-left: 2px; }
.rec-row .rr-side { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.rec-row .rr-body { padding: 0 4px 16px 25px; }
.empty-v { color: var(--muted); }
.actions.end { justify-content: flex-end; }
.actions form { display: contents; }
.danger-zone { margin-top: 28px; padding-top: 20px; border-top: 2px dashed var(--line-strong); }
.danger-zone.first { margin-top: 0; padding-top: 0; border-top: none; }
.void-lead { margin: 0 0 8px; font-weight: 700; }
dialog.overlay { border: 0; margin: 0; width: auto; height: auto; max-width: none; max-height: none; background: transparent; color: inherit; }
dialog.overlay:not([open]) { display: none; }
.overlay-close-form { display: contents; }
button.overlay-close { border: 0; padding: 0; cursor: default; }
.sheet-h form { margin: 0; }
textarea.field { min-height: 100px; resize: vertical; line-height: 1.7; margin-bottom: 0; }
button.x { border: 0; background-color: transparent; font: inherit; font-size: 24px; cursor: pointer; }
.revision-link { color: inherit; }
.sum-list.revision + .sum-list.revision { margin-top: 22px; }
.revision-item + .revision-item { margin-top: 4px; }
.sum-list.revision .msg-body { font-size: inherit; }

@media print {
  body * { display: none !important; }
}
