@import url("https://fonts.googleapis.com/css2?family=DM+Sans:wght@400;500;600;700&family=Noto+Sans+Thai:wght@400;500;600;700&display=swap");

:root {
  color-scheme: light;
  --ink: #17324d;
  --muted: #6b7d8d;
  --subtle: #8c9aa7;
  --line: #dce5e8;
  --line-strong: #cbd8dc;
  --canvas: #f2f8f8;
  --surface: #ffffff;
  --surface-soft: #f7fafb;
  --teal: #0f7185;
  --teal-dark: #0a5c6e;
  --teal-soft: #e1f2f2;
  --confirmed: #36a68d;
  --confirmed-soft: #dff4ee;
  --waitlist: #d7a927;
  --waitlist-soft: #fff3cc;
  --coordination: #6d83b3;
  --coordination-soft: #e4ebf8;
  --danger: #c44b53;
  --danger-soft: #fdebed;
  --shadow: 0 24px 70px rgba(35, 73, 86, 0.13), 0 2px 8px rgba(35, 73, 86, 0.06);
  --slot-height: 104px;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  background: var(--canvas);
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  color: var(--ink);
  font-family: "Noto Sans Thai", "DM Sans", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.5;
  background: var(--canvas);
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  color: inherit;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 3px solid rgba(15, 113, 133, 0.22);
  outline-offset: 2px;
}

[hidden] {
  display: none !important;
}

.page-grid {
  position: fixed;
  inset: 0;
  z-index: -1;
  background-image:
    linear-gradient(rgba(20, 95, 110, 0.045) 1px, transparent 1px),
    linear-gradient(90deg, rgba(20, 95, 110, 0.045) 1px, transparent 1px),
    radial-gradient(circle at 15% 0%, rgba(62, 165, 174, 0.11), transparent 30%),
    radial-gradient(circle at 90% 20%, rgba(109, 131, 179, 0.08), transparent 28%);
  background-size: 28px 28px, 28px 28px, auto, auto;
}

.app-shell {
  width: min(1180px, calc(100% - 40px));
  min-height: calc(100vh - 40px);
  margin: 20px auto;
  overflow: hidden;
  border: 1px solid rgba(188, 207, 211, 0.75);
  border-radius: 26px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.app-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  padding: 28px 28px 18px;
}

.title-wrap {
  min-width: 0;
}

.eyebrow,
.section-kicker {
  margin: 0 0 5px;
  color: var(--teal);
  font-family: "DM Sans", sans-serif;
  font-size: 0.69rem;
  font-weight: 700;
  letter-spacing: 0.2em;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 4px;
  font-size: clamp(1.55rem, 3vw, 2.15rem);
  line-height: 1.25;
  letter-spacing: -0.025em;
}

.subtitle {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 9px;
}

.icon-button,
.small-button,
.view-tab,
.today-button,
.sync-chip {
  border: 1px solid var(--line);
  background: var(--surface);
  cursor: pointer;
  transition: border-color 160ms ease, background 160ms ease, color 160ms ease, transform 160ms ease, box-shadow 160ms ease;
}

.icon-button:hover,
.small-button:hover,
.today-button:hover,
.sync-chip:hover {
  border-color: #b7cacf;
  background: var(--surface-soft);
}

.icon-button:active,
.small-button:active,
.today-button:active,
.view-tab:active,
.button:active {
  transform: translateY(1px);
}

.icon-button:disabled,
.slot-cell:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.icon-button {
  display: inline-grid;
  width: 44px;
  height: 44px;
  flex: 0 0 auto;
  place-items: center;
  padding: 0;
  border-radius: 12px;
}

.icon-button.primary {
  border-color: var(--teal);
  color: #fff;
  background: var(--teal);
  box-shadow: 0 8px 20px rgba(15, 113, 133, 0.18);
}

.icon-button.primary:hover {
  border-color: var(--teal-dark);
  background: var(--teal-dark);
}

.icon-button.compact {
  width: 40px;
  height: 40px;
}

.icon-button svg,
.small-button svg,
.view-tab svg,
.guide-bar svg,
.metric-icon svg,
.empty-icon svg,
.danger-mark svg {
  width: 21px;
  height: 21px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.sync-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 38px;
  padding: 7px 12px;
  border-radius: 999px;
  color: var(--muted);
  font-size: 0.76rem;
  white-space: nowrap;
}

.sync-chip:disabled {
  cursor: default;
}

.sync-dot {
  width: 8px;
  height: 8px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: var(--confirmed);
  box-shadow: 0 0 0 4px var(--confirmed-soft);
}

.sync-chip.loading .sync-dot {
  background: var(--waitlist);
  box-shadow: 0 0 0 4px var(--waitlist-soft);
  animation: pulse 1.2s infinite;
}

.sync-chip.error .sync-dot {
  background: var(--danger);
  box-shadow: 0 0 0 4px var(--danger-soft);
}

@keyframes pulse {
  50% { opacity: 0.45; }
}

.planner-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 0 28px 18px;
}

.view-switcher {
  display: flex;
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #edf3f4;
}

.view-tab {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 40px;
  padding: 8px 13px;
  border-color: transparent;
  border-radius: 10px;
  color: var(--muted);
  background: transparent;
  font-size: 0.82rem;
  font-weight: 600;
}

.view-tab svg {
  width: 18px;
  height: 18px;
}

.view-tab:hover {
  color: var(--ink);
}

.view-tab.active {
  color: var(--teal);
  background: #fff;
  box-shadow: 0 2px 8px rgba(32, 70, 82, 0.1);
}

.date-navigator {
  display: flex;
  align-items: center;
  gap: 7px;
}

.small-button,
.today-button {
  height: 38px;
  border-radius: 10px;
}

.small-button {
  display: inline-grid;
  width: 38px;
  place-items: center;
  padding: 0;
}

.small-button svg {
  width: 18px;
  height: 18px;
}

.today-button {
  padding: 0 13px;
  color: var(--teal);
  background: var(--teal-soft);
  font-size: 0.8rem;
  font-weight: 700;
}

.date-display {
  min-width: 270px;
  margin: 0 0 0 14px;
  color: var(--ink);
  font-size: 0.95rem;
  font-weight: 700;
  text-align: right;
}

.guide-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  min-height: 48px;
  padding: 10px 28px;
  border-top: 1px solid #e8eef0;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  background: #f6fafb;
  font-size: 0.75rem;
}

.guide-bar p {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
}

.guide-bar svg {
  width: 17px;
  height: 17px;
  color: var(--ink);
}

.legend {
  display: flex;
  align-items: center;
  gap: 16px;
  white-space: nowrap;
}

.legend span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.status-swatch {
  width: 10px;
  height: 10px;
  border-radius: 3px;
}

.status-swatch.confirmed { background: var(--confirmed-soft); border: 1px solid #bfe6da; }
.status-swatch.waitlist { background: var(--waitlist-soft); border: 1px solid #f0d98e; }
.status-swatch.coordination { background: var(--coordination-soft); border: 1px solid #ccd7ec; }

.view-panel {
  min-height: 520px;
}

.timetable-scroll {
  overflow: auto;
  max-height: calc(100vh - 270px);
  min-height: 520px;
}

.schedule-grid {
  position: relative;
  display: grid;
  grid-template-columns: 78px minmax(310px, 1fr) minmax(310px, 1fr);
  grid-template-rows: 50px repeat(var(--slot-count, 26), var(--slot-height));
  min-width: 700px;
}

.grid-header,
.time-cell,
.slot-cell {
  border-right: 1px solid var(--line-strong);
  border-bottom: 1px solid var(--line);
}

.grid-header {
  position: sticky;
  top: 0;
  z-index: 8;
  display: grid;
  place-items: center;
  color: var(--ink);
  background: rgba(244, 249, 249, 0.98);
  font-family: "DM Sans", "Noto Sans Thai", sans-serif;
  font-size: 0.84rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  backdrop-filter: blur(8px);
}

.grid-header:last-of-type,
.slot-cell.room-two {
  border-right: 0;
}

.time-header {
  left: 0;
  z-index: 10;
  box-shadow: 3px 0 8px rgba(31, 64, 73, 0.08);
}

.time-cell {
  position: sticky;
  left: 0;
  z-index: 7;
  display: flex;
  align-items: flex-start;
  justify-content: flex-end;
  padding: 7px 10px 0 4px;
  color: var(--muted);
  background: #fbfcfd;
  font-family: "DM Sans", sans-serif;
  font-size: 0.72rem;
  font-variant-numeric: tabular-nums;
  box-shadow: 3px 0 8px rgba(31, 64, 73, 0.06);
}

.time-cell.full-hour {
  color: var(--ink);
  font-weight: 700;
}

.slot-cell {
  width: 100%;
  min-width: 0;
  padding: 0;
  border-top: 0;
  border-left: 0;
  color: transparent;
  background: rgba(255, 255, 255, 0.5);
  cursor: cell;
}

.slot-cell:hover {
  background: rgba(15, 113, 133, 0.045);
  box-shadow: inset 0 0 0 1px rgba(15, 113, 133, 0.16);
}

.slot-cell:disabled:hover {
  background: rgba(255, 255, 255, 0.5);
  box-shadow: none;
}

.case-card {
  position: relative;
  z-index: 4;
  display: flex;
  min-height: 0;
  flex-direction: column;
  align-items: flex-start;
  gap: 1px;
  margin: 3px 5px;
  overflow: hidden;
  padding: 7px 10px 6px 13px;
  border: 1px solid transparent;
  border-radius: 9px;
  color: var(--ink);
  text-align: left;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(39, 73, 80, 0.07);
  transition: filter 140ms ease, transform 140ms ease, box-shadow 140ms ease;
}

.case-card::before {
  position: absolute;
  inset: 0 auto 0 0;
  width: 4px;
  background: currentColor;
  content: "";
}

.case-card:hover {
  z-index: 6;
  filter: saturate(1.08);
  transform: translateY(-1px);
  box-shadow: 0 8px 20px rgba(39, 73, 80, 0.13);
}

.case-card.confirmed {
  border-color: #bee5da;
  color: #21806d;
  background: var(--confirmed-soft);
}

.case-card.waitlist {
  border-color: #efd98e;
  color: #a27a0b;
  background: var(--waitlist-soft);
}

.case-card.coordination {
  border-color: #cbd6eb;
  color: #566e9f;
  background: var(--coordination-soft);
}

.case-card > * {
  max-width: 100%;
  overflow: hidden;
  color: var(--ink);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.case-time {
  font-family: "DM Sans", "Noto Sans Thai", sans-serif;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.case-patient {
  font-size: 0.78rem;
  font-weight: 700;
}

.case-doctor,
.case-procedure,
.case-anesthesia {
  color: var(--muted);
  font-size: 0.68rem;
}

.case-doctor {
  font-weight: 600;
}

.case-anesthesia {
  font-size: 0.66rem;
}

.daily-empty {
  position: absolute;
  top: 280px;
  left: 78px;
  right: 0;
  z-index: 2;
  color: var(--subtle);
  font-size: 0.78rem;
  text-align: center;
  pointer-events: none;
}

.month-header,
.dashboard-heading-row {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 18px;
  padding: 24px 28px 18px;
}

.month-header h2,
.dashboard-heading-row h2 {
  margin-bottom: 0;
  font-size: 1.35rem;
}

.month-summary,
.dashboard-heading-row > p {
  margin-bottom: 1px;
  color: var(--muted);
  font-size: 0.82rem;
}

.month-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  padding: 0 28px 28px;
}

.weekday {
  padding: 9px 8px;
  border-bottom: 1px solid var(--line-strong);
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 700;
  text-align: center;
}

.month-day {
  position: relative;
  min-height: 104px;
  padding: 10px;
  border: 0;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  color: var(--ink);
  background: #fff;
  text-align: left;
  cursor: pointer;
  transition: background 150ms ease, box-shadow 150ms ease;
}

.month-day:nth-child(7n + 7) {
  border-right: 0;
}

.month-day:hover {
  z-index: 2;
  background: #f6fbfb;
  box-shadow: inset 0 0 0 1px rgba(15, 113, 133, 0.22);
}

.month-day.outside {
  color: #b4bec6;
  background: #fafcfc;
}

.month-day.selected {
  background: #eef8f8;
  box-shadow: inset 0 0 0 2px var(--teal);
}

.month-day.today .day-number {
  color: #fff;
  background: var(--teal);
}

.day-number {
  display: inline-grid;
  width: 28px;
  height: 28px;
  place-items: center;
  border-radius: 50%;
  font-family: "DM Sans", sans-serif;
  font-size: 0.78rem;
  font-weight: 700;
}

.day-case-count {
  position: absolute;
  top: 13px;
  right: 10px;
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 600;
}

.dashboard-panel {
  padding-bottom: 28px;
  background: #fafcfc;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  padding: 0 28px 16px;
}

.metric-card {
  display: flex;
  align-items: center;
  gap: 13px;
  min-width: 0;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #fff;
  box-shadow: 0 4px 14px rgba(43, 72, 82, 0.045);
}

.metric-icon {
  display: grid;
  width: 42px;
  height: 42px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 13px;
  color: var(--teal);
  background: var(--teal-soft);
}

.metric-card.confirmed .metric-icon { color: var(--confirmed); background: var(--confirmed-soft); }
.metric-card.waitlist .metric-icon { color: #ac810f; background: var(--waitlist-soft); }
.metric-card.coordination .metric-icon { color: var(--coordination); background: var(--coordination-soft); }

.metric-card p,
.metric-card small {
  display: block;
  margin: 0;
  color: var(--muted);
}

.metric-card p {
  font-size: 0.76rem;
  font-weight: 600;
}

.metric-card strong {
  display: block;
  margin: 1px 0 -1px;
  font-family: "DM Sans", sans-serif;
  font-size: 1.65rem;
  line-height: 1.1;
}

.metric-card small {
  overflow: hidden;
  font-size: 0.64rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  padding: 0 28px;
}

.dashboard-card {
  min-width: 0;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #fff;
}

.dashboard-card.usage-card {
  grid-column: 1 / -1;
}

.card-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
}

.card-heading h3 {
  margin-bottom: 0;
  font-size: 1rem;
}

.status-breakdown {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.breakdown-row {
  display: grid;
  grid-template-columns: minmax(110px, auto) 1fr 42px;
  align-items: center;
  gap: 10px;
  font-size: 0.75rem;
}

.breakdown-label {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  white-space: nowrap;
}

.breakdown-label i {
  width: 9px;
  height: 9px;
  border-radius: 3px;
}

.breakdown-track,
.usage-track {
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: #edf2f3;
}

.breakdown-bar,
.usage-bar {
  width: 0;
  height: 100%;
  border-radius: inherit;
  transition: width 300ms ease;
}

.breakdown-number {
  color: var(--muted);
  font-family: "DM Sans", sans-serif;
  font-size: 0.7rem;
  text-align: right;
}

.busy-days-list {
  display: flex;
  min-height: 118px;
  flex-direction: column;
  gap: 8px;
}

.busy-day {
  display: grid;
  grid-template-columns: 34px 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 7px 9px;
  border-radius: 10px;
  background: var(--surface-soft);
}

.busy-rank {
  display: grid;
  width: 26px;
  height: 26px;
  place-items: center;
  border-radius: 8px;
  color: var(--teal);
  background: var(--teal-soft);
  font-family: "DM Sans", sans-serif;
  font-size: 0.7rem;
  font-weight: 700;
}

.busy-date {
  margin: 0;
  font-size: 0.74rem;
  font-weight: 600;
}

.busy-count {
  color: var(--muted);
  font-size: 0.7rem;
}

.room-usage {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 20px;
}

.usage-item {
  display: grid;
  grid-template-columns: 50px 1fr auto;
  align-items: center;
  gap: 12px;
}

.usage-room {
  font-family: "DM Sans", sans-serif;
  font-size: 0.78rem;
  font-weight: 700;
}

.usage-value {
  color: var(--muted);
  font-family: "DM Sans", "Noto Sans Thai", sans-serif;
  font-size: 0.7rem;
  white-space: nowrap;
}

.empty-state {
  display: flex;
  min-height: 118px;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: var(--subtle);
  text-align: center;
}

.empty-state p {
  margin: 0;
  font-size: 0.75rem;
}

.empty-icon {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border-radius: 12px;
  color: var(--teal);
  background: var(--teal-soft);
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  overflow: auto;
  place-items: center;
  padding: 28px 16px;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  border: 0;
  background: rgba(29, 53, 67, 0.56);
  cursor: default;
  backdrop-filter: blur(5px);
  animation: fade-in 160ms ease both;
}

.modal-card {
  position: relative;
  z-index: 1;
  width: min(100%, 680px);
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.7);
  border-radius: 20px;
  background: #fff;
  box-shadow: 0 30px 90px rgba(20, 42, 52, 0.28);
  animation: modal-in 180ms ease both;
}

@keyframes fade-in {
  from { opacity: 0; }
}

@keyframes modal-in {
  from { opacity: 0; transform: translateY(10px) scale(0.985); }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 20px 20px 17px;
  border-bottom: 1px solid var(--line);
}

.modal-header h2 {
  margin-bottom: 0;
  font-size: 1.25rem;
}

#case-form,
#auth-form {
  padding: 18px 20px 20px;
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.field {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 6px;
  color: var(--ink);
  font-size: 0.78rem;
  font-weight: 600;
}

.field.full {
  grid-column: 1 / -1;
}

.field input,
.field select,
.field textarea {
  width: 100%;
  min-height: 44px;
  padding: 9px 11px;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  color: var(--ink);
  background: #fff;
  font-size: 0.85rem;
  font-weight: 400;
  transition: border-color 150ms ease, box-shadow 150ms ease;
}

.field textarea {
  min-height: 84px;
  resize: vertical;
}

.field input::placeholder,
.field textarea::placeholder {
  color: #a3afb7;
}

.field input:hover,
.field select:hover,
.field textarea:hover {
  border-color: #aebfc4;
}

.field input:focus,
.field select:focus,
.field textarea:focus {
  border-color: var(--teal);
  outline: 0;
  box-shadow: 0 0 0 3px rgba(15, 113, 133, 0.12);
}

.form-error {
  margin: 14px 0 0;
  padding: 9px 11px;
  border-radius: 9px;
  color: #9c3038;
  background: var(--danger-soft);
  font-size: 0.75rem;
  font-weight: 500;
}

.modal-actions {
  display: flex;
  align-items: center;
  gap: 9px;
  margin: 20px -20px -20px;
  padding: 14px 20px;
  border-top: 1px solid var(--line);
  background: #fbfcfc;
}

.action-spacer {
  flex: 1;
}

.button {
  min-height: 41px;
  padding: 9px 15px;
  border: 1px solid transparent;
  border-radius: 10px;
  font-size: 0.8rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 150ms ease, border-color 150ms ease, transform 150ms ease, opacity 150ms ease;
}

.button.primary {
  color: #fff;
  background: var(--teal);
}

.button.primary:hover { background: var(--teal-dark); }

.button.secondary {
  border-color: var(--line);
  color: var(--muted);
  background: #fff;
}

.button.secondary:hover { border-color: #b8c9cd; background: var(--surface-soft); }

.button.danger {
  color: #fff;
  background: var(--danger);
}

.button.danger:hover { background: #ac3942; }

.button.danger.ghost {
  color: var(--danger);
  background: var(--danger-soft);
}

.button:disabled {
  cursor: wait;
  opacity: 0.65;
}

.button-loader {
  display: none;
  width: 14px;
  height: 14px;
  border: 2px solid rgba(255, 255, 255, 0.35);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 700ms linear infinite;
}

.button.loading {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.button.loading .button-loader { display: inline-block; }

@keyframes spin { to { transform: rotate(360deg); } }

.confirm-card {
  width: min(100%, 410px);
  padding: 28px;
  text-align: center;
}

.danger-mark {
  display: grid;
  width: 54px;
  height: 54px;
  place-items: center;
  margin: 0 auto 15px;
  border-radius: 17px;
  color: var(--danger);
  background: var(--danger-soft);
}

.danger-mark svg {
  width: 27px;
  height: 27px;
}

.confirm-card h2 {
  margin-bottom: 6px;
  font-size: 1.2rem;
}

.confirm-card > p {
  margin-bottom: 22px;
  color: var(--muted);
  font-size: 0.82rem;
}

.confirm-actions {
  display: flex;
  justify-content: center;
  gap: 9px;
}

.auth-card {
  width: min(100%, 460px);
}

.auth-intro {
  margin-bottom: 16px;
  color: var(--muted);
  font-size: 0.77rem;
}

.auth-intro code {
  padding: 2px 5px;
  border-radius: 5px;
  color: var(--teal-dark);
  background: var(--teal-soft);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

#auth-form .field + .field {
  margin-top: 13px;
}

.auth-actions {
  justify-content: flex-end;
  margin-top: 18px;
}

.auth-actions #logout-button {
  margin-right: auto;
}

.toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 80;
  max-width: min(380px, calc(100% - 44px));
  padding: 11px 15px;
  border: 1px solid #c7e5dc;
  border-radius: 12px;
  color: #206f60;
  background: #effaf6;
  box-shadow: 0 12px 30px rgba(30, 69, 78, 0.14);
  font-size: 0.78rem;
  font-weight: 600;
  opacity: 0;
  pointer-events: none;
  transform: translateY(10px);
  transition: opacity 180ms ease, transform 180ms ease;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

.toast.error {
  border-color: #f0c8cd;
  color: #9c3038;
  background: var(--danger-soft);
}

body.modal-open {
  overflow: hidden;
}

@media (max-width: 980px) {
  .planner-toolbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .date-navigator {
    width: 100%;
  }

  .date-display {
    flex: 1;
  }

  .guide-bar {
    align-items: flex-start;
    flex-direction: column;
    gap: 8px;
  }

  .metric-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 720px) {
  :root { --slot-height: 96px; }

  .app-shell {
    width: 100%;
    min-height: 100vh;
    margin: 0;
    border: 0;
    border-radius: 0;
  }

  .app-header {
    align-items: center;
    padding: 20px 16px 14px;
  }

  .subtitle,
  .sync-chip {
    display: none;
  }

  h1 { font-size: 1.42rem; }

  .eyebrow { font-size: 0.57rem; }

  .header-actions { gap: 7px; }

  .icon-button {
    width: 40px;
    height: 40px;
  }

  .planner-toolbar {
    padding: 0 16px 14px;
  }

  .view-switcher {
    width: 100%;
  }

  .view-tab {
    flex: 1;
    justify-content: center;
    padding: 8px 9px;
  }

  .view-tab span { display: none; }

  .date-display {
    min-width: 0;
    margin-left: 5px;
    font-size: 0.8rem;
  }

  .guide-bar {
    padding: 10px 16px;
  }

  .guide-bar > p { display: none; }

  .legend {
    width: 100%;
    justify-content: space-between;
    gap: 8px;
    font-size: 0.67rem;
  }

  .month-header,
  .dashboard-heading-row {
    align-items: flex-start;
    flex-direction: column;
    padding: 20px 16px 14px;
  }

  .month-grid {
    padding: 0 0 20px;
  }

  .month-day {
    min-height: 82px;
    padding: 6px;
  }

  .day-case-count {
    top: 9px;
    right: 6px;
  }

  .metric-grid,
  .dashboard-grid {
    grid-template-columns: 1fr;
    padding-right: 16px;
    padding-left: 16px;
  }

  .metric-grid {
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }

  .metric-card {
    align-items: flex-start;
    gap: 9px;
    padding: 13px;
  }

  .metric-icon {
    width: 34px;
    height: 34px;
  }

  .metric-icon svg {
    width: 18px;
    height: 18px;
  }

  .metric-card strong { font-size: 1.4rem; }

  .metric-card small { display: none; }

  .dashboard-card.usage-card { grid-column: auto; }

  .room-usage { grid-template-columns: 1fr; }

  .modal {
    align-items: end;
    padding: 12px 0 0;
  }

  .modal-card {
    max-height: calc(100vh - 12px);
    overflow: auto;
    border-radius: 20px 20px 0 0;
  }

  .form-grid {
    grid-template-columns: 1fr;
  }

  .field.full {
    grid-column: auto;
  }

  .modal-actions {
    position: sticky;
    bottom: -20px;
    z-index: 2;
  }

  .confirm-card {
    padding: 25px 20px;
  }

  .toast {
    right: 12px;
    bottom: 12px;
    max-width: calc(100% - 24px);
  }
}

@media print {
  @page { size: landscape; margin: 8mm; }

  body { background: #fff; }

  .page-grid,
  .header-actions,
  .planner-toolbar,
  .guide-bar,
  .modal,
  .toast {
    display: none !important;
  }

  .app-shell {
    width: 100%;
    min-height: 0;
    margin: 0;
    border: 0;
    box-shadow: none;
  }

  .app-header { padding: 0 0 12px; }

  .subtitle { display: block; }

  .view-panel[hidden] { display: none !important; }

  .timetable-scroll {
    max-height: none;
    min-height: 0;
    overflow: visible;
  }

  .schedule-grid {
    grid-template-columns: 62px 1fr 1fr;
    grid-template-rows: 34px repeat(var(--slot-count, 26), 28px);
    min-width: 0;
  }

  .grid-header,
  .time-cell {
    position: static;
    box-shadow: none;
  }

  .case-card {
    margin: 1px 3px;
    padding: 3px 7px 3px 9px;
    box-shadow: none;
  }

  .case-procedure { display: none; }

  .month-grid,
  .metric-grid,
  .dashboard-grid {
    padding-right: 0;
    padding-left: 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
