:root {
  color-scheme: light;
  --ink: #0f3048;
  --ink-soft: #254d68;
  --muted: #657b8b;
  --line: #d7e2e8;
  --paper: #f3f7f9;
  --white: #ffffff;
  --blue: #087f94;
  --blue-dark: #056276;
  --blue-soft: #d9f1f4;
  --green: #247b52;
  --green-soft: #ddf5e7;
  --amber: #a86613;
  --amber-soft: #fff1c9;
  --red: #b93232;
  --red-soft: #ffe2e2;
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Kaku Gothic ProN", "Yu Gothic", Meiryo, sans-serif;
}

* { box-sizing: border-box; }
html { min-width: 320px; background: var(--paper); }
body { margin: 0; color: var(--ink); background: var(--paper); -webkit-tap-highlight-color: transparent; }
button { font: inherit; touch-action: manipulation; }
button:focus-visible { outline: 4px solid rgba(8, 127, 148, .3); outline-offset: 2px; }
.app-shell { min-height: 100vh; display: grid; grid-template-columns: 228px minmax(0, 1fr); }
.sidebar { background: var(--ink); color: white; padding: 28px 18px 22px; display: flex; flex-direction: column; gap: 24px; }
.brand-block { display: flex; align-items: center; gap: 12px; }
.brand-mark { width: 48px; height: 48px; flex: 0 0 48px; border: 1px solid rgba(255,255,255,.4); border-radius: 15px; display: grid; place-items: center; color: #8ee3ed; font-size: 24px; font-weight: 800; }
.sidebar h1 { font-size: 17px; margin: 4px 0 0; font-weight: 700; }
.eyebrow { color: var(--muted); font-size: 11px; font-weight: 800; letter-spacing: .12em; margin: 0; text-transform: uppercase; }
.eyebrow.light { color: #9be7ee; }
.sidebar .eyebrow { color: #9be7ee; }
.primary-nav { display: grid; gap: 8px; margin-top: 20px; }
.nav-item { min-height: 58px; border: 0; background: transparent; color: #c3d2dc; text-align: left; padding: 12px 14px; border-radius: 12px; cursor: pointer; display: flex; align-items: center; gap: 12px; font-size: 15px; font-weight: 700; }
.nav-item:hover, .nav-item.active { background: rgba(255,255,255,.12); color: white; }
.nav-icon { width: 23px; text-align: center; color: #8ee3ed; font-size: 21px; line-height: 1; }
.sidebar-note { margin-top: auto; color: #c3d2dc; font-size: 13px; line-height: 1.6; border-top: 1px solid rgba(255,255,255,.14); padding: 18px 4px 0; }
.sidebar-note small { display: block; color: #829ab1; margin-top: 3px; }
.status-dot { width: 9px; height: 9px; display: inline-block; background: #68d391; border-radius: 50%; margin-right: 6px; }
.main-content { max-width: 1340px; width: 100%; margin: 0 auto; padding: 30px 38px 64px; }
.topbar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 26px; }
.topbar h2 { margin: 6px 0 0; font-size: clamp(24px, 3vw, 31px); letter-spacing: -.03em; }
.topbar-actions { display: flex; align-items: center; gap: 12px; }
.live-badge { min-height: 42px; display: inline-flex; align-items: center; background: var(--green-soft); color: var(--green); padding: 0 14px; border-radius: 999px; font-size: 13px; font-weight: 800; white-space: nowrap; }
.pulse { width: 9px; height: 9px; display: inline-block; border-radius: 50%; background: #48bb78; margin-right: 7px; }
.icon-button { min-width: 54px; min-height: 50px; border: 1px solid var(--line); background: white; border-radius: 12px; cursor: pointer; color: var(--ink); font-size: 22px; display: inline-flex; align-items: center; justify-content: center; gap: 7px; font-weight: 800; box-shadow: 0 1px 2px rgba(15, 48, 72, .04); }
.icon-button .button-label { font-size: 14px; }
.hero-panel { min-height: 142px; display: flex; justify-content: space-between; align-items: center; background: linear-gradient(120deg, #123d5a, #087f94); color: white; padding: 28px 32px; border-radius: 20px; margin-bottom: 27px; box-shadow: 0 8px 20px rgba(15, 48, 72, .1); }
.hero-panel h3 { font-size: clamp(18px, 2.5vw, 22px); margin: 9px 0 7px; }
.hero-panel p:not(.eyebrow) { color: #d9f1f4; margin: 0; font-size: 14px; line-height: 1.7; }
.hero-symbol { color: #9be7ee; font-size: 76px; font-weight: 200; line-height: 1; padding-right: 10px; }
.section-heading { display: flex; justify-content: space-between; align-items: end; }
.summary-heading { margin-bottom: 12px; }
.queue-heading { margin: 34px 0 12px; }
.section-heading h3 { margin: 5px 0 0; font-size: 20px; }
.helper-text, .last-updated { color: var(--muted); font-size: 13px; }
.metric-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 13px; }
.metric { min-height: 132px; text-align: left; position: relative; border: 2px solid transparent; background: var(--white); padding: 18px 18px 14px; border-radius: 16px; cursor: pointer; color: var(--ink); box-shadow: 0 3px 10px rgba(15, 48, 72, .045); transition: border-color .15s, transform .15s, box-shadow .15s; }
.metric:hover, .metric.active { border-color: var(--blue); box-shadow: 0 5px 14px rgba(8, 127, 148, .12); }
.metric:active, .primary-button:active, .secondary-button:active, .filter:active, .nav-item:active { transform: scale(.985); }
.metric-label { display: block; color: var(--muted); font-size: 14px; font-weight: 700; }
.metric-value { display: block; font-size: 38px; line-height: 1; font-weight: 850; margin-top: 12px; }
.metric-value.blue { color: var(--blue); }
.metric-value.amber { color: var(--amber); }
.metric-value.green { color: var(--green); }
.metric-value.red { color: var(--red); }
.metric-link { position: absolute; right: 16px; bottom: 16px; color: var(--muted); font-size: 12px; font-weight: 700; }
.metric-link span { color: var(--blue); font-size: 19px; vertical-align: -1px; }
.filter-row { display: flex; gap: 9px; margin-bottom: 14px; overflow-x: auto; padding: 2px 2px 5px; scrollbar-width: thin; }
.filter { min-height: 48px; border: 1px solid var(--line); background: white; color: var(--muted); border-radius: 999px; padding: 0 17px; cursor: pointer; white-space: nowrap; font-size: 14px; font-weight: 700; }
.filter.active { background: var(--ink); border-color: var(--ink); color: white; }
.visit-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 13px; }
.visit-card { min-height: 184px; display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 14px 18px; background: white; border: 1px solid var(--line); border-radius: 17px; padding: 20px 21px; box-shadow: 0 3px 10px rgba(15, 48, 72, .04); }
.visit-main { min-width: 0; }
.visit-id { color: var(--muted); font-size: 12px; font-family: ui-monospace, monospace; }
.visit-name { font-size: 21px; font-weight: 850; margin: 9px 0 0; overflow-wrap: anywhere; }
.honorific { font-size: .65em; font-weight: 700; color: var(--muted); margin-left: 3px; }
.status-stack { grid-column: 1 / -1; display: flex; align-items: center; justify-content: space-between; gap: 10px; min-width: 0; }
.status-badge { display: inline-flex; align-items: center; min-height: 36px; width: fit-content; border-radius: 8px; padding: 0 12px; font-size: 14px; font-weight: 850; white-space: nowrap; }
.status-OUTSIDE_WAITING { background: var(--blue-soft); color: #0c6171; }
.status-RETURN_REQUESTED, .status-REMINDER_SENT { background: var(--amber-soft); color: #975a16; }
.status-ATTENTION_REQUIRED { background: var(--red-soft); color: var(--red); }
.status-RETURNED { background: var(--green-soft); color: var(--green); }
.status-CANCELLED, .status-CLOSED { background: #edf2f7; color: var(--muted); }
.notification { min-width: 0; color: var(--muted); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.notification-dot { width: 8px; height: 8px; display: inline-block; border-radius: 50%; background: #06c755; margin-right: 5px; }
.actions { display: flex; gap: 8px; justify-content: stretch; }
.primary-button, .secondary-button { min-height: 56px; border-radius: 11px; padding: 0 18px; cursor: pointer; font-size: 15px; font-weight: 850; white-space: nowrap; }
.primary-button { border: 1px solid var(--blue); background: var(--blue); color: white; box-shadow: 0 3px 7px rgba(8, 127, 148, .18); }
.primary-button:hover { background: var(--blue-dark); }
.secondary-button { border: 1px solid var(--line); background: white; color: var(--ink); }
.primary-button:disabled, .secondary-button:disabled { opacity: .45; cursor: not-allowed; box-shadow: none; }
.action-button { min-width: 178px; }
.toast { position: fixed; left: 50%; bottom: max(24px, env(safe-area-inset-bottom)); z-index: 4; max-width: min(90vw, 520px); background: var(--ink); color: white; padding: 15px 20px; border-radius: 12px; opacity: 0; transform: translate(-50%, 10px); pointer-events: none; transition: .2s; font-size: 15px; font-weight: 700; box-shadow: 0 8px 25px rgba(15, 48, 72, .2); }
.toast.error { background: var(--red); }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.hidden { display: none !important; }
.patient-header { background: #e6f6f7; border: 1px solid #c6e8eb; padding: 30px; border-radius: 20px; margin-bottom: 18px; }
.line-bubble { width: 56px; height: 34px; border-radius: 17px; background: #06c755; color: white; display: grid; place-items: center; font-size: 12px; font-weight: 850; margin-bottom: 24px; }
.patient-header h3 { font-size: 26px; margin: 8px 0; }
.patient-header p:last-child { color: #52606d; font-size: 14px; line-height: 1.7; margin: 0; }
.patient-card-wrap { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.patient-card { background: white; border: 1px solid var(--line); border-radius: 17px; padding: 23px; box-shadow: 0 3px 10px rgba(15, 48, 72, .04); }
.patient-card h4 { margin: 11px 0 16px; font-size: 23px; }
.patient-message { color: #52606d; min-height: 51px; font-size: 15px; line-height: 1.8; }
.patient-card .primary-button { width: 100%; margin-top: 14px; min-height: 62px; font-size: 17px; }
.empty { color: var(--muted); background: white; border: 1px dashed var(--line); padding: 45px 30px; text-align: center; border-radius: 16px; display: grid; justify-items: center; gap: 7px; font-size: 14px; }
.empty strong { color: var(--ink); font-size: 16px; }
.empty-icon { width: 38px; height: 38px; display: grid; place-items: center; border-radius: 50%; background: var(--green-soft); color: var(--green); font-size: 20px; font-weight: 850; margin-bottom: 4px; }
.modal-backdrop { position: fixed; inset: 0; z-index: 5; display: grid; place-items: center; padding: 20px; background: rgba(15, 48, 72, .48); }
.confirm-dialog { width: min(100%, 490px); background: white; border-radius: 20px; padding: 30px; box-shadow: 0 15px 45px rgba(15, 48, 72, .25); }
.confirm-icon { width: 42px; height: 42px; display: grid; place-items: center; border-radius: 50%; background: var(--amber-soft); color: var(--amber); font-size: 22px; font-weight: 900; margin-bottom: 20px; }
.confirm-dialog h3 { font-size: 22px; margin: 8px 0 12px; }
.confirm-message { color: #52606d; font-size: 15px; line-height: 1.8; margin: 0; }
.confirm-actions { display: grid; grid-template-columns: 1fr 1.35fr; gap: 10px; margin-top: 26px; }
.confirm-actions .primary-button, .confirm-actions .secondary-button { width: 100%; }
@media (max-width: 1100px) {
  .app-shell { display: block; }
  .sidebar { padding: 14px 18px 12px; display: flex; flex-direction: row; align-items: center; gap: 18px; }
  .brand-mark { width: 44px; height: 44px; flex-basis: 44px; }
  .sidebar h1 { font-size: 16px; }
  .primary-nav { display: flex; gap: 6px; margin: 0 0 0 auto; }
  .nav-item { min-height: 52px; padding: 8px 13px; }
  .sidebar-note { display: none; }
  .main-content { padding: 25px 24px 56px; }
}
@media (max-width: 820px) {
  .sidebar { align-items: stretch; overflow-x: auto; }
  .brand-block { flex: 0 0 auto; align-items: center; }
  .primary-nav { flex: 1 0 auto; margin-left: auto; }
  .nav-item { font-size: 14px; }
  .nav-icon { display: none; }
  .main-content { padding: 22px 16px 50px; }
  .topbar { align-items: flex-start; margin-bottom: 20px; }
  .topbar-actions { gap: 7px; }
  .live-badge { min-height: 40px; padding: 0 10px; font-size: 12px; }
  .icon-button { min-width: 50px; min-height: 48px; }
  .icon-button .button-label { display: none; }
  .hero-panel { min-height: 140px; padding: 23px 22px; border-radius: 17px; }
  .hero-symbol { font-size: 58px; padding-right: 0; }
  .metric-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .metric { min-height: 120px; padding: 15px; }
  .metric-value { font-size: 34px; }
  .metric-link { right: 13px; bottom: 13px; }
  .helper-text { font-size: 12px; }
  .visit-list, .patient-card-wrap { grid-template-columns: 1fr; }
  .visit-card { min-height: 0; padding: 18px; }
  .visit-name { font-size: 20px; }
  .actions { grid-column: 1 / -1; }
  .action-button { width: 100%; min-height: 60px; }
  .patient-header { padding: 24px; }
  .patient-header h3 { font-size: 23px; }
}
@media (max-width: 520px) {
  .sidebar { padding-left: 12px; padding-right: 12px; gap: 10px; }
  .brand-mark { width: 40px; height: 40px; flex-basis: 40px; border-radius: 12px; font-size: 21px; }
  .sidebar h1 { font-size: 14px; }
  .sidebar .eyebrow { font-size: 9px; }
  .nav-item { min-height: 48px; padding: 7px 10px; font-size: 12px; }
  .topbar-copy { min-width: 0; }
  .topbar h2 { font-size: 23px; }
  .live-badge { font-size: 0; width: 40px; padding: 0; justify-content: center; }
  .live-badge .pulse { margin: 0; }
  .hero-panel { align-items: flex-start; }
  .hero-symbol { display: none; }
  .section-heading { align-items: flex-end; }
  .section-heading h3 { font-size: 18px; }
  .helper-text { max-width: 120px; text-align: right; line-height: 1.4; }
  .status-stack { align-items: flex-start; flex-direction: column; gap: 7px; }
  .notification { max-width: 100%; }
  .confirm-dialog { padding: 24px 20px; }
}
@media (pointer: coarse) {
  .primary-button, .secondary-button { min-height: 60px; }
  .filter { min-height: 52px; }
  .nav-item { min-height: 58px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; animation-duration: .01ms !important; }
}
