/* ===== RESET & BASE ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #f5f6fa;
  --surface: #ffffff;
  --surface2: #f0f2f8;
  --border: #e2e5ef;
  --text: #1a1d2e;
  --text-muted: #7b8099;
  --primary: #4f8ef7;
  --primary-dark: #3a76e8;
  --danger: #e74c3c;
  --today-bg: #4f8ef7;
  --radius: 10px;
  --shadow: 0 2px 12px rgba(0,0,0,.08);
  --shadow-lg: 0 8px 32px rgba(0,0,0,.15);
  --header-h: 64px;
}

body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ===== HEADER ===== */
header {
  height: var(--header-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 100;
  flex-shrink: 0;
}

header h1 {
  font-size: 20px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -.4px;
}

.header-left { display: flex; align-items: center; gap: 12px; }
.header-right { margin-left: auto; display: flex; gap: 10px; }

/* ===== BUTTONS ===== */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 16px; border-radius: 8px; border: none;
  font-size: 13px; font-weight: 500; cursor: pointer;
  transition: background .15s, transform .1s;
  white-space: nowrap;
}
.btn:active { transform: scale(.97); }
.btn svg { width: 16px; height: 16px; fill: currentColor; }

.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }

.btn-secondary { background: var(--surface2); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { background: #e5e8f2; }

.btn-ghost { background: transparent; color: var(--text-muted); border: 1px solid var(--border); }
.btn-ghost:hover { background: var(--surface2); color: var(--text); }

.btn-danger { background: #fde8e8; color: var(--danger); }
.btn-danger:hover { background: #fbd5d5; }

.btn-outlook { background: #e8f0fe; color: #0072c6; border: 1px solid #bdd4f5; }
.btn-outlook:hover { background: #d0e3fc; }

/* ===== MAIN LAYOUT ===== */
main {
  display: flex;
  flex: 1;
  overflow: hidden;
}

/* ===== SIDEBAR ===== */
.sidebar {
  width: 260px;
  min-width: 260px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  padding-bottom: 20px;
}

/* ===== MINI CALENDAR ===== */
.mini-cal {
  padding: 16px;
  border-bottom: 1px solid var(--border);
}

.mini-cal-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 12px;
}
.mini-cal-header button {
  background: none; border: none; cursor: pointer;
  font-size: 20px; color: var(--text-muted); padding: 2px 6px;
  border-radius: 6px; line-height: 1;
}
.mini-cal-header button:hover { background: var(--surface2); color: var(--text); }
.mini-cal-header span { font-weight: 600; font-size: 13px; }

.mini-cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
  text-align: center;
}

.mini-cal-grid .day-label {
  font-size: 10px; color: var(--text-muted); font-weight: 600;
  padding: 4px 0; text-transform: uppercase;
}

.mini-cal-grid .mini-day {
  width: 30px; height: 30px; display: flex; align-items: center;
  justify-content: center; border-radius: 50%; font-size: 12px;
  cursor: pointer; margin: 0 auto; transition: background .12s;
}
.mini-day:hover { background: var(--surface2); }
.mini-day.other-month { color: var(--text-muted); opacity: .4; }
.mini-day.today { background: var(--today-bg); color: #fff; font-weight: 700; }
.mini-day.selected { background: var(--primary-dark); color: #fff; font-weight: 700; }
.mini-day.has-event::after {
  content: ''; display: block; width: 4px; height: 4px;
  border-radius: 50%; background: var(--primary);
  position: absolute; bottom: 3px; left: 50%; transform: translateX(-50%);
}
.mini-day { position: relative; }

/* ===== AGENDA LIST ===== */
.agenda-list {
  flex: 1;
  padding: 12px 16px;
}

.agenda-list h4 {
  font-size: 11px; font-weight: 700; text-transform: uppercase;
  color: var(--text-muted); letter-spacing: .6px;
  margin-bottom: 8px; margin-top: 12px;
}
.agenda-list h4:first-child { margin-top: 0; }

.agenda-item {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 8px 10px; border-radius: 8px; cursor: pointer;
  transition: background .12s; margin-bottom: 4px;
}
.agenda-item:hover { background: var(--surface2); }

.agenda-dot {
  width: 8px; height: 8px; border-radius: 50%;
  margin-top: 4px; flex-shrink: 0;
}

.agenda-info { flex: 1; min-width: 0; }
.agenda-title {
  font-size: 12px; font-weight: 600; white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis;
}
.agenda-time { font-size: 11px; color: var(--text-muted); margin-top: 1px; }

.empty-state {
  color: var(--text-muted); font-size: 12px; text-align: center;
  padding: 24px 0;
}

/* ===== CALENDAR SECTION ===== */
.calendar-section {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg);
}

.cal-header {
  display: flex; align-items: center; gap: 16px;
  padding: 14px 24px; background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.cal-nav {
  display: flex; align-items: center; gap: 8px;
}
.cal-nav button {
  background: none; border: 1px solid var(--border); cursor: pointer;
  font-size: 18px; color: var(--text-muted); padding: 4px 10px;
  border-radius: 8px; line-height: 1; transition: all .12s;
}
.cal-nav button:hover { background: var(--surface2); color: var(--text); }
.cal-nav h2 { font-size: 18px; font-weight: 700; min-width: 200px; }

.view-tabs {
  display: flex; gap: 4px; background: var(--surface2);
  border-radius: 8px; padding: 3px;
}
.tab {
  background: none; border: none; padding: 5px 12px;
  border-radius: 6px; cursor: pointer; font-size: 12px;
  font-weight: 500; color: var(--text-muted); transition: all .12s;
}
.tab.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.tab:hover:not(.active) { color: var(--text); }

/* ===== MONTH VIEW ===== */
#calView { flex: 1; overflow: auto; padding: 16px; }

.month-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 1px;
  background: var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  min-height: calc(100% - 0px);
}

.month-col-header {
  background: var(--surface);
  padding: 8px 0;
  text-align: center;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-muted);
  letter-spacing: .5px;
}

.month-cell {
  background: var(--surface);
  padding: 8px;
  min-height: 100px;
  cursor: pointer;
  transition: background .1s;
  vertical-align: top;
}
.month-cell:hover { background: #f8f9fd; }
.month-cell.other-month { background: #fafbfe; }
.month-cell.other-month .cell-day { color: #ccc; }
.month-cell.today .cell-day {
  background: var(--today-bg); color: #fff;
  border-radius: 50%; width: 26px; height: 26px;
  display: flex; align-items: center; justify-content: center;
}
.month-cell.selected { background: #eef3fe; }

.cell-day {
  font-size: 13px; font-weight: 600; margin-bottom: 4px;
  color: var(--text);
}

.cell-events { display: flex; flex-direction: column; gap: 2px; }

.cell-event {
  font-size: 11px; font-weight: 500; padding: 2px 6px;
  border-radius: 4px; white-space: nowrap; overflow: hidden;
  text-overflow: ellipsis; color: #fff; cursor: pointer;
}
.cell-event:hover { opacity: .85; }

.cell-more {
  font-size: 10px; color: var(--text-muted);
  padding: 1px 6px; font-weight: 600;
}

/* ===== WEEK VIEW ===== */
.week-grid {
  display: grid;
  grid-template-columns: 52px repeat(7, 1fr);
  gap: 1px;
  background: var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  height: 100%;
}

.week-header-cell {
  background: var(--surface);
  padding: 10px 4px;
  text-align: center;
  font-size: 11px; font-weight: 600; text-transform: uppercase;
  color: var(--text-muted); letter-spacing: .4px;
}
.week-header-cell.today-col { color: var(--primary); }
.week-header-cell .wh-day { font-size: 20px; font-weight: 800; color: var(--text); display: block; line-height: 1.2; }
.week-header-cell.today-col .wh-day { color: var(--today-bg); }
.week-time-col { background: var(--surface); }

.week-body { display: contents; }

.week-time-cell {
  background: var(--surface);
  text-align: right; padding-right: 8px;
  font-size: 10px; color: var(--text-muted);
  height: 48px; line-height: 48px; flex-shrink: 0;
}
.week-day-col {
  background: var(--surface);
  position: relative;
  height: 1152px; /* 24h * 48px */
  cursor: pointer;
}
.week-day-col.today-col { background: #fafcff; }
.week-hour-line {
  position: absolute; left: 0; right: 0;
  border-top: 1px solid var(--border);
  height: 48px;
}

.week-event {
  position: absolute; left: 3px; right: 3px;
  border-radius: 5px; padding: 3px 6px;
  font-size: 11px; font-weight: 600; color: #fff;
  overflow: hidden; cursor: pointer; z-index: 2;
}
.week-event:hover { opacity: .85; filter: brightness(1.1); }

.week-now-line {
  position: absolute; left: 0; right: 0;
  height: 2px; background: var(--danger); z-index: 3;
}
.week-now-line::before {
  content: ''; width: 8px; height: 8px; border-radius: 50%;
  background: var(--danger); position: absolute; left: -4px; top: -3px;
}

/* ===== DAY VIEW ===== */
.day-grid {
  display: grid;
  grid-template-columns: 52px 1fr;
  gap: 1px;
  background: var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  height: 100%;
}

.day-col {
  background: var(--surface);
  position: relative;
  height: 1152px;
  cursor: pointer;
}

/* ===== AGENDA/LIST VIEW ===== */
.list-view { display: flex; flex-direction: column; gap: 8px; }
.list-month-group { margin-bottom: 16px; }
.list-month-title {
  font-size: 13px; font-weight: 700; text-transform: uppercase;
  color: var(--text-muted); letter-spacing: .6px;
  padding: 0 4px 8px; border-bottom: 1px solid var(--border); margin-bottom: 8px;
}
.list-event-item {
  display: flex; gap: 14px; align-items: flex-start;
  padding: 12px 14px; background: var(--surface);
  border-radius: var(--radius); cursor: pointer;
  transition: box-shadow .12s, transform .1s;
  border-left: 3px solid var(--primary);
}
.list-event-item:hover { box-shadow: var(--shadow); transform: translateX(2px); }
.list-event-date {
  text-align: center; min-width: 44px;
}
.list-event-date .led { font-size: 22px; font-weight: 800; color: var(--text); line-height: 1; }
.list-event-date .lem { font-size: 10px; text-transform: uppercase; color: var(--text-muted); font-weight: 600; }
.list-event-body { flex: 1; }
.list-event-title { font-weight: 600; font-size: 14px; }
.list-event-meta { font-size: 12px; color: var(--text-muted); margin-top: 3px; }
.list-empty { text-align: center; color: var(--text-muted); padding: 60px 20px; }
.list-empty p { font-size: 16px; margin-bottom: 6px; }
.list-empty small { font-size: 12px; }

/* ===== MODAL ===== */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.45);
  display: flex; align-items: center; justify-content: center;
  z-index: 1000; opacity: 0; pointer-events: none;
  transition: opacity .2s;
}
.modal-overlay.open { opacity: 1; pointer-events: all; }

.modal {
  background: var(--surface);
  border-radius: 14px;
  width: 480px; max-width: 95vw;
  max-height: 90vh; overflow-y: auto;
  box-shadow: var(--shadow-lg);
  transform: translateY(16px);
  transition: transform .2s;
}
.modal-overlay.open .modal { transform: translateY(0); }

.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 20px 24px 0;
}
.modal-header h3 { font-size: 17px; font-weight: 700; }
.close-btn {
  background: none; border: none; font-size: 22px; cursor: pointer;
  color: var(--text-muted); line-height: 1; padding: 2px 6px;
  border-radius: 6px;
}
.close-btn:hover { background: var(--surface2); color: var(--text); }

form { padding: 16px 24px 20px; display: flex; flex-direction: column; gap: 12px; }

.form-group { display: flex; flex-direction: column; gap: 5px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

label { font-size: 12px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: .4px; }
.required { color: var(--danger); }

input[type="text"], input[type="date"], input[type="time"], textarea {
  padding: 9px 12px; border: 1.5px solid var(--border); border-radius: 8px;
  font-size: 13px; font-family: inherit; color: var(--text);
  background: var(--surface); transition: border-color .15s;
  outline: none;
}
input:focus, textarea:focus { border-color: var(--primary); }
textarea { resize: vertical; }

.checkbox-label {
  display: flex; align-items: center; gap: 8px;
  text-transform: none; letter-spacing: 0;
  font-size: 13px; cursor: pointer;
}
.checkbox-label input { width: 16px; height: 16px; accent-color: var(--primary); cursor: pointer; }

.color-picker { display: flex; gap: 8px; flex-wrap: wrap; padding: 4px 0; }
.color-dot {
  width: 26px; height: 26px; border-radius: 50%; cursor: pointer;
  transition: transform .15s; position: relative;
}
.color-dot:hover { transform: scale(1.15); }
.color-dot.active::after {
  content: '✓'; position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 13px; font-weight: 700;
}

.modal-actions {
  display: flex; align-items: center; gap: 10px;
  padding-top: 8px; border-top: 1px solid var(--border); margin-top: 4px;
}
.spacer { flex: 1; }

/* ===== TOAST ===== */
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%) translateY(20px);
  background: #1a1d2e; color: #fff; padding: 10px 20px;
  border-radius: 8px; font-size: 13px; font-weight: 500;
  opacity: 0; pointer-events: none; transition: all .3s;
  z-index: 2000; white-space: nowrap;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ===== SCROLLBAR ===== */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: #c0c5d8; }

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
  .sidebar { display: none; }
  header { padding: 0 12px; }
  .cal-header { flex-wrap: wrap; padding: 10px 12px; gap: 8px; }
  #calView { padding: 8px; }
  .month-cell { min-height: 60px; padding: 4px; }
  .cell-event { display: none; }
  .cell-more { display: block !important; }
}
