:root {
  --bg: #f3f6fb;
  --text: #1d2939;
  --muted: #667085;
  --card: #ffffff;
  --line: #e4e7ec;
  --brand: #1f6feb;
  --brand-2: #12b76a;
  --danger: #f04438;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "SUIT", sans-serif;
  color: var(--text);
  background: var(--bg);
  min-height: 100vh;
  position: relative;
}

.bg-gradient {
  position: fixed;
  inset: 0;
  background:
    radial-gradient(900px 500px at -5% -10%, #d4ecff 20%, transparent 60%),
    radial-gradient(800px 450px at 110% 0%, #dff8ec 10%, transparent 58%);
  z-index: -1;
}

.topbar {
  max-width: 1100px;
  margin: 0 auto;
  padding: 32px 20px 14px;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
}

.eyebrow {
  margin: 0;
  color: var(--muted);
  font-weight: 700;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
}

h1 {
  margin: 8px 0 0;
  font-size: clamp(28px, 4vw, 42px);
  line-height: 1.1;
}

.today {
  margin: 0;
  color: var(--muted);
  font-weight: 500;
}

.session-line {
  display: flex;
  align-items: center;
  gap: 8px;
}

.login-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 20px;
}

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

.login-card h2 {
  margin: 8px 0 10px;
}

.login-help {
  margin: 0 0 12px;
  color: var(--muted);
  font-size: 14px;
}

.auth-mode-tabs {
  display: inline-flex;
  gap: 6px;
  background: #e2ebf7;
  padding: 4px;
  border-radius: 12px;
  margin-bottom: 10px;
}

.login-form {
  display: grid;
  gap: 8px;
}

.signup-message {
  margin: 10px 0 0;
  color: var(--brand);
  min-height: 18px;
  font-size: 13px;
}

.login-error {
  margin: 10px 0 0;
  color: var(--danger);
  min-height: 18px;
  font-size: 13px;
}

.pending-email {
  margin: 8px 0 16px;
  font-size: 14px;
  font-weight: 700;
}

.member-badge {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
}

.approval-list {
  list-style: none;
  margin: 12px 0 0;
  padding: 0;
  display: grid;
  gap: 8px;
}

.approval-item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: center;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
}

.approval-meta {
  display: grid;
  gap: 2px;
}

.approval-meta strong {
  font-size: 14px;
}

.approval-meta span {
  color: var(--muted);
  font-size: 12px;
}

.layout {
  max-width: 1100px;
  margin: 0 auto;
  padding: 16px 20px 40px;
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
}

.panel {
  background: color-mix(in srgb, var(--card) 92%, #f5f8ff 8%);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 20px;
  box-shadow: 0 8px 25px rgba(16, 24, 40, 0.05);
}

.panel h2 {
  margin: 0 0 14px;
  font-size: 20px;
}

.topbar-actions {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
}

.tabs {
  display: flex;
  gap: 6px;
  background: #e2ebf7;
  padding: 4px;
  border-radius: 12px;
}

.tab-btn {
  background: transparent;
  color: var(--muted);
  border: none;
  padding: 8px 16px;
  border-radius: 8px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.tab-btn:hover {
  background: rgba(255, 255, 255, 0.5);
  color: var(--text);
}

.tab-btn.active {
  background: #ffffff;
  color: var(--brand);
  box-shadow: 0 2px 8px rgba(16, 24, 40, 0.05);
}

.hidden {
  display: none !important;
}

.todo-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 12px;
}

.todo-form {
  display: grid;
  grid-template-columns: minmax(240px, 1fr) minmax(180px, 220px) auto;
  gap: 8px;
  margin-bottom: 12px;
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="datetime-local"],
input[type="time"],
select {
  border: 1px solid var(--line);
  background: #fff;
  padding: 12px 14px;
  border-radius: 10px;
  font: inherit;
}

button {
  border: none;
  background: var(--brand);
  color: #fff;
  padding: 10px 14px;
  border-radius: 10px;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

button:hover {
  filter: brightness(0.95);
}

button.ghost {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--line);
  font-weight: 600;
}

.todo-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 8px;
}

.todo-item {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 10px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px;
}

.todo-item input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--brand-2);
}

.todo-content {
  display: grid;
  gap: 4px;
}

.todo-item span {
  word-break: break-word;
}

.due-time {
  color: var(--muted);
  font-size: 12px;
}

.todo-item.done span {
  color: var(--muted);
  text-decoration: line-through;
}

.todo-item.done .due-time {
  text-decoration: none;
}

.delete {
  background: #fff;
  color: var(--danger);
  border: 1px solid #ffd6d3;
  padding: 6px 10px;
}

/* Calendar Panel */
.calendar-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

.calendar-head h2 {
  margin: 0;
}

.calendar-view-toggle {
  display: flex;
  gap: 4px;
  background: #e2ebf7;
  padding: 4px;
  border-radius: 8px;
  margin-right: auto;
  margin-left: 16px;
}

.calendar-view-toggle .tab-btn {
  padding: 4px 10px;
  font-size: 13px;
}

.calendar-nav {
  display: flex;
  align-items: center;
  gap: 8px;
}

.cal-current-week {
  font-size: 14px;
  font-weight: 700;
  min-width: 150px;
  text-align: center;
}

.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 8px;
  min-height: 200px;
}

.calendar-grid.monthly-view {
  grid-template-rows: auto;
}

.calendar-grid.monthly-view .cal-day {
  min-height: 100px;
}

.calendar-grid.monthly-view .cal-day-header {
  font-size: 12px;
  margin-bottom: 4px;
  padding-bottom: 4px;
}

.calendar-grid.monthly-view .cal-day.other-month {
  opacity: 0.5;
  background: #fdfdfd;
}

.cal-day {
  background: #f8fbff;
  border: 1px solid #e2ebf7;
  border-radius: 12px;
  padding: 10px;
  display: flex;
  flex-direction: column;
}

.cal-day-header {
  font-size: 14px;
  font-weight: 700;
  color: var(--muted);
  text-align: center;
  margin-bottom: 8px;
  padding-bottom: 8px;
  border-bottom: 1px solid #e2ebf7;
  min-height: 40px; /* Ensure space for holiday name */
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.cal-day-header.sunday,
.cal-day-header.holiday {
  color: var(--danger);
}

.cal-day-header.saturday {
  color: var(--brand);
}

.holiday-name {
  display: block;
  font-size: 11px;
  font-weight: 500;
  color: var(--danger);
  margin-top: 2px;
}

.cal-day-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 12px;
}

.cal-event {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 6px;
  word-break: break-word;
}

.cal-event.todo {
  border-left: 3px solid var(--brand-2);
}

.cal-event.schedule {
  border-left: 3px solid var(--brand);
}

.cal-event.schedule.status-휴가 {
  border-left-color: #f04438;
  background: #fff0f0;
}

.cal-event.schedule.status-재택 {
  border-left-color: #12b76a;
  background: #f0f7ff;
}

.cal-event.done {
  opacity: 0.6;
  text-decoration: line-through;
}

.cal-event-title {
  font-weight: 600;
  margin-bottom: 2px;
}

.cal-event-time {
  color: var(--muted);
  font-size: 11px;
}

.schedule-form {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  margin-bottom: 12px;
}

.schedule-help {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.schedule-quick-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.schedule-quick-actions .ghost {
  padding: 8px 10px;
  font-size: 12px;
}

.duty-week-grid {
  display: grid;
  gap: 8px;
}

.duty-week-head {
  display: grid;
  grid-template-columns: 30px 60px 80px 1fr 1fr;
  gap: 8px;
  align-items: center;
}

.duty-week-head span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.duty-week-row {
  display: grid;
  grid-template-columns: 30px 60px 80px 1fr 1fr;
  gap: 8px;
  align-items: center;
}

.duty-week-row > span {
  color: var(--muted);
  font-weight: 700;
  font-size: 13px;
}

.holiday-indicator {
  font-size: 11px;
  color: var(--danger);
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.time-field {
  display: grid;
  grid-template-columns: 1fr;
}

.time-field input[type="time"] {
  width: 100%;
}

.weekly-total-hours {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.schedule-error {
  margin: 0;
  color: var(--danger);
  font-size: 13px;
  min-height: 18px;
}

.schedule-list {
  display: grid;
  gap: 10px;
}

.schedule-person {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px;
}

.schedule-person-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
}

.schedule-person-name {
  margin: 0;
  font-size: 15px;
}

.schedule-week {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 6px;
}

.schedule-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 4px;
  font-size: 14px;
  border: 1px solid #eef2f6;
  border-radius: 10px;
  padding: 8px 4px;
  background: #fdfdfd;
  cursor: pointer;
  transition: box-shadow 0.2s;
}

.schedule-item:hover {
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
}

.schedule-item.edit-mode {
  cursor: default;
  gap: 6px;
  padding: 8px;
}

.schedule-item.edit-mode .edit-status,
.schedule-item.edit-mode .edit-time {
  width: 100%;
  padding: 4px;
  font-size: 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
}

.edit-btn-group {
  display: flex;
  gap: 4px;
  width: 100%;
}

.edit-btn-group button {
  flex: 1;
  padding: 4px;
  font-size: 12px;
  border-radius: 6px;
}

.schedule-item.status-휴가 {
  background: #fff0f0;
  border-color: #ffd6d3;
}

.schedule-item.status-재택 {
  background: #f0f7ff;
  border-color: #d6e8ff;
}

.schedule-day {
  color: var(--muted);
  font-size: 12px;
}

.schedule-badge {
  color: var(--brand);
  font-weight: 700;
}

.schedule-time-text {
  color: var(--muted);
  font-size: 12px;
}

.schedule-delete {
  background: #fff;
  color: var(--danger);
  border: 1px solid #ffd6d3;
  padding: 4px 8px;
  font-size: 12px;
}

.schedule-empty {
  color: var(--muted);
  font-size: 13px;
}

@media (min-width: 860px) {
  .layout:not(.single-column) {
    grid-template-columns: 1fr 1fr;
  }

  .calendar-panel {
    grid-column: 1 / -1;
  }
}

@media (max-width: 860px) {
  .calendar-grid:not(.monthly-view) {
    grid-template-columns: 1fr;
  }
  
  .calendar-grid:not(.monthly-view) .cal-day-header {
    text-align: left;
    margin-bottom: 4px;
    padding-bottom: 4px;
  }
  
  .calendar-grid:not(.monthly-view) .cal-day-content {
    flex-direction: row;
    flex-wrap: wrap;
  }
  
  .calendar-grid:not(.monthly-view) .cal-event {
    flex: 1 1 200px;
  }

  .calendar-grid.monthly-view {
    font-size: 11px;
    gap: 4px;
  }

  .calendar-grid.monthly-view .cal-day {
    padding: 4px;
    min-height: 80px;
  }

  .calendar-grid.monthly-view .cal-event {
    padding: 2px 4px;
    font-size: 10px;
  }
  
  .calendar-grid.monthly-view .cal-event-time {
    display: none;
  }
}

@media (max-width: 680px) {
  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .topbar-actions {
    align-items: flex-start;
    width: 100%;
  }

  .session-line {
    width: 100%;
    justify-content: space-between;
  }

  .approval-item {
    grid-template-columns: 1fr;
  }

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

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

  .duty-week-row {
    grid-template-columns: 24px 60px 60px 1fr 1fr;
  }

  .duty-week-head {
    grid-template-columns: 24px 60px 60px 1fr 1fr;
  }

  .schedule-item {
    grid-template-columns: 44px 1fr;
  }
}
