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

:root {
  --header-h: 3.5rem;
  --filters-h: 4rem;
}

body {
  font-family: system-ui, sans-serif;
  margin: 0;
  background: #f5f5f5;
  color: #333;
  min-height: 100vh;
}

header {
  background: #1a73e8;
  color: white;
  padding: 1rem 2rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
}
.header-brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}
.links-menu { position: relative; }
.links-btn {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 2px solid rgba(255,255,255,0.65);
  background: rgba(255,255,255,0.15);
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  transition: background 0.15s;
}
.links-btn:hover { background: rgba(255,255,255,0.3); }
.links-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  background: white;
  border-radius: 8px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.15);
  padding: 0.4rem 0;
  min-width: 260px;
  z-index: 200;
}
.links-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.4rem 1rem;
  gap: 1rem;
}
.links-row:hover { background: #f5f5f5; }
.links-prop-name {
  font-size: 0.85rem;
  font-weight: 500;
  color: #333;
  white-space: nowrap;
}
.links-icons { display: flex; gap: 0.5rem; align-items: center; }
.link-icon-wrap { display: flex; align-items: center; }
.link-icon { width: 18px; height: 18px; border-radius: 3px; opacity: 0.8; transition: opacity 0.15s; }
.link-icon:hover { opacity: 1; }
.nisaloc-link {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: white;
  text-decoration: none;
  font-weight: 600;
  font-size: 1.1rem;
  opacity: 0.95;
}
.nisaloc-link:hover { opacity: 1; }
.header-controls {
  display: flex;
  align-items: center;
  gap: 1rem;
}

/* ── Filters ── */
.filters {
  padding: 0.75rem 2rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  background: white;
  border-bottom: 1px solid #e0e0e0;
  position: sticky;
  top: var(--header-h);
  z-index: 99;
}
.pill {
  padding: 0.3rem 0.85rem;
  border-radius: 999px;
  border: 1.5px solid;
  cursor: pointer;
  font-size: 0.82rem;
  font-weight: 500;
  transition: background 0.15s, color 0.15s;
}
.filter-separator {
  width: 1px;
  height: 1.5rem;
  background: #e0e0e0;
  align-self: center;
  margin: 0 0.25rem;
}

/* ── View toggle (in header) ── */
.view-toggle {
  display: flex;
  gap: 0;
  border: 1.5px solid rgba(255,255,255,0.6);
  border-radius: 999px;
  overflow: hidden;
}
.view-btn {
  padding: 0.3rem 0.7rem;
  border: none;
  border-radius: 0;
  background: transparent;
  color: rgba(255,255,255,0.85);
  font-size: 1rem;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  line-height: 1;
}
.view-btn:hover {
  background: rgba(255,255,255,0.15);
  color: white;
}
.view-btn.active {
  background: white;
  color: #1a73e8;
}
/* ── Refresh button (in header) ── */
.refresh-btn {
  padding: 0.3rem 0.65rem;
  border-radius: 999px;
  border: 1.5px solid rgba(255,255,255,0.6);
  background: transparent;
  color: rgba(255,255,255,0.85);
  font-size: 1rem;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
  line-height: 1;
}
.refresh-btn:hover {
  background: rgba(255,255,255,0.15);
  border-color: white;
  color: white;
}
.refresh-btn:disabled {
  opacity: 0.5;
  cursor: default;
}

/* ── List view ── */
.list-group { margin-bottom: 1.5rem; }
.list-row-wrapper {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-bottom: 0.4rem;
}
.list-month {
  margin: 0 0 0.5rem;
  font-size: 1rem;
  font-weight: 700;
  text-transform: capitalize;
  color: #444;
  border-bottom: 1px solid #e0e0e0;
  padding-bottom: 0.3rem;
}
.list-row {
  display: flex;
  align-items: stretch;
  border-left: 4px solid #ccc;
  border-radius: 4px;
  background: white;
  box-shadow: 0 1px 3px rgba(0,0,0,0.07);
  flex: 1;
  overflow: hidden;
}
.list-row-color {
  width: 6px;
  flex-shrink: 0;
}
.list-row-countdown {
  width: 2.8rem;
  height: 2.8rem;
  flex-shrink: 0;
  border-radius: 50%;
  border: 2px solid;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  font-weight: 700;
  line-height: 1;
}
.list-row-countdown small {
  font-size: 0.6rem;
  font-weight: 500;
  opacity: 0.8;
}
.list-row-body {
  padding: 0.5rem 0.75rem;
  flex: 1;
}
.list-row-title {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.9rem;
  margin-bottom: 0.15rem;
}
.list-row-renter {
}
.list-row-dates {
  font-size: 0.8rem;
  color: #666;
}
.list-row-edit {
  background: none;
  border: none;
  color: #666;
  font-size: 1rem;
  padding: 0 0.4rem;
  cursor: pointer;
  flex-shrink: 0;
  align-self: center;
}
.list-row-edit:hover { color: #1a73e8; }
.list-row-delete {
  background: none;
  border: none;
  color: #666;
  font-size: 1rem;
  padding: 0 0.75rem;
  cursor: pointer;
  flex-shrink: 0;
  align-self: center;
  position: relative;
  top: 2px;
}
.list-row-delete:hover { color: #e53935; }

/* ── Status ── */
.status { padding: 1rem 2rem; color: #555; }
.status.error { color: #c0392b; }

/* ── Calendar wrapper ── */
.cal-wrapper {
  padding: 0 2rem 2rem;
  max-width: 1200px;
  margin: 0 auto;
}

/* ── Calendar month header ── */
.cal-month-header {
  margin: 1.5rem 0 0.5rem;
  font-size: 1.1rem;
  font-weight: 600;
  text-transform: capitalize;
  color: #444;
}

/* ── Calendar grid ── */
/* ── Calendar grid (spanning events) ── */
.cal-outer {
  border: 1px solid #e0e0e0;
  border-radius: 6px;
  overflow: hidden;
}
.cal-headers {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  background: #e0e0e0;
  gap: 1px;
}
.day-header {
  background: #f8f9fa;
  text-align: center;
  padding: 0.4rem 0;
  font-size: 0.75rem;
  font-weight: 700;
  color: #666;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.cal-week-block {
  border-top: 1px solid #e0e0e0;
  background: white;
  padding-bottom: 3px;
}
.cal-week-block:first-child { border-top: none; }
.cal-days-row {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  background: #e0e0e0;
  gap: 1px;
}
.day-cell {
  background: white;
  min-height: 32px;
  padding: 0.25rem;
}
.day-cell.other-month { background: #fafafa; }
.day-cell.today { background: #e8f0fe; }
.day-num {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  color: #555;
}
.day-cell.today .day-num {
  color: white;
  background: #1a73e8;
  border-radius: 50%;
  width: 1.6em;
  height: 1.6em;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.day-cell.other-month .day-num { color: #bbb; }
.cal-event-row {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  background: white;
  padding: 1px 2px 0;
  min-height: 20px;
}
.event-span {
  display: flex;
  align-items: center;
  gap: 2px;
  color: white;
  font-size: 0.7rem;
  padding: 1px 5px;
  margin: 0 1px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: pointer;
  border-radius: 2px;
  height: 18px;
}
.event-span.span-first  { border-radius: 9px 2px 2px 9px; margin-left: calc(100% / 14); }
.event-span.span-last   { border-radius: 2px 9px 9px 2px; margin-right: calc(100% / 14); }
.event-span.span-first.span-last { border-radius: 9px; }
.event-span.span-checkout { width: 50%; }
.event-span:hover { filter: brightness(0.9); }

/* ── Platform logo in event bar / list row ── */
.platform-logo {
  width: 12px;
  height: 12px;
  object-fit: contain;
  vertical-align: middle;
  margin-right: 3px;
  flex-shrink: 0;
}

/* ── Platform emoji icon (Perso ♥ / Direct ◆) ── */
.platform-emoji {
  font-size: 11px;
  line-height: 1;
  margin-right: 3px;
  vertical-align: middle;
  flex-shrink: 0;
}

/* ── Platform filter pill with icon ── */
.pill.pill-icon {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.pill.pill-icon .platform-logo,
.pill.pill-icon .platform-emoji {
  margin-right: 0;
}

/* ── Event detail panel ── */
.event-detail {
  background: white;
  border-left: 4px solid #1a73e8;
  border-radius: 6px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  padding: 0.75rem 2.5rem 0.75rem 1rem;
  position: fixed;
  top: 0; /* set dynamically by JS */
  left: 1.5rem;
  right: 1.5rem;
  z-index: 90;
}
.event-detail-close {
  position: absolute;
  top: 0.5rem;
  right: 0.6rem;
  background: none;
  border: none;
  font-size: 1rem;
  cursor: pointer;
  color: #999;
  line-height: 1;
}
.event-detail-close:hover { color: #333; }
.event-detail-header {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin-bottom: 0.25rem;
}
.event-detail-logo { width: 16px; height: 16px; object-fit: contain; }
.event-detail-edit {
  background: none;
  border: none;
  color: #666;
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
  padding: 0 0.1rem;
}
.event-detail-edit:hover { color: #1a73e8; }
.event-detail-delete {
  background: none;
  border: none;
  color: #bbb;
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
  padding: 0 0.1rem;
}
.event-detail-delete:hover { color: #e53935; }
.event-detail-summary {
  font-size: 0.95rem;
  margin-bottom: 0.25rem;
  display: flex;
  align-items: center;
  gap: 0.3rem;
}
.event-detail-dates {
  font-size: 0.85rem;
  color: #555;
  display: flex;
  align-items: center;
  gap: 0.15rem;
  flex-wrap: wrap;
}

/* ── Footer ── */
.last-refresh {
  text-align: center;
  font-size: 0.8rem;
  color: #999;
  padding: 1.5rem 1rem 1rem;
}

/* ── Auth overlay ── */
[x-cloak] { display: none !important; }

.auth-overlay {
  position: fixed;
  inset: 0;
  background: #f5f5f5;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}
.auth-box {
  background: white;
  border-radius: 10px;
  box-shadow: 0 2px 20px rgba(0,0,0,0.12);
  padding: 2rem;
  width: 100%;
  max-width: 380px;
  text-align: center;
}
.auth-box h2 { margin: 0 0 0.5rem; color: #1a73e8; }
.auth-box p { color: #555; margin: 0 0 1rem; }
.auth-input {
  width: 100%;
  padding: 0.6rem 0.8rem;
  border: 1px solid #ccc;
  border-radius: 6px;
  font-size: 1rem;
  margin-bottom: 0.75rem;
  box-sizing: border-box;
}
.auth-input:focus { outline: none; border-color: #1a73e8; }
.otp-input { letter-spacing: 0.3em; text-align: center; font-size: 1.3rem; }
.btn-otp {
  width: 100%;
  padding: 0.65rem;
  background: #1a73e8;
  color: white;
  border: none;
  border-radius: 6px;
  font-size: 1rem;
  cursor: pointer;
  margin-bottom: 0.5rem;
}
.btn-otp:hover:not(:disabled) { background: #1558b0; }
.btn-otp:disabled { opacity: 0.6; cursor: default; }
.btn-back {
  background: none;
  border: none;
  color: #1a73e8;
  cursor: pointer;
  font-size: 0.9rem;
}
.btn-back:hover { text-decoration: underline; }
.auth-error { color: #c0392b; font-size: 0.9rem; margin-top: 0.5rem; }
.btn-signout {
  background: rgba(255,255,255,0.15);
  border: 1px solid rgba(255,255,255,0.5);
  color: white;
  border-radius: 4px;
  padding: 0.25rem 0.75rem;
  cursor: pointer;
  font-size: 0.85rem;
  white-space: nowrap;
}
.btn-signout:hover { background: rgba(255,255,255,0.25); }

/* ── Add-event button ── */
.add-event-btn {
  margin-left: auto;
  width: 2rem;
  height: 2rem;
  border-radius: 50%;
  border: none;
  background: #1a73e8;
  color: white;
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  align-self: center;
}
.add-event-btn:hover { background: #1558b0; }

/* ── Block-dates modal ── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
}
.modal-card {
  background: white;
  border-radius: 10px;
  box-shadow: 0 4px 24px rgba(0,0,0,0.2);
  padding: 1.5rem;
  width: 100%;
  max-width: 420px;
  position: relative;
}
.modal-close {
  position: absolute;
  top: 0.75rem;
  right: 0.75rem;
  background: none;
  border: none;
  font-size: 1.2rem;
  line-height: 1;
  color: #999;
  cursor: pointer;
  padding: 0.15rem 0.4rem;
  border-radius: 4px;
}
.modal-close:hover { color: #333; background: #f0f0f0; }
.modal-card h3 { margin: 0 0 1.2rem; font-size: 1.1rem; color: #222; }
.modal-field { margin-bottom: 1rem; }
.modal-field label { display: block; font-size: 0.82rem; font-weight: 600; color: #555; margin-bottom: 0.3rem; }
.modal-row { display: flex; gap: 1rem; }
.modal-row > div { flex: 1; }
.modal-select,
.modal-input {
  width: 100%;
  padding: 0.5rem 0.6rem;
  border: 1px solid #ccc;
  border-radius: 6px;
  font-size: 0.9rem;
  color: #333;
}
.modal-select:focus,
.modal-input:focus { outline: none; border-color: #1a73e8; }
.modal-textarea { resize: vertical; min-height: 3.5rem; font-family: inherit; }
.modal-radio-group { display: flex; gap: 1.5rem; }
.modal-radio { display: flex; align-items: center; gap: 0.4rem; font-size: 0.9rem; cursor: pointer; }
.modal-error { color: #c0392b; font-size: 0.85rem; margin: 0 0 0.75rem; }
.modal-actions { display: flex; justify-content: flex-end; gap: 0.75rem; margin-top: 1.25rem; }
.modal-cancel {
  padding: 0.45rem 1rem;
  border: 1px solid #ccc;
  border-radius: 6px;
  background: white;
  color: #555;
  font-size: 0.9rem;
  cursor: pointer;
}
.modal-cancel:hover { background: #f0f0f0; }
.modal-submit {
  padding: 0.45rem 1.2rem;
  border: none;
  border-radius: 6px;
  background: #1a73e8;
  color: white;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
}
.modal-submit:hover { background: #1558b0; }
.modal-submit-danger { background: #e53935; }
.modal-submit-danger:hover { background: #b71c1c; }
.modal-submit:disabled,
.modal-cancel:disabled { opacity: 0.6; cursor: not-allowed; }
.delete-confirm-desc { font-size: 0.95rem; font-weight: 500; margin: 0.5rem 0 0.25rem; }
.delete-confirm-dates { font-size: 0.85rem; color: #555; margin-bottom: 0.5rem; }

