* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

:root {
  --bg: #f4f6f8;
  --card: #ffffff;
  --text: #17212b;
  --muted: #6b7280;
  --line: #e5e7eb;
  --primary: #111827;
  --primary-2: #1f2937;
  --accent: #2563eb;
  --success-bg: #dcfce7;
  --success-text: #166534;
  --warn-bg: #fef3c7;
  --warn-text: #92400e;
  --error-bg: #fee2e2;
  --error-text: #991b1b;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.08);
  --radius: 18px;
}

html,
body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Arial, sans-serif;
}

body {
  min-height: 100vh;
  padding-bottom: 90px;
}

.app {
  max-width: 760px;
  margin: 0 auto;
  padding: 16px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 14px;
}

.brand {
  font-size: 22px;
  font-weight: 700;
  line-height: 1.2;
}

.close-btn {
  border: 0;
  border-radius: 12px;
  padding: 10px 14px;
  background: var(--card);
  color: var(--text);
  box-shadow: var(--shadow);
  cursor: pointer;
  font-size: 14px;
}

.hero {
  background: linear-gradient(135deg, #111827 0%, #374151 100%);
  color: #fff;
  border-radius: 24px;
  padding: 20px;
  box-shadow: var(--shadow);
  margin-bottom: 16px;
}

.hero-subtitle {
  font-size: 13px;
  opacity: 0.8;
  margin-bottom: 8px;
}

.hero-title {
  font-size: 26px;
  font-weight: 700;
  line-height: 1.2;
  margin-bottom: 10px;
}

.hero-text {
  font-size: 15px;
  line-height: 1.5;
  opacity: 0.92;
}

.status {
  margin-top: 14px;
  display: inline-block;
  padding: 8px 12px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
}

.status.ok {
  background: var(--success-bg);
  color: var(--success-text);
}

.status.warn {
  background: var(--warn-bg);
  color: var(--warn-text);
}

.status.error {
  background: var(--error-bg);
  color: var(--error-text);
}

.section {
  display: none;
}

.section.active {
  display: block;
}

.cards {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
}

.card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
}

.card-title {
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 8px;
}

.card-text {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.5;
  margin-bottom: 14px;
}

.grid-menu {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 12px;
}

.menu-btn {
  border: 0;
  border-radius: 18px;
  padding: 16px;
  background: var(--card);
  box-shadow: var(--shadow);
  text-align: left;
  cursor: pointer;
  min-height: 110px;
}

.menu-btn-title {
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 6px;
  color: var(--text);
}

.menu-btn-text {
  font-size: 13px;
  color: var(--muted);
  line-height: 1.45;
}

.profile-row {
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}

.profile-row:last-child {
  border-bottom: 0;
}

.profile-label {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 4px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.profile-value {
  font-size: 15px;
  line-height: 1.4;
  word-break: break-word;
}

.events-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}

.events-status {
  font-size: 13px;
  color: var(--muted);
  line-height: 1.4;
}

.refresh-btn {
  border: 0;
  border-radius: 12px;
  padding: 10px 14px;
  background: var(--primary);
  color: #fff;
  cursor: pointer;
  font-size: 14px;
  white-space: nowrap;
}

.event-card {
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 16px;
  margin-bottom: 12px;
  background: #fff;
}

.event-card:last-child {
  margin-bottom: 0;
}

.event-date {
  font-size: 13px;
  color: var(--accent);
  font-weight: 700;
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.event-title {
  font-size: 18px;
  font-weight: 700;
  line-height: 1.35;
  margin-bottom: 10px;
}

.event-details {
  font-size: 14px;
  color: var(--text);
  line-height: 1.5;
  margin-bottom: 12px;
  white-space: pre-line;
}

.event-meta {
  display: grid;
  gap: 10px;
  margin-bottom: 12px;
}

.event-meta-item {
  background: #f9fafb;
  border-radius: 14px;
  padding: 12px 14px;
}

.event-meta-label {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 4px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.event-meta-value {
  font-size: 14px;
  color: var(--text);
  line-height: 1.45;
  white-space: pre-line;
  word-break: break-word;
}

.event-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.link-list {
  display: grid;
  gap: 10px;
}

.link-btn,
.action-btn {
  border: 0;
  width: 100%;
  text-align: left;
  border-radius: 14px;
  padding: 14px 16px;
  background: #f9fafb;
  color: var(--text);
  cursor: pointer;
  font-size: 15px;
}

.action-btn {
  width: auto;
  min-width: 160px;
}

.action-btn.primary {
  background: var(--primary);
  color: #fff;
}

.action-btn.secondary {
  background: #e5e7eb;
  color: var(--text);
}

.empty-box {
  border: 1px dashed var(--line);
  border-radius: 18px;
  padding: 18px;
  font-size: 14px;
  color: var(--muted);
  line-height: 1.5;
  background: #fafafa;
}

.small-note {
  margin-top: 10px;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.4;
}

.bottom-nav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
  background: rgba(244, 246, 248, 0.96);
  backdrop-filter: blur(10px);
  border-top: 1px solid var(--line);
}

.bottom-nav-inner {
  max-width: 760px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.nav-btn {
  border: 0;
  border-radius: 14px;
  padding: 10px 8px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
}

.nav-btn.active {
  background: #e5e7eb;
  color: var(--text);
}

/* Меню выбора календаря */

.calendar-menu-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 9999;
}

.calendar-menu-overlay.active {
  display: flex;
}

.calendar-menu-card {
  width: 100%;
  max-width: 420px;
  background: var(--card);
  border-radius: 18px;
  padding: 18px;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.2);
}

.calendar-menu-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 10px;
}

.calendar-menu-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
}

.calendar-menu-close {
  border: 0;
  background: #e5e7eb;
  border-radius: 10px;
  padding: 8px 12px;
  cursor: pointer;
  font-size: 14px;
  color: var(--text);
}

.calendar-menu-event-title {
  font-size: 14px;
  line-height: 1.45;
  color: var(--muted);
  margin-bottom: 14px;
}

.calendar-menu-actions {
  display: grid;
  gap: 10px;
}

.calendar-menu-btn {
  border: 0;
  border-radius: 14px;
  padding: 14px 16px;
  cursor: pointer;
  font-size: 15px;
  text-align: left;
}

.calendar-menu-btn.primary {
  background: var(--primary);
  color: #fff;
}

.calendar-menu-btn.secondary {
  background: #e5e7eb;
  color: var(--text);
}

@media (max-width: 520px) {
  .grid-menu {
    grid-template-columns: 1fr;
  }

  .hero-title {
    font-size: 22px;
  }

  .event-actions .action-btn {
    width: 100%;
  }

  .calendar-menu-card {
    max-width: 100%;
  }

  .calendar-menu-actions .calendar-menu-btn {
    width: 100%;
  }
}