:root {
  --bg: #f3f5f9;
  --panel: #ffffff;
  --panel-2: #eef1f6;
  --line: #d9dee8;
  --text: #1b2130;
  --muted: #6b7488;
  --accent: #0284c7;
  --prep: #8b97b3;
  --ready: #f5b71c;
  --inprog: #f05252;
  --recover: #2ecc71;
  --radius: 10px;
  --font: -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Pretendard", "Malgun Gothic", "Noto Sans KR", system-ui, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font-family: var(--font); background: var(--bg); color: var(--text); font-size: 14px; -webkit-text-size-adjust: 100%; overscroll-behavior: none; }
#app { height: 100%; display: flex; flex-direction: column; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }
::-webkit-scrollbar { width: 8px; height: 8px; } ::-webkit-scrollbar-thumb { background: #2b3755; border-radius: 4px; }

/* ---------- 상단바 ---------- */
.topbar { display: flex; align-items: center; gap: 8px; padding: 8px 12px; background: var(--panel); border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 16px; white-space: nowrap; }
.clock { color: var(--muted); font-weight: 400; font-size: 13px; font-variant-numeric: tabular-nums; }
.conn-dot { width: 9px; height: 9px; border-radius: 50%; background: #ef4444; box-shadow: 0 0 6px #ef4444; flex-shrink: 0; }
.conn-dot.on { background: #22c55e; box-shadow: 0 0 6px #22c55e; }
.topbar-search { flex: 1; min-width: 140px; max-width: 300px; }
.topbar-search input { width: 100%; padding: 7px 10px; border-radius: 8px; border: 1px solid var(--line); background: var(--bg); color: var(--text); }
.topbar-actions { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; margin-left: auto; }
.btn { background: var(--panel-2); border: 1px solid var(--line); color: var(--text); padding: 6px 10px; border-radius: 8px; font-size: 13px; line-height: 1.2; white-space: nowrap; position: relative; }
.btn:hover { background: #253354; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #082f49; font-weight: 700; }
.btn.primary:hover { background: #7dd3fc; }
.btn.danger { background: #7f1d1d; border-color: #991b1b; }
.btn.sm { padding: 3px 8px; font-size: 12px; }
.btn.on { outline: 2px solid var(--accent); }
.btn .badge { position: absolute; top: -6px; right: -6px; background: #ef4444; color: #fff; border-radius: 10px; font-size: 10px; padding: 1px 5px; min-width: 16px; text-align: center; }
.opacity-ctl { display: flex; align-items: center; gap: 4px; font-size: 12px; color: var(--muted); }
.opacity-ctl input { width: 80px; }

/* ---------- 레이아웃 ---------- */
.layout { flex: 1; display: flex; min-height: 0; }
.sidebar { width: 178px; background: var(--panel); border-right: 1px solid var(--line); display: flex; flex-direction: column; padding: 8px; gap: 3px; overflow-y: auto; }
.cat-btn { display: flex; align-items: center; gap: 8px; padding: 9px 10px; border-radius: 8px; border: 1px solid transparent; background: transparent; color: var(--text); text-align: left; width: 100%; font-size: 14px; font-weight: 600; }
.cat-btn:hover { background: var(--panel-2); }
.cat-btn.active { background: var(--panel-2); border-color: var(--line); }
.cat-btn .dot { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; }
.cat-btn .count { margin-left: auto; color: var(--muted); font-weight: 400; font-size: 12px; white-space: nowrap; display: flex; align-items: center; gap: 4px; }
.ready-badge { background: var(--ready); color: #1a1200; font-weight: 800; font-size: 11px; border-radius: 999px; padding: 1px 6px; }
.cat-chips { display: none; gap: 6px; overflow-x: auto; padding: 6px 8px; background: var(--panel); border-bottom: 1px solid var(--line); scrollbar-width: none; }
.cat-chips::-webkit-scrollbar { display: none; }
.cat-chips .cat-btn { width: auto; padding: 5px 11px; border-radius: 999px; white-space: nowrap; background: var(--bg); border-color: var(--line); font-size: 13px; }
.cat-chips .cat-btn.active { background: var(--panel-2); border-color: var(--accent); }

.board { flex: 1; overflow-y: auto; padding: 10px 12px; min-width: 0; }
.group { margin-bottom: 14px; }
.group-head { display: flex; align-items: center; gap: 8px; padding: 4px 8px 6px; font-weight: 700; font-size: 14px; }
.group-head .bar { width: 4px; height: 16px; border-radius: 2px; }
.group-head .count { color: var(--muted); font-weight: 400; font-size: 12px; }
.group-head .add-here { margin-left: auto; opacity: .7; }
.group-head .add-here:hover { opacity: 1; }
.empty { color: var(--muted); padding: 12px; text-align: center; font-size: 13px; }

/* ---------- 환자 행 ---------- */
.row {
  display: grid; grid-template-columns: 44px 128px 108px minmax(180px, 2fr) 170px minmax(140px, 1.25fr) 68px;
  gap: 8px; align-items: center; padding: 7px 10px; margin-bottom: 5px;
  background: var(--panel); border-radius: var(--radius); border: 1px solid var(--line); border-left: 5px solid var(--prep);
  transition: background .2s, border-color .2s;
}
.row.calling { animation: pulse-ready 1.8s ease-in-out infinite; }
.row.s-inprog { border-left-color: var(--inprog); background: #2a1616; }
.row.s-recover { border-left-color: var(--recover); background: #10241a; }
.row.flash { animation: flash .9s ease-out; }
@keyframes flash { 0% { outline: 3px solid var(--accent); } 100% { outline: 3px solid transparent; } }
@keyframes pulse-ready { 0%, 100% { box-shadow: 0 0 0 0 rgba(245, 183, 28, 0); } 50% { box-shadow: 0 0 0 3px rgba(245, 183, 28, .35); } }
.cell { min-width: 0; }

/* 드롭다운 버튼 (pill) */
.pill { display: inline-flex; align-items: center; gap: 4px; max-width: 100%; padding: 6px 8px; border-radius: 8px; border: 1px solid var(--line); background: var(--bg); color: var(--text); font-weight: 600; font-size: 13px; text-align: left; }
.pill:hover { border-color: #3b4a73; background: #0f1830; }
.pill .txt { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pill .caret { color: var(--muted); font-size: 10px; margin-left: auto; flex-shrink: 0; }
.pill.empty .txt { color: var(--muted); font-weight: 400; }
.pill.doctor { width: 100%; justify-content: center; padding: 6px 4px; font-weight: 800; }
.pill.doctor.call { border-color: var(--ready); color: var(--ready); }
.pill.loc { width: 100%; }
.pill.status { width: 100%; border: none; color: #0b1220; }
.pill.status .caret { color: inherit; opacity: .6; }
.pill.status.prep { background: var(--prep); }
.pill.status.ready { background: var(--ready); }
.pill.status.inprog { background: var(--inprog); color: #fff; }
.pill.status.recover { background: var(--recover); }
.pill.status .elapsed { font-size: 11px; font-weight: 500; opacity: .8; margin-left: auto; white-space: nowrap; }

.cell-patient { cursor: pointer; }
.cell-patient .name { font-weight: 700; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cell-patient .chart { color: var(--muted); font-size: 12px; }
.cell-patient .cat-tag { font-size: 11px; color: var(--muted); }

.items { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; }
.chip { display: inline-flex; align-items: center; gap: 3px; padding: 3px 8px; border-radius: 999px; font-size: 12px; font-weight: 600; background: #26314d; border: 1px solid #344366; color: var(--text); cursor: pointer; user-select: none; -webkit-user-select: none; white-space: nowrap; }
.chip.surgery { background: #35275c; border-color: #5e49a3; }
.chip.procedure { background: #1b3a4f; border-color: #2b6b8f; }
.chip.done { background: #123d26; border-color: #22c55e; color: #a7f3c4; text-decoration: line-through; opacity: .8; }
.chip.done::before { content: none; }
.chip.add { background: transparent; border-style: dashed; color: var(--muted); font-weight: 500; }
.chip.add:hover { color: var(--text); }
.chip-sep { color: var(--muted); font-size: 12px; }

.cell-memo textarea, .cell-memo input { width: 100%; resize: none; min-height: 32px; max-height: 110px; padding: 6px 8px; border-radius: 8px; border: 1px solid transparent; background: rgba(0, 0, 0, .18); color: var(--text); line-height: 1.35; }
.cell-memo textarea:hover, .cell-memo input:hover { border-color: var(--line); }
.cell-memo textarea:focus, .cell-memo input:focus { border-color: var(--accent); outline: none; background: var(--bg); }
.cell-memo ::placeholder { color: #55617f; }
.cell-actions { display: flex; gap: 4px; justify-content: flex-end; }
.btn.done-btn { padding: 6px 7px; font-size: 12px; color: var(--muted); }
.btn.done-btn:hover { color: var(--text); }

/* ---------- 피드 ---------- */
.feed { width: 320px; background: var(--panel); border-left: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; }
.feed.collapsed { display: none; }
.feed-head { display: flex; align-items: center; justify-content: space-between; padding: 6px 8px; border-bottom: 1px solid var(--line); }
.feed-tabs { display: flex; gap: 4px; }
.feed-tab { background: transparent; border: 1px solid transparent; color: var(--muted); padding: 4px 8px; border-radius: 6px; font-size: 12px; }
.feed-tab.active { background: var(--panel-2); color: var(--text); border-color: var(--line); }
.feed-list { flex: 1; overflow-y: auto; padding: 8px; display: flex; flex-direction: column; gap: 6px; }
.feed-item { font-size: 12px; padding: 6px 8px; border-radius: 8px; background: var(--bg); border: 1px solid var(--line); }
.feed-item.msg { background: #182a40; border-color: #27476a; }
.feed-item.mine { background: #16331f; border-color: #2a6a42; }
.feed-item .meta { color: var(--muted); font-size: 11px; display: flex; gap: 6px; margin-bottom: 2px; }
.feed-item .meta .who { color: var(--text); font-weight: 600; }
.feed-item .pname { color: var(--accent); font-weight: 600; }
.feed-item .text { white-space: pre-wrap; word-break: break-word; font-size: 13px; }
.feed-item.ev-status .text b { color: var(--ready); }
.feed-form { border-top: 1px solid var(--line); padding: 6px 8px; display: flex; flex-direction: column; gap: 4px; }
.feed-form select { background: var(--bg); border: 1px solid var(--line); border-radius: 6px; padding: 4px 6px; font-size: 12px; }
.feed-input-row { display: flex; gap: 4px; }
.feed-input-row input { flex: 1; padding: 7px 8px; border-radius: 6px; border: 1px solid var(--line); background: var(--bg); color: var(--text); }

/* ---------- 드롭다운 메뉴 / 팝오버 ---------- */
.menu-backdrop { position: fixed; inset: 0; z-index: 149; }
.menu { position: fixed; z-index: 150; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 6px; min-width: 180px; max-width: calc(100vw - 16px); max-height: 70vh; overflow-y: auto; box-shadow: 0 12px 40px rgba(0, 0, 0, .55); }
.menu-title { font-size: 11px; color: var(--muted); font-weight: 600; padding: 4px 8px 6px; }
.menu-custom { display: flex; gap: 4px; padding: 2px 4px 6px; }
.menu-custom input { flex: 1; padding: 7px 9px; border-radius: 8px; border: 1px solid var(--line); background: var(--bg); color: var(--text); min-width: 0; }
.menu-item { display: flex; align-items: center; gap: 8px; width: 100%; padding: 9px 10px; border-radius: 8px; border: none; background: transparent; color: var(--text); text-align: left; font-size: 14px; }
.menu-item:hover { background: var(--panel-2); }
.menu-item.selected { background: var(--panel-2); font-weight: 700; }
.menu-item.selected::after { content: '✓'; margin-left: auto; color: var(--accent); }
.menu-item .sw { width: 12px; height: 12px; border-radius: 3px; flex-shrink: 0; }
.menu-item.danger { color: #fca5a5; }
.menu-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; padding: 2px; }
.menu-grid .menu-item { justify-content: center; padding: 8px 4px; font-size: 13px; background: var(--bg); border: 1px solid var(--line); }
.menu-grid .menu-item.selected { border-color: var(--accent); }
.menu-grid .menu-item.selected::after { content: none; }
.menu-sep { height: 1px; background: var(--line); margin: 4px 0; }
.menu.sheet { left: 0 !important; right: 0; bottom: 0; top: auto !important; max-width: none; border-radius: 16px 16px 0 0; padding: 10px 10px calc(10px + env(safe-area-inset-bottom)); max-height: 75vh; }
.menu.sheet .menu-item { padding: 12px 12px; font-size: 15px; }
.menu-section { padding: 2px 0; }
.menu-section .menu-title { padding-top: 8px; }
.chip-grid { display: flex; flex-wrap: wrap; gap: 5px; padding: 2px 4px 6px; }

/* ---------- 모달 ---------- */
.modal-backdrop { position: fixed; inset: 0; background: rgba(0, 0, 0, .55); z-index: 100; display: flex; align-items: center; justify-content: center; padding: 12px; }
.modal { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; width: 100%; max-width: 640px; max-height: 92vh; overflow-y: auto; padding: 16px; box-shadow: 0 20px 60px rgba(0, 0, 0, .6); }
.modal.wide { max-width: 900px; }
.modal h2 { margin: 0 0 12px; font-size: 17px; display: flex; align-items: center; justify-content: space-between; }
.modal h3 { margin: 16px 0 6px; font-size: 14px; color: var(--muted); }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.form-grid .full { grid-column: 1 / -1; }
.field label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 3px; }
.field input, .field select, .field textarea { width: 100%; padding: 8px 10px; border-radius: 8px; border: 1px solid var(--line); background: var(--bg); color: var(--text); }
.field textarea { min-height: 70px; resize: vertical; }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 14px; }
.modal .items { margin-top: 4px; }
.timeline { display: flex; flex-direction: column; gap: 4px; max-height: 50vh; overflow-y: auto; }
.tl-item { display: grid; grid-template-columns: 54px 70px 1fr; gap: 8px; font-size: 13px; padding: 5px 8px; background: var(--bg); border-radius: 6px; }
.tl-item .t { color: var(--muted); font-variant-numeric: tabular-nums; }
.tl-item .who { color: var(--accent); font-size: 12px; }
.tl-item.msg { background: #182a40; }
.list-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.list-table th, .list-table td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
.list-table th { color: var(--muted); font-size: 12px; font-weight: 600; }
.list-table tr.clickable { cursor: pointer; }
.list-table tr.clickable:hover td { background: var(--panel-2); }
.setting-row { display: flex; align-items: center; gap: 6px; padding: 4px 0; }
.setting-row input[type="text"] { flex: 1; padding: 6px 8px; border-radius: 6px; border: 1px solid var(--line); background: var(--bg); color: var(--text); }
.setting-row input[type="color"] { width: 32px; height: 28px; padding: 0; border: none; background: none; }
.check { display: flex; align-items: center; gap: 6px; padding: 3px 0; font-size: 13px; }
.doctor-filter { display: flex; flex-wrap: wrap; gap: 6px; margin-left: 20px; }
.doctor-filter label { display: flex; gap: 3px; align-items: center; font-size: 12px; background: var(--bg); padding: 3px 8px; border-radius: 999px; border: 1px solid var(--line); }
.hint { font-size: 12px; color: var(--muted); }
.search-results { margin-top: 6px; }

.toast { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); background: #0ea5e9; color: #082f49; font-weight: 600; padding: 10px 16px; border-radius: 10px; z-index: 200; box-shadow: 0 6px 24px rgba(0, 0, 0, .4); max-width: 90vw; font-size: 13px; }
.toast.err { background: #ef4444; color: #fff; }

/* ---------- 중간 폭 (노트북, 피드 열림) : 2줄 ---------- */
@media (min-width: 861px) and (max-width: 1360px) {
  .row, .board-head { grid-template-columns: 44px 150px 128px 1fr 44px; grid-template-areas: "doc pat loc status actions" "items items items memo memo"; }
  .cell-doctor { grid-area: doc; } .cell-patient { grid-area: pat; } .cell-loc { grid-area: loc; } .cell-status { grid-area: status; }
  .cell-actions { grid-area: actions; } .cell-items { grid-area: items; } .cell-memo { grid-area: memo; }
}

/* ---------- 모바일 ---------- */
@media (max-width: 860px) {
  .topbar { padding: 6px 8px; gap: 6px; }
  .brand { font-size: 15px; }
  #btnAdd .label, #btnMe .label, #btnDone .label { display: none; }
  .btn { padding: 6px 8px; }
  .clock, #btnFloat, #btnCompact, #btnCopyText, #opacityCtl { display: none; }
  #btnRole { font-size: 12px; }
  .topbar-search { order: 10; flex-basis: 100%; max-width: none; }
  .topbar-actions { margin-left: 0; }
  .layout { flex-direction: column; }
  .sidebar { display: none; }
  .cat-chips { display: flex; }
  .board { padding: 8px; }
  .row { grid-template-columns: 44px 1fr 118px; grid-template-areas: "doc pat loc" "status status status" "items items items" "memo memo actions"; padding: 8px 8px; gap: 6px; }
  .cell-doctor { grid-area: doc; } .cell-patient { grid-area: pat; } .cell-loc { grid-area: loc; } .cell-items { grid-area: items; }
  .cell-status { grid-area: status; } .cell-memo { grid-area: memo; } .cell-actions { grid-area: actions; }
  .pill.status { padding: 8px 10px; font-size: 14px; }
  .feed { position: fixed; inset: auto 0 0 0; height: 70vh; width: auto; border-left: none; border-top: 1px solid var(--line); border-radius: 14px 14px 0 0; z-index: 60; box-shadow: 0 -10px 40px rgba(0, 0, 0, .5); }
  .form-grid { grid-template-columns: 1fr; }
  .modal { padding: 12px; max-height: 94vh; }
  .tl-item { grid-template-columns: 44px 60px 1fr; }
}
@media (min-width: 861px) { #btnFeedClose { display: none; } }

/* ---------- 플로팅(소형) 모드: 환자 목록만, 좁고 낮게 ---------- */
body.float { font-size: 13px; }
body.float .topbar { padding: 4px 6px; gap: 4px; flex-wrap: nowrap; }
body.float .brand { font-size: 13px; }
body.float .brand #clinicName, body.float .clock, body.float .topbar-search, body.float #btnFloat, body.float #btnCopyText, body.float #btnMe, body.float #btnSettings, body.float #btnDone { display: none; }
body.float .topbar-actions { gap: 3px; }
body.float .btn { padding: 4px 7px; font-size: 12px; }
body.float #btnAdd .label { display: none; }
body.float #btnCompact { display: inline-block; }
body.float .sidebar, body.float .feed { display: none; }
body.float .cat-chips { display: flex; padding: 4px 6px; gap: 4px; }
body.float .cat-chips .cat-btn { padding: 3px 9px; font-size: 12px; }
body.float .board { padding: 6px; }
body.float .group { margin-bottom: 8px; }
body.float .group-head { padding: 2px 4px 4px; font-size: 12px; }
body.float .group-head .add-here { display: none; }
body.float .row {
  grid-template-columns: 30px minmax(56px, 1fr) minmax(64px, auto) 112px 40px; grid-template-areas: "doc pat loc status act" "items items items items items" "memo memo memo memo memo";
  gap: 4px 6px; padding: 5px 7px; margin-bottom: 4px; border-left-width: 4px; border-radius: 8px;
}
body.float .cell-doctor { grid-area: doc; } body.float .cell-patient { grid-area: pat; } body.float .cell-loc { grid-area: loc; } body.float .cell-status { grid-area: status; }
body.float .cell-items { grid-area: items; } body.float .cell-memo { grid-area: memo; } body.float .cell-actions { grid-area: act; }
body.float .pill { padding: 4px 6px; font-size: 12px; border-radius: 6px; }
body.float .pill.doctor { padding: 4px 2px; }
body.float .cell-patient .name { font-size: 13px; }
body.float .cell-patient .chart { display: inline; font-size: 11px; margin-left: 3px; }
body.float .chip { padding: 1px 6px; font-size: 11px; }
body.float .chip.add { padding: 1px 5px; }
body.float .cell-items:empty, body.float .cell-memo.empty { display: none; }
body.float .cell-memo input { min-height: 24px; padding: 2px 6px; font-size: 12px; background: transparent; }
body.float .cell-memo input:not(:focus) { border-color: transparent; }
body.float .items .chip-sep { display: none; }

/* ---------- 단계 / 직군 강조 / 분류 선택 ---------- */
.chip.step { background: #243247; border-color: #3a4c6b; }
.chip.current { font-weight: 800; }
.chip.current::before { content: none; }
.items .chip:not(.done):not(.current):not(.add) { opacity: .8; }
.chip.dragging { opacity: .3; }
.chip.over { outline: 2px dashed var(--accent); }
.chip-sep.all-done { color: var(--recover); font-weight: 700; }
.row.hot { box-shadow: inset 0 0 0 2px var(--accent); }
.row.hot .cell-patient .name::before { content: '👉 '; }
.cat-btn .chk { color: var(--muted); font-size: 13px; }
.cat-btn.active .chk { color: var(--accent); }
.cat-btn.off { opacity: .55; }
.cat-chips .cat-btn.off { opacity: .55; }
.chip.custom { background: #ffffff; border-color: #cbd5e1; color: var(--text); } /* 직접 입력: 흰색 */
.chip.step { background: #e0f2fe; border-color: #7dd3fc; color: #075985; }        /* 진행단계: 연한 파랑 */
body.float #btnRole { display: inline-block; }

/* ---------- 로그인 화면 ---------- */
.auth-form { max-width: 380px; margin: 0 auto; }
.auth-form .field { margin-bottom: 10px; }
.auth-msg { background: #3b1d1d; border: 1px solid #7f1d1d; color: #fecaca; padding: 8px 10px; border-radius: 8px; font-size: 13px; margin-top: 4px; }

/* ---------- 밝은 테마 (기본) ---------- */
.btn { background: #f7f9fc; }
.btn:hover { background: #e9edf4; }
.btn.primary { background: #0284c7; border-color: #0284c7; color: #fff; }
.btn.primary:hover { background: #0369a1; }
.btn.danger { background: #fee2e2; border-color: #fca5a5; color: #991b1b; }
.row { background: #fff; box-shadow: 0 1px 2px rgba(16, 24, 40, .06); }
.row.s-ready { background: #fff6dc; }
.row.s-inprog { background: #ffe9e9; }
.row.s-recover { background: #e7f8ee; }
.pill { background: #fff; }
.pill:hover { background: #f3f5f9; border-color: #b9c2d4; }
.pill.status.prep { color: #fff; }
.pill.status.inprog { color: #fff; }
.chip { background: #e9edf4; border-color: #cfd6e3; color: #1b2130; }
.chip.surgery { background: #fee2e2; border-color: #f87171; color: #991b1b; }     /* 수술: 빨강 */
.chip.procedure { background: #ffedd5; border-color: #fb923c; color: #9a3412; }   /* 시술: 주황 */
.chip.care { background: #ecfccb; border-color: #a3e635; color: #3f6212; }        /* 관리: 연두 */
.chip.done { background: #f1f5f9; border-color: #cbd5e1; color: #94a3b8; opacity: 1; } /* 완료: 회색 */
.chip.add { background: transparent; }
.cell-memo textarea, .cell-memo input { background: rgba(16, 24, 40, .04); }
.cell-memo textarea:focus, .cell-memo input:focus { background: #fff; }
.cell-memo ::placeholder { color: #9aa3b5; }
.feed-item.msg { background: #e8f3fb; border-color: #bcdcf0; }
.feed-item.mine { background: #e7f8ee; border-color: #a7e3bf; }
.feed-item.ev-status .text b { color: #b45309; }
.tl-item.msg { background: #e8f3fb; }
.menu { box-shadow: 0 12px 40px rgba(16, 24, 40, .2); }
.menu-grid .menu-item { background: #fff; }
.modal-backdrop { background: rgba(16, 24, 40, .35); }
.toast { background: #0284c7; color: #fff; }
.auth-msg { background: #fee2e2; border-color: #fca5a5; color: #991b1b; }
.ready-badge { color: #1a1200; }
.conn-dot.on { box-shadow: none; }
::-webkit-scrollbar-thumb { background: #c9d1df; }

/* ---------- 예약 ---------- */
.resv-nav { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; margin-bottom: 8px; }
.resv-nav input[type="date"] { padding: 5px 8px; border-radius: 8px; border: 1px solid var(--line); background: var(--panel); color: var(--text); }
.resv-days { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; margin-bottom: 8px; }
.resv-day { padding: 6px 2px; border-radius: 8px; border: 1px solid var(--line); background: var(--panel); color: var(--text); font-size: 12px; text-align: center; }
.resv-day .n { color: var(--muted); font-size: 11px; margin-top: 2px; }
.resv-day.today { border-color: var(--accent); }
.resv-day.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.resv-day.on .n { color: #e0f2fe; }
.resv-add { border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; background: var(--panel-2); }
.resv-add summary { cursor: pointer; font-weight: 700; font-size: 13px; }
.resv-add textarea { width: 100%; min-height: 90px; padding: 8px; border-radius: 8px; border: 1px solid var(--line); background: var(--panel); color: var(--text); resize: vertical; margin-top: 4px; }
.resv-add select { padding: 4px 6px; border-radius: 6px; border: 1px solid var(--line); background: var(--panel); }
.resv-row { display: grid; grid-template-columns: 64px 1fr auto; gap: 8px; align-items: center; padding: 7px 8px; border: 1px solid var(--line); border-radius: 10px; margin-bottom: 5px; background: var(--panel); }
.resv-row.st-arrived { background: #ecfdf3; border-color: #bbf7d0; }
.resv-row.st-noshow, .resv-row.st-cancelled, .resv-row.st-done { opacity: .55; }
.resv-badge.done { background: #e0e7ff; color: #3730a3; }
.resv-row .pill.resv-time { width: 100%; justify-content: center; font-variant-numeric: tabular-nums; }
.resv-name { cursor: pointer; min-width: 0; }
.resv-name .chart { color: var(--muted); font-size: 12px; }
.resv-name .hint { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.resv-actions { display: flex; gap: 4px; align-items: center; }
.resv-badge { font-size: 12px; font-weight: 700; padding: 3px 8px; border-radius: 999px; background: var(--panel-2); color: var(--muted); }
.resv-badge.arrived { background: #dcfce7; color: #166534; }
.resv-badge.noshow { background: #fee2e2; color: #991b1b; }
@media (max-width: 860px) {
  #btnResv .label { display: none; }
  .resv-days { grid-template-columns: repeat(7, minmax(64px, 1fr)); overflow-x: auto; }
  .resv-row { grid-template-columns: 56px 1fr; }
  .resv-actions { grid-column: 1 / -1; justify-content: flex-end; }
}
body.float #btnResv .label { display: none; }

/* ---------- 담당자 / 스마트닥터 붙여넣기 ---------- */
.cell-status { display: flex; gap: 4px; align-items: center; }
.cell-status .pill.status { flex: 1; min-width: 0; }
.assignee { flex-shrink: 0; max-width: 72px; padding: 6px 7px; border-radius: 8px; border: 1px solid var(--line); background: var(--panel); color: var(--text); font-size: 12px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.assignee:hover { border-color: var(--accent); }
.assignee.empty { color: var(--muted); font-weight: 400; border-style: dashed; }
.assignee.me { background: #e0f2fe; border-color: #7dd3fc; color: #075985; }
.phone-row { display: flex; gap: 6px; align-items: center; }
.phone-row input { flex: 1; }
.resv-memo { font-size: 12px; color: var(--text); opacity: .8; white-space: normal; line-height: 1.35; margin-top: 2px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.sd-import { border: 1px dashed #93c5fd; background: #f0f7ff; border-radius: 10px; padding: 8px 10px; margin-bottom: 8px; }
.sd-title { font-weight: 700; font-size: 13px; margin-bottom: 4px; }
.sd-import textarea { width: 100%; padding: 8px; border-radius: 8px; border: 1px solid var(--line); background: #fff; resize: vertical; }
.sd-table { max-height: 60vh; overflow-y: auto; border: 1px solid var(--line); border-radius: 10px; }
.sd-row { display: grid; grid-template-columns: 28px 64px 110px 80px 1fr 120px; gap: 6px; align-items: center; padding: 4px 8px; border-bottom: 1px solid var(--line); font-size: 13px; }
.sd-row input:not([type]) , .sd-row input[class] { width: 100%; padding: 4px 6px; border: 1px solid transparent; border-radius: 6px; background: transparent; }
.sd-row input:not([type="checkbox"]):hover, .sd-row input:not([type="checkbox"]):focus { border-color: var(--line); background: #fff; }
.sd-headrow { position: sticky; top: 0; background: var(--panel-2); font-weight: 700; color: var(--muted); font-size: 12px; z-index: 1; }
.sd-row.off { opacity: .4; }
.sd-row.dup { background: #f8fafc; }
.sd-st { font-size: 11px; color: var(--muted); }
.sd-st.cancel { color: #b91c1c; font-weight: 700; }
@media (max-width: 860px) { .sd-row { grid-template-columns: 24px 54px 1fr 70px; } .sd-row .sd-memo, .sd-row .sd-st, .sd-headrow span:nth-child(5), .sd-headrow span:nth-child(6) { display: none; } }
body.float .assignee { max-width: 46px; padding: 4px 5px; font-size: 11px; }

/* 데스크탑 플로팅 앱: 소형 모드에서도 항상 위 / 투명도 조절 표시 */
body.float.desktop-app #btnFloat { display: inline-block; }
body.float.desktop-app .topbar { flex-wrap: wrap; }
body.float.desktop-app .opacity-ctl span { display: none; }
body.float.desktop-app .opacity-ctl input { width: 64px; }
body.float.desktop-app #btnRole { max-width: 92px; overflow: hidden; text-overflow: ellipsis; }
body.desktop-app #opacityCtl { display: flex; }

/* ---------- 자체 대화상자 (prompt/confirm 대체) ---------- */
.dlg-backdrop { position: fixed; inset: 0; z-index: 300; background: rgba(16, 24, 40, .35); display: flex; align-items: center; justify-content: center; padding: 12px; }
.dlg { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 16px; width: 100%; max-width: 420px; box-shadow: 0 20px 60px rgba(16, 24, 40, .25); }
.dlg-title { font-weight: 700; font-size: 15px; margin-bottom: 8px; }
.dlg-msg { font-size: 14px; white-space: pre-wrap; line-height: 1.45; margin-bottom: 4px; }
.dlg-input { width: 100%; padding: 9px 10px; border-radius: 8px; border: 1px solid var(--line); background: var(--panel); color: var(--text); font-size: 14px; margin-top: 4px; }
textarea.dlg-input { min-height: 200px; resize: vertical; font-family: inherit; }
.dlg-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 12px; }

/* ---------- ⋯ 더보기: 소형 모드와 휴대폰에서만 ---------- */
#btnMore { display: none; }
body.float #btnMore { display: inline-block; }
@media (max-width: 860px) { #btnMore { display: inline-block; } }

/* ---------- 소형 모드에서도 💬 메시지 창 열기 ---------- */
body.float .feed:not(.collapsed) {
  display: flex; position: fixed; inset: auto 0 0 0; height: 72vh; width: auto; border-left: none; border-top: 1px solid var(--line);
  border-radius: 14px 14px 0 0; z-index: 60; box-shadow: 0 -10px 40px rgba(16, 24, 40, .2);
}
body.float #btnFeedClose { display: inline-block; }
body.desktop-app #btnCompact { display: inline-block; } /* 플로팅 앱: 좁은 창에서 전체 화면으로 바꿔도 소형으로 돌아올 버튼 유지 */

/* 자주 사용하는 세트 */
.chip.preset { background: #fef9c3; border-color: #facc15; color: #713f12; }
.menu-section:first-of-type .menu-grid .menu-item { font-weight: 600; }

/* ---------- 맨 위 열 제목 ---------- */
.board-head { display: grid; grid-template-columns: 44px 128px 108px minmax(180px, 2fr) 170px minmax(140px, 1.25fr) 68px; gap: 2px 8px;
  padding: 10px 10px 6px 15px; margin-top: -10px; position: sticky; top: -10px; z-index: 5; background: var(--bg);
  font-size: 12px; font-weight: 700; color: var(--muted); }
.board-head .cell-status { display: block; }
@media (max-width: 860px) { .board-head { display: none; } .drag-handle { display: none; } }
body.float .board-head, body.float .drag-handle { display: none; }
/* ---------- 환자 순서 끌기 ---------- */
.drag-handle { cursor: grab; color: #9aa3b5; margin-right: 4px; font-weight: 400; user-select: none; -webkit-user-select: none; }
.drag-handle:hover { color: var(--accent); }
.row.dragging-row { opacity: .4; }
.row.drop-before { box-shadow: 0 -3px 0 0 var(--accent); }
.row.drop-after { box-shadow: 0 3px 0 0 var(--accent); }
.order-btns { display: inline-flex; gap: 4px; align-items: center; margin-right: auto; }
.sw-dot { display: inline-block; width: 10px; height: 10px; border-radius: 3px; vertical-align: middle; }
.pill.status .elapsed { opacity: .85; }

/* 상태 메뉴: 큰 상태 이름(제목)을 눌러 세부 없이 선택 */
.menu-title-btn { display: flex; align-items: center; gap: 6px; width: 100%; border: 1px solid transparent; background: transparent; border-radius: 8px;
  padding: 6px 8px; margin-top: 4px; font-size: 13px; font-weight: 800; color: var(--text); text-align: left; cursor: pointer; }
.menu-title-btn:hover { background: var(--panel-2); border-color: var(--line); }
.menu-title-btn.selected { background: var(--panel-2); border-color: var(--accent); }
.menu-title-btn.selected::after { content: '✓'; margin-left: auto; color: var(--accent); }
.menu-title-btn .sw { width: 12px; height: 12px; border-radius: 3px; flex-shrink: 0; }

/* 스마트닥터 붙여넣기: 기존 예약 취소 처리 줄 */
.sd-row.sd-cancel { background: #fef2f2; }
.sd-row.sd-cancel input:not([type="checkbox"]) { text-decoration: line-through; color: #991b1b; }

/* 진행 단계 한 줄로 접기 */
.items.fit { flex-wrap: nowrap; overflow: hidden; }
.items.fit > * { flex-shrink: 0; }
.fit-hide { display: none !important; }
.chip.fit-more { background: var(--panel); border: 1px dashed #94a3b8; color: #475569; font-weight: 800; opacity: 1 !important; }
.chip.fit-more:hover { border-color: var(--accent); color: var(--accent); }
/* 예약 검색 */
.resv-search { width: 100%; padding: 9px 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--panel); color: var(--text); font-size: 14px; margin-bottom: 8px; }
.resv-date-label { display: block; margin: 10px 0 4px; padding: 4px 8px; border: none; background: transparent; color: var(--accent); font-weight: 800; font-size: 13px; cursor: pointer; }
.resv-date-label:hover { text-decoration: underline; }

/* 단계 추가 메뉴: 열어둔 채 계속 추가 */
.menu.keep-open .menu-head { display: flex; align-items: center; gap: 8px; position: sticky; top: -6px; z-index: 2; background: var(--panel); padding: 2px 0 4px; }
.menu.keep-open .menu-head .menu-title { flex: 1; padding-bottom: 2px; }
.menu-preview-wrap { position: sticky; top: 28px; z-index: 2; background: var(--panel); padding: 2px 4px 8px; border-bottom: 1px solid var(--line); margin-bottom: 4px; }
.menu-preview { display: flex; gap: 4px; align-items: center; overflow-x: auto; white-space: nowrap; padding: 4px 2px; scrollbar-width: thin; }
.menu-preview .chip { flex-shrink: 0; cursor: default; }
.menu-item.picked { animation: picked .6s ease-out; }
@keyframes picked { 0% { background: #bbf7d0; border-color: #22c55e; } 100% { background: inherit; } }

/* 스마트닥터 자동 연동으로 들어온 예약 */
.sd-tag { display: inline-block; font-size: 10px; font-weight: 800; color: #fff; background: #0e7490; border-radius: 4px; padding: 0 4px; margin-right: 5px; vertical-align: 1px; }

/* 귀가 / 원장 확인 버튼 (작게, 위아래로) */
.cell-actions { flex-direction: column; align-items: stretch; gap: 3px; }
.cell-actions .btn { padding: 3px 4px; font-size: 11px; }
.btn.ack-btn { color: #b91c1c; border-color: #fca5a5; background: #fff; font-weight: 700; }
.btn.ack-btn.on { background: #dc2626; border-color: #dc2626; color: #fff; }
.row.acked { outline: 3px solid #dc2626; outline-offset: -3px; }
.row.acked.calling { animation: none; } /* 원장님이 확인하면 깜빡임 멈춤 */
.ack-tag { display: inline-block; margin-left: 5px; font-size: 10px; font-weight: 800; color: #fff; background: #dc2626; border-radius: 4px; padding: 0 4px; vertical-align: 2px; }
body.float .cell-actions .btn { padding: 2px 2px; font-size: 10px; }
.menu-preview-wrap { display: flex; align-items: center; gap: 6px; }
.menu-preview-wrap .menu-preview { flex: 1; min-width: 0; }
.menu-preview-wrap .clear-steps { flex-shrink: 0; font-size: 11px; color: #b91c1c; }
/* 단계 추가 메뉴는 폭을 고정하고, 위 미리보기 줄은 옆으로 스크롤 */
.menu.keep-open:not(.sheet) { width: min(460px, calc(100vw - 16px)); }
.menu.keep-open .menu-preview-wrap { max-width: 100%; }

/* 환자별 메시지 말풍선 (이름 밑, 3분) */
.row-msgs { grid-row: 2; grid-column: 2 / -1; display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.msg-bubble { position: relative; display: flex; align-items: center; gap: 6px; background: #fef9c3; border: 1px solid #facc15; border-radius: 4px 10px 10px 10px; padding: 4px 8px; font-size: 13px; cursor: pointer; min-width: 0; animation: mbIn .25s ease-out; }
.msg-bubble::before { content: '└'; color: #a16207; margin-right: -2px; }
.msg-bubble .mb-who { font-weight: 800; color: #854d0e; flex-shrink: 0; }
.msg-bubble .mb-text { flex: 1; min-width: 0; white-space: pre-wrap; word-break: break-all; color: #1f2937; }
.msg-bubble .mb-time { color: #a16207; font-size: 11px; flex-shrink: 0; }
.msg-bubble .mb-pin { flex-shrink: 0; border: 1px solid #eab308; background: #fff; color: #854d0e; border-radius: 6px; font-size: 11px; padding: 1px 5px; cursor: pointer; }
.msg-bubble .mb-x { flex-shrink: 0; color: #a16207; font-weight: 800; padding: 0 2px; }
.msg-bubble:hover { background: #fef08a; }
@keyframes mbIn { from { opacity: 0; transform: translateY(-3px); } to { opacity: 1; transform: none; } }
.chip.msg-add { margin-left: 2px; background: transparent; border-style: dashed; font-weight: 500; cursor: pointer; }
body.float .chip.msg-add { padding: 1px 5px; }
@media (min-width: 861px) and (max-width: 1360px) {
  .row.has-msgs { grid-template-areas: "doc pat loc status actions" ". msgs msgs msgs msgs" "items items items memo memo"; }
  .row-msgs { grid-area: msgs; }
}
@media (max-width: 860px) {
  .row.has-msgs { grid-template-areas: "doc pat loc" ". msgs msgs" "status status status" "items items items" "memo memo actions"; }
  .row-msgs { grid-area: msgs; }
}
body.float .row.has-msgs { grid-template-areas: "doc pat loc status act" "msgs msgs msgs msgs msgs" "items items items items items" "memo memo memo memo memo"; }
body.float .row-msgs { grid-area: msgs; }
body.float .msg-bubble { font-size: 12px; padding: 3px 6px; gap: 4px; }
body.float .msg-bubble .mb-time { display: none; }

/* 직원 근무(휴무)표 */
.sch .modal-head { display: flex; align-items: center; gap: 8px; }
.sch .modal-head h2 { flex: 1; margin: 0; }
.sch-err { background: #fef2f2; border: 1px solid #fca5a5; color: #b91c1c; border-radius: 8px; padding: 8px 10px; margin: 8px 0; font-size: 13px; }
.sch-today { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 10px 0; }
.sch-day { border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; background: #f8fafc; }
.sch-day-h { font-weight: 800; margin-bottom: 6px; }
.sch-offs { display: flex; flex-direction: column; gap: 3px; font-size: 13px; }
.sch-off { display: flex; gap: 8px; }
.sch-off b { flex-shrink: 0; min-width: 58px; color: #475569; }
.sch-off span { white-space: pre-wrap; }
.sch-off.k-event b, .sch-off.k-event span { color: #6d28d9; }
.sch-off.k-leave b { color: #b45309; }
.sch-none { color: var(--muted); font-size: 13px; }
.sch-tabs { display: flex; gap: 4px; flex-wrap: wrap; margin: 6px 0; }
.sch-tabs .btn.on { background: #0ea5e9; color: #fff; border-color: #0ea5e9; }
.sch-title { margin: 8px 0 4px; font-size: 15px; }
.sch-scroll { overflow: auto; max-height: 58vh; border: 1px solid var(--line); border-radius: 8px; }
.sch-table { border-collapse: collapse; width: 100%; font-size: 12.5px; min-width: 760px; }
.sch-table th, .sch-table td { border: 1px solid #e2e8f0; padding: 4px 6px; vertical-align: top; white-space: pre-wrap; }
.sch-table thead th { position: sticky; top: 0; background: #f1f5f9; z-index: 1; }
.sch-table thead th.we { color: #dc2626; }
.sch-table tbody th { background: #f8fafc; text-align: left; white-space: nowrap; color: #475569; width: 70px; }
.sch-date td { background: #fffbeb; font-weight: 800; text-align: center; }
.sch-date td.other { color: #cbd5e1; }
.sch-event td, .sch-event th { background: #f5f3ff; color: #6d28d9; }
.sch-leave th { color: #b45309; }
.sch-table td.today { background: #e0f2fe; box-shadow: inset 2px 0 #0ea5e9, inset -2px 0 #0ea5e9; }
.sch-date td.today { background: #0ea5e9; color: #fff; }
.sch-files { display: flex; flex-wrap: wrap; gap: 4px; margin: 4px 0; }
body.float #btnSchedule { display: none; }
@media (max-width: 860px) { #btnSchedule .label { display: none; } .sch-today { grid-template-columns: 1fr; } }

/* 고정 메모 (메모 칸 밑) */
.pins { display: flex; flex-direction: column; gap: 2px; margin-top: 3px; }
.pin { display: flex; align-items: flex-start; gap: 4px; background: #fef2f2; border-left: 3px solid #dc2626; border-radius: 4px; padding: 2px 4px 2px 6px; color: #991b1b; font-weight: 700; font-size: 12.5px; }
.pin .pin-t { flex: 1; min-width: 0; white-space: pre-wrap; word-break: break-all; }
.pin .pin-x { flex-shrink: 0; border: none; background: none; color: #dc2626; cursor: pointer; font-size: 12px; padding: 0 2px; opacity: .55; }
.pin .pin-x:hover { opacity: 1; }
body.float .pin { font-size: 11.5px; }
.feed-pin { margin-left: auto; border: 1px solid #fca5a5; background: #fff; color: #b91c1c; border-radius: 6px; font-size: 11px; padding: 0 5px; cursor: pointer; }

/* 수술중: 얇은 한 줄 (원장 / 이름 / 위치 / 상태 / 메모 작게) */
.row.slim { padding-top: 3px; padding-bottom: 3px; row-gap: 3px; min-height: 0; }
.row.slim .cell-items, .row.slim .cell-actions, .row.slim .cell-patient > .chart { display: none; }
.row.slim .cell-status { grid-column: 5; }
.row.slim .cell-memo { grid-column: 6 / -1; display: flex; align-items: center; gap: 6px; min-width: 0; }
.row.slim .cell-memo.empty textarea, .row.slim .cell-memo.empty input { opacity: .5; }
.row.slim .cell-memo textarea, .row.slim .cell-memo input { flex: 1; min-width: 60px; height: 24px !important; min-height: 0; padding: 2px 6px; font-size: 12px; line-height: 18px; overflow: hidden; }
.row.slim .cell-memo textarea:focus { height: 64px !important; overflow: auto; }
.row.slim .pins { flex-direction: row; flex-wrap: nowrap; margin-top: 0; min-width: 0; overflow: hidden; flex-shrink: 1; }
.row.slim .pin { font-size: 11px; padding: 1px 4px 1px 5px; white-space: nowrap; }
.row.slim .pin .pin-t { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row.slim .pill { padding-top: 3px; padding-bottom: 3px; font-size: 12.5px; }
.row.slim .pill.status { padding-top: 3px; padding-bottom: 3px; }
.row.slim .cell-patient .name { font-size: 13.5px; }
.row.slim .doctor, .row.slim .pill.doctor { padding-top: 3px; padding-bottom: 3px; }
@media (min-width: 861px) and (max-width: 1360px) {
  .row.slim { grid-template-columns: 44px 150px 128px 170px 1fr; grid-template-areas: "doc pat loc status memo"; }
  .row.slim.has-msgs { grid-template-areas: "doc pat loc status memo" ". msgs msgs msgs msgs"; }
  .row.slim .cell-status { grid-area: status; } .row.slim .cell-memo { grid-area: memo; }
}
@media (max-width: 860px) {
  .row.slim { grid-template-columns: 40px 1fr auto 104px; grid-template-areas: "doc pat loc status" "memo memo memo memo"; padding: 4px 6px; gap: 3px 5px; }
  .row.slim.has-msgs { grid-template-areas: "doc pat loc status" ". msgs msgs msgs" "memo memo memo memo"; }
  .row.slim .cell-status { grid-area: status; } .row.slim .cell-memo { grid-area: memo; }
  .row.slim .cell-memo.empty { display: none; }
  .row.slim .pill.status { padding: 3px 6px; font-size: 12px; }
}
body.float .row.slim { grid-template-columns: 30px minmax(56px, 1fr) minmax(64px, auto) 112px; grid-template-areas: "doc pat loc status" "memo memo memo memo"; padding: 3px 7px; }
body.float .row.slim.has-msgs { grid-template-areas: "doc pat loc status" "msgs msgs msgs msgs" "memo memo memo memo"; }
body.float .row.slim .cell-memo.empty { display: none; }
body.float .row.slim .cell-status { grid-area: status; } body.float .row.slim .cell-memo { grid-area: memo; }
body.float .row.slim .cell-memo input { height: 20px !important; font-size: 11px; }
.chip.slim-msg { margin-left: 6px; padding: 0 4px; font-size: 11px; vertical-align: 1px; }

/* 근무표: 직군별 색 + 옆으로 밀어도 직군 칸 고정 */
.sch-table th.sch-role { position: sticky; left: 0; z-index: 2; background: var(--rc-bg, #f8fafc); color: var(--rc, #475569); border-left: 4px solid var(--rc, #cbd5e1); font-weight: 800; }
.sch-table thead th.sch-corner { position: sticky; left: 0; z-index: 3; }
.sch-table .sch-date th.sch-corner { position: sticky; left: 0; z-index: 2; background: #fffbeb; }
.sch-table tr.sch-rolerow td { background: var(--rc-row, transparent); }
.sch-table tr.sch-rolerow td.today { background: #e0f2fe; }
.sch-table tr.sch-event td { background: #f5f3ff; }
.sch-off b.sch-role { color: var(--rc); background: var(--rc-bg); border-radius: 4px; padding: 0 5px; }
.profile { display: inline-block; margin-left: 5px; font-size: 11px; font-weight: 700; color: #475569; background: #f1f5f9; border-radius: 4px; padding: 0 4px; vertical-align: 1px; }
.row.slim .cell-patient .name .profile { display: none; }
/* 근무표 실선 테두리 (옆으로 밀어도 고정 칸 테두리가 남도록 separate) */
.sch-table { border-collapse: separate; border-spacing: 0; border-top: 1px solid #64748b; border-left: 1px solid #64748b; }
.sch-table th, .sch-table td { border: none; border-right: 1px solid #94a3b8; border-bottom: 1px solid #94a3b8; }
.sch-table thead th { border-bottom: 2px solid #475569; }
.sch-table tr.sch-date td, .sch-table tr.sch-date th { border-top: 2px solid #475569; }
.sch-table th.sch-role, .sch-table th.sch-corner { border-right: 2px solid #475569; }
.sch-scroll { border: none; }

/* 예약 달력 */
.cal-head { display: flex; align-items: center; gap: 8px; margin: 10px 0 4px; }
.cal-head b { font-size: 16px; min-width: 100px; text-align: center; }
.cal-head .btn.on, .cal-btn.on { background: #0ea5e9; color: #fff; border-color: #0ea5e9; }
.cal-sum { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; font-weight: 700; margin-bottom: 6px; font-size: 13px; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.cal-w { text-align: center; font-size: 12px; font-weight: 700; color: #475569; padding: 2px 0; }
.cal-w.sun, .cal-d.sun .cal-n { color: #dc2626; } .cal-w.sat, .cal-d.sat .cal-n { color: #2563eb; }
.cal-d { display: flex; flex-direction: column; align-items: stretch; gap: 2px; min-height: 64px; padding: 4px 6px; border: 1px solid #cbd5e1; border-radius: 8px; background: #fff; cursor: pointer; text-align: left; font: inherit; color: inherit; min-width: 0; }
.cal-d:hover { border-color: #0ea5e9; background: #f0f9ff; }
.cal-d.other { opacity: .45; }
.cal-d.today { border: 2px solid #0ea5e9; }
.cal-n { font-size: 12px; font-weight: 700; }
.cal-t { font-size: 17px; font-weight: 800; text-align: center; color: #0f172a; }
.cal-t.none { color: #cbd5e1; font-weight: 400; }
.cal-gs { display: flex; flex-direction: column; gap: 1px; }
.cal-g { display: inline-block; font-size: 11px; font-weight: 700; color: var(--gc); background: color-mix(in srgb, var(--gc) 12%, #fff); border-radius: 4px; padding: 0 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cal-closed { font-size: 10.5px; color: #94a3b8; }
.cal-grid.detail .cal-d { min-height: 110px; }
.cal-grid.detail .cal-t { font-size: 14px; text-align: left; }
@media (max-width: 860px) { .cal-grid { gap: 2px; } .cal-d { padding: 3px; min-height: 52px; } .cal-t { font-size: 14px; } .cal-g { font-size: 10px; padding: 0 2px; } }
.resv.cal-mode .resv-add, .resv.cal-mode .sd-import, .resv.cal-mode .resv-days { display: none; }
.profile-in { display: flex; gap: 6px; } .profile-in select { width: 80px; }

/* 예약메모 줄 (자동, 직원 메모와 따로) */
.resv-memo-line { font-size: 12px; color: #334155; background: #f1f5f9; border-radius: 6px; padding: 2px 6px; margin-bottom: 3px; white-space: pre-wrap; word-break: break-all; }
body.float .resv-memo-line { font-size: 11px; margin-bottom: 2px; }
.row.slim .resv-memo-line { margin: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; flex: 0 1 auto; max-width: 50%; font-size: 11px; }

/* ===== 세로 간격 줄이기 (한 화면에 더 많은 환자) ===== */
.board { padding: 6px 10px; }
.board-head { padding-top: 2px; padding-bottom: 2px; }
.group { margin-bottom: 6px; }
.group-head { padding: 1px 6px 3px; font-size: 13px; }
.group-head .add-here { padding: 1px 7px; font-size: 11px; }
.row { padding: 3px 8px; margin-bottom: 3px; gap: 3px 8px; }
.pill { padding: 3px 7px; font-size: 12.5px; line-height: 1.25; }
.pill.doctor { padding: 3px 4px; }
.cell-patient .name { font-size: 14px; line-height: 1.2; }
.cell-patient .chart { font-size: 11px; line-height: 1.15; }
.cell-memo textarea, .cell-memo input { min-height: 26px; padding: 3px 6px; line-height: 1.3; }
.chip { padding: 1px 7px; line-height: 1.35; }
.items { gap: 3px; }
.cell-actions .btn { padding: 2px 4px; font-size: 11px; line-height: 1.2; }
/* 넓은 화면: 확인·귀가를 옆으로 나란히 (위아래로 쌓으면 줄이 두꺼워짐) */
@media (min-width: 1361px) { .cell-actions { flex-direction: row; align-items: center; justify-content: flex-end; gap: 3px; } }
.msg-bubble { padding: 2px 8px; font-size: 12.5px; }
.pin { padding: 1px 4px 1px 6px; }
@media (min-width: 861px) and (max-width: 1360px) {
  .row { grid-template-areas: "doc pat loc status actions" "items items items memo actions"; }
  .row.has-msgs { grid-template-areas: "doc pat loc status actions" ". msgs msgs msgs actions" "items items items memo actions"; }
  .cell-actions { align-self: stretch; justify-content: center; }
}
@media (max-width: 860px) {
  .row { padding: 5px 6px; gap: 4px; }
  .pill.status { padding: 4px 8px; font-size: 13px; }
}

/* ===== 플로팅 창도 세로 간격 줄이기 ===== */
body.float .board { padding: 4px 5px; }
body.float .group { margin-bottom: 4px; }
body.float .group-head { padding: 0 4px 2px; font-size: 11.5px; }
body.float .row {
  grid-template-areas: "doc pat loc status act" "items items items items act" "memo memo memo memo memo";
  gap: 3px 5px; padding: 3px 6px; margin-bottom: 3px;
}
body.float .row.has-msgs { grid-template-areas: "doc pat loc status act" "msgs msgs msgs msgs act" "items items items items act" "memo memo memo memo memo"; }
body.float .cell-actions { align-self: stretch; justify-content: center; gap: 2px; }
body.float .cell-actions .btn { padding: 1px 2px; line-height: 1.2; }
body.float .pill { padding: 2px 6px; line-height: 1.25; }
body.float .pill.doctor { padding: 2px 2px; }
body.float .chip { padding: 0 6px; line-height: 1.4; }
body.float .cell-memo input { min-height: 20px; padding: 1px 6px; }
body.float .msg-bubble { padding: 1px 6px; }

/* ===== 분류 제목: 색 띠 대신 '구분선' 모양 (환자 카드와 다르게 보이도록) =====
   굵은 진한 글씨 + 작은 분류 색 점 + 회색 인원 + 아래 진한 밑줄. 배경은 바탕색이라 카드처럼 안 보임. 스크롤해도 위에 고정 */
.group-head {
  position: sticky; top: -6px; z-index: 6;
  background: var(--bg); border: none; border-bottom: 2px solid #475569; border-radius: 0;
  padding: 8px 2px 3px; margin: 0 0 5px; font-size: 15px; font-weight: 800; letter-spacing: -.2px; color: #0f172a;
}
.group:first-child .group-head { padding-top: 2px; }
.group-head .bar { display: inline-block; width: 10px; height: 10px; border-radius: 50%; background: var(--cat, #64748b); flex-shrink: 0; }
.group-head .count { background: #e2e8f0; color: #334155; font-size: 12px; font-weight: 700; border-radius: 999px; padding: 0 8px; }
.group-head .add-here { margin-left: auto; }
.group { margin-bottom: 4px; }
body.float .group-head { top: -4px; padding: 5px 1px 2px; font-size: 13px; border-bottom-width: 1.5px; margin-bottom: 3px; }
body.float .group:first-child .group-head { padding-top: 1px; }
body.float .group-head .bar { width: 8px; height: 8px; }
body.float .group-head .count { font-size: 11px; padding: 0 6px; }

/* ===== 플로팅 창: 한 번에 더 많은 환자 ===== */
#btnCats { display: none; }
body.float #btnCats { display: inline-block; position: relative; }
#btnCats .dot { position: absolute; top: 1px; right: 1px; width: 7px; height: 7px; border-radius: 50%; background: #ef4444; }
body.float:not(.cats-open) .cat-chips { display: none; }
body.float .topbar { padding: 2px 4px; gap: 3px; }
body.float .topbar .btn { padding: 2px 6px; font-size: 12px; }
body.float .conn-dot { margin: 0 2px; }
body.float .board { padding: 2px 4px; }
body.float .group { margin-bottom: 2px; }
body.float .group-head { padding: 3px 1px 1px; font-size: 12.5px; margin-bottom: 2px; line-height: 1.25; }
body.float .group:first-child .group-head { padding-top: 0; }
body.float .row { margin-bottom: 2px; padding: 2px 5px; }
body.float .cat-chips { padding: 2px 4px; }

/* '…대기' 가 오래되면 깜빡임 (1초 주기, 너무 빠르지 않게) */
@keyframes wait-blink { 0%, 100% { filter: none; box-shadow: 0 0 0 0 rgba(220, 38, 38, 0); } 50% { filter: brightness(1.25) saturate(1.2); box-shadow: 0 0 0 3px rgba(220, 38, 38, .75); } }
.row.wait-long .pill.status { animation: wait-blink 1s ease-in-out infinite; }
.row.wait-long .pill.status .elapsed { background: #dc2626; color: #fff; font-weight: 800; border-radius: 4px; padding: 0 4px; opacity: 1; }
@media (prefers-reduced-motion: reduce) { .row.wait-long .pill.status { animation: none; box-shadow: 0 0 0 3px rgba(220, 38, 38, .75); } }

/* 폰 알림 설정 */
.push-box { display: flex; flex-direction: column; gap: 6px; }
.push-howto { background: #fff7ed; border: 1px solid #fdba74; color: #9a3412; border-radius: 8px; padding: 8px 10px; font-size: 13px; line-height: 1.5; }
.push-prefs { border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; display: flex; flex-direction: column; gap: 4px; }
.push-prefs .pp-h { font-weight: 700; font-size: 12.5px; margin-top: 4px; }
.push-prefs .pp-row { display: flex; flex-wrap: wrap; gap: 4px 12px; }
.push-prefs label.chk { font-size: 13px; display: inline-flex; align-items: center; gap: 3px; }
@keyframes row-flash { 0%, 100% { box-shadow: none; } 30% { box-shadow: 0 0 0 3px #0ea5e9; } }
.row.flash { animation: row-flash 1.2s ease-in-out 2; }

/* 아이폰: 화면 맨 위 시계·배터리 줄(상태바) 밑으로 내려서 시작 (그 자리에서는 Safari가 흐리게 처리함).
   PC·안드로이드에서는 값이 0 이라 변화 없음 */
.topbar { padding-top: calc(8px + env(safe-area-inset-top, 0px)); padding-left: calc(12px + env(safe-area-inset-left, 0px)); padding-right: calc(12px + env(safe-area-inset-right, 0px)); }
@media (max-width: 860px) { .topbar { padding-top: calc(6px + env(safe-area-inset-top, 0px)); padding-left: calc(8px + env(safe-area-inset-left, 0px)); padding-right: calc(8px + env(safe-area-inset-right, 0px)); } }
body.float .topbar { padding-top: calc(2px + env(safe-area-inset-top, 0px)); }
.board { padding-bottom: calc(10px + env(safe-area-inset-bottom, 0px)); }
@media (max-width: 860px) { .feed { padding-bottom: env(safe-area-inset-bottom, 0px); } }
.modal-backdrop { padding-top: calc(12px + env(safe-area-inset-top, 0px)); padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px)); }

.push-devs { display: flex; flex-direction: column; gap: 3px; }
.push-dev { display: flex; align-items: center; gap: 6px; font-size: 12.5px; border: 1px solid var(--line); border-radius: 6px; padding: 3px 6px; }
.push-dev .hint { flex: 1; min-width: 0; word-break: break-all; }
.push-dev.bad { border-color: #fca5a5; background: #fef2f2; }
