/* ── CSS custom properties ────────────────────────── */
:root {
  --bg:              #f8fafc;
  --header-from:     #6366f1;
  --header-to:       #8b5cf6;
  --cell-border:     #e2e8f0;
  --today-color:     #6366f1;
  --other-cell:      #f1f5f9;
  --cell-hover:      rgba(0,0,0,0.04);
  --other-num-color: #b0bec5;
  --sz-day-num:      24px;
  --sz-event-text:   18px;
}

/* ── Reset ────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; overflow: hidden; }

body {
  font-family: 'Segoe UI', system-ui, sans-serif;
  background: var(--bg);
  color: #e2e8f0;
  display: flex;
  flex-direction: column;
}

/* ── Header ───────────────────────────────────────── */
.cal-header {
  flex-shrink: 0;
  background: linear-gradient(135deg, var(--header-from) 0%, var(--header-to) 100%);
  padding: 10px 20px;
  display: flex;
  align-items: center;
  gap: 14px;
  user-select: none;
}

.nav-group { display: flex; align-items: center; gap: 6px; }

.nav-btn {
  background: rgba(255,255,255,0.15);
  border: none; color: #fff;
  width: 30px; height: 30px;
  border-radius: 50%;
  cursor: pointer; font-size: 18px;
  display: flex; align-items: center; justify-content: center;
  transition: background 0.15s;
}
.nav-btn:hover { background: rgba(255,255,255,0.28); }

.month-year-selectors { display: flex; gap: 6px; }
.month-year-selectors select {
  background: rgba(255,255,255,0.15);
  border: 1px solid rgba(255,255,255,0.25);
  color: #fff;
  padding: 4px 8px;
  border-radius: 7px;
  font-size: 14px; font-weight: 600;
  cursor: pointer;
  appearance: none; -webkit-appearance: none; outline: none;
  transition: background 0.15s;
}
.month-year-selectors select:hover { background: rgba(255,255,255,0.25); }
.month-year-selectors select option { background: #312e81; color: #fff; }
#sel-month { min-width: 110px; }
#sel-year  { min-width: 74px; }

.header-mid { flex: 1; text-align: center; font-size: 16px; font-weight: 500; color: rgba(255,255,255,0.75); }
.header-right { display: flex; gap: 8px; align-items: center; }

.btn-today {
  background: rgba(255,255,255,0.15);
  border: 1px solid rgba(255,255,255,0.3);
  color: #fff; padding: 5px 14px; border-radius: 7px;
  cursor: pointer; font-size: 16px; font-weight: 500;
  transition: background 0.15s;
}
.btn-today:hover { background: rgba(255,255,255,0.28); }

.btn-manage {
  background: rgba(255,255,255,0.2);
  border: 1px solid rgba(255,255,255,0.35);
  color: #fff; padding: 5px 14px; border-radius: 7px;
  cursor: pointer; font-size: 16px; font-weight: 600;
  transition: background 0.15s;
}
.btn-manage:hover { background: rgba(255,255,255,0.32); }

/* ── Day-name row ─────────────────────────────────── */
.days-row {
  flex-shrink: 0;
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  border-bottom: 1px solid var(--cell-border);
}
.day-name {
  text-align: center; padding: 6px 0;
  font-size: 18px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 1px;
  color: #475569;
}
.day-name.weekend { color: var(--header-from); }

/* ── Full-page grid ───────────────────────────────── */
.grid {
  flex: 1; min-height: 0;
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  grid-auto-rows: 1fr;
  border-top: 1px solid var(--cell-border);
  border-left: 1px solid var(--cell-border);
  overflow: hidden;
}

/* ── Cells ────────────────────────────────────────── */
.cell {
  border-right: 1px solid var(--cell-border);
  border-bottom: 1px solid var(--cell-border);
  padding: 5px 6px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  cursor: pointer;
  transition: background 0.12s;
}
.cell.other-month   { background: var(--other-cell); }
.cell.current-month { background: transparent; }
.cell.current-month:hover { background: var(--cell-hover); }
.cell.other-month:hover   { background: var(--cell-hover); }
.cell.current-month.holiday,
.cell.today.holiday { background: rgba(239,68,68,0.07); }

.cell-head {
  flex-shrink: 0; margin-bottom: 3px;
  display: flex; align-items: center; gap: 5px;
}

.holiday-marker {
  width: 9px; height: 9px; border-radius: 50%;
  background: #ef4444; flex-shrink: 0;
}

.day-num {
  font-size: var(--sz-day-num);
  width: calc(var(--sz-day-num) + 14px);
  height: calc(var(--sz-day-num) + 14px);
  display: flex; align-items: center; justify-content: center;
  border-radius: 50%;
  font-weight: 500;
}
.cell.other-month .day-num   { color: var(--other-num-color); }
.cell.current-month .day-num { color: #64748b; }
.cell.today .day-num {
  background: var(--today-color);
  color: #fff; font-weight: 700;
  box-shadow: 0 2px 10px rgba(0,0,0,0.4);
}

.cell-body {
  flex: 1; min-height: 0;
  display: flex; flex-direction: column;
  overflow: hidden;
}

/* ── Event area (exclusive) ───────────────────────── */
.cell-event-area { flex-shrink: 0; }

.event-chip {
  display: flex; align-items: center; gap: 4px;
  padding: 3px 7px;
  border-radius: 4px;
  font-size: var(--sz-event-text);
  font-weight: 700;
  overflow: hidden;
}
.event-chip .chip-dot {
  width: 5px; height: 5px; border-radius: 50%;
  background: rgba(255,255,255,0.55);
  flex-shrink: 0;
}
.event-chip .chip-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ── Sidebar ──────────────────────────────────────── */
.sidebar {
  position: fixed; top: 0; right: 0;
  width: 480px; height: 100%;
  background: #1e293b;
  box-shadow: -6px 0 40px rgba(0,0,0,0.6);
  transform: translateX(100%);
  transition: transform 0.3s cubic-bezier(0.4,0,0.2,1);
  z-index: 600;
  display: flex; flex-direction: column; overflow: hidden;
}
.sidebar.open { transform: translateX(0); }

.sidebar-backdrop {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.45);
  z-index: 599; opacity: 0; pointer-events: none;
  transition: opacity 0.3s;
}
.sidebar-backdrop.open { opacity: 1; pointer-events: auto; }

.sidebar-head {
  padding: 18px 22px;
  border-bottom: 1px solid #243044;
  background: #0f172a;
  display: flex; align-items: center; justify-content: space-between;
  flex-shrink: 0;
}
.sidebar-title { font-size: 22px; font-weight: 700; color: #e2e8f0; }
.sidebar-close {
  background: none; border: none; color: #475569;
  cursor: pointer; font-size: 22px; line-height: 1;
  transition: color 0.15s;
}
.sidebar-close:hover { color: #e2e8f0; }

/* Tabs */
.sidebar-tabs {
  display: flex;
  border-bottom: 1px solid #243044;
  background: #0f172a;
  flex-shrink: 0;
}
.s-tab {
  flex: 1; padding: 13px 0;
  font-size: 18px; font-weight: 600;
  border: none; background: none; color: #475569;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: color 0.15s, border-color 0.15s;
}
.s-tab.active { color: #e2e8f0; border-bottom-color: var(--header-from); }
.s-tab:hover:not(.active) { color: #94a3b8; }

.sidebar-body { flex: 1; min-height: 0; overflow-y: auto; }
.sidebar-body::-webkit-scrollbar { width: 5px; }
.sidebar-body::-webkit-scrollbar-track { background: transparent; }
.sidebar-body::-webkit-scrollbar-thumb { background: #334155; border-radius: 3px; }

.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* Label manager sections */
.lm-section { padding: 18px 22px; }

.lm-section-title {
  display: flex; align-items: center; gap: 10px;
  font-size: 18px; font-weight: 700; color: #e2e8f0;
  margin-bottom: 14px;
}
.lm-badge {
  font-size: 12px; font-weight: 600; color: #64748b;
  background: #0f172a; border: 1px solid #334155;
  padding: 3px 9px; border-radius: 10px;
  text-transform: uppercase; letter-spacing: 0.5px;
}

.add-form { display: flex; gap: 9px; align-items: center; margin-bottom: 13px; }

.lni {
  flex: 1; min-width: 0;
  background: #0f172a; border: 1px solid #334155; color: #e2e8f0;
  padding: 9px 12px; border-radius: 8px; font-size: 18px; outline: none;
  transition: border-color 0.15s;
}
.lni:focus { border-color: var(--header-from); }
.lni::placeholder { color: #3d5068; }

input[type="color"] {
  width: 40px; height: 40px;
  border: 2px solid #334155; border-radius: 8px;
  padding: 3px; background: #0f172a;
  cursor: pointer; flex-shrink: 0;
  transition: border-color 0.15s;
}
input[type="color"]:hover { border-color: var(--header-from); }
input[type="color"]::-webkit-color-swatch-wrapper { padding: 0; }
input[type="color"]::-webkit-color-swatch { border: none; border-radius: 4px; }
input[type="color"]::-moz-color-swatch   { border: none; border-radius: 4px; }

.btn-add-sm {
  background: linear-gradient(135deg, var(--header-from), var(--header-to));
  border: none; color: #fff;
  padding: 9px 16px; border-radius: 8px;
  font-size: 18px; font-weight: 600;
  cursor: pointer; white-space: nowrap; transition: opacity 0.15s;
}
.btn-add-sm:hover { opacity: 0.85; }

.lm-list { display: flex; flex-direction: column; gap: 6px; }

.lm-item {
  display: flex; align-items: center; gap: 10px;
  padding: 11px 13px; border-radius: 9px;
  background: #0f172a; border: 1px solid transparent;
  transition: border-color 0.15s;
}
.lm-item:hover { border-color: #334155; }
.lm-swatch { width: 16px; height: 16px; border-radius: 4px; flex-shrink: 0; }
.lm-name   { flex: 1; font-size: 18px; color: #cbd5e1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lm-count  { font-size: 18px; color: #475569; flex-shrink: 0; }
.lm-del {
  background: none; border: none; color: #3d5068;
  cursor: pointer; font-size: 18px; line-height: 1;
  padding: 3px 5px; border-radius: 4px;
  transition: color 0.15s, background 0.15s;
}
.lm-del:hover { color: #ef4444; background: rgba(239,68,68,0.1); }
.lm-empty { font-size: 18px; color: #3d5068; padding: 18px 0; text-align: center; }

/* ── Appearance tab ───────────────────────────────── */
.setting-group { padding: 18px 22px; }

.sg-title {
  font-size: 18px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 1px;
  color: #475569; margin-bottom: 16px;
}

.setting-row {
  display: flex; align-items: center; justify-content: space-between;
  gap: 14px; margin-bottom: 16px;
}
.setting-row:last-child { margin-bottom: 0; }

.sl { font-size: 18px; color: #94a3b8; }
.sc { display: flex; align-items: center; gap: 10px; }

input[type="range"] {
  -webkit-appearance: none; appearance: none;
  width: 130px; height: 4px;
  border-radius: 2px; outline: none; cursor: pointer;
  background: #334155;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 18px; height: 18px; border-radius: 50%;
  background: var(--header-from); cursor: pointer; border: none;
}
input[type="range"]::-moz-range-thumb {
  width: 18px; height: 18px; border-radius: 50%;
  background: var(--header-from); cursor: pointer; border: none;
}

.sv {
  font-size: 18px; color: #64748b;
  width: 46px; text-align: right;
  font-variant-numeric: tabular-nums;
}


.setting-divider { height: 1px; background: #243044; }

.btn-reset {
  width: 100%; padding: 11px;
  background: none; border: 1px solid #334155;
  color: #94a3b8; border-radius: 9px;
  font-size: 18px; font-weight: 500; cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
}
.btn-reset:hover { border-color: #ef4444; color: #fca5a5; }

/* ── Sidebar footer ───────────────────────────────── */
.sidebar-footer {
  padding: 16px 22px; border-top: 1px solid #243044;
  background: #0f172a; display: flex; gap: 10px; flex-shrink: 0;
}
.io-btn {
  flex: 1; font-size: 18px; font-weight: 600;
  padding: 11px 0; border-radius: 8px;
  border: 1px solid #334155; background: transparent;
  color: #94a3b8; cursor: pointer; text-align: center;
  transition: border-color 0.15s, color 0.15s;
}
.io-btn:hover { border-color: var(--header-from); color: #818cf8; }
.io-btn-danger { color: #f87171; border-color: #450a0a; }
.io-btn-danger:hover { border-color: #ef4444; color: #fca5a5; }
.import-wrap { flex: 1; position: relative; display: block; }
.import-wrap input[type="file"] {
  position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; height: 100%;
}

/* ── Date Popover ─────────────────────────────────── */
.popover {
  position: fixed;
  background: #1e293b; border: 1px solid #334155;
  border-radius: 14px; box-shadow: 0 20px 50px rgba(0,0,0,0.7);
  width: 260px; z-index: 700; overflow: hidden;
}
.popover.hidden { display: none; }

.pop-head {
  padding: 10px 14px; background: #0f172a;
  display: flex; align-items: center; justify-content: space-between;
  border-bottom: 1px solid #243044;
}
.pop-title { font-size: 14px; font-weight: 600; color: #64748b; }
.pop-close {
  background: none; border: none; color: #475569;
  cursor: pointer; font-size: 16px; line-height: 1; transition: color 0.15s;
}
.pop-close:hover { color: #e2e8f0; }

.pop-body { max-height: 320px; overflow-y: auto; }
.pop-body::-webkit-scrollbar { width: 3px; }
.pop-body::-webkit-scrollbar-thumb { background: #334155; border-radius: 2px; }

.pop-section { padding: 6px 0; }
.pop-section + .pop-section { border-top: 1px solid #1e293b; }

.pop-section-label {
  padding: 4px 14px 5px;
  font-size: 12px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 1px;
  color: #475569;
  display: flex; align-items: center; gap: 6px;
}
.pop-section-badge {
  font-size: 12px; font-weight: 600;
  background: #334155; color: #64748b;
  padding: 1px 5px; border-radius: 3px; letter-spacing: 0;
}

.pop-row {
  display: flex; align-items: center; gap: 9px;
  padding: 6px 14px; cursor: pointer; transition: background 0.1s;
}
.pop-row:hover { background: #0f172a; }
.pop-row input[type="radio"]    { accent-color: #ef4444; cursor: pointer; flex-shrink: 0; }
.pop-row input[type="checkbox"] { accent-color: var(--header-from); cursor: pointer; flex-shrink: 0; }
.pop-swatch { width: 9px; height: 9px; border-radius: 2px; flex-shrink: 0; }
.pop-lbl      { font-size: 12px; color: #cbd5e1; flex: 1; }
.pop-lbl.none { color: #475569; font-style: italic; }
.pop-hint { padding: 10px 14px; font-size: 14px; color: #3d5068; text-align: center; }

/* ── Toast ────────────────────────────────────────── */
.toast {
  position: fixed; bottom: 24px; left: 50%;
  transform: translateX(-50%) translateY(0);
  background: #1e293b; border: 1px solid #334155;
  color: #e2e8f0; padding: 9px 20px; border-radius: 9px;
  font-size: 13px; box-shadow: 0 10px 30px rgba(0,0,0,0.55);
  z-index: 800; pointer-events: none; opacity: 1;
  transition: opacity 0.35s, transform 0.35s;
}
.toast.hidden  { opacity: 0; transform: translateX(-50%) translateY(8px); }
.toast.success { border-color: #22c55e; }
.toast.error   { border-color: #ef4444; color: #fca5a5; }

/* ── Bulk Assign section ──────────────────────────── */
.bulk-section { border-top: 1px solid #243044; }
.auto-section { border-top: 1px solid #243044; }

.auto-weights { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; }
.aw-row { display: flex; align-items: center; gap: 12px; }
.aw-label { flex: 1; font-size: 18px; color: #94a3b8; }
.aw-input {
  width: 80px; text-align: right;
  background: #0f172a; border: 1px solid #334155; color: #e2e8f0;
  padding: 7px 10px; border-radius: 8px; font-size: 18px; outline: none;
  transition: border-color 0.15s;
}
.aw-input:focus { border-color: var(--header-from); }

.bulk-row { display: flex; gap: 9px; margin-bottom: 10px; }

.bulk-sel {
  flex: 1; min-width: 0;
  background: #0f172a; border: 1px solid #334155; color: #94a3b8;
  padding: 9px 11px; border-radius: 8px; font-size: 18px; outline: none;
  cursor: pointer; transition: border-color 0.15s;
  appearance: none; -webkit-appearance: none;
}
.bulk-sel:focus { border-color: var(--header-from); }
.bulk-sel option { background: #0f172a; }

.bulk-btns { display: flex; gap: 9px; }
.bulk-btn {
  flex: 1;
  background: none; border: 1px solid #334155; color: #94a3b8;
  padding: 9px 6px; border-radius: 8px; font-size: 18px; font-weight: 600;
  cursor: pointer; transition: border-color 0.15s, color 0.15s;
}
.bulk-btn:hover { border-color: var(--header-from); color: #818cf8; }

/* ── Report tab ───────────────────────────────────── */
.report-body { padding: 0; }

.report-section {
  padding: 16px 22px;
  border-bottom: 1px solid #243044;
}
.report-section:last-child { border-bottom: none; }

.report-header {
  display: flex; align-items: center; gap: 10px;
  margin-bottom: 7px;
}
.report-swatch { width: 14px; height: 14px; border-radius: 50%; flex-shrink: 0; }
.report-name { flex: 1; font-size: 18px; font-weight: 700; color: #e2e8f0; }
.report-total {
  font-size: 14px; color: #FFFFFF;
  background: #0f172a; border: 1px solid #334155;
  padding: 2px 9px; border-radius: 8px;
}

.report-label-row {
  display: flex; align-items: center; gap: 10px;
  padding: 4px 0 4px 22px;
}
.report-label-dot { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; }
.report-label-name { flex: 1; font-size: 18px; color: #94a3b8; }
.report-label-count { font-size: 18px; color: #FFFFFF; min-width: 24px; text-align: right; }

.report-empty     { font-size: 18px; color: #3d5068; padding: 24px; text-align: center; }
.report-empty-sub { font-size: 18px; color: #3d5068; padding: 4px 0 4px 22px; }

.report-ranges {
  margin-top: 10px;
  display: flex; flex-direction: column; gap: 3px;
}
.report-range {
  display: flex; align-items: center; justify-content: space-between;
  padding: 7px 12px; border-radius: 7px;
  background: rgba(255,255,255,0.03); border: 1px solid transparent;
  cursor: pointer; transition: background 0.12s, border-color 0.12s;
}
.report-range:hover {
  background: rgba(99,102,241,0.12); border-color: rgba(99,102,241,0.3);
}
.rr-label { font-size: 16px; color: #94a3b8; }
.rr-count { font-size: 14px; color: #475569; margin-left: 10px; flex-shrink: 0; }
.report-range:hover .rr-label { color: #c7d2fe; }
.report-range:hover .rr-count { color: #818cf8; }

/* ── Report filter ────────────────────────────────── */
.report-filter {
  padding: 18px 22px 14px;
  border-bottom: 1px solid #243044;
  display: flex; flex-direction: column; gap: 10px;
}

.rf-scope { display: flex; gap: 7px; }

.rf-btn {
  flex: 1; padding: 9px 0;
  border: 1px solid #334155; background: none;
  color: #64748b; border-radius: 8px;
  font-size: 18px; font-weight: 600; cursor: pointer;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
}
.rf-btn.active { background: var(--header-from); border-color: var(--header-from); color: #fff; }
.rf-btn:hover:not(.active) { border-color: var(--header-from); color: #94a3b8; }

.rf-selects { display: flex; gap: 8px; }
.rf-selects.hidden { display: none; }
