:root {
  --bg: #0a0f1f;
  --bg-elev: #111a33;
  --bg-card: #15203f;
  --border: #1f2d52;
  --text: #e6ecff;
  --text-muted: #8a9bc4;
  --accent: #22d3ee;
  --accent-2: #6366f1;
  --accent-soft: rgba(34, 211, 238, 0.12);
  --danger: #f87171;
  --success: #34d399;
  --radius: 10px;
  --focus: 2px solid var(--accent);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  line-height: 1.5;
  min-height: 100vh;
}

.screen { min-height: 100vh; display: flex; flex-direction: column; }
.hidden { display: none !important; }

/* Brand bar */
.brand-bar, .topbar {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.85rem 1.5rem;
  background: var(--bg-elev);
  border-bottom: 1px solid var(--border);
}
.topbar { justify-content: flex-start; }

.brand { display: flex; align-items: center; gap: 0.6rem; }
.brand-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #06121f;
  font-weight: 700;
  font-size: 0.8rem;
  letter-spacing: 0.5px;
}
.brand-name { font-weight: 600; font-size: 1.05rem; letter-spacing: 0.2px; }

.demo-badge {
  margin-left: auto;
  background: var(--accent-soft);
  color: var(--accent);
  border: 1px solid rgba(34, 211, 238, 0.35);
  border-radius: 999px;
  padding: 0.15rem 0.7rem;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* Hero / landing */
.hero {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 2rem 1.5rem 3rem;
  gap: 1.5rem;
}
.hero h1 {
  font-size: clamp(2rem, 5vw, 3rem);
  margin: 0;
  background: linear-gradient(120deg, var(--text), var(--accent));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.tagline { max-width: 640px; color: var(--text-muted); font-size: 1.05rem; margin: 0; }

.login-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.75rem;
  max-width: 420px;
  width: 100%;
  text-align: left;
}
.login-card h2 { margin: 0 0 0.5rem; font-size: 1.2rem; }
.demo-notice { color: var(--text-muted); font-size: 0.9rem; margin: 0 0 1.25rem; }
.fineprint { color: var(--text-muted); font-size: 0.8rem; max-width: 560px; margin: 0; }

/* Buttons */
.btn {
  font: inherit;
  font-weight: 600;
  border-radius: 8px;
  padding: 0.6rem 1.1rem;
  border: 1px solid transparent;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, opacity 0.15s;
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn:focus-visible { outline: var(--focus); outline-offset: 2px; }
.btn-primary { background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #06121f; }
.btn-primary:hover:not(:disabled) { filter: brightness(1.08); }
.btn-secondary { background: var(--bg-elev); color: var(--text); border-color: var(--border); }
.btn-secondary:hover:not(:disabled) { border-color: var(--accent); }
.btn-ghost { background: transparent; color: var(--text-muted); border-color: var(--border); }
.btn-ghost:hover { color: var(--text); border-color: var(--accent); }

/* Busy button: an animated pseudo-element spinner sits beside the label. The empty
   content contributes no text, so the existing label stays intact and legible. */
.btn-busy { position: relative; padding-left: 2.3rem; }
/* Keep the busy button legible even while disabled mid-update. */
.btn-busy:disabled { opacity: 1; }
.btn-busy::before {
  content: "";
  position: absolute;
  left: 0.85rem;
  top: 50%;
  width: 1rem;
  height: 1rem;
  margin-top: -0.5rem;
  border: 2px solid rgba(6, 18, 31, 0.35);
  border-top-color: #06121f;
  border-radius: 50%;
  animation: btn-busy-spin 0.7s linear infinite;
}
@keyframes btn-busy-spin { to { transform: rotate(360deg); } }

/* Reduced-motion fallback: hold a static ring so the wait is still indicated. */
@media (prefers-reduced-motion: reduce) {
  .btn-busy::before { animation: none; border-top-color: rgba(6, 18, 31, 0.35); }
}

/* The import button is a dark secondary button, so its busy spinner uses a light ring with an
   accent head to stay visible against the dark background (higher specificity than .btn-busy). */
.btn-secondary.btn-busy::before { border-color: rgba(230, 236, 255, 0.25); border-top-color: var(--accent); }

/* Workspace */
.workspace-body { padding: 2rem 1.5rem; max-width: 960px; margin: 0 auto; width: 100%; }
.workspace-body h2 { margin: 0 0 0.5rem; }
.overview-text { color: var(--text-muted); margin: 0 0 1.75rem; max-width: 640px; }

.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
}
.integration-card h3 { margin: 0 0 1rem; }

.status-row { display: flex; align-items: center; gap: 0.6rem; margin-bottom: 1rem; }
.status-label { color: var(--text-muted); font-size: 0.9rem; }
.status-dot {
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--text-muted);
}
.status-dot-connected { background: var(--success); }
.status-dot-disconnected { background: var(--text-muted); }
.status-dot-reconnect { background: var(--danger); }

.actions-row { display: flex; flex-wrap: wrap; gap: 0.75rem; margin-bottom: 1rem; }

.calendar-picker { margin-bottom: 1rem; }
.field-label { display: block; font-size: 0.85rem; color: var(--text-muted); margin-bottom: 0.35rem; }
.select {
  width: 100%;
  background: var(--bg-elev);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.55rem 0.7rem;
  font: inherit;
}
.select:focus-visible { outline: var(--focus); outline-offset: 2px; }
.field-help { font-size: 0.78rem; color: var(--text-muted); margin: 0.35rem 0 0; }

/* Explicit, scoped holiday updates. The settings panel is always visible so the country
   selection stays discoverable; desktop splits years and countries into two columns. */
.holiday-section { border-top: 1px solid var(--border); padding-top: 1rem; margin-top: 1rem; }
.holiday-section h4 { margin: 0 0 0.35rem; }
.holiday-section > .actions-row { margin: 0.85rem 0; }
.holiday-section a { color: var(--accent); }
.holiday-settings { margin: 0.75rem 0; }
.holiday-columns { display: grid; grid-template-columns: minmax(180px, 220px) 1fr; gap: 1rem; align-items: start; }
.holiday-fieldset { border: 1px solid var(--border); border-radius: 8px; margin: 0; padding: 0.75rem; min-width: 0; }
.holiday-fieldset legend { font-size: 0.85rem; color: var(--text-muted); padding: 0 0.25rem; }
.holiday-years { display: flex; flex-wrap: wrap; gap: 1rem; }
.holiday-country-search { margin-bottom: 0.5rem; }
.holiday-country-count { font-size: 0.78rem; color: var(--text-muted); margin: 0 0 0.5rem; }
/* Single-column scrollable, bordered list. Rows are filtered with the existing .hidden class
   (display:none!important) so it overrides .holiday-choice's flex display. */
.holiday-countries { border: 1px solid var(--border); border-radius: 8px; padding: 0.5rem 0.75rem; max-height: 320px; overflow-y: auto; }
.holiday-choice { display: flex; align-items: flex-start; gap: 0.4rem; font-size: 0.85rem; padding: 0.15rem 0; }
.holiday-choice input { accent-color: var(--accent); margin-top: 0.3rem; }
.holiday-choice input:focus-visible { outline: var(--focus); outline-offset: 2px; }
.holiday-success { color: var(--success); }

/* Verified banner */
.verified-banner {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: rgba(52, 211, 153, 0.1);
  border: 1px solid rgba(52, 211, 153, 0.4);
  border-radius: 8px;
  padding: 0.7rem 1rem;
  margin-bottom: 1rem;
  color: var(--success);
  font-size: 0.9rem;
}
.verified-icon { font-weight: 700; }

/* Events */
.events-section { margin-top: 1rem; }
.events-header { display: flex; align-items: baseline; gap: 0.75rem; margin-bottom: 0.75rem; }
.events-header h4 { margin: 0; }
.events-count { color: var(--text-muted); font-size: 0.85rem; }

.state-msg { color: var(--text-muted); padding: 0.5rem 0; font-size: 0.9rem; }
.state-error { color: var(--danger); }

.events-table { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
.events-table th, .events-table td {
  text-align: left;
  padding: 0.55rem 0.6rem;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}
.events-table th { color: var(--text-muted); font-weight: 600; font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.4px; }
.events-table td { color: var(--text); }
.events-table tr:hover td { background: rgba(34, 211, 238, 0.04); }
.event-id { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.78rem; color: var(--text-muted); word-break: break-all; }
.event-link { color: var(--accent); text-decoration: none; }
.event-link:hover { text-decoration: underline; }
.event-link:focus-visible { outline: var(--focus); outline-offset: 2px; }
/* Invalid-event problems render as a compact, plain-text list inside the table cell. */
.problem-list { margin: 0; padding-left: 1.1rem; }
.problem-list li { margin: 0; }

/* Calendar validation failures: scoped to the invalid-result panel only, so the standalone
   loader stays neutral and a valid import keeps the existing green banner. Uses --danger
   (#f87171) with a subtle tinted background and a strong left edge. */
.validation-errors {
  background: rgba(248, 113, 113, 0.08);
  border: 1px solid rgba(248, 113, 113, 0.45);
  border-left: 4px solid var(--danger);
  border-radius: 8px;
  padding: 0.75rem 1rem;
}
.validation-errors .events-header { align-items: center; margin-bottom: 0.5rem; }
/* Textual marker, not an asset; hidden from assistive tech because the heading states the failure. */
.validation-errors-mark { color: var(--danger); font-weight: 700; font-size: 1.05rem; line-height: 1; }
.validation-errors h4 { color: var(--danger); }
.validation-errors .events-count {
  color: var(--danger);
  background: rgba(248, 113, 113, 0.14);
  border-radius: 999px;
  padding: 0.1rem 0.5rem;
  font-weight: 600;
}
.validation-errors-summary { margin: 0 0 0.75rem; color: var(--danger); font-size: 0.9rem; }
.validation-errors .problem-list li { color: var(--danger); }
/* Row hover emphasis stays inside this panel instead of the global cyan table hover. */
.validation-errors .events-table tr:hover td { background: rgba(248, 113, 113, 0.08); }
/* Keep the untrusted date value on a single line inside the failure panel. */
.validation-errors .events-table td:first-child { white-space: nowrap; }
.pill {
  display: inline-block;
  padding: 0.1rem 0.5rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
}
.pill-confirmed { background: rgba(52, 211, 153, 0.12); color: var(--success); }
.pill-tentative { background: rgba(34, 211, 238, 0.12); color: var(--accent); }
.pill-other { background: var(--bg-elev); color: var(--text-muted); }

/* Responsive */
@media (max-width: 640px) {
  .events-table { font-size: 0.78rem; }
  /* Stack the years and countries columns below 640px. */
  .holiday-columns { grid-template-columns: 1fr; }
  .topbar { flex-wrap: wrap; }
  .demo-badge { margin-left: 0; }
}
