:root {
  --bg-primary: #0a0e17;
  --bg-secondary: #111827;
  --bg-tertiary: #1f2937;
  --bg-card: #1e293b;
  --bg-card-hover: #273444;
  --border-color: #2d3a4f;
  --border-light: #374151;
  --text-primary: #f1f5f9;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --accent-primary: #3b82f6;
  --accent-primary-hover: #2563eb;
  --accent-secondary: #8b5cf6;
  --accent-success: #10b981;
  --accent-warning: #f59e0b;
  --accent-danger: #ef4444;
  --accent-info: #06b6d4;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.4), 0 2px 4px -1px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.4), 0 4px 6px -2px rgba(0, 0, 0, 0.3);
  --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.5), 0 10px 10px -5px rgba(0, 0, 0, 0.3);
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-xl: 24px;
  --transition-fast: 150ms ease;
  --transition-normal: 250ms ease;
  --transition-slow: 350ms ease;
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --header-height: 72px;
  --sidebar-width: 280px;
}

[data-theme="light"] {
  --bg-primary: #f8fafc;
  --bg-secondary: #ffffff;
  --bg-tertiary: #f1f5f9;
  --bg-card: #ffffff;
  --bg-card-hover: #f8fafc;
  --border-color: #e2e8f0;
  --border-light: #e2e8f0;
  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #94a3b8;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
  --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
}

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

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font-sans);
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
  transition: background var(--transition-normal), color var(--transition-normal);
}

.app-container {
  display: grid;
  grid-template-rows: var(--header-height) 1fr auto;
  grid-template-columns: 1fr var(--sidebar-width);
  min-height: 100vh;
  max-width: 1400px;
  margin: 0 auto;
}

.app-header {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-color);
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-left, .header-center, .header-right {
  display: flex;
  align-items: center;
}

.header-center {
  flex: 1;
  justify-content: center;
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
}

.logo-icon {
  width: 32px;
  height: 32px;
  color: var(--accent-primary);
}

.logo-text {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.02em;
}

.page-title {
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--text-primary);
}

.header-right {
  gap: 16px;
}

.lang-selector select {
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  padding: 8px 36px 8px 12px;
  border-radius: var(--radius-md);
  font-size: 0.875rem;
  font-family: inherit;
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.lang-selector select:focus {
  outline: none;
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
}

.theme-toggle {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 1px solid var(--border-color);
  background: var(--bg-tertiary);
  color: var(--text-primary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background var(--transition-fast), border-color var(--transition-fast), transform var(--transition-fast);
}

.theme-toggle:hover {
  background: var(--bg-card-hover);
  border-color: var(--border-light);
  transform: scale(1.05);
}

.theme-toggle:focus {
  outline: none;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.3);
}

.theme-toggle svg {
  width: 20px;
  height: 20px;
  transition: opacity var(--transition-fast), transform var(--transition-fast);
}

[data-theme="light"] .sun-icon {
  display: none;
}

[data-theme="dark"] .moon-icon {
  display: none;
}

.app-main {
  display: grid;
  grid-template-columns: 1fr var(--sidebar-width);
  gap: 24px;
  padding: 24px;
  max-width: 1400px;
  margin: 0 auto;
  width: 100%;
}

.calendar-section {
  min-width: 0;
}

.calendar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  flex-wrap: wrap;
  gap: 12px;
}

.month-nav {
  display: flex;
  align-items: center;
  gap: 16px;
}

.nav-btn {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 1px solid var(--border-color);
  background: var(--bg-card);
  color: var(--text-primary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-fast);
}

.nav-btn:hover {
  background: var(--bg-card-hover);
  border-color: var(--border-light);
}

.nav-btn:focus {
  outline: none;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.3);
}

.nav-btn svg {
  width: 20px;
  height: 20px;
}

.month-display {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 200px;
  justify-content: center;
}

.month-name {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-primary);
  text-transform: capitalize;
}

.year {
  font-size: 1.25rem;
  font-weight: 500;
  color: var(--text-secondary);
}

.today-btn {
  padding: 10px 20px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  background: var(--bg-card);
  color: var(--text-primary);
  font-size: 0.875rem;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.today-btn:hover {
  background: var(--accent-primary);
  border-color: var(--accent-primary);
  color: white;
}

.today-btn:focus {
  outline: none;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.3);
}

.calendar-grid {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-md);
}

.weekdays {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  background: var(--bg-tertiary);
  border-bottom: 1px solid var(--border-color);
}

.weekday {
  padding: 14px 8px;
  text-align: center;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}

.days {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  grid-auto-rows: minmax(100px, 1fr);
}

.day-cell {
  position: relative;
  padding: 8px;
  min-height: 100px;
  border-right: 1px solid var(--border-color);
  border-bottom: 1px solid var(--border-color);
  background: var(--bg-card);
  cursor: pointer;
  transition: background var(--transition-fast);
  display: flex;
  flex-direction: column;
}

.day-cell:nth-child(7n) {
  border-right: none;
}

.day-cell:hover {
  background: var(--bg-card-hover);
}

.day-cell.today {
  background: rgba(59, 130, 246, 0.1);
  border-color: var(--accent-primary);
}

.day-cell.today .day-number {
  color: var(--accent-primary);
  font-weight: 700;
}

.day-cell.other-month {
  opacity: 0.4;
}

.day-cell.other-month:hover {
  background: var(--bg-card);
}

.day-cell.has-events {
  background: rgba(139, 92, 246, 0.05);
}

.day-number {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-primary);
  margin-bottom: 6px;
}

.day-events {
  display: flex;
  flex-direction: column;
  gap: 3px;
  flex: 1;
  overflow: hidden;
}

.event-dot {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  font-size: 0.625rem;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

.event-dot svg {
  width: 10px;
  height: 10px;
  flex-shrink: 0;
}

.event-dot.meeting { background: rgba(59, 130, 246, 0.2); color: #93c5fd; }
.event-dot.deadline { background: rgba(239, 68, 68, 0.2); color: #fca5a5; }
.event-dot.birthday { background: rgba(245, 158, 11, 0.2); color: #fde047; }
.event-dot.travel { background: rgba(139, 92, 246, 0.2); color: #c4b5fd; }
.event-dot.training { background: rgba(16, 185, 129, 0.2); color: #86efac; }
.event-dot.vacation { background: rgba(6, 182, 212, 0.2); color: #67e8f9; }
.event-dot.appointment { background: rgba(236, 72, 153, 0.2); color: #f9a8d4; }
.event-dot.reminder { background: rgba(107, 114, 128, 0.2); color: #d1d5db; }

.event-dot.tragedy { background: rgba(239, 68, 68, 0.2); color: #fca5a5; }
.event-dot.victory { background: rgba(16, 185, 129, 0.2); color: #86efac; }
.event-dot.death { background: rgba(107, 114, 128, 0.2); color: #d1d5db; }
.event-dot.birth { background: rgba(245, 158, 11, 0.2); color: #fde047; }
.event-dot.culture { background: rgba(139, 92, 246, 0.2); color: #c4b5fd; }

.event-dot svg { width: 12px; height: 12px; flex-shrink: 0; }

.more-events {
  font-size: 0.625rem;
  color: var(--text-muted);
  padding: 2px 6px;
  text-align: center;
}

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 16px;
  padding: 8px 0;
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  font-size: 0.75rem;
  color: var(--text-secondary);
}

.legend-color {
  width: 10px;
  height: 10px;
  border-radius: 2px;
}

.info-panel {
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-width: 0;
}

.info-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow-md);
}

.info-card h2 {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 12px;
}

.info-card p {
  font-size: 0.875rem;
  color: var(--text-secondary);
  line-height: 1.7;
}

.stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 16px;
}

.stat {
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 16px;
  text-align: center;
}

.stat-value {
  display: block;
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--accent-primary);
  line-height: 1.2;
}

.stat-label {
  display: block;
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-top: 4px;
}

.legend-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.legend-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px;
  background: var(--bg-tertiary);
  border-radius: var(--radius-md);
  transition: background var(--transition-fast);
}

.legend-row:hover {
  background: var(--bg-card-hover);
}

.legend-icon {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}

.legend-text {
  font-size: 0.875rem;
  color: var(--text-secondary);
}

.app-footer {
  grid-column: 1 / -1;
  padding: 16px 24px;
  text-align: center;
  border-top: 1px solid var(--border-color);
  background: var(--bg-secondary);
}

.app-footer p {
  font-size: 0.875rem;
  color: var(--text-muted);
}

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  z-index: 1000;
  opacity: 0;
  visibility: hidden;
  transition: opacity var(--transition-normal), visibility var(--transition-normal);
}

.modal-overlay:not([hidden]) {
  opacity: 1;
  visibility: visible;
}

.modal {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-xl);
  max-width: 480px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-xl);
  transform: scale(0.95) translateY(20px);
  transition: transform var(--transition-normal);
}

.modal-overlay:not([hidden]) .modal {
  transform: scale(1) translateY(0);
}

.modal-close {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1px solid var(--border-color);
  background: var(--bg-tertiary);
  color: var(--text-primary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-fast);
  z-index: 10;
}

.modal-close:hover {
  background: var(--accent-danger);
  border-color: var(--accent-danger);
  color: white;
}

.modal-close svg {
  width: 20px;
  height: 20px;
}

.modal-header {
  padding: 24px 24px 16px;
  border-bottom: 1px solid var(--border-color);
  position: relative;
}

.modal-date {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--accent-primary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 4px;
}

.modal-event-type {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  font-size: 0.75rem;
  font-weight: 500;
  text-transform: capitalize;
}

.modal-body {
  padding: 24px;
}

.modal-body h3 {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 16px;
}

.modal-meta {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 20px;
}

.meta-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  background: var(--bg-tertiary);
  border-radius: var(--radius-md);
  font-size: 0.875rem;
  color: var(--text-secondary);
}

.meta-item svg {
  width: 20px;
  height: 20px;
  color: var(--text-muted);
  flex-shrink: 0;
}

.modal-description {
  padding: 16px;
  background: var(--bg-tertiary);
  border-radius: var(--radius-md);
  border-left: 3px solid var(--accent-primary);
  font-size: 0.875rem;
  line-height: 1.7;
  color: var(--text-secondary);
}

@media (max-width: 1024px) {
  .app-container {
    grid-template-columns: 1fr;
    grid-template-rows: var(--header-height) 1fr auto;
  }

  .app-main {
    grid-template-columns: 1fr;
  }

  .info-panel {
    flex-direction: row;
    flex-wrap: wrap;
  }

  .info-card {
    flex: 1;
    min-width: 280px;
  }
}

@media (max-width: 768px) {
  :root {
    --header-height: 64px;
  }

  .app-header {
    padding: 0 16px;
  }

  .page-title {
    font-size: 1rem;
  }

  .logo-text {
    display: none;
  }

  .app-main {
    padding: 16px;
    gap: 16px;
  }

  .month-display {
    min-width: 160px;
  }

  .month-name {
    font-size: 1.25rem;
  }

  .year {
    font-size: 1rem;
  }

  .weekday {
    padding: 10px 4px;
    font-size: 0.625rem;
  }

  .day-cell {
    min-height: 80px;
    padding: 6px;
  }

  .day-number {
    font-size: 0.8rem;
  }

  .event-dot {
    font-size: 0.55rem;
    padding: 1px 4px;
  }

  .info-panel {
    flex-direction: column;
  }

  .info-card {
    min-width: 0;
  }

  .stats {
    grid-template-columns: 1fr;
  }

  .modal {
    margin: 16px;
    max-height: calc(100vh - 32px);
  }

  .modal-body {
    padding: 20px;
  }
}

@media (max-width: 480px) {
  .header-right {
    gap: 8px;
  }

  .lang-selector select {
    padding: 6px 28px 6px 8px;
    font-size: 0.8rem;
  }

  .today-btn {
    padding: 8px 12px;
    font-size: 0.8rem;
  }

  .nav-btn {
    width: 40px;
    height: 40px;
  }

  .month-name {
    font-size: 1.1rem;
  }
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.calendar-grid {
  animation: fadeIn 0.4s ease, slideUp 0.4s ease;
}

.day-cell {
  animation: fadeIn 0.3s ease backwards;
}

.day-cell:nth-child(1) { animation-delay: 0ms; }
.day-cell:nth-child(2) { animation-delay: 10ms; }
.day-cell:nth-child(3) { animation-delay: 20ms; }
.day-cell:nth-child(4) { animation-delay: 30ms; }
.day-cell:nth-child(5) { animation-delay: 40ms; }
.day-cell:nth-child(6) { animation-delay: 50ms; }
.day-cell:nth-child(7) { animation-delay: 60ms; }
.day-cell:nth-child(8) { animation-delay: 70ms; }
.day-cell:nth-child(9) { animation-delay: 80ms; }
.day-cell:nth-child(10) { animation-delay: 90ms; }
.day-cell:nth-child(11) { animation-delay: 100ms; }
.day-cell:nth-child(12) { animation-delay: 110ms; }
.day-cell:nth-child(13) { animation-delay: 120ms; }
.day-cell:nth-child(14) { animation-delay: 130ms; }
.day-cell:nth-child(15) { animation-delay: 140ms; }
.day-cell:nth-child(16) { animation-delay: 150ms; }
.day-cell:nth-child(17) { animation-delay: 160ms; }
.day-cell:nth-child(18) { animation-delay: 170ms; }
.day-cell:nth-child(19) { animation-delay: 180ms; }
.day-cell:nth-child(20) { animation-delay: 190ms; }
.day-cell:nth-child(21) { animation-delay: 200ms; }
.day-cell:nth-child(22) { animation-delay: 210ms; }
.day-cell:nth-child(23) { animation-delay: 220ms; }
.day-cell:nth-child(24) { animation-delay: 230ms; }
.day-cell:nth-child(25) { animation-delay: 240ms; }
.day-cell:nth-child(26) { animation-delay: 250ms; }
.day-cell:nth-child(27) { animation-delay: 260ms; }
.day-cell:nth-child(28) { animation-delay: 270ms; }
.day-cell:nth-child(29) { animation-delay: 280ms; }
.day-cell:nth-child(30) { animation-delay: 290ms; }
.day-cell:nth-child(31) { animation-delay: 300ms; }
.day-cell:nth-child(32) { animation-delay: 310ms; }
.day-cell:nth-child(33) { animation-delay: 320ms; }
.day-cell:nth-child(34) { animation-delay: 330ms; }
.day-cell:nth-child(35) { animation-delay: 340ms; }
.day-cell:nth-child(36) { animation-delay: 350ms; }
.day-cell:nth-child(37) { animation-delay: 360ms; }
.day-cell:nth-child(38) { animation-delay: 370ms; }
.day-cell:nth-child(39) { animation-delay: 380ms; }
.day-cell:nth-child(40) { animation-delay: 390ms; }
.day-cell:nth-child(41) { animation-delay: 400ms; }
.day-cell:nth-child(42) { animation-delay: 410ms; }

.event-dot {
  animation: slideUp 0.2s ease backwards;
}

.focus-visible:focus {
  outline: none;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.4);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}