:root {
  --bg: #f4f7fb;
  --panel: #ffffff;
  --panel-soft: #fbfdff;
  --muted: #607086;
  --text: #152232;
  --border: #dbe3ee;
  --accent: #2f6fed;
  --accent-soft: #eaf1ff;
  --success: #18804b;
  --success-soft: #eaf8f1;
  --danger: #b42318;
  --danger-soft: #fff0ee;
  --warning: #ad6a00;
  --warning-soft: #fff5df;
  --busy-soft: #fff2f7;
  --busy-border: #f3bfd4;
  --shadow: 0 14px 36px rgba(28, 52, 84, .08);
  --radius: 18px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; padding: 0; }
body {
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: linear-gradient(180deg, #f8fbff 0%, var(--bg) 100%);
  color: var(--text);
}

a { color: inherit; text-decoration: none; }
button, input { font: inherit; }
button { cursor: pointer; }

.shell { max-width: 1840px; margin: 0 auto; padding: 20px clamp(12px, 2vw, 28px); }
.layout { display: grid; grid-template-columns: 360px 1fr; gap: 24px; align-items: start; }
.sidebar, .main { display: grid; gap: 20px; }
.panel, .brand-card, .hero-card, .day-card, .date-card { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.panel, .brand-card, .hero-card { padding: 20px; }
.day-card, .date-card { overflow: hidden; }
.subdued-panel { background: linear-gradient(180deg, #ffffff 0%, #f9fbff 100%); }

.eyebrow { margin: 0 0 8px; font-size: 12px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--accent); }
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 10px; font-size: 30px; line-height: 1.1; }
h2 { margin-bottom: 10px; font-size: 24px; }
h3 { margin-bottom: 6px; font-size: 18px; }
.muted { color: var(--muted); }
.strongish { font-weight: 600; }
.top-gap { margin-top: 14px; }
.no-margin { margin: 0; }
.compact-bottom { margin-bottom: 12px; }

.meta-list { display: grid; gap: 12px; margin: 18px 0; }
.meta-list > div { display: flex; justify-content: space-between; gap: 12px; font-size: 14px; }
.meta-list span { color: var(--muted); }
.meta-list strong { text-align: right; }

.button-row { display: flex; flex-wrap: wrap; gap: 10px; }
.button, button {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 0 16px; border-radius: 12px; border: none;
  background: var(--accent); color: #fff; font-weight: 600;
}
.button.ghost, .ghost { background: transparent; border: 1px solid var(--border); color: var(--text); }
.button.small { min-height: 38px; padding: 0 12px; font-size: 14px; }
.danger-button { background: transparent; color: var(--danger); border: 1px solid rgba(180,35,24,.2); min-height: 38px; }
.error-box { margin-top: 16px; padding: 12px 14px; border-radius: 14px; background: var(--danger-soft); color: var(--danger); }
.success-box { margin-top: 16px; padding: 12px 14px; border-radius: 14px; background: var(--success-soft); color: var(--success); }

.group-list, .preset-list, .change-list, .date-stack { display: grid; gap: 12px; }
.group-link, .preset-card {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 14px; border-radius: 14px; border: 1px solid var(--border); background: var(--panel-soft);
}
.group-link.active { border-color: var(--accent); background: var(--accent-soft); }
.group-link span { color: var(--muted); font-size: 14px; }
.preset-title { font-weight: 700; }

.stack-form, .compact-form { display: grid; gap: 12px; }
.inline-form { display: flex; gap: 10px; flex-wrap: wrap; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
input[type="text"], input[type="number"], input[type="email"], select {
  width: 100%; min-height: 46px; padding: 0 14px; border-radius: 12px; border: 1px solid var(--border); background: #fff;
}
label { display: block; margin-bottom: 8px; font-size: 14px; color: var(--muted); }
.checkbox-line { display: inline-flex; align-items: center; gap: 10px; margin-top: 12px; color: var(--text); }
.checkbox-line input { width: 18px; height: 18px; }

.hero-top { display: flex; justify-content: space-between; gap: 20px; align-items: start; }
.summary-grid { display: grid; grid-template-columns: repeat(3, minmax(120px, 1fr)); gap: 12px; }
.summary-grid-wide { grid-template-columns: repeat(4, minmax(120px, 1fr)); }
.summary-pill {
  padding: 14px; border-radius: 16px; background: #f8fbff; border: 1px solid var(--border); min-width: 132px;
}
.summary-pill span { display: block; color: var(--muted); font-size: 13px; margin-bottom: 6px; }
.summary-pill strong { font-size: 24px; }

.filters-box { margin-top: 20px; padding-top: 18px; border-top: 1px solid var(--border); }
.filters-header { display: flex; justify-content: space-between; gap: 12px; align-items: start; margin-bottom: 14px; }
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; }
.chips-grid { display: flex; flex-wrap: wrap; gap: 10px; }
.chip {
  position: relative; display: inline-flex; align-items: center; border-radius: 999px; border: 1px solid var(--border);
  background: #fff; color: var(--text); padding: 10px 14px; font-weight: 600;
}
.chip input { position: absolute; opacity: 0; pointer-events: none; }
.chip-active, .chip:has(input:checked) { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }

.schedule-panel { display: grid; gap: 12px; }
.date-card { border: 1px solid var(--border); background: #fff; }
.date-header {
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  padding: 18px 20px; border-bottom: 1px solid var(--border); background: linear-gradient(180deg, #fcfdff, #f6f9fe);
}
.date-header h3 { margin: 0 0 4px; }
.date-tag {
  display: inline-flex; align-items: center; min-height: 32px; padding: 0 12px;
  border-radius: 999px; border: 1px solid var(--border); color: var(--muted); background: #fff;
  font-weight: 700; font-size: 13px;
}

.event-list { display: grid; gap: 1px; background: var(--border); }
.clean-list { background: transparent; gap: 12px; }
.event-card {
  display: grid; grid-template-columns: 92px 1fr; gap: 16px; padding: 18px 20px; background: #fff;
  border-bottom: 1px solid var(--border);
}
.clean-list .event-card { border: 1px solid var(--border); border-radius: 16px; }
.event-time { display: grid; align-content: start; gap: 4px; }
.event-time strong { font-size: 24px; line-height: 1; }
.event-time span { color: var(--muted); font-size: 14px; }
.event-content { display: grid; gap: 12px; }
.event-topline { display: flex; justify-content: space-between; gap: 12px; align-items: start; }
.event-topline h3 { margin: 0; font-size: 18px; }
.badges { display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-end; }
.badge {
  display: inline-flex; align-items: center; min-height: 28px; padding: 0 10px; border-radius: 999px;
  background: #eef3f8; color: #345; font-size: 13px; font-weight: 700;
}
.badge.accent { background: var(--accent-soft); color: var(--accent); }
.badge.warning { background: var(--warning-soft); color: var(--warning); }
.badge.success { background: var(--success-soft); color: var(--success); }
.badge.danger { background: var(--danger-soft); color: var(--danger); }
.ghost-badge { background: #f6f8fb; color: var(--muted); }

.event-meta-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.event-meta-grid .wide { grid-column: span 3; }
.meta-label { display: block; margin-bottom: 6px; color: var(--muted); font-size: 13px; }

.weekday-stack { display: grid; gap: 12px; }
.weekday-row {
  display: grid; grid-template-columns: 160px 1fr; gap: 16px; padding: 14px 16px;
  border: 1px solid var(--border); border-radius: 16px; background: #fbfdff;
}
.weekday-name { font-weight: 800; }
.weekday-items { display: flex; flex-wrap: wrap; gap: 10px; }
.weekday-pill {
  display: grid; gap: 4px; min-width: 220px; padding: 12px 14px; border-radius: 14px;
  border: 1px solid var(--border); background: #fff;
}
.weekday-pill strong { font-size: 14px; }
.weekday-pill span { font-weight: 600; }
.weekday-pill em { color: var(--muted); font-style: normal; font-size: 13px; }

.section-header, .change-meta { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.change-item { padding: 14px 16px; border-radius: 14px; border: 1px solid var(--border); background: #fbfdff; }
.change-item p { margin: 10px 0 0; }
.change-meta time { color: var(--muted); font-size: 13px; }

.empty-state { min-height: calc(100vh - 120px); display: grid; place-items: center; }
.empty-state .hero-card { width: min(680px, 100%); }

@media (max-width: 1280px) {
  .layout { grid-template-columns: 320px 1fr; }
  .summary-grid-wide { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 1040px) {
  .layout { grid-template-columns: 1fr; }
  .hero-top, .filters-header, .section-header, .event-topline, .date-header { flex-direction: column; align-items: stretch; }
  .summary-grid, .summary-grid-wide, .form-grid, .event-meta-grid, .weekday-row { grid-template-columns: 1fr; }
  .event-meta-grid .wide { grid-column: span 1; }
}

@media (max-width: 720px) {
  .shell { padding: 14px; }
  .event-card { grid-template-columns: 1fr; }
  .button-row, .inline-form { flex-direction: column; }
  .button, button { width: 100%; }
  .weekday-pill { min-width: 0; width: 100%; }
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  backdrop-filter: blur(12px);
  background: rgba(248, 251, 255, .86);
  border-bottom: 1px solid rgba(219, 227, 238, .9);
}
.topbar-inner {
  max-width: 1840px;
  margin: 0 auto;
  padding: 14px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.brand-link { display: inline-flex; align-items: center; gap: 10px; font-weight: 800; }
.brand-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 12px;
  background: var(--accent-soft);
  color: var(--accent);
  border: 1px solid rgba(47,111,237,.18);
}
.brand-text { font-size: 18px; }
.topbar-actions { display: flex; align-items: center; gap: 10px; }
.topbar-actions form { margin: 0; }

input[type="password"] {
  width: 100%; min-height: 46px; padding: 0 14px; border-radius: 12px; border: 1px solid var(--border); background: #fff;
}

.preset-card-active {
  border-color: var(--accent);
  background: var(--accent-soft);
}
.preset-card-wide { align-items: flex-start; }
.compact-actions { justify-content: flex-end; }
.chip-strip { display: flex; flex-wrap: wrap; gap: 8px; }
.narrow-state .hero-card { width: min(480px, 100%); }
.auth-card { padding: 28px; }
code {
  display: inline-block;
  padding: 2px 6px;
  border-radius: 8px;
  background: #f1f5fb;
  border: 1px solid var(--border);
  font-size: .95em;
}

@media (max-width: 720px) {
  .topbar-inner { padding: 12px 14px; }
  .topbar-actions { width: 100%; justify-content: flex-end; }
}

.public-shell {
  width: 100%;
  max-width: none;
  margin: 0;
  display: grid;
  gap: 18px;
}

.card-lite {
  border: 1px solid var(--border);
  background: #fff;
  border-radius: 22px;
  padding: 22px;
  box-shadow: 0 18px 46px rgba(18, 36, 76, .06);
}

.public-hero-top {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: start;
}

.public-summary-grid {
  margin-top: 18px;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.summary-text {
  font-size: 15px !important;
  line-height: 1.35;
}

.public-filters {
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px solid var(--border);
}

.public-filters-header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: start;
  margin-bottom: 14px;
}

.public-schedule .date-stack {
  display: grid;
  gap: 14px;
}

.irregular-card {
  border: 1px solid var(--border);
  border-radius: 16px;
}

@media (max-width: 900px) {
  .public-hero-top,
  .public-filters-header {
    flex-direction: column;
    align-items: stretch;
  }

  .public-summary-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 640px) {
  .public-summary-grid {
    grid-template-columns: 1fr;
  }
}


.app-footer {
  padding: 0 24px 18px;
}

.app-footer-inner {
  max-width: 1840px;
  margin: 0 auto;
}

.footer-admin-link {
  font-size: 12px;
  color: var(--muted);
  opacity: .7;
}

.footer-admin-link:hover {
  opacity: 1;
}

.select-input {
  width: 100%;
  min-height: 46px;
  padding: 0 14px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: #fff;
  font: inherit;
  color: var(--text);
}

.explorer-shell {
  width: 100%;
  max-width: none;
}

.explorer-summary-grid {
  margin-bottom: 20px;
}

.explorer-controls {
  display: grid;
  grid-template-columns: minmax(220px, 280px) 1fr;
  gap: 18px;
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px solid var(--border);
}

.group-switcher-form label,
.group-switcher-form .muted {
  margin-bottom: 10px;
}

.group-switcher-row {
  display: grid;
  gap: 10px;
}

.no-top-border {
  margin-top: 0;
  padding-top: 0;
  border-top: none;
}

.free-day-card {
  border-color: rgba(24, 128, 75, .16);
  background: linear-gradient(180deg, #fbfffd 0%, var(--success-soft) 100%);
}

.free-day-header {
  background: linear-gradient(180deg, #f8fff9 0%, #edf9f1 100%);
}

.busy-day-card {
  border-color: rgba(243, 191, 212, .7);
  background: linear-gradient(180deg, #fffefe 0%, #fff9fb 100%);
}

.free-day-state {
  display: grid;
  gap: 6px;
  padding: 22px 20px;
  color: var(--success);
}

.free-day-state strong {
  font-size: 20px;
}

.view-switcher {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.view-switcher .button.is-active {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent);
}

.calendar-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 14px;
}

.calendar-day {
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 14px;
  display: grid;
  gap: 12px;
  min-height: 170px;
}

.calendar-day-busy {
  background: linear-gradient(180deg, #fff8fb 0%, var(--busy-soft) 100%);
  border-color: var(--busy-border);
}

.calendar-day-free {
  background: linear-gradient(180deg, #fbfffd 0%, var(--success-soft) 100%);
  border-color: rgba(24, 128, 75, .2);
}

.calendar-day-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: start;
}

.calendar-day-head strong {
  display: block;
  font-size: 16px;
  line-height: 1.2;
}

.calendar-count {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, .78);
  border: 1px solid rgba(21, 34, 50, .08);
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
}

.calendar-day-body {
  display: grid;
  gap: 8px;
  align-content: start;
}

.calendar-item {
  display: grid;
  gap: 3px;
  padding: 10px 12px;
  border-radius: 14px;
  background: rgba(255, 255, 255, .78);
  border: 1px solid rgba(21, 34, 50, .06);
}

.calendar-item strong {
  font-size: 13px;
}

.calendar-item span {
  font-weight: 600;
  line-height: 1.25;
}

.calendar-item em {
  font-style: normal;
  font-size: 12px;
  color: var(--muted);
}

.calendar-free-state {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 74px;
  border-radius: 16px;
  background: rgba(255,255,255,.64);
  border: 1px dashed rgba(24, 128, 75, .28);
  color: var(--success);
  font-weight: 800;
}

@media (max-width: 1040px) {
  .explorer-controls {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 720px) {
  .app-footer {
    padding: 0 14px 16px;
  }

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


.smtp-starttls-cell,
.notify-cell {
  display: flex;
  align-items: end;
}

.calendar-month {
  display: grid;
  gap: 12px;
  margin-bottom: 24px;
}

.calendar-month-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}

.calendar-month-header h3 {
  margin: 0;
  font-size: 24px;
}

.calendar-weekdays,
.calendar-month-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 12px;
  align-items: stretch;
}


.calendar-weekdays > *,
.calendar-month-grid > * {
  min-width: 0;
}

.calendar-weekdays span {
  font-size: 13px;
  font-weight: 700;
  color: var(--muted);
  padding: 0 4px;
}

.calendar-weekdays .is-weekend {
  color: #ab6a73;
}

.calendar-spacer {
  min-height: 220px;
  border-radius: 18px;
  border: 1px dashed rgba(21, 34, 50, .08);
  background: linear-gradient(180deg, rgba(255,255,255,.55) 0%, rgba(244,247,251,.9) 100%);
}

.calendar-day-head .muted {
  line-height: 1.2;
}

.calendar-day {
  min-height: 220px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.calendar-day-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: start;
  gap: 10px;
  flex: 0 0 auto;
}

.calendar-count {
  flex: 0 0 auto;
  white-space: nowrap;
  align-self: start;
}

.calendar-day-body {
  min-height: 0;
  overflow: visible;
  padding-right: 0;
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  justify-content: flex-start;
  align-items: stretch;
}

.calendar-item,
.calendar-free-state {
  flex: 0 0 auto;
}



.calendar-date-block {
  min-width: 0;
  display: grid;
  gap: 2px;
}

.calendar-date-compact {
  display: block;
  font-size: 30px;
  line-height: 1;
  letter-spacing: -.04em;
}

.calendar-date-full {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  min-height: 24px;
  padding: 0 8px;
  border-radius: 999px;
  background: rgba(255,255,255,.72);
  border: 1px solid rgba(21,34,50,.08);
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

.calendar-day-head .muted {
  margin-top: 2px;
}

.calendar-day-head {
  gap: 8px;
}

.calendar-count {
  font-size: 12px;
  padding: 0 9px;
}

.calendar-item {
  padding: 10px 11px;
}

.calendar-item strong {
  line-height: 1.2;
}

.calendar-item span {
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.calendar-month-grid {
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 12px;
  align-items: stretch;
}

@media (max-width: 1400px) {
  .calendar-date-compact {
    font-size: 26px;
  }
}

@media (max-width: 1100px) {
  .shell {
    max-width: none;
  }

  .public-summary-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .calendar-weekdays,
  .calendar-month-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .calendar-weekdays {
    display: none;
  }

  .calendar-day,
  .calendar-spacer {
    min-height: 0;
  }

  .calendar-spacer {
    display: none;
  }

  .calendar-date-compact {
    font-size: 24px;
  }
}

@media (max-width: 720px) {
  .card-lite {
    padding: 16px;
    border-radius: 18px;
  }

  .public-shell {
    gap: 14px;
  }

  .public-summary-grid {
    grid-template-columns: 1fr;
  }

  .view-switcher {
    flex-direction: column;
  }

  .view-switcher .button,
  .compact-actions .button,
  .compact-actions a.button {
    width: 100%;
  }

  .calendar-month-grid {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .calendar-day {
    min-height: 0;
  }

  .calendar-date-compact {
    font-size: 22px;
  }

  .calendar-count {
    font-size: 11px;
  }
}


.dashboard-tabs {
  display: flex;
  gap: 0.75rem;
  margin-top: 1rem;
  flex-wrap: wrap;
}

.dashboard-tab {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.7rem 1rem;
  border: 1px solid var(--line, #d9deef);
  border-radius: 999px;
  text-decoration: none;
  color: var(--text, #172554);
  background: #fff;
  font-weight: 600;
}

.dashboard-tab.is-active {
  background: #eef2ff;
  border-color: #8ea2ff;
}

.tab-count {
  display: inline-flex;
  min-width: 1.4rem;
  height: 1.4rem;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  background: #fff;
  border: 1px solid #d9deef;
  font-size: 0.78rem;
  padding: 0 0.35rem;
}

.history-list {
  display: grid;
  gap: 1rem;
}

.history-card {
  border: 1px solid #d9deef;
  border-radius: 18px;
  padding: 1rem 1.1rem;
  background: #fff;
}

.history-topline {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: flex-start;
  margin-bottom: 0.75rem;
}

.history-meta {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.history-kind {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 0.28rem 0.7rem;
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  border: 1px solid #d9deef;
  background: #f8fafc;
}

.history-kind-added { background: #ecfdf3; border-color: #b7ebc6; color: #166534; }
.history-kind-removed { background: #fff1f2; border-color: #fecdd3; color: #be123c; }
.history-kind-changed { background: #eff6ff; border-color: #bfdbfe; color: #1d4ed8; }
.history-kind-initial { background: #f5f3ff; border-color: #ddd6fe; color: #6d28d9; }

.history-message {
  margin: 0 0 0.8rem;
  font-weight: 600;
}

.history-details {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1rem;
  color: #5b6788;
  font-size: 0.94rem;
}

.empty-history {
  display: grid;
  gap: 0.35rem;
  border: 1px dashed #d9deef;
  border-radius: 18px;
  padding: 1.2rem;
  background: #fbfcff;
}

@media (max-width: 760px) {
  .history-topline {
    flex-direction: column;
  }

  .history-card {
    padding: 0.9rem;
  }
}
