/* ===== 麻酔記録 画面 ===== */
:root {
  --nav-w: 230px;
  --label-w: 150px;
  --col-w: 28px;
  --ink: #1f2937;
  --grid: #dbe3ee;
  --grid-strong: #9fb0c6;
  --sbp: #dc2626;
  --hr: #16a34a;
  --spo2: #2563eb;
  --etco2: #7c3aed;
  --rr: #0891b2;
}
body { color: var(--ink); font-size: 13px; }

.anes-header {
  background: linear-gradient(90deg, #075985, #0c4a6e);
  color: #fff; position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 7px 14px; box-shadow: 0 2px 6px rgba(0,0,0,.15);
}
.hdr-btn { display: inline-flex; align-items: center; gap: 6px; padding: 6px 10px; border-radius: 6px; background: rgba(255,255,255,.12); color: #fff; font-size: 12px; white-space: nowrap; }
.hdr-btn:hover { background: rgba(255,255,255,.22); }
.hdr-btn-primary { background: #10b981; font-weight: 700; }

/* 共通入力 */
.ainp { border: 1px solid #cbd5e1; border-radius: 5px; padding: 4px 6px; font-size: 12px; background: #fff; color: var(--ink); min-width: 0; }
.ainp:focus { outline: 2px solid #7dd3fc; outline-offset: 0; border-color: #0ea5e9; }
.nav-btn { display: inline-flex; align-items: center; justify-content: center; gap: 4px; padding: 5px 8px; border-radius: 5px; border: 1px solid #cbd5e1; background: #fff; font-size: 12px; white-space: nowrap; cursor: pointer; }
.nav-btn:hover { background: #f1f5f9; }
.nav-btn.primary { background: #0284c7; border-color: #0284c7; color: #fff; font-weight: 600; }
.nav-btn.primary:hover { background: #0369a1; }
.nav-btn.danger { color: #b91c1c; border-color: #fca5a5; }

/* 患者属性欄 */
.anes-attr { background: #fff; border-bottom: 1px solid #e2e8f0; padding: 6px 14px; position: sticky; top: 46px; z-index: 40; }
.attr-grid { display: flex; flex-wrap: wrap; gap: 6px 10px; align-items: flex-end; }
.attr-grid label { display: flex; flex-direction: column; font-size: 10px; color: #64748b; gap: 2px; }
.attr-grid .attr-wide { flex: 1 1 220px; }
.attr-grid .attr-wide input { width: 100%; }
.attr-toggle { font-size: 11px; color: #0369a1; padding: 5px 8px; border: 1px dashed #7dd3fc; border-radius: 5px; background: #f0f9ff; }
.preop-panel { margin-top: 6px; padding: 8px 10px; background: #f8fafc; border: 1px solid #e2e8f0; border-radius: 6px; display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 4px 16px; font-size: 11.5px; }
.preop-panel .pk { color: #64748b; font-size: 10px; }
.preop-panel .pv { white-space: pre-wrap; }
.preop-panel .risk { color: #b91c1c; font-weight: 600; }

/* 本体 */
.anes-body { display: flex; align-items: stretch; min-height: calc(100vh - 110px); }
.anes-nav { width: var(--nav-w); flex: 0 0 var(--nav-w); background: #f8fafc; border-right: 1px solid #e2e8f0; padding: 8px; overflow-y: auto; position: sticky; top: 104px; height: calc(100vh - 104px); }
.nav-sec { background: #fff; border: 1px solid #e2e8f0; border-radius: 7px; padding: 7px; margin-bottom: 8px; }
.nav-time { background: #0c4a6e; color: #fff; border-radius: 7px; padding: 7px; margin-bottom: 8px; }
.nav-time .nav-title { color: #bae6fd; }
.nav-title { font-size: 11px; font-weight: 700; color: #0369a1; margin-bottom: 5px; display: flex; align-items: center; gap: 5px; }
.nav-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; }
.nav-grid .ev-btn { font-size: 11.5px; padding: 6px 4px; border-radius: 5px; border: 1px solid #cbd5e1; background: #fff; cursor: pointer; text-align: center; }
.nav-grid .ev-btn:hover { background: #e0f2fe; border-color: #7dd3fc; }
.nav-grid .ev-btn.done { background: #ecfdf5; border-color: #6ee7b7; color: #065f46; }
.nav-grid .ev-btn.wide { grid-column: span 2; }
.nav-now { padding: 4px 9px; border-radius: 5px; border: 1px solid #7dd3fc; background: transparent; color: #bae6fd; font-size: 12px; font-weight: 700; }
.nav-now.active { background: #10b981; border-color: #10b981; color: #fff; }
.inf-row { padding: 5px 0; border-top: 1px dashed #e2e8f0; }
.inf-row:first-of-type { border-top: 0; }
.inf-name { font-size: 11px; font-weight: 600; margin-bottom: 3px; }
.inf-calc { font-size: 10px; color: #64748b; margin-top: 2px; min-height: 12px; }
.la-summary { font-size: 10.5px; color: #475569; margin-top: 5px; line-height: 1.5; }
.la-summary .warn { color: #b45309; font-weight: 600; }
.la-summary .over { color: #b91c1c; font-weight: 700; }

/* チャート */
.anes-main { flex: 1 1 auto; min-width: 0; padding: 8px 10px; }
.chart-toolbar { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 6px; flex-wrap: wrap; }
.legend { display: flex; gap: 10px; font-size: 11px; color: #475569; align-items: center; }
.legend span { display: inline-flex; align-items: center; gap: 3px; }
.chart-scroll { overflow-x: auto; background: #fff; border: 1px solid #e2e8f0; border-radius: 8px; }
.row { display: flex; align-items: stretch; border-bottom: 1px solid var(--grid); }
.row-label { flex: 0 0 var(--label-w); width: var(--label-w); position: sticky; left: 0; z-index: 5; background: #f8fafc; border-right: 1px solid var(--grid-strong); font-size: 11px; padding: 3px 6px; display: flex; align-items: center; gap: 4px; color: #334155; font-weight: 600; white-space: nowrap; overflow: hidden; }
.row-label .sub { font-weight: 400; color: #94a3b8; font-size: 10px; }
.row-body { position: relative; flex: 0 0 auto; }
.row-header .row-body { height: 22px; }
.row-chart .row-body { height: 280px; }
.row-num .row-body { height: 20px; }
.row-lane .row-body { height: 26px; }
.row-fluid2 .row-body { height: 30px; }
.row-remark .row-body { height: 30px; }
.cell { position: absolute; top: 0; height: 100%; display: flex; align-items: center; justify-content: center; font-size: 10.5px; font-variant-numeric: tabular-nums; border-right: 1px solid var(--grid); cursor: pointer; }
.cell:hover { background: #f0f9ff; }
.cell.half { border-right-color: var(--grid-strong); }
.row-header .cell { font-size: 10px; color: #475569; cursor: default; justify-content: flex-start; padding-left: 2px; border-right-color: transparent; }
.row-header .cell.half { border-right-color: transparent; }
.row-header .cell .tlabel { position: absolute; left: 2px; top: 3px; white-space: nowrap; }
.mark { position: absolute; top: 2px; height: 22px; display: flex; align-items: center; gap: 3px; font-size: 10.5px; white-space: nowrap; cursor: pointer; z-index: 2; }
.mark .dot { width: 9px; height: 9px; border-radius: 50%; background: #0284c7; flex: 0 0 9px; }
.mark .tri { width: 0; height: 0; border-left: 5px solid transparent; border-right: 5px solid transparent; border-top: 8px solid #b45309; }
.mark .txt { background: rgba(255,255,255,.85); padding: 0 2px; border-radius: 2px; }
.mark:hover .txt { background: #fef3c7; }
.bar { position: absolute; top: 5px; height: 16px; border-radius: 3px; font-size: 10px; display: flex; align-items: center; padding-left: 4px; white-space: nowrap; overflow: hidden; cursor: pointer; z-index: 1; }
.bar.propofol { background: #fde68a; border: 1px solid #f59e0b; }
.bar.remifentanil { background: #c7d2fe; border: 1px solid #6366f1; }
.bar.sevoflurane { background: #bbf7d0; border: 1px solid #22c55e; }
.vline { position: absolute; top: 0; bottom: 0; width: 0; border-left: 1.5px dashed #0ea5e9; z-index: 1; }
.vline.ev { border-color: #f97316; }

/* 下部パネル */
.panels { display: grid; grid-template-columns: 1.4fr 1fr 1fr; gap: 10px; margin-top: 10px; }
.panel-wide { grid-column: 1 / -1; }
.anes-side { width: 220px; flex: 0 0 220px; background: #f8fafc; border-left: 1px solid #e2e8f0; padding: 8px; overflow-y: auto; position: sticky; top: 104px; height: calc(100vh - 104px); }
.chip-group { display: flex; flex-wrap: wrap; gap: 3px; align-items: center; margin-bottom: 4px; }
.chip-label { font-size: 10px; color: #64748b; width: 34px; flex: 0 0 34px; }
.chip { font-size: 11px; padding: 3px 7px; border-radius: 999px; border: 1px solid #cbd5e1; background: #fff; cursor: pointer; }
.chip:hover { background: #f0f9ff; }
.chip.on { background: #0284c7; border-color: #0284c7; color: #fff; font-weight: 600; }
.bar.fluid { background: #e0f2fe; border: 1px solid #38bdf8; }
.panel { background: #fff; border: 1px solid #e2e8f0; border-radius: 8px; padding: 10px 12px; }
.panel-title { font-size: 12px; font-weight: 700; color: #0369a1; margin-bottom: 6px; display: flex; align-items: center; gap: 6px; }
.remark-list { max-height: 260px; overflow-y: auto; font-size: 12px; }
.remark-item { display: flex; gap: 8px; align-items: flex-start; padding: 3px 0; border-bottom: 1px dashed #e2e8f0; }
.remark-item .t { font-variant-numeric: tabular-nums; color: #475569; flex: 0 0 44px; }
.remark-item .k { flex: 0 0 56px; font-size: 10px; padding: 1px 4px; border-radius: 3px; text-align: center; }
.remark-item .k.event { background: #ffedd5; color: #9a3412; }
.remark-item .k.remark { background: #e0f2fe; color: #075985; }
.remark-item .k.bolus { background: #fee2e2; color: #991b1b; }
.remark-item .k.inf { background: #ede9fe; color: #5b21b6; }
.remark-item .k.la { background: #dcfce7; color: #166534; }
.remark-item .k.sed { background: #fef9c3; color: #854d0e; }
.remark-item .k.fluid { background: #e0f2fe; color: #0369a1; }
.remark-item .k.vital { background: #f1f5f9; color: #334155; }
.remark-item .x { flex: 1 1 auto; white-space: pre-wrap; }
.remark-item .del { color: #94a3b8; cursor: pointer; } .remark-item .del:hover { color: #dc2626; }
.tot-table { width: 100%; font-size: 12px; border-collapse: collapse; }
.tot-table td { padding: 3px 4px; border-bottom: 1px dashed #e2e8f0; }
.tot-table td:last-child { text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; }
.image-list { display: flex; flex-wrap: wrap; gap: 6px; }
.image-list a img { height: 64px; border: 1px solid #e2e8f0; border-radius: 4px; }

/* モーダル */
.modal { position: fixed; inset: 0; background: rgba(15,23,42,.45); z-index: 100; display: flex; align-items: center; justify-content: center; padding: 16px; }
.modal-box { background: #fff; border-radius: 10px; padding: 16px; max-width: 980px; width: 100%; max-height: 92vh; overflow: auto; box-shadow: 0 10px 40px rgba(0,0,0,.3); }
.modal-title { font-size: 14px; font-weight: 700; margin-bottom: 10px; display: flex; align-items: center; gap: 8px; }
.ocr-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.ocr-table th, .ocr-table td { border: 1px solid #e2e8f0; padding: 2px 4px; text-align: center; }
.ocr-table input { width: 58px; text-align: center; }
.ocr-table td:nth-child(2) input { width: 80px; }
.ocr-table tr.off { opacity: .4; }
.dropzone { border: 2px dashed #7dd3fc; border-radius: 8px; padding: 18px; text-align: center; color: #0369a1; background: #f0f9ff; cursor: pointer; }
.dropzone.over { background: #e0f2fe; }
.toast { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); background: #0f172a; color: #fff; padding: 8px 14px; border-radius: 6px; font-size: 12px; z-index: 200; box-shadow: 0 4px 16px rgba(0,0,0,.3); }
.modal.hidden, .toast.hidden, .preop-panel.hidden, input.hidden, a.hidden, div.hidden { display: none !important; }
.toast.warning { background: #b45309; } .toast.error { background: #b91c1c; } .toast.success { background: #047857; }

/* 一覧 */
.ltable { width: 100%; border-collapse: collapse; font-size: 12px; }
.ltable th { text-align: left; font-size: 11px; color: #64748b; border-bottom: 2px solid #e2e8f0; padding: 4px 6px; white-space: nowrap; }
.ltable td { padding: 5px 6px; border-bottom: 1px solid #f1f5f9; white-space: nowrap; }
.ltable tr:hover td { background: #f0f9ff; }
.stats-table { border-collapse: collapse; font-size: 12px; }
.stats-table th, .stats-table td { border: 1px solid #e2e8f0; padding: 4px 10px; text-align: right; }
.stats-table th:first-child, .stats-table td:first-child { text-align: left; }
.stats-table tfoot td { font-weight: 700; background: #f8fafc; }

@media (max-width: 900px) {
  .anes-body { flex-direction: column; }
  .anes-nav, .anes-side { width: 100%; flex-basis: auto; position: static; height: auto; border: 0; }
  .panels { grid-template-columns: 1fr; }
}

/* ===== 印刷（A4 横） ===== */
#print-root { display: none; }
@media print {
  @page { size: A4 landscape; margin: 8mm; }
  body { background: #fff; font-size: 10px; }
  #app-shell, .modal, .toast { display: none !important; }
  #print-root { display: block; }
  body { width: 100%; overflow: hidden; }
  .pr-head { padding-right: 12px; display: flex; justify-content: space-between; align-items: flex-end; border-bottom: 2px solid #0c4a6e; padding-bottom: 3px; margin-bottom: 4px; }
  .pr-head h1 { font-size: 14px; font-weight: 700; color: #0c4a6e; }
  .pr-attr { display: grid; grid-template-columns: repeat(8, 1fr); gap: 2px 8px; font-size: 9.5px; margin-bottom: 4px; }
  .pr-attr b { color: #475569; font-weight: 600; margin-right: 3px; }
  .pr-chart { width: 100%; }
  .pr-chart { overflow: hidden; }
  .pr-chart .row-label { font-size: 8.5px; padding: 1px 3px; }
  .pr-chart .row-header .row-body { height: 14px; }
  .pr-chart .row-num .row-body { height: 15px; }
  .pr-chart .row-lane .row-body { height: 18px; }
  .pr-chart .row-fluid2 .row-body { height: 28px; }
  .pr-chart .row-remark .row-body { height: 28px; }
  .pr-chart .cell { font-size: 8.5px; }
  .pr-chart .mark { font-size: 8.5px; height: 18px; }
  .pr-chart .bar { font-size: 8.5px; height: 14px; top: 3px; }
  .pr-cols { column-count: 2; column-gap: 8px; }
  .pr-item { break-inside: avoid; border-bottom: 1px dotted #e2e8f0; padding: 1px 0; }
  .pr-item .t { display: inline-block; width: 34px; font-variant-numeric: tabular-nums; color: #475569; }
  .pr-bottom { display: grid; grid-template-columns: 1.6fr 1fr 1fr; gap: 8px; margin-top: 4px; font-size: 8.5px; }
  .pr-bottom h3 { font-size: 10px; font-weight: 700; color: #0c4a6e; border-bottom: 1px solid #cbd5e1; margin-bottom: 2px; }
  .pr-bottom table { width: 100%; border-collapse: collapse; }
  .pr-bottom td { padding: 1px 3px; vertical-align: top; border-bottom: 1px dotted #e2e8f0; }
  .pr-bottom td.t { white-space: nowrap; width: 36px; font-variant-numeric: tabular-nums; }
}
