* { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --primary: #4a6cf7;
  --primary-dark: #3b5de7;
  --bg: #f0f2f5;
  --card: #ffffff;
  --text: #1a1a2e;
  --text-secondary: #6b7280;
  --border: #e5e7eb;
  --warn: #f59e0b;
  --done: #22c55e;
  --danger: #ef4444;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.container { max-width: 500px; margin: 0 auto; padding: 0 12px 80px; }

/* Header */
.header { padding: 16px 0 12px; }
.header-top { display: flex; align-items: center; justify-content: space-between; }
.header h1 { font-size: 20px; font-weight: 700; letter-spacing: -0.3px; }
.subtitle { font-size: 13px; color: var(--text-secondary); margin-top: 2px; }
.header-actions { display: flex; gap: 8px; }
.btn-icon { text-decoration: none; font-size: 20px; padding: 4px; }

/* Card */
.card {
  background: var(--card);
  border-radius: 14px;
  padding: 16px;
  margin-bottom: 12px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}

/* Stats Card */
.stats-main { display: flex; align-items: center; gap: 20px; }
.stats-progress { position: relative; width: 100px; height: 100px; flex-shrink: 0; }
.progress-ring { width: 100%; height: 100%; transform: rotate(-90deg); }
.progress-bg { fill: none; stroke: #e9ecef; stroke-width: 8; }
.progress-fill { fill: none; stroke: var(--primary); stroke-width: 8; stroke-linecap: round; transition: stroke-dashoffset 0.8s ease; }
.progress-text {
  position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
  font-size: 22px; font-weight: 700; color: var(--primary);
}
.progress-text small { font-size: 12px; font-weight: 400; color: var(--text-secondary); }
.stats-info { flex: 1; }
.stat-row { display: flex; align-items: baseline; margin-bottom: 4px; font-size: 14px; }
.stat-label { color: var(--text-secondary); min-width: 60px; }
.stat-value { font-weight: 700; font-size: 18px; margin: 0 4px; }
.stat-value.warn { color: var(--warn); }
.stat-value.done { color: var(--done); }
.stat-unit { color: var(--text-secondary); font-size: 12px; }

/* Month Nav */
.month-nav {
  display: flex; align-items: center; justify-content: center;
  gap: 20px; margin-bottom: 12px;
}
.nav-btn { font-size: 28px; color: var(--primary); text-decoration: none; padding: 4px 12px; }
.nav-title { font-size: 16px; font-weight: 600; }

/* Quick Add */
.quick-add-header { display: flex; justify-content: space-between; align-items: center; cursor: pointer; font-weight: 600; }
.quick-add-body { margin-top: 12px; }
.today-label { font-size: 14px; color: var(--text-secondary); margin-bottom: 10px; }
.trip-btns { display: flex; gap: 8px; flex-wrap: wrap; }
.trip-btn {
  padding: 10px 16px; border: none; border-radius: 10px;
  background: var(--bg); color: var(--text);
  font-size: 14px; font-weight: 600; cursor: pointer;
  transition: all 0.15s; flex: 1; min-width: 65px;
}
.trip-btn:active { transform: scale(0.96); }
.trip-btn.big { background: #fef3c7; color: #92400e; }
.trip-btn.zero { background: #fee2e2; color: #991b1b; }
.trip-btn.custom { background: #e0e7ff; color: #3730a3; }

.custom-input { display: flex; gap: 8px; margin-top: 8px; }
.custom-input input { flex: 1; padding: 8px 12px; border: 1px solid var(--border); border-radius: 8px; font-size: 14px; }
.custom-input button { padding: 8px 16px; border: none; border-radius: 8px; background: var(--primary); color: white; font-weight: 600; }

/* Note Card */
.note-card { display: flex; gap: 8px; align-items: center; }
.note-card input { flex: 1; padding: 8px 12px; border: 1px solid var(--border); border-radius: 8px; font-size: 14px; }
.note-card button { padding: 8px 16px; border: none; border-radius: 8px; background: var(--primary); color: white; font-weight: 600; }

/* Calendar */
.weekday-header { display: grid; grid-template-columns: repeat(7, 1fr); text-align: center; margin-bottom: 8px; }
.weekday-header span { font-size: 12px; color: var(--text-secondary); padding: 4px 0; }

.calendar-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 3px; }
.cal-cell {
  aspect-ratio: 1; display: flex; flex-direction: column; align-items: center;
  justify-content: center; border-radius: 10px; cursor: pointer;
  transition: all 0.15s; position: relative; padding: 2px;
  min-height: 52px;
}
.cal-cell:active { transform: scale(0.92); }
.cal-cell.empty { cursor: default; }
.cal-cell.empty:active { transform: none; }
.cal-cell.future { opacity: 0.35; cursor: default; }
.cal-cell.future:active { transform: none; }
.cal-cell.today { background: var(--primary); color: white; box-shadow: 0 2px 8px rgba(74,108,247,0.3); }
.cal-cell.today .cal-date { color: white; }
.cal-cell.today .cal-day-shift { color: rgba(255,255,255,0.7); }
.cal-cell.today .cal-count { background: rgba(255,255,255,0.25); color: white; }

.cal-date { font-size: 15px; font-weight: 600; }
.cal-day-shift { font-size: 9px; color: #aaa; margin-top: 1px; }
.cal-count {
  font-size: 11px; font-weight: 700; color: var(--primary);
  background: #eef2ff; border-radius: 50%; width: 22px; height: 22px;
  display: flex; align-items: center; justify-content: center;
  margin-top: 1px;
}
.cal-count.big { background: #fef3c7; color: #92400e; }
.cal-count.zero { background: #fee2e2; color: #991b1b; font-size: 9px; }
.cal-note { position: absolute; top: 2px; right: 4px; font-size: 8px; }

/* Modal */
.modal-overlay {
  position: fixed; top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.4); z-index: 100;
  display: none; align-items: center; justify-content: center;
  padding: 20px; backdrop-filter: blur(4px);
}
.modal-overlay.active { display: flex; }
.modal {
  background: white; border-radius: 18px; padding: 24px;
  width: 100%; max-width: 340px; animation: modalIn 0.2s ease;
}
@keyframes modalIn { from { transform: scale(0.9); opacity: 0; } to { transform: scale(1); opacity: 1; } }

.modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; }
.modal-header #modalDate { font-size: 16px; font-weight: 700; }
.modal-shift { font-size: 13px; color: var(--text-secondary); }
.modal-body { text-align: center; }
.modal-count-display { display: flex; align-items: center; justify-content: center; gap: 16px; margin-bottom: 4px; }
.count-btn {
  width: 44px; height: 44px; border-radius: 50%; border: 2px solid var(--border);
  background: white; font-size: 22px; cursor: pointer; color: var(--text);
  display: flex; align-items: center; justify-content: center;
}
.count-btn:active { background: var(--bg); }
.modal-count { font-size: 42px; font-weight: 700; min-width: 60px; }
.count-hint { font-size: 13px; color: var(--text-secondary); display: block; margin-bottom: 12px; }
.modal-body input { width: 100%; padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px; font-size: 14px; margin-bottom: 16px; }
.modal-actions { display: flex; gap: 8px; margin-bottom: 12px; }
.modal-actions button { flex: 1; padding: 12px; border: none; border-radius: 10px; font-size: 15px; font-weight: 600; cursor: pointer; }
.btn-primary { background: var(--primary); color: white; }
.btn-secondary { background: var(--bg); color: var(--text); }
.modal-presets { display: flex; gap: 8px; }
.modal-presets button {
  flex: 1; padding: 8px; border: 1px solid var(--border); border-radius: 8px;
  background: white; font-size: 13px; cursor: pointer; color: var(--text);
}
.modal-presets button:active { background: var(--bg); }

/* Login */
.login-page { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 20px; background: var(--bg); }
.login-card { background: white; border-radius: 20px; padding: 36px 28px; width: 100%; max-width: 360px; text-align: center; box-shadow: 0 4px 20px rgba(0,0,0,0.08); }
.login-icon { font-size: 48px; margin-bottom: 12px; }
.login-card h2 { margin-bottom: 4px; }
.login-subtitle { color: var(--text-secondary); font-size: 14px; margin-bottom: 24px; }
.login-card input { width: 100%; padding: 14px; border: 2px solid var(--border); border-radius: 12px; font-size: 16px; text-align: center; margin-bottom: 12px; }
.login-card input:focus { outline: none; border-color: var(--primary); }
.login-card button { width: 100%; padding: 14px; border: none; border-radius: 12px; background: var(--primary); color: white; font-size: 16px; font-weight: 600; cursor: pointer; }
.error-text { color: var(--danger); font-size: 13px; margin-bottom: 8px; }

/* Settings */
.section-title { font-size: 16px; font-weight: 700; margin-bottom: 16px; }
.section-subtitle { font-size: 14px; font-weight: 600; color: var(--text-secondary); margin: 16px 0 8px; }
.form-group { margin-bottom: 12px; }
.form-group label { display: block; font-size: 13px; color: var(--text-secondary); margin-bottom: 4px; }
.form-group input, .form-group select {
  width: 100%; padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px; font-size: 14px;
}
.form-group input:focus { outline: none; border-color: var(--primary); }
.form-row { display: flex; gap: 8px; }
.form-group.half { flex: 1; }
.checkbox-label { display: flex !important; align-items: center; gap: 8px; font-size: 14px !important; color: var(--text) !important; cursor: pointer; }
.checkbox-label input[type="checkbox"] { width: 18px; height: 18px; }
.btn-group { display: flex; gap: 8px; }

/* Toast */
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: #323232; color: white; padding: 12px 24px;
  border-radius: 12px; font-size: 14px; font-weight: 500;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  opacity: 0; transition: opacity 0.3s; z-index: 200;
  white-space: nowrap;
}
.toast.show { opacity: 1; }

.register-link { text-align: center; margin-top: 20px; font-size: 14px; color: var(--text-secondary); }
.register-link a { color: var(--primary); text-decoration: none; font-weight: 600; }
.hint-text { font-size: 12px; color: #aaa; margin: 8px 0 0; }

/* Rotation mode toggle */
.rotation-mode-group {
  display: flex; gap: 8px;
}
.radio-label {
  flex: 1; display: flex; align-items: center; justify-content: center;
  gap: 6px; padding: 10px; border: 2px solid var(--border);
  border-radius: 10px; cursor: pointer; font-size: 14px; font-weight: 600;
  transition: all 0.15s; background: white;
}
.radio-label.active {
  border-color: var(--primary); background: #eef2ff; color: var(--primary);
}
.radio-label input[type="radio"] { display: none; }

.header-left { display: flex; align-items: center; gap: 8px; }
.user-badge { background: #eef2ff; color: var(--primary); font-size: 12px; font-weight: 600; padding: 2px 10px; border-radius: 20px; white-space: nowrap; }
.user-switcher { position: relative; }
.user-dropdown { position: absolute; top: 100%; right: 0; background: white; border-radius: 10px; box-shadow: 0 4px 20px rgba(0,0,0,0.12); min-width: 120px; z-index: 50; padding: 4px; }
.user-dropdown a { display: block; padding: 8px 14px; font-size: 14px; color: var(--text); text-decoration: none; border-radius: 6px; }
.user-dropdown a:hover { background: var(--bg); }

/* Note input row */
.note-input-row input {
  width: 100%; padding: 10px 12px;
  border: 1px solid var(--border); border-radius: 10px;
  font-size: 14px; outline: none;
}
.note-input-row input:focus { border-color: var(--primary); }

/* Default trips adjuster */
.default-trips-adjuster {
  display: flex; align-items: center; gap: 4px;
  background: var(--bg); border-radius: 20px;
  padding: 2px 4px; font-size: 12px;
}
.dt-label { color: var(--text-secondary); padding: 0 2px; font-size: 11px; }
.dt-btn {
  width: 22px; height: 22px; border: none;
  border-radius: 50%; background: var(--card);
  font-size: 14px; font-weight: 700; cursor: pointer;
  color: var(--primary); display: flex;
  align-items: center; justify-content: center;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}
.dt-btn:active { transform: scale(0.9); }
.dt-val { font-weight: 700; font-size: 13px; min-width: 16px; text-align: center; }

/* Auto-fill hint */
.auto-fill-hint {
  margin-top: 10px; padding: 8px 12px;
  background: #fefce8; border: 1px solid #fde68a;
  border-radius: 10px; font-size: 12px; color: #92400e;
  line-height: 1.5;
}
.auto-fill-hint.warn {
  background: #eef2ff; border-color: #a5b4fc;
  color: #3730a3;
}

/* Shift name list (settings) */
.shift-name-item {
  display: flex; gap: 6px; align-items: center;
  margin-bottom: 8px;
}
.shift-name-item .sn-input {
  flex: 1; padding: 10px 12px;
  border: 1px solid var(--border); border-radius: 10px;
  font-size: 14px; outline: none;
}
.shift-name-item .sn-input:focus { border-color: var(--primary); }
.sn-remove {
  width: 32px; height: 32px; border: none;
  border-radius: 50%; background: #fee2e2;
  color: #991b1b; font-size: 14px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.sn-remove:active { transform: scale(0.9); }

/* Modal shift selector */
#modalShiftSelect {
  padding: 6px 10px; border: 1px solid var(--border);
  border-radius: 8px; font-size: 14px;
  background: white; cursor: pointer;
  min-width: 100px; text-align: center;
}

/* Scrollbar */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-thumb { background: #ccc; border-radius: 2px; }

/* Announcement card */
.announcement-card {
  background: #fefce8;
  border: 1px solid #fde68a;
  border-radius: 12px;
  padding: 12px 16px;
  margin-bottom: 12px;
}
.announcement-header {
  font-weight: 700;
  font-size: 14px;
  color: #92400e;
  margin-bottom: 6px;
}
.announcement-content {
  font-size: 13px;
  color: #78350f;
  line-height: 1.6;
}
