:root {
  --bg: #eef3f9;
  --panel: #ffffff;
  --text: #243447;
  --muted: #708399;
  --line: #d6e0ea;
  --accent: #0f9d58;
  --accent-soft: #d8f3e5;
  --google: #1a73e8;
  --google-soft: #d9e8ff;
  --shadow: 0 20px 50px rgba(36, 52, 71, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Segoe UI", Tahoma, sans-serif;
  background:
    radial-gradient(circle at top left, rgba(15, 157, 88, 0.16), transparent 30%),
    radial-gradient(circle at top right, rgba(26, 115, 232, 0.12), transparent 24%),
    var(--bg);
  color: var(--text);
}

body.embed-mode {
  background: #fff;
}

body.newsletter-embed-mode {
  background: #fff;
}

button,
input,
textarea,
select {
  font: inherit;
}

.app-shell {
  display: grid;
  grid-template-columns: 250px minmax(0, 1fr);
  min-height: 100vh;
}

body.embed-mode .app-shell {
  display: block;
  min-height: auto;
}

body.embed-mode .sidebar,
body.embed-mode .topbar,
body.embed-mode #eventDialog {
  display: none;
}

body.embed-mode .calendar-layout {
  padding: 0;
}

body.embed-mode .schedule-card {
  border-radius: 0;
  box-shadow: none;
  border-left: 0;
  border-right: 0;
}

body.embed-mode .day-delete-button {
  display: none;
}

body.newsletter-embed-mode .app-shell {
  display: block;
  min-height: auto;
}

body.newsletter-embed-mode .sidebar {
  padding: 0;
  background: transparent;
  border-right: 0;
  backdrop-filter: none;
}

body.newsletter-embed-mode .sidebar-top {
  gap: 0;
}

body.newsletter-embed-mode .sidebar-top > :not(.newsletter-panel) {
  display: none;
}

body.newsletter-embed-mode .calendar-layout,
body.newsletter-embed-mode #eventDialog,
body.newsletter-embed-mode #newsletterAdmin {
  display: none;
}

body.newsletter-embed-mode .newsletter-panel {
  margin: 0;
  border-radius: 0;
  box-shadow: none;
  border-left: 0;
  border-right: 0;
  border-top: 0;
}

.sidebar {
  padding: 28px;
  background: rgba(255, 255, 255, 0.75);
  backdrop-filter: blur(16px);
  border-right: 1px solid rgba(214, 224, 234, 0.9);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 20px;
}

.sidebar-top,
.sidebar-bottom {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 24px;
}

.brand-copy {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

.brand-mark {
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  border-radius: 16px;
  background: linear-gradient(135deg, #0f9d58, #1a73e8);
  color: #fff;
  font-weight: 700;
}

.brand p,
.panel p {
  margin: 4px 0 0;
  color: var(--muted);
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 18px;
  margin-top: 20px;
  box-shadow: var(--shadow);
}

.panel h2 {
  margin: 0 0 8px;
  font-size: 16px;
}

.panel-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.compact-panel {
  padding: 14px;
  border-radius: 18px;
  box-shadow: 0 10px 24px rgba(36, 52, 71, 0.08);
}

.compact-panel h2 {
  margin-bottom: 6px;
  font-size: 13px;
}

.compact-panel p,
.compact-panel .agenda-list,
.compact-panel .agenda-item,
.compact-panel .empty-state {
  font-size: 12px;
}

.balloon-filters {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.compact-check {
  font-size: 12px;
  color: var(--text);
  justify-content: flex-start;
  gap: 8px;
}

.compact-check span {
  flex: 1;
}

.balloon-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  text-decoration: none;
  color: var(--google);
  font-size: 11px;
  font-weight: 600;
  background: transparent;
  border: 0;
  padding: 0;
  cursor: pointer;
}

.balloon-link-icon {
  font-size: 12px;
}

.newsletter-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.newsletter-form .secondary-button,
#newsletterAdmin .primary-button {
  width: 100%;
}

#newsletterAdmin {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.newsletter-admin-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.newsletter-admin-heading h2 {
  margin: 0;
}

.subscriber-block {
  margin-top: 10px;
}

.subscriber-block h3 {
  margin: 0 0 8px;
  font-size: 12px;
  color: var(--text);
}

.subscriber-list {
  margin-top: 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 280px;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
}

.subscriber-email-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.subscriber-item {
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
  font-size: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.subscriber-email {
  min-width: 0;
  width: 100%;
  overflow-wrap: anywhere;
  font-size: 12px;
  color: var(--text);
  font-weight: 600;
}

.subscriber-summary {
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
}

.subscriber-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: nowrap;
}

.subscriber-download {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 30px;
  padding: 4px 8px;
  border-radius: 6px;
  border: 1px solid var(--google);
  color: var(--google);
  text-decoration: none;
  font-size: 11px;
  font-weight: 600;
  background: #fff;
  white-space: nowrap;
}

.subscriber-remove {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 30px;
  padding: 4px 8px;
  border: 1px solid #d64545;
  background: #fff;
  color: #d64545;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}

.stack {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 12px;
}

.primary-button,
.secondary-button,
.ghost-button,
.nav-button,
.mini-add,
.icon-button {
  border: 0;
  border-radius: 14px;
  cursor: pointer;
}

.primary-button {
  background: var(--accent);
  color: white;
  padding: 14px 18px;
  width: 100%;
  font-weight: 600;
}

.secondary-button,
.ghost-button,
.nav-button {
  padding: 12px 14px;
  background: #fff;
  color: var(--text);
  border: 1px solid var(--line);
}

.ghost-button {
  background: #f5f8fb;
}

.hidden {
  display: none;
}

.logout-link {
  text-align: center;
  text-decoration: none;
  width: 100%;
}

.install-app-button {
  width: auto;
  align-self: flex-start;
  padding: 6px 10px;
  font-size: 11px;
  border-radius: 10px;
  background: #0f9d58;
  border: 1px solid #0f9d58;
  color: #fff;
}

.install-app-button:disabled {
  opacity: 1;
  color: #fff;
}

.install-help {
  border: 1px solid #c9e9d5;
  background: #edf9f1;
  color: #1f5d37;
  border-radius: 12px;
  padding: 10px 12px;
  font-size: 12px;
}

.install-help strong {
  display: block;
  margin-bottom: 4px;
}

.install-help p {
  margin: 0;
}

body.is-standalone-app #toggleGoogleSettings,
body.is-standalone-app #disconnectGoogle,
body.is-standalone-app #googleSettingsForm,
body.is-standalone-app #installAppButton,
body.is-standalone-app #installHelpNotice {
  display: none !important;
}

.app-update {
  border: 1px solid #c9e9d5;
  background: #edf9f1;
  color: #1f5d37;
  border-radius: 12px;
  padding: 10px 12px;
  font-size: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.app-update-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.app-update-button,
.app-refresh-button {
  width: auto;
  padding: 6px 10px;
  font-size: 11px;
  border-radius: 10px;
}

.calendar-layout {
  padding: 26px;
  min-width: 0;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 18px;
}

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

.topbar h1 {
  margin: 0 0 0 10px;
  font-size: 28px;
  text-transform: capitalize;
}

.legend {
  display: flex;
  gap: 18px;
  color: var(--muted);
  font-size: 14px;
  align-items: center;
  flex-wrap: wrap;
}

.legend span {
  display: inline-flex;
  align-items: center;
}

.dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 999px;
  margin-right: 8px;
}

.dot-local { background: var(--accent); }
.dot-google { background: var(--google); }
.dot-busy { background: #d64545; }
.dot-free { background: #0f9d58; }
.dot-cancelled { background: #d6aa00; }

.refresh-button {
  border: 1px solid #0f9d58;
  background: #0f9d58;
  color: #fff;
  border-radius: 10px;
  padding: 8px 12px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}

.schedule-card {
  background: rgba(255, 255, 255, 0.86);
  border: 1px solid rgba(214, 224, 234, 0.95);
  border-radius: 18px;
  overflow: hidden;
  box-shadow: 0 10px 24px rgba(36, 52, 71, 0.08);
  margin-bottom: 0;
}

.calendar-views {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.schedule-toolbar {
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: 11px;
  background: rgba(246, 249, 252, 0.92);
}

.schedule-list {
  display: flex;
  flex-direction: column;
}

.schedule-row {
  display: grid;
  grid-template-columns: 90px 1fr;
  min-height: 96px;
  background: rgba(255, 255, 255, 0.9);
  border-bottom: 1px solid var(--line);
}

.schedule-row.is-today {
  background: linear-gradient(180deg, rgba(216, 243, 229, 0.8), rgba(255, 255, 255, 0.92));
}

.schedule-day {
  border-right: 1px solid var(--line);
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 3px;
  background: rgba(246, 249, 252, 0.82);
}

.schedule-day-header {
  display: flex;
  align-items: flex-start;
  justify-content: flex-start;
  gap: 4px;
}

.schedule-day strong {
  font-size: 11px;
  text-transform: capitalize;
  min-width: 0;
  line-height: 1.2;
}

.schedule-day span {
  color: var(--muted);
  font-size: 9px;
}

.day-delete-button {
  font-size: 9px;
  color: #d64545;
  flex-shrink: 0;
  gap: 2px;
}

.schedule-events {
  padding: 8px 10px;
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 6px;
}

.schedule-row-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.schedule-row-title {
  color: var(--muted);
  font-size: 10px;
}

.mini-add {
  width: 26px;
  height: 26px;
  background: #f0f5fb;
  color: var(--muted);
}

.event-chip {
  text-align: left;
  padding: 6px 8px;
  border-radius: 10px;
  border: 0;
  font-size: 11px;
  line-height: 1.3;
}

.event-chip.block {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 8px 10px;
  min-width: 150px;
  max-width: 220px;
  flex: 0 1 190px;
}

.event-chip.block strong {
  font-size: 11px;
}

.event-chip.block span,
.event-chip.block small {
  font-size: 10px;
}

.event-chip.block a {
  color: inherit;
  text-decoration: underline;
}

.event-chip.local {
  background: var(--accent-soft);
  color: #14613d;
}

.event-chip.status-busy {
  background: #fde1e1;
  color: #a42828;
}

.event-chip.status-free {
  background: #d8f3e5;
  color: #14613d;
}

.event-chip.status-cancelled {
  background: #fff3c9;
  color: #8a6a00;
}

.event-chip.google {
  background: var(--google-soft);
  color: #1a4f9c;
}

.agenda-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.agenda-item {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 12px;
  border-radius: 14px;
  background: #f7fafc;
  border: 1px solid var(--line);
}

.agenda-item strong {
  font-size: 14px;
}

.agenda-item span,
.agenda-item small {
  color: var(--muted);
}

.empty-state {
  color: var(--muted);
}

.schedule-empty {
  color: var(--muted);
  font-size: 13px;
  padding: 10px 0;
}

.location-link-row {
  margin: -4px 0 0;
  color: var(--muted);
  font-size: 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.location-link-row a,
.agenda-item a {
  color: var(--google);
  text-decoration: none;
  font-weight: 600;
}

.map-link-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 10px 16px;
  border-radius: 14px;
  border: 2px solid var(--accent);
  background: var(--accent);
  color: #fff !important;
  box-shadow: 0 10px 24px rgba(15, 157, 88, 0.2);
}

.repeat-copy-field {
  min-width: 190px;
  flex: 1 1 190px;
  gap: 4px;
  font-size: 12px;
  color: var(--text);
}

.repeat-copy-field select {
  min-height: 44px;
  padding: 10px 12px;
  border-radius: 14px;
}

dialog {
  width: min(620px, calc(100vw - 32px));
  border: 0;
  border-radius: 24px;
  padding: 0;
  box-shadow: 0 30px 80px rgba(18, 31, 46, 0.24);
}

dialog::backdrop {
  background: rgba(18, 31, 46, 0.44);
}

.event-form {
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  background: #fff;
}

.form-error {
  border: 1px solid #f4b1b1;
  background: #fde1e1;
  color: #a42828;
  padding: 10px 12px;
  border-radius: 12px;
  font-size: 13px;
}

.dialog-header,
.dialog-actions,
.grid-two {
  display: grid;
  gap: 14px;
}

.dialog-header {
  grid-template-columns: 1fr auto;
  align-items: center;
}

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

label {
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 14px;
}

input,
textarea,
select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px 14px;
  background: #fbfdff;
}

.checkbox-row {
  flex-direction: row;
  align-items: center;
}

.checkbox-row input {
  width: auto;
}

.dialog-actions {
  grid-template-columns: 1fr 1fr;
}

.icon-button {
  width: 40px;
  height: 40px;
  background: #f4f8fc;
}

@media (max-width: 1024px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    border-right: 0;
    border-bottom: 1px solid rgba(214, 224, 234, 0.9);
    padding: 18px;
  }

  .calendar-layout {
    padding: 18px;
  }
}

.login-body {
  min-height: 100vh;
  display: grid;
  place-items: center;
}

.login-shell {
  width: min(100%, 440px);
  padding: 24px;
}

.login-card {
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid rgba(214, 224, 234, 0.95);
  border-radius: 28px;
  padding: 28px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.login-card h1 {
  margin: 0;
}

.login-card p {
  margin: 0 0 6px;
  color: var(--muted);
}

.login-error {
  border: 1px solid #f4b1b1;
  background: #fde1e1;
  color: #a42828;
  padding: 12px 14px;
  border-radius: 14px;
}

@media (max-width: 720px) {
  #toggleGoogleSettings,
  #disconnectGoogle {
    display: none !important;
  }

  .app-shell {
    display: flex;
    flex-direction: column;
    min-height: auto;
  }

  .calendar-layout {
    padding: 14px;
  }

  .topbar,
  .topbar-left,
  .grid-two,
  .dialog-actions {
    display: flex;
    flex-direction: column;
    align-items: stretch;
  }

  .legend {
    display: flex;
    flex-direction: row;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
  }

  .legend span {
    font-size: 12px;
  }

  .refresh-button {
    align-self: flex-start;
  }

  .calendar-views {
    display: flex;
    flex-direction: column;
    width: 100%;
  }

  .schedule-card,
  .schedule-row {
    width: 100%;
  }

  .schedule-row {
    grid-template-columns: 74px 1fr;
  }

  .schedule-day {
    padding: 8px;
  }

  .schedule-events {
    padding: 8px;
  }

  .event-chip.block {
    min-width: 0;
    max-width: none;
    flex: 1 1 100%;
  }

  .subscriber-item {
    flex-direction: column;
    align-items: stretch;
  }

  .subscriber-list {
    max-height: none;
    overflow: visible;
  }

  .subscriber-summary {
    align-items: stretch;
  }

  .newsletter-admin-heading {
    align-items: stretch;
  }

  .subscriber-remove {
    width: 100%;
  }

  .subscriber-actions {
    align-items: center;
    flex-wrap: nowrap;
  }

  .subscriber-actions .subscriber-download,
  .subscriber-actions .subscriber-remove {
    width: auto;
    flex: 0 0 auto;
  }
}
