:root {
  --bg: #ffffff;
  --bg-soft: #f7f6f3;
  --bg-hover: #efeee9;
  --text: #2f2f2f;
  --text-soft: #787673;
  --text-mute: #9b9a97;
  --border: #ebebea;
  --border-soft: #f1f1ef;
  --accent: #2383e2;
  --accent-soft: #e7f3fb;
  --busy: #fef0ef;
  --busy-border: #fcd9d6;
  --busy-text: #c0413a;
  --mine: #fdf5e6;
  --mine-border: #f3dca8;
  --mine-text: #a06c00;
  --floor2-tint: #f4f4f3;
  --floor2-header: #ececea;
  --shadow: 0 1px 2px rgba(15, 15, 15, 0.04), 0 2px 8px rgba(15, 15, 15, 0.04);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; background: var(--bg-soft); color: var(--text); }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Pretendard",
    "Apple SD Gothic Neo", "Noto Sans KR", Roboto, Helvetica, Arial, sans-serif;
  font-size: 14px;
  line-height: 1.5;
}

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 28px; background: var(--bg);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 10;
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark {
  width: 32px; height: 32px; border-radius: 8px;
  background: linear-gradient(135deg, #2f2f2f, #555);
  color: #fff; font-weight: 700; display: grid; place-items: center;
  font-family: ui-serif, Georgia, serif;
}
.brand-title { font-weight: 600; font-size: 15px; }
.brand-sub { font-size: 12px; color: var(--text-mute); }
.brand-link {
  margin-left: 14px; padding: 6px 12px;
  border: 1px solid var(--border); border-radius: 6px;
  font-size: 12px; color: var(--text-soft);
}
.brand-link:hover { background: var(--bg-hover); color: var(--text); }

.date-nav { display: flex; align-items: center; gap: 6px; }
.date-nav input[type="date"] {
  padding: 6px 10px; border: 1px solid var(--border); border-radius: 6px;
  background: var(--bg); font: inherit;
}
.ghost {
  background: transparent; border: 1px solid transparent; color: var(--text);
  padding: 6px 10px; border-radius: 6px; cursor: pointer; font: inherit;
  text-decoration: none; display: inline-block;
}
.ghost:hover { background: var(--bg-hover); }
a.ghost { line-height: 1; }

.layout {
  display: grid; grid-template-columns: minmax(0, 1fr) 340px;
  gap: 20px; padding: 24px 28px; max-width: 1400px; margin: 0 auto;
}
@media (max-width: 980px) {
  .layout { grid-template-columns: 1fr; }
}

.card {
  background: var(--bg); border: 1px solid var(--border); border-radius: 10px;
  box-shadow: var(--shadow); padding: 18px 20px;
}
.card-head {
  display: flex; align-items: baseline; justify-content: space-between;
  margin-bottom: 14px;
}
.card-head h2 { margin: 0; font-size: 16px; font-weight: 600; letter-spacing: -0.01em; }
.hint { color: var(--text-mute); font-size: 12px; }

.timetable-wrap { overflow: auto; border: 1px solid var(--border-soft); border-radius: 8px; }
.timetable {
  width: 100%; border-collapse: collapse; table-layout: fixed;
  font-size: 13px; user-select: none;
}
.timetable thead th {
  position: sticky; top: 0; background: var(--bg);
  border-bottom: 1px solid var(--border);
  font-weight: 600; padding: 10px 8px; text-align: center; color: var(--text-soft);
  z-index: 1;
}
.timetable th.time-col, .timetable td.time-cell {
  width: 56px; text-align: right; padding-right: 10px; color: var(--text-mute);
  font-variant-numeric: tabular-nums; background: var(--bg);
  border-right: 1px solid var(--border-soft);
}
.timetable td {
  height: 22px; border-bottom: 1px dashed var(--border-soft);
  border-right: 1px solid var(--border-soft);
  cursor: pointer; position: relative;
}
.timetable tr.hour-end td { border-bottom: 1px solid var(--border); }
.timetable td:hover:not(.busy):not(.mine) { background: var(--accent-soft); }
.timetable td.selected { background: var(--accent-soft); outline: 2px solid var(--accent); outline-offset: -2px; }
.timetable td.busy {
  background: var(--busy); color: var(--busy-text); cursor: default;
}
.timetable td.mine {
  background: var(--mine); color: var(--mine-text); cursor: default;
}
.timetable td.block-start {
  font-size: 11px; padding: 2px 6px; vertical-align: top; line-height: 1.25;
  font-weight: 500;
}
.timetable td.continued {
  color: transparent;
}

/* 2층 컬럼 옅은 회색 색조 */
.timetable thead th.floor2 { background: var(--floor2-header); }
.timetable td.floor2:not(.busy):not(.mine) { background: var(--floor2-tint); }
.timetable td.floor2:hover:not(.busy):not(.mine) { background: var(--accent-soft); }

.legend {
  display: flex; gap: 16px; margin-top: 10px; font-size: 12px; color: var(--text-soft);
  flex-wrap: wrap;
}
.dot { display:inline-block; width:10px; height:10px; border-radius: 3px; vertical-align: middle; margin-right: 6px; }
.dot-free { background: var(--bg); border:1px solid var(--border); }
.dot-busy { background: var(--busy); border:1px solid var(--busy-border); }
.dot-mine { background: var(--mine); border:1px solid var(--mine-border); }

.form { display: flex; flex-direction: column; gap: 12px; }
.field { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--text-soft); }
.field input, .field select {
  padding: 8px 10px; border: 1px solid var(--border); border-radius: 6px;
  font: inherit; color: var(--text); background: var(--bg);
}
.field input:focus, .field select:focus {
  outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft);
}
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.primary {
  background: var(--text); color: #fff; border: 0; padding: 10px 14px;
  border-radius: 6px; font-weight: 600; cursor: pointer;
  transition: background 0.15s;
}
.primary:hover { background: #000; }
.primary:disabled { background: var(--text-mute); cursor: not-allowed; }

.form-msg { font-size: 12px; min-height: 16px; }
.form-msg.ok { color: #2d7a3e; }
.form-msg.err { color: var(--busy-text); }

.my-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 8px; }
.my-list li {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 12px; background: var(--bg-soft); border: 1px solid var(--border-soft);
  border-radius: 6px;
}
.my-list .meta { font-size: 12px; color: var(--text-soft); }
.my-list .title { font-weight: 500; }
.my-list .cancel {
  background: transparent; border: 1px solid var(--border); color: var(--busy-text);
  padding: 4px 10px; border-radius: 6px; cursor: pointer; font-size: 12px;
}
.my-list .cancel:hover { background: var(--busy); border-color: var(--busy-border); }
.my-list .empty { color: var(--text-mute); padding: 12px; text-align: center; }

/* ── User identity (Phase 2) ────────────────────────────────────── */
.user-info {
  font-size: 13px; color: var(--text-soft);
  padding: 6px 10px; border-radius: 6px;
  background: var(--bg-soft); border: 1px solid var(--border-soft);
}
.user-info b { color: var(--text); margin-right: 4px; }
.user-info a {
  color: var(--accent); text-decoration: none; margin-left: 4px;
  font-size: 12px;
}
.user-info a:hover { text-decoration: underline; }
.hidden { display: none !important; }

/* Modal overlay */
.modal {
  position: fixed; inset: 0; background: rgba(15,15,15,0.45);
  display: flex; align-items: center; justify-content: center;
  z-index: 100; padding: 24px;
}
.modal-body {
  background: var(--bg); padding: 24px 28px; border-radius: 10px;
  box-shadow: 0 10px 32px rgba(0,0,0,0.18);
  min-width: 320px; max-width: 90vw;
}
.modal-body h2 { margin: 0 0 8px 0; font-size: 18px; font-weight: 600; }
.modal-body .hint { display: block; margin-bottom: 14px; }
.modal-body select {
  width: 100%; padding: 10px 12px;
  border: 1px solid var(--border); border-radius: 6px;
  font: inherit; background: var(--bg);
}

/* ── Tabs ─────────────────────────────────────────────────────── */
.tabs {
  display: flex; gap: 4px; padding: 0 28px; max-width: 1400px; margin: 0 auto;
  background: var(--bg-soft); border-bottom: 1px solid var(--border);
}
.tab {
  background: transparent; border: 0; padding: 12px 18px;
  font: inherit; color: var(--text-soft); cursor: pointer;
  border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.tab:hover { color: var(--text); }
.tab.active {
  color: var(--text); font-weight: 600;
  border-bottom-color: var(--accent);
}
.panel.hidden { display: none; }

/* 9층 textarea */
.field textarea {
  padding: 8px 10px; border: 1px solid var(--border); border-radius: 6px;
  font: inherit; color: var(--text); background: var(--bg);
  resize: vertical; min-height: 60px;
}
.field textarea:focus {
  outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft);
}

/* 9층 캘린더는 1시간 단위 → 2층/6층(30분 단위)과 비슷한 높이가 되도록 2배로 */
#timetable9 td { height: 44px; }
#timetable9 td.block-start { vertical-align: middle; }

/* 9층 - 내 신청은 파란 계열 */
.timetable td.mine9 {
  cursor: default; font-size: 11px; padding: 4px 6px;
  vertical-align: top; line-height: 1.3; font-weight: 500;
}
.timetable td.mine9 .mine9-title {
  font-weight: 600;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.timetable td.mine9 .mine9-status { font-size: 10px; opacity: 0.85; }

/* 다른 디피니트 임직원의 9층 신청 (mine9-other) — 보라 계열 */
.timetable td.mine9-other {
  background: #ede9fe;            /* violet-100 */
  color: #6d28d9;                 /* violet-700 */
  border-left: 3px solid #8b5cf6; /* violet-500 */
}

/* 2층/6층 — 디피니트 임직원이 자체 DB로 식별된 셀 (by-dfinite) */
.timetable td.busy.by-dfinite, .timetable td.mine.by-dfinite {
  border-left: 3px solid #2563eb;
}
.timetable td .sub { font-size: 10px; opacity: 0.8; font-weight: 400; }
.timetable td.mine9-approved {
  background: #dbeafe;             /* blue-100 */
  color: #1d4ed8;                  /* blue-700 */
  border-left: 3px solid #2563eb;  /* blue-600 */
}
.timetable td.mine9-pending {
  background: #eff6ff;             /* blue-50 */
  color: #1e40af;                  /* blue-800 */
  border-left: 3px solid #93c5fd;  /* blue-300 */
  background-image: repeating-linear-gradient(
    -45deg, transparent 0 6px, rgba(37,99,235,0.07) 6px 12px);
}

/* 상태 chip (내 신청 리스트) */
.chip {
  display: inline-block; padding: 1px 7px; border-radius: 10px;
  font-size: 11px; font-weight: 500; margin-left: 6px;
  vertical-align: 1px;
}
.chip.status-approved { background: #dbeafe; color: #1d4ed8; }
.chip.status-pending  { background: #fef3c7; color: #92400e; }
.chip.status-rejected { background: var(--busy); color: var(--busy-text); }
.chip.status-cancelled { background: var(--bg-soft); color: var(--text-mute); }
.chip.chip-user { background: #dbeafe; color: #1d4ed8; }

.my-list .meta.err { color: var(--busy-text); }
.f9-item { gap: 8px; align-items: flex-start; }
.f9-item-body { flex: 1; min-width: 0; }
.f9-room { font-weight: 600; }
.f9-event-title {
  margin-top: 2px; font-size: 13px; color: var(--text);
  font-weight: 500; line-height: 1.35;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.f9-when { color: var(--text-mute); font-size: 11px; margin-top: 2px; }
.my-list li.clickable { cursor: pointer; transition: background 0.12s; }
.my-list li.clickable:hover { background: var(--bg-hover); }

/* 지난 신청 collapse */
.f9-past-wrap {
  background: transparent !important; border: 0 !important; padding: 0 !important;
  display: block !important;
}
.f9-past-wrap details summary {
  cursor: pointer; padding: 8px 10px; color: var(--text-soft);
  font-size: 12px; list-style: none;
  border: 1px dashed var(--border); border-radius: 6px;
  user-select: none;
}
.f9-past-wrap details summary::-webkit-details-marker { display: none; }
.f9-past-wrap details summary::before {
  content: "▸ "; display: inline-block; transition: transform 0.15s;
}
.f9-past-wrap details[open] summary::before { content: "▾ "; }
.f9-past-wrap details summary:hover { background: var(--bg-hover); }
.f9-past-list { margin-top: 8px; opacity: 0.85; }
.f9-past-list li { font-size: 13px; }

/* 9층 안내 박스 */
.notice {
  margin-top: 10px; padding: 10px 12px; background: #fff8e1;
  border: 1px solid #f3dca8; border-radius: 6px; font-size: 12px; color: #6b4e00;
  line-height: 1.5;
}
.notice strong { color: #a06c00; }

.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%) translateY(20px);
  background: #2f2f2f; color: #fff; padding: 10px 16px; border-radius: 8px;
  font-size: 13px; opacity: 0; pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.err { background: var(--busy-text); }
