:root {
  --bg: #f7f7fb;
  --surface: #ffffff;
  --indigo-950: #1e1b4b;
  --indigo-900: #312e81;
  --indigo-700: #4338ca;
  --indigo-600: #4f46e5;
  --indigo-200: #c7d2fe;
  --indigo-100: #e0e7ff;
  --indigo-50: #eef2ff;
  --slate-700: #334155;
  --slate-500: #64748b;
  --slate-400: #94a3b8;
  --slate-300: #cbd5e1;
  --slate-200: #e2e8f0;
  --rose-600: #e11d48;
  --rose-100: #ffe4e6;
  --emerald-600: #059669;
  --amber-50: #fffbeb;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Malgun Gothic", sans-serif;
  background: var(--bg);
  color: #1f1b3d;
}
.mono { font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--indigo-950);
  color: white;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
}
.brand { display: flex; align-items: center; gap: 10px; }
.logo {
  width: 36px; height: 36px;
  border-radius: 10px;
  background: var(--indigo-600);
  display: flex; align-items: center; justify-content: center;
  font-size: 18px;
}
.brand-title { font-weight: 700; font-size: 14px; line-height: 1.2; }
.brand-sub { font-size: 11px; color: var(--indigo-200); font-family: monospace; }
.bell-btn {
  position: relative;
  width: 36px; height: 36px;
  border-radius: 10px;
  border: none;
  background: var(--indigo-900);
  color: white;
  font-size: 16px;
  cursor: pointer;
}
.bell-btn:hover { background: #3730a3; }
.bell-count {
  position: absolute; top: -4px; right: -4px;
  background: var(--rose-600);
  color: white;
  font-size: 10px;
  border-radius: 999px;
  width: 16px; height: 16px;
  display: flex; align-items: center; justify-content: center;
  font-family: monospace;
}

.week-nav {
  max-width: 960px;
  margin: 0 auto;
  padding: 16px 16px 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.nav-btn {
  width: 32px; height: 32px;
  border-radius: 8px;
  border: 1px solid var(--slate-200);
  background: white;
  cursor: pointer;
  font-size: 16px;
}
.nav-btn:hover { background: var(--slate-200); }
.week-label { font-weight: 600; font-family: monospace; color: var(--slate-700); font-size: 14px; }

.grid-wrap {
  max-width: 960px;
  margin: 0 auto;
  padding: 16px;
  overflow-x: auto;
}
table.grid {
  width: 100%;
  border-collapse: collapse;
  min-width: 480px;
}
.grid th { padding-bottom: 8px; text-align: center; }
.day-date { font-size: 12px; font-family: monospace; color: var(--slate-400); }
.day-date.today { color: var(--indigo-600); }
.day-label { font-size: 14px; font-weight: 700; color: var(--slate-700); }
.day-label.today { color: var(--indigo-700); }
.hour-label {
  text-align: right;
  padding-right: 8px;
  font-size: 12px;
  font-family: monospace;
  color: var(--slate-400);
  vertical-align: top;
  padding-top: 6px;
  white-space: nowrap;
  width: 56px;
}
.grid td.cell {
  border: 1px solid var(--slate-200);
  padding: 4px;
  vertical-align: top;
  height: 48px;
}
.grid td.cell.now { background: var(--amber-50); }

.slot-empty {
  width: 100%; height: 100%; min-height: 44px;
  border: none; background: transparent;
  border-radius: 8px;
  color: var(--slate-300);
  font-size: 16px;
  cursor: pointer;
}
.slot-empty:hover { background: var(--indigo-50); color: var(--indigo-600); }

.slot-booked {
  width: 100%; height: 100%; min-height: 44px;
  border: 1px solid var(--indigo-200);
  background: var(--indigo-50);
  border-radius: 8px;
  text-align: left;
  padding: 6px 8px;
  cursor: pointer;
}
.slot-booked:hover { background: var(--indigo-100); }
.slot-name { font-size: 13px; font-weight: 700; color: var(--indigo-900); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.slot-dept { font-size: 11px; color: var(--indigo-600); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.slot-time { font-size: 10px; color: var(--indigo-400); font-family: monospace; margin-top: 2px; }
.slot-booked.locked { opacity: 0.55; cursor: default; }
.slot-empty.locked { opacity: 0.3; cursor: default; }
.slot-empty.locked:hover { background: transparent; color: var(--slate-300); }

.hint {
  max-width: 960px;
  margin: 0 auto;
  padding: 0 16px 32px;
  font-size: 12px;
  color: var(--slate-500);
  line-height: 1.6;
}

.overlay {
  position: fixed; inset: 0;
  background: rgba(15, 23, 42, 0.4);
  display: flex; align-items: center; justify-content: center;
  padding: 16px;
  z-index: 30;
}
.overlay.hidden { display: none; }
.overlay.panel-mode { justify-content: flex-end; align-items: stretch; padding: 0; background: transparent; }

.modal {
  background: white;
  border-radius: 14px;
  box-shadow: 0 20px 40px rgba(0,0,0,0.2);
  width: 100%;
  max-width: 380px;
  padding: 20px;
}
.modal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.modal-head h2 { font-size: 16px; margin: 0; color: #1e293b; }
.icon-btn { border: none; background: none; font-size: 16px; color: var(--slate-400); cursor: pointer; }
.icon-btn:hover { color: var(--slate-700); }
.modal-meta { font-size: 12px; color: var(--slate-500); margin-bottom: 12px; }

.field { margin-bottom: 12px; }
.field label { font-size: 12px; color: var(--slate-500); display: block; margin-bottom: 4px; }
.field input, .field select {
  width: 100%;
  border: 1px solid var(--slate-300);
  border-radius: 8px;
  padding: 9px 10px;
  font-size: 14px;
}
.field input:focus, .field select:focus { outline: none; border-color: var(--indigo-600); box-shadow: 0 0 0 2px var(--indigo-100); }
.row-2 { display: flex; gap: 10px; }
.row-2 .field { flex: 1; }

.error-text { color: var(--rose-600); font-size: 12px; margin: -4px 0 10px; }

.btn-row { display: flex; gap: 8px; }
.btn-primary {
  flex: 1;
  background: var(--indigo-900);
  color: white;
  border: none;
  border-radius: 8px;
  padding: 10px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}
.btn-primary:hover { background: #3730a3; }
.btn-danger {
  border: 1px solid var(--rose-100);
  background: white;
  color: var(--rose-600);
  border-radius: 8px;
  padding: 10px 14px;
  cursor: pointer;
  font-size: 15px;
}
.btn-danger:hover { background: var(--rose-100); }
.btn-full {
  width: 100%;
  background: var(--indigo-900);
  color: white;
  border: none;
  border-radius: 8px;
  padding: 10px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}
.btn-full:hover { background: #3730a3; }

.unlock-note { display: flex; gap: 6px; align-items: center; font-size: 13px; color: var(--slate-700); margin-bottom: 10px; }
.checkbox-field { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--slate-700); margin-bottom: 12px; cursor: pointer; }
.checkbox-field input { width: 16px; height: 16px; }
.header-actions { display: flex; gap: 8px; align-items: center; }
.bell-btn.admin-active { background: #b45309; }
.admin-banner {
  max-width: 960px; margin: 8px auto 0; padding: 0 16px;
  font-size: 12px; color: #92400e;
}

.panel {
  width: 320px;
  max-width: 85vw;
  background: white;
  height: 100%;
  box-shadow: -8px 0 24px rgba(0,0,0,0.15);
  padding: 16px;
  overflow-y: auto;
}
.panel-scrim { flex: 1; background: rgba(15, 23, 42, 0.3); }
.notif-item {
  border: 1px solid var(--slate-200);
  border-radius: 8px;
  padding: 10px 12px;
  margin-bottom: 8px;
}
.notif-name { font-size: 14px; font-weight: 700; color: var(--slate-700); }
.notif-dept { font-size: 13px; color: var(--slate-400); font-weight: 400; }
.notif-time { font-size: 12px; color: var(--slate-500); font-family: monospace; margin-top: 4px; }
.notif-cancelled { font-size: 11px; color: #fb7185; margin-top: 4px; }
.empty-note { color: var(--slate-400); font-size: 14px; text-align: center; margin-top: 40px; }

.toast {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  padding: 10px 16px;
  border-radius: 10px;
  color: white;
  font-size: 14px;
  font-weight: 600;
  box-shadow: 0 10px 24px rgba(0,0,0,0.2);
  z-index: 40;
  background: #1e293b;
}
.toast.success { background: var(--emerald-600); }
.toast.cancel { background: var(--rose-600); }
.toast.error { background: #be123c; }
.hidden { display: none !important; }

@media (max-width: 480px) {
  .topbar { padding: 10px 12px; }
  .logo { width: 30px; height: 30px; font-size: 15px; }
  .brand-title { font-size: 13px; }
  .brand-sub { font-size: 10px; }
  .bell-btn { width: 32px; height: 32px; font-size: 14px; }
  .header-actions { gap: 6px; }

  .week-nav { padding: 12px 10px 0; }
  .nav-btn { width: 28px; height: 28px; font-size: 14px; }
  .week-label { font-size: 12px; }

  .grid-wrap { padding: 8px; }
  table.grid { min-width: 0; width: 100%; table-layout: fixed; }
  .hour-label { width: 32px; font-size: 9px; padding-right: 3px; }
  .day-date { font-size: 9px; }
  .day-label { font-size: 11px; }
  .grid td.cell { padding: 1px; height: 40px; }
  .slot-name { font-size: 10px; }
  .slot-dept { font-size: 9px; }
  .slot-time { font-size: 8px; }
  .slot-empty { font-size: 13px; min-height: 36px; }
  .slot-booked { padding: 3px 4px; min-height: 36px; }

  .hint { font-size: 11px; padding: 0 10px 24px; }

  .overlay { padding: 10px; }
  .modal { padding: 16px; border-radius: 12px; }
  .field input, .field select { font-size: 16px; padding: 10px; }
  .panel { width: 100%; max-width: 100%; }
}
