:root {
  --bg: #06060e;
  --card: rgba(255,255,255,0.04);
  --card-border: rgba(255,255,255,0.06);
  --card2: rgba(255,255,255,0.02);
  --glass: rgba(255,255,255,0.06);
  --accent: #e94560;
  --accent-glow: rgba(233,69,96,0.3);
  --text: #f0f0f5;
  --text2: #6b6b80;
  --green: #34d399;
  --red: #f43f5e;
  --orange: #fb923c;
  --blue: #60a5fa;
  --purple: #a78bfa;
  --cyan: #22d3ee;
  --radius: 14px;
  --radius-sm: 10px;
}

* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'Segoe UI', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  user-select: none;
  -webkit-user-select: none;
  overflow-x: hidden;
}

/* ── Tab Bar ── */
.tab-bar {
  position: fixed; bottom: 0; left: 0; right: 0;
  display: flex;
  background: rgba(6,6,14,0.92);
  backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
  border-top: 1px solid var(--card-border);
  padding: 4px 0 env(safe-area-inset-bottom, 6px);
  z-index: 100;
}
.tab-bar button {
  flex: 1; background: none; border: none;
  color: var(--text2); font-size: 10px;
  display: flex; flex-direction: column; align-items: center; gap: 1px;
  padding: 6px 0; cursor: pointer;
  transition: color .2s, transform .15s;
}
.tab-bar button:active { transform: scale(0.9); }
.tab-bar button.active { color: var(--accent); }
.tab-bar button svg { width: 22px; height: 22px; }

/* ── Pages ── */
.page {
  display: none; flex: 1; padding: 12px 14px 80px;
  overflow-y: auto; overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
}
.page.active { display: flex; flex-direction: column; animation: fadeIn .25s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ── Month Nav ── */
.month-nav {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 0; margin-bottom: 6px;
}
.month-nav .nav-center { text-align: center; }
.month-nav h2 { font-size: 20px; font-weight: 800; letter-spacing: -0.3px; }
.month-nav .nav-sub { font-size: 12px; color: var(--text2); font-weight: 500; }
.month-nav button {
  background: var(--glass); border: 1px solid var(--card-border);
  color: var(--accent); width: 38px; height: 38px;
  border-radius: 50%; font-size: 18px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: all .15s;
  backdrop-filter: blur(10px);
}
.month-nav button:active { transform: scale(0.88); background: var(--accent-glow); }

/* ── Cycle Legend ── */
.cycle-legend {
  display: flex; align-items: center; justify-content: center;
  gap: 6px; padding: 8px 12px; margin-bottom: 8px;
  background: var(--card); border: 1px solid var(--card-border);
  border-radius: var(--radius); backdrop-filter: blur(10px);
}
.cl-item {
  display: flex; align-items: center; gap: 4px;
  font-size: 11px; font-weight: 700;
}
.cl-dot { width: 8px; height: 8px; border-radius: 50%; }
.cl-arrow { font-size: 10px; color: var(--text2); }

.pattern-info {
  text-align: center; font-size: 11px; color: var(--green);
  padding: 2px 0 6px; font-weight: 500;
}

/* ── Info Bar ── */
.info-bar {
  display: grid; grid-template-columns: repeat(4, 1fr);
  gap: 6px; margin-bottom: 10px;
}
.info-badge {
  background: var(--card); border: 1px solid var(--card-border);
  border-radius: var(--radius-sm); padding: 10px 4px;
  text-align: center; backdrop-filter: blur(10px);
}
.info-badge .label {
  font-size: 9px; color: var(--text2); text-transform: uppercase;
  letter-spacing: 0.8px; font-weight: 600;
}
.info-badge .value { font-size: 16px; font-weight: 800; margin-top: 3px; }

/* ── Calendar Grid ── */
.day-names {
  display: grid; grid-template-columns: repeat(7, 1fr);
  gap: 3px; margin-bottom: 4px;
}
.day-names span {
  text-align: center; font-size: 11px; font-weight: 700;
  color: var(--text2); padding: 6px 0;
}
.day-names span:nth-child(6),
.day-names span:nth-child(7) { color: var(--red); opacity: 0.7; }

.cal-grid {
  display: grid; grid-template-columns: repeat(7, 1fr); gap: 3px;
}
.cal-cell {
  aspect-ratio: 1;
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-sm);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px; cursor: pointer; position: relative;
  transition: transform .12s, box-shadow .2s;
}
.cal-cell:active { transform: scale(0.9); }
.cal-cell.empty { background: transparent; border-color: transparent; pointer-events: none; }
.cal-cell.today {
  border-color: var(--accent);
  box-shadow: 0 0 12px var(--accent-glow), inset 0 0 12px rgba(233,69,96,0.08);
}
.cal-cell.holiday .day-num { color: var(--red); }
.cal-cell.weekend .day-num { color: var(--red); opacity: 0.6; }
.cal-cell .day-num { font-size: 13px; font-weight: 700; line-height: 1; }
.cal-cell .shift-badge {
  font-size: 7.5px; font-weight: 800; padding: 1px 5px;
  border-radius: 4px; color: #fff; line-height: 1.3;
  letter-spacing: 0.3px;
}

/* ── Modal ── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.75);
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  z-index: 200; display: none;
  align-items: flex-end; justify-content: center;
}
.modal-overlay.open { display: flex; }
.modal {
  background: #111122;
  border-top: 1px solid rgba(255,255,255,0.1);
  width: 100%; max-width: 500px; max-height: 90dvh;
  border-radius: 24px 24px 0 0;
  padding: 24px 18px env(safe-area-inset-bottom, 18px);
  overflow-y: auto;
  animation: slideUp .3s cubic-bezier(.22,1,.36,1);
}
@keyframes slideUp { from { transform: translateY(100%); } }

.modal-handle {
  width: 36px; height: 4px; background: rgba(255,255,255,0.15);
  border-radius: 2px; margin: 0 auto 16px;
}
.modal h3 { font-size: 16px; font-weight: 700; }
.modal .holiday-tag {
  display: inline-block; background: var(--red); color: #fff;
  font-size: 10px; font-weight: 700; padding: 2px 8px;
  border-radius: 6px; margin-top: 4px;
}
.modified-tag {
  display: inline-block; background: var(--orange); color: #000;
  font-size: 9px; font-weight: 800; padding: 2px 8px;
  border-radius: 6px; margin-left: 6px; text-transform: uppercase;
  letter-spacing: 0.5px;
}
.pattern-hint {
  font-size: 12px; color: var(--text2); margin-top: 8px;
  padding: 8px 12px; background: var(--glass);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-sm);
}

.modal-section { margin-top: 18px; }
.modal-section .section-title {
  font-size: 10px; color: var(--text2); text-transform: uppercase;
  letter-spacing: 1.2px; font-weight: 700; margin-bottom: 10px;
}

/* Shift grid */
.shift-grid {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px;
}
.shift-btn {
  background: var(--glass); border: 2px solid transparent;
  border-radius: var(--radius-sm); padding: 12px 4px;
  text-align: center; cursor: pointer;
  transition: all .2s; color: var(--text);
}
.shift-btn:active { transform: scale(0.93); }
.shift-btn.selected {
  border-color: currentColor;
  background: rgba(255,255,255,0.08);
  box-shadow: 0 0 16px rgba(255,255,255,0.05);
}
.shift-btn .shift-icon { font-size: 22px; display: block; margin-bottom: 4px; }
.shift-btn .shift-code { font-size: 11px; font-weight: 800; display: block; }
.shift-btn .shift-name { font-size: 8px; color: var(--text2); margin-top: 2px; display: block; }

/* Overtime */
.overtime-row {
  display: flex; align-items: center; justify-content: center;
  gap: 16px; margin-top: 8px;
}
.overtime-row button {
  width: 44px; height: 44px; border-radius: 50%;
  border: 1px solid var(--card-border);
  font-size: 22px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: all .15s;
}
.overtime-row button:active { transform: scale(0.88); }
.overtime-row .minus { background: rgba(244,63,94,0.1); color: var(--red); }
.overtime-row .plus { background: rgba(52,211,153,0.1); color: var(--green); }
.overtime-row .ot-val { font-size: 24px; font-weight: 900; min-width: 70px; text-align: center; }

/* Total */
.total-hours {
  display: flex; justify-content: space-between; align-items: center;
  background: linear-gradient(135deg, rgba(233,69,96,0.1), rgba(233,69,96,0.02));
  border: 1px solid rgba(233,69,96,0.15);
  padding: 14px 18px; border-radius: var(--radius); margin-top: 14px;
}
.total-hours .th-label { font-size: 14px; font-weight: 500; }
.total-hours .th-val { font-size: 26px; font-weight: 900; color: var(--accent); }

/* Note */
.note-input {
  width: 100%; background: var(--glass);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-sm); color: var(--text);
  padding: 12px 14px; font-size: 14px; font-family: inherit;
  resize: vertical; min-height: 60px; margin-top: 8px;
  transition: border-color .2s;
}
.note-input:focus { border-color: var(--accent); outline: none; }
.note-input::placeholder { color: var(--text2); }

/* Modal buttons */
.modal-actions { display: flex; gap: 8px; margin-top: 18px; }
.modal-actions button {
  flex: 1; padding: 15px; border: none;
  border-radius: var(--radius); font-size: 15px; font-weight: 700;
  cursor: pointer; transition: all .15s;
}
.modal-actions button:active { transform: scale(0.96); }
.btn-cancel { background: var(--glass); color: var(--text); border: 1px solid var(--card-border) !important; }
.btn-save {
  background: linear-gradient(135deg, #e94560, #c73659);
  color: #fff; box-shadow: 0 4px 16px var(--accent-glow);
}
.btn-delete {
  background: rgba(52,211,153,0.08); color: var(--green); font-size: 13px !important;
  margin-top: 8px; width: 100%; padding: 12px !important;
  border: 1px solid rgba(52,211,153,0.15) !important; border-radius: var(--radius); cursor: pointer;
}
.btn-pattern-start {
  background: rgba(233,69,96,0.08); color: var(--accent); font-size: 12px;
  margin-top: 8px; width: 100%; padding: 12px; font-weight: 600;
  border: 1px solid rgba(233,69,96,0.15); border-radius: var(--radius); cursor: pointer;
}

/* ── Cards (Summary, Year, Holidays) ── */
.summary-card {
  background: var(--card); border: 1px solid var(--card-border);
  border-radius: var(--radius); padding: 16px;
  margin-bottom: 10px; backdrop-filter: blur(10px);
}
.summary-card h4 {
  font-size: 10px; color: var(--text2); text-transform: uppercase;
  letter-spacing: 1.2px; font-weight: 700; margin-bottom: 12px;
}
.summary-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid rgba(255,255,255,0.03);
}
.summary-row:last-child { border: none; }
.summary-row .sr-left { display: flex; align-items: center; gap: 10px; font-size: 14px; }
.summary-row .sr-icon { width: 20px; text-align: center; font-size: 16px; }
.summary-row .sr-val { font-weight: 800; font-size: 14px; }

/* Progress */
.progress-bar {
  height: 8px; background: rgba(255,255,255,0.04);
  border-radius: 4px; overflow: hidden; margin-top: 10px;
}
.progress-bar .fill { height: 100%; border-radius: 4px; transition: width .6s cubic-bezier(.22,1,.36,1); }
.progress-text {
  display: flex; justify-content: space-between;
  font-size: 12px; color: var(--text2); margin-top: 6px; font-weight: 500;
}

/* ── Half-year card ── */
.half-year-card {
  background: linear-gradient(135deg, rgba(233,69,96,0.08), rgba(96,165,250,0.06));
  border: 1px solid rgba(233,69,96,0.12);
  border-radius: var(--radius); padding: 16px; margin-bottom: 10px;
}
.half-year-card h4 {
  font-size: 10px; color: var(--accent); text-transform: uppercase;
  letter-spacing: 1.2px; font-weight: 800; margin-bottom: 12px;
}
.hy-toggle {
  display: flex; gap: 6px; margin-bottom: 12px;
}
.hy-toggle button {
  flex: 1; padding: 10px; border: 1px solid var(--card-border);
  border-radius: var(--radius-sm); background: var(--glass);
  color: var(--text2); font-size: 12px; font-weight: 700;
  cursor: pointer; transition: all .2s;
}
.hy-toggle button:active { transform: scale(0.95); }
.hy-toggle button.active {
  background: var(--accent); color: #fff;
  border-color: var(--accent); box-shadow: 0 4px 12px var(--accent-glow);
}

/* ── Year ── */
.year-month-row {
  display: flex; align-items: center; gap: 8px;
  padding: 9px 0;
  border-bottom: 1px solid rgba(255,255,255,0.03);
}
.year-month-row:last-child { border: none; }
.ym-name { width: 36px; font-size: 13px; font-weight: 700; }
.ym-bar {
  flex: 1; height: 6px; background: rgba(255,255,255,0.04);
  border-radius: 3px; overflow: hidden;
}
.ym-bar .fill { height: 100%; border-radius: 3px; transition: width .6s cubic-bezier(.22,1,.36,1); }
.ym-info { width: 80px; text-align: right; font-size: 11px; color: var(--text2); font-weight: 500; }
.ym-diff { width: 44px; text-align: right; font-size: 12px; font-weight: 800; }

/* ── Holidays ── */
.holiday-item {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid rgba(255,255,255,0.03);
}
.holiday-item:last-child { border: none; }
.hi-name { font-size: 14px; font-weight: 600; }
.hi-date { font-size: 12px; color: var(--text2); margin-top: 2px; }
.hi-tag {
  font-size: 10px; padding: 4px 10px; border-radius: 6px;
  font-weight: 700; white-space: nowrap;
}
.hi-tag.workday { background: rgba(244,63,94,0.12); color: var(--red); }
.hi-tag.weekend { background: rgba(255,255,255,0.04); color: var(--text2); }

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 0; }
