:root {
  --bg: #f6f8fc;
  --surface: #ffffff;
  --surface-2: #f1f5fb;
  --text: #172033;
  --muted: #65728a;
  --primary: #123a6f;
  --primary-2: #0d2d57;
  --accent: #f2b705;
  --danger: #b42318;
  --success: #027a48;
  --warning: #b54708;
  --border: #d8e0ec;
  --shadow: 0 16px 40px rgba(13, 45, 87, 0.12);
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

[hidden] {
  display: none !important;
}

body.portal-auth-only #loginCard label,
body.portal-auth-only #loginCard input,
body.portal-auth-only #loginBtn,
body.portal-auth-only #showSetPasswordBtn,
body.portal-auth-only #backToPublicLandingBtn,
body.portal-auth-only #setPasswordPanel,
body.portal-auth-only #loginCard .muted {
  display: none !important;
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
  font-family: "IBM Plex Sans Thai", "Sarabun", "Noto Sans Thai", system-ui, sans-serif;
  color: var(--text);
  background: radial-gradient(circle at top left, #eaf2ff, transparent 34rem), var(--bg);
}

.app-footer {
  margin-top: auto;
  padding: 14px 16px;
  text-align: center;
  color: var(--muted);
  font-size: 0.86rem;
  border-top: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.8);
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 90;
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: center;
  padding: 1rem clamp(1rem, 3vw, 2rem);
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
}

.home-link {
  margin-left: auto;
  text-decoration: none;
  white-space: nowrap;
}

.menu-toggle {
  display: none;
  width: 48px;
  height: 48px;
  flex: 0 0 auto;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 8px 18px rgba(13, 45, 87, 0.08);
  cursor: pointer;
}

.menu-toggle span {
  display: block;
  width: 22px;
  height: 2px;
  margin: 5px auto;
  border-radius: 999px;
  background: var(--primary);
  transition: transform 0.18s, opacity 0.18s;
}

body.menu-open .menu-toggle span:nth-child(1) {
  transform: translateY(7px) rotate(45deg);
}

body.menu-open .menu-toggle span:nth-child(2) {
  opacity: 0;
}

body.menu-open .menu-toggle span:nth-child(3) {
  transform: translateY(-7px) rotate(-45deg);
}

.sidebar-backdrop {
  display: none;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.9rem;
}

.logo {
  width: 54px;
  height: 54px;
  object-fit: contain;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 6px 16px rgba(13, 45, 87, 0.12);
}

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

h1 {
  font-size: clamp(1.05rem, 2vw, 1.45rem);
}

h2 {
  font-size: clamp(1.25rem, 2vw, 1.65rem);
  margin-bottom: 0.35rem;
}

.muted, .hint {
  color: var(--muted);
}

.hint {
  display: block;
  margin-top: 0.35rem;
  font-size: 0.84rem;
}

.layout {
  flex: 1 0 auto;
  width: min(1240px, calc(100% - 2rem));
  margin: 1.4rem auto 3rem;
}

.public-landing,
.login-card {
  min-height: calc(100vh - 120px);
  display: grid;
  place-items: center;
  padding: 2.5rem 0;
}

.public-landing {
  align-content: center;
  gap: 1rem;
}

.card, .table-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.card {
  padding: clamp(1rem, 3vw, 1.5rem);
}

.card.wide {
  width: min(760px, 100%);
}

.login-card .card.wide {
  padding: clamp(1.35rem, 4vw, 2rem);
}

.login-card h2 {
  font-size: clamp(1.8rem, 4vw, 2.45rem);
}

.divider {
  height: 1px;
  background: var(--border);
  margin: 1.2rem 0;
}

.set-password-panel h3 {
  margin: 0 0 0.35rem;
  font-size: 1.08rem;
  color: var(--primary);
}

label {
  display: block;
  margin: 0.9rem 0 0.35rem;
  font-weight: 700;
}

input, select, textarea {
  width: 100%;
  min-height: 46px;
  padding: 0.78rem 0.9rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  font: inherit;
  background: #fff;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

input:focus, select:focus, textarea:focus {
  border-color: #6ea4e8;
  box-shadow: 0 0 0 4px rgba(110, 164, 232, 0.2);
}

textarea {
  resize: vertical;
}

.inline-row {
  display: flex;
  gap: 0.6rem;
}

.inline-row input {
  flex: 1;
}

.btn {
  border: 0;
  min-height: 44px;
  border-radius: 8px;
  padding: 0.78rem 1rem;
  font: inherit;
  font-weight: 800;
  cursor: pointer;
  transition: transform 0.12s, box-shadow 0.12s, opacity 0.12s;
  white-space: nowrap;
}

.btn:hover {
  transform: translateY(-1px);
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
}

.btn.primary {
  color: white;
  background: var(--primary);
  box-shadow: 0 10px 22px rgba(18, 58, 111, 0.18);
}

.btn.primary:hover {
  background: var(--primary-2);
}

.btn.secondary {
  color: var(--primary);
  background: #e8f1ff;
}

.btn.ghost {
  color: var(--primary);
  background: transparent;
  border: 1px solid var(--border);
}

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

.btn.success {
  color: #fff;
  background: var(--success);
}

.btn.full {
  width: 100%;
  margin-top: 1rem;
}

.alert {
  margin-top: 1rem;
  padding: 0.9rem 1rem;
  border-radius: 8px;
  background: #fff1f0;
  color: var(--danger);
  border: 1px solid #ffd8d5;
}

.alert.success {
  background: #ecfdf3;
  color: #047857;
  border-color: #bbf7d0;
}

.app-shell {
  display: grid;
  grid-template-columns: 230px 1fr;
  gap: 1rem;
}

.sidebar {
  position: sticky;
  top: 94px;
  align-self: start;
  display: grid;
  gap: 0.55rem;
  padding: 0.8rem;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}

.nav {
  text-align: left;
  border: 0;
  min-height: 44px;
  border-radius: 8px;
  padding: 0.9rem 1rem;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-weight: 800;
  cursor: pointer;
}

.nav.active, .nav:hover {
  color: var(--primary);
  background: #e8f1ff;
}

.content {
  min-width: 0;
}

.page {
  display: none;
}

.page.active {
  display: block;
}

.landing-hero {
  display: grid;
  min-height: 220px;
  align-items: end;
  padding: clamp(1.2rem, 4vw, 2rem);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: linear-gradient(135deg, rgba(18, 58, 111, 0.96), rgba(29, 95, 167, 0.86)), url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='240' height='120' viewBox='0 0 240 120'%3E%3Cg fill='none' stroke='%23ffffff' stroke-opacity='.16'%3E%3Cpath d='M0 60h240M40 0v120M120 0v120M200 0v120'/%3E%3Ccircle cx='60' cy='60' r='34'/%3E%3Ccircle cx='180' cy='60' r='34'/%3E%3C/g%3E%3C/svg%3E");
  color: #fff;
  box-shadow: var(--shadow);
}

.landing-hero h2 {
  color: #fff;
  font-size: clamp(1.65rem, 4vw, 2.45rem);
}

.landing-hero .muted {
  color: #dbeafe;
}

.eyebrow {
  margin-bottom: 0.45rem;
  color: var(--accent);
  font-size: 0.88rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.system-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
  margin-top: 1rem;
}

.system-card {
  min-height: 190px;
  display: grid;
  align-content: start;
  gap: 0.65rem;
  padding: 1.15rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #fff;
  color: var(--text);
  text-align: left;
  font: inherit;
  box-shadow: var(--shadow);
}

.system-card.available {
  cursor: pointer;
}

.system-card.available:hover {
  border-color: #9abce8;
  transform: translateY(-1px);
}

.system-card.disabled {
  opacity: 0.68;
  cursor: not-allowed;
}

.system-icon {
  display: grid;
  place-items: center;
  width: 52px;
  height: 52px;
  border-radius: 8px;
  background: var(--primary);
  color: #fff;
  font-weight: 900;
}

.system-icon.accent {
  background: var(--accent);
  color: #231a00;
}

.system-card strong {
  color: var(--primary);
  font-size: 1.25rem;
}

.system-card small {
  color: var(--muted);
  font-size: 0.95rem;
  line-height: 1.6;
}

.page-header {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: center;
  margin-bottom: 1rem;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.4rem 1rem;
}

.field {
  min-width: 0;
}

.span-2 {
  grid-column: span 2;
}

.check-field {
  display: flex;
  align-items: end;
  padding-bottom: 0.25rem;
}

.checkbox-line {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  margin: 0;
  font-weight: 700;
}

.checkbox-line input {
  width: 20px;
  height: 20px;
}

.recurrence-box {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.9rem;
  background: #f8fbff;
}

.recurrence-panel {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.8rem 1rem;
  margin-top: 0.9rem;
}

.weekday-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.55rem;
}

.weekday-grid label {
  min-height: 44px;
  display: flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.55rem 0.7rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  font-weight: 700;
}

.weekday-grid input {
  width: 18px;
  height: 18px;
}

.actions-row {
  display: flex;
  gap: 0.7rem;
  justify-content: flex-start;
  margin-top: 0.8rem;
}

.user-box {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  color: var(--muted);
  font-weight: 700;
}

.table-card {
  overflow: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 900px;
}

th, td {
  text-align: left;
  padding: 0.85rem 0.9rem;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--surface-2);
  color: var(--primary);
  font-size: 0.92rem;
}

tr:hover td {
  background: #fbfdff;
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.25rem 0.55rem;
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 800;
  white-space: nowrap;
}

.badge.APPROVED, .badge.BOOKED {
  color: var(--success);
  background: #ecfdf3;
}

.badge.PENDING_APPROVAL {
  color: var(--warning);
  background: #fff7ed;
}

.badge.REJECTED, .badge.CANCELLED {
  color: var(--danger);
  background: #fff1f0;
}

.subject-summary {
  display: grid;
  gap: 0.25rem;
  min-width: 0;
}

.subject-summary strong,
.subject-summary span,
.subject-summary small {
  overflow-wrap: anywhere;
}

.subject-summary span {
  color: var(--primary);
  font-weight: 800;
  font-size: 0.92rem;
}

.subject-summary small {
  color: var(--muted);
  font-weight: 600;
  line-height: 1.45;
}

.action-stack {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}

.action-stack .btn {
  padding: 0.55rem 0.75rem;
  border-radius: 8px;
  font-size: 0.88rem;
}

.empty-state {
  display: grid;
  min-height: 120px;
  place-items: center;
  color: var(--muted);
  font-weight: 800;
  text-align: center;
}

.toast {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  max-width: min(420px, calc(100% - 2rem));
  padding: 1rem 1.1rem;
  border-radius: 8px;
  color: white;
  background: var(--primary);
  box-shadow: var(--shadow);
  font-weight: 800;
  z-index: 100;
}

.calendar-card {
  padding: 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.calendar-toolbar {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 1rem;
  margin-bottom: 0.8rem;
}

.calendar-toolbar h3 {
  text-align: center;
  color: var(--primary);
}

.calendar-nav-actions,
.calendar-view-actions {
  display: flex;
  gap: 0.45rem;
  flex-wrap: wrap;
}

.calendar-view-actions {
  justify-content: end;
}

.calendar-view-actions .active {
  box-shadow: inset 0 0 0 1px rgba(18, 58, 111, 0.08);
}

.calendar-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.9rem;
  align-items: center;
  margin-bottom: 0.8rem;
  color: var(--muted);
  font-weight: 700;
  font-size: 0.92rem;
}

.legend-dot {
  display: inline-block;
  width: 12px;
  height: 12px;
  margin-right: 0.35rem;
  border-radius: 999px;
  vertical-align: -1px;
}

.legend-dot.approved {
  background: var(--success);
}

.legend-dot.pending {
  background: #eab308;
}

.legend-dot.other {
  background: var(--muted);
}

.calendar-room-filter {
  display: grid;
  grid-template-columns: minmax(90px, auto) minmax(180px, 320px);
  gap: 0.7rem;
  align-items: center;
  margin-bottom: 0.9rem;
}

.calendar-room-filter label {
  margin: 0;
}

.calendar-month-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
}

.calendar-weekdays {
  overflow: hidden;
  border: 1px solid var(--border);
  border-bottom: 0;
  border-radius: 8px 8px 0 0;
  background: var(--surface-2);
}

.calendar-weekdays div {
  padding: 0.65rem;
  color: var(--primary);
  font-weight: 800;
  text-align: center;
}

.calendar-day {
  min-height: 132px;
  padding: 0.55rem;
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  background: #fff;
}

.calendar-month-grid:not(.calendar-weekdays) {
  border-left: 1px solid var(--border);
}

.calendar-day.muted-day {
  background: #f8fafc;
  color: var(--muted);
}

.calendar-day.today {
  box-shadow: inset 0 0 0 2px rgba(242, 183, 5, 0.85);
}

.calendar-day-number {
  display: inline-grid;
  place-items: center;
  min-width: 28px;
  height: 28px;
  margin-bottom: 0.35rem;
  border-radius: 999px;
  font-weight: 800;
}

.calendar-events {
  display: grid;
  gap: 0.35rem;
}

.calendar-event {
  display: grid;
  gap: 0.1rem;
  width: 100%;
  min-height: 0;
  padding: 0.45rem 0.5rem;
  border: 0;
  border-left: 4px solid currentColor;
  border-radius: 6px;
  text-align: left;
  cursor: pointer;
  font: inherit;
  color: var(--primary);
  background: #eef6ff;
}

.calendar-event:hover {
  transform: translateY(-1px);
}

.calendar-event.approved {
  color: var(--success);
  background: #ecfdf3;
}

.calendar-event.pending {
  color: #a16207;
  background: #fef9c3;
}

.calendar-event.other {
  color: var(--muted);
  background: #f1f5f9;
}

.calendar-event span,
.calendar-event strong,
.calendar-event small {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.calendar-event span {
  font-size: 0.78rem;
  font-weight: 800;
}

.calendar-event strong {
  color: var(--text);
  font-size: 0.86rem;
}

.calendar-event small {
  color: currentColor;
  font-size: 0.76rem;
  font-weight: 700;
}

.calendar-more,
.calendar-no-event {
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 700;
}

.calendar-week-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(180px, 1fr));
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
}

.calendar-week-day {
  min-height: 360px;
  border-right: 1px solid var(--border);
  background: #fff;
}

.calendar-week-day:last-child {
  border-right: 0;
}

.calendar-week-heading {
  display: grid;
  gap: 0.15rem;
  padding: 0.75rem;
  background: var(--surface-2);
  color: var(--primary);
}

.calendar-week-events {
  display: grid;
  align-content: start;
  gap: 0.5rem;
  padding: 0.65rem;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 140;
  display: grid;
  place-items: center;
  padding: 1rem;
  background: rgba(15, 23, 42, 0.42);
}

.modal-card {
  width: min(760px, 100%);
  max-height: min(86vh, 760px);
  overflow: auto;
  border-radius: 12px;
  background: var(--surface);
  box-shadow: 0 26px 70px rgba(15, 23, 42, 0.28);
  border: 1px solid var(--border);
}

.modal-header {
  position: sticky;
  top: 0;
  z-index: 1;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  padding: 1.1rem;
  border-bottom: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.96);
}

.modal-header h2 {
  margin: 0;
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0;
  padding: 0.4rem 1.1rem 1.1rem;
}

.detail-item {
  display: grid;
  gap: 0.3rem;
  padding: 0.8rem 0;
  border-bottom: 1px solid var(--border);
}

.detail-item:nth-child(odd) {
  padding-right: 1rem;
}

.detail-item span {
  color: var(--muted);
  font-weight: 800;
  font-size: 0.86rem;
}

.detail-item strong {
  font-weight: 700;
  line-height: 1.55;
  overflow-wrap: anywhere;
}

@media (max-width: 900px) {
  .topbar, .page-header, .inline-row, .actions-row, .user-box {
    align-items: stretch;
    flex-direction: column;
  }

  .topbar {
    position: static;
  }

  .brand {
    align-items: flex-start;
  }

  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    display: flex;
    overflow-x: auto;
    padding: 0.55rem;
    scrollbar-width: thin;
  }

  .nav {
    flex: 0 0 auto;
    text-align: center;
    white-space: nowrap;
  }

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

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

  .span-2 {
    grid-column: span 1;
  }

  .recurrence-panel {
    grid-template-columns: 1fr;
  }

  .weekday-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .calendar-toolbar {
    grid-template-columns: 1fr;
  }

  .calendar-toolbar h3 {
    text-align: left;
  }

  .calendar-view-actions {
    justify-content: start;
  }

  .calendar-day {
    min-height: 108px;
    padding: 0.4rem;
  }
}

@media (max-width: 640px) {
  html,
  body {
    width: 100%;
    overflow-x: hidden;
    padding-bottom: 0;
  }

  .layout {
    width: 100% !important;
    margin: 0 auto !important;
    padding: 0.75rem 0 1.5rem !important;
  }

  .topbar {
    position: sticky;
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    align-items: center;
    gap: 0.55rem;
    width: 100vw;
    max-width: 100vw;
    padding: 0.65rem 0.5rem;
    overflow: hidden;
  }

  .brand {
    order: 2;
    gap: 0.65rem;
    min-width: 0;
    width: 100%;
  }

  .logo {
    width: 44px;
    height: 44px;
    flex: 0 0 auto;
  }

  .brand h1 {
    max-width: 100%;
    overflow-wrap: anywhere;
    line-height: 1.35;
  }

  .brand p {
    display: none;
  }

  .home-link {
    order: 3;
    margin-left: 0;
    min-height: 42px;
    padding: 0.6rem 0.7rem;
    font-size: 0.88rem;
    max-width: 118px;
  }

  .menu-toggle {
    order: 1;
    display: block;
    width: 44px;
    height: 44px;
  }

  .user-box {
    position: fixed;
    top: 90px;
    right: 0.75rem;
    left: 0.75rem;
    z-index: 96;
    display: none;
    padding: 0.85rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: #fff;
    box-shadow: var(--shadow);
  }

  body.menu-open .user-box:not([hidden]) {
    display: grid;
  }

  h1 {
    font-size: 1.05rem;
  }

  h2 {
    font-size: 1.22rem;
  }

  .brand p,
  .page-header p {
    font-size: 0.9rem;
    line-height: 1.45;
  }

  .public-landing,
  .login-card {
    min-height: auto;
    width: min(560px, calc(100% - 1.5rem));
    margin-inline: auto;
    padding: 0;
  }

  .card {
    padding: 1rem;
    width: 100%;
    margin-inline: auto;
  }

  .card,
  .form-grid,
  .field,
  input,
  select,
  textarea,
  .btn {
    max-width: 100%;
  }

  input,
  select,
  textarea {
    display: block;
    width: 100%;
    inline-size: 100%;
    min-width: 0;
    box-sizing: border-box;
  }

  input[type="date"],
  input[type="time"] {
    padding-right: 0.75rem;
  }

  .form-grid {
    width: 100%;
    max-width: 560px;
    margin-inline: auto;
    min-width: 0;
    overflow: clip;
    gap: 0.35rem 0;
  }

  .field {
    min-width: 0;
  }

  label {
    line-height: 1.45;
  }

  .landing-hero {
    min-height: 190px;
  }

  .system-card {
    min-height: auto;
  }

  .app-shell {
    gap: 0.75rem;
    width: min(560px, calc(100% - 1.5rem));
    margin-inline: auto;
    min-width: 0;
  }

  .content,
  .page {
    width: 100%;
    min-width: 0;
  }

  .content {
    padding: 0;
    overflow: hidden;
  }

  .page {
    max-width: 560px;
    margin-inline: auto;
  }

  .page-header {
    width: 100%;
    max-width: 560px;
    margin-inline: auto;
    margin-bottom: 0.85rem;
  }

  .page-header .btn {
    width: auto;
    align-self: flex-start;
  }

  .sidebar-backdrop {
    position: fixed;
    inset: 0;
    z-index: 84;
    display: block;
    background: rgba(15, 23, 42, 0.34);
  }

  .sidebar {
    position: fixed;
    top: 82px;
    right: 0.75rem;
    left: 0.75rem;
    bottom: auto;
    z-index: 95;
    display: none;
    max-height: calc(100vh - 100px);
    overflow-y: auto;
    padding: 0.65rem;
    border-radius: 8px;
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
    background: rgba(255, 255, 255, 0.98);
    backdrop-filter: blur(14px);
  }

  body.menu-open .sidebar {
    display: grid;
  }

  .nav {
    width: 100%;
    padding: 0.85rem 1rem;
    font-size: 0.9rem;
    text-align: left;
  }

  .table-card {
    overflow: visible;
    border: 0;
    background: transparent;
    box-shadow: none;
  }

  table,
  thead,
  tbody,
  tr,
  th,
  td {
    display: block;
    width: 100%;
    min-width: 0;
  }

  thead {
    display: none;
  }

  tbody {
    display: grid;
    gap: 0.85rem;
  }

  tr {
    overflow: hidden;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: 0 10px 28px rgba(13, 45, 87, 0.08);
  }

  tr:hover td {
    background: transparent;
  }

  td {
    display: grid;
    grid-template-columns: 92px minmax(0, 1fr);
    gap: 0.75rem;
    align-items: start;
    padding: 0.72rem 0.85rem;
    border-bottom: 1px solid var(--border);
    line-height: 1.45;
    overflow-wrap: anywhere;
  }

  td::before {
    content: attr(data-label);
    color: var(--muted);
    font-size: 0.82rem;
    font-weight: 800;
  }

  td:last-child {
    border-bottom: 0;
  }

  td[data-label="ห้อง"],
  td[data-label="วันที่/เวลา"],
  td[data-label="สถานะ"] {
    background: #fbfdff;
  }

  .empty-row {
    box-shadow: none;
  }

  .empty-row td {
    display: block;
    padding: 0;
  }

  .empty-row td::before {
    content: "";
  }

  .action-stack {
    display: grid;
    grid-template-columns: 1fr;
    width: 100%;
  }

  .action-stack .btn,
  .actions-row .btn {
    width: 100%;
  }

  .actions-row {
    display: grid;
    grid-template-columns: 1fr;
  }

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

  .calendar-card {
    padding: 0.75rem;
  }

  .calendar-nav-actions,
  .calendar-view-actions {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .calendar-view-actions {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

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

  .calendar-month-grid {
    display: grid;
    grid-template-columns: 1fr;
  }

  .calendar-weekdays {
    display: none;
  }

  .calendar-day {
    min-height: auto;
    border: 1px solid var(--border);
    border-radius: 8px;
    margin-bottom: 0.65rem;
  }

  .calendar-day.muted-day {
    display: none;
  }

  .calendar-day-number {
    margin-bottom: 0.5rem;
  }

  .calendar-event span,
  .calendar-event strong,
  .calendar-event small {
    white-space: normal;
  }

  .calendar-week-grid {
    grid-template-columns: 1fr;
    overflow: visible;
    border: 0;
    gap: 0.65rem;
  }

  .calendar-week-day {
    min-height: auto;
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow: hidden;
  }

  .modal-backdrop {
    align-items: end;
    padding: 0.5rem;
  }

  .modal-card {
    max-height: 88vh;
    border-radius: 12px 12px 0 0;
  }

  .modal-header {
    flex-direction: column;
  }

  .modal-header .btn {
    width: 100%;
  }

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

  .detail-item:nth-child(odd) {
    padding-right: 0;
  }

  .toast {
    right: 0.75rem;
    left: 0.75rem;
    bottom: 0.75rem;
    max-width: none;
  }
}

@media (max-width: 430px) {
  .layout {
    width: 100% !important;
    padding-inline: 0 !important;
  }

  .app-shell {
    width: calc(100% - 1.2rem);
  }

  .public-landing,
  .login-card {
    width: calc(100% - 1.2rem);
  }

  .topbar {
    padding: 0.55rem 0.45rem;
    gap: 0.45rem;
  }

  .brand {
    flex-direction: row;
    gap: 0.5rem;
  }

  .logo {
    width: 40px;
    height: 40px;
  }

  h1 {
    font-size: 0.98rem;
  }

  .home-link {
    padding-inline: 0.58rem;
    font-size: 0.82rem;
    max-width: 104px;
  }

  .menu-toggle {
    width: 42px;
    height: 42px;
  }

  .user-box .btn,
  .inline-row .btn {
    width: 100%;
  }

  .content {
    padding-inline: 0;
  }

  .page-header .btn {
    width: auto;
  }

  input,
  select,
  textarea {
    font-size: 16px;
  }

  td {
    grid-template-columns: 82px minmax(0, 1fr);
    padding: 0.68rem 0.75rem;
  }

  .checkbox-line {
    align-items: flex-start;
    line-height: 1.45;
  }

  .recurrence-box {
    padding: 0.8rem;
  }

  .landing-hero {
    padding: 1rem;
  }

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

  .calendar-nav-actions,
  .calendar-view-actions {
    grid-template-columns: 1fr;
  }

  .nav {
    padding-inline: 0.75rem;
    font-size: 0.86rem;
  }
}
