/* =====================================================
   BASE RESET & VARIABLES
   ===================================================== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --c-bg:       #f7f6f2;
  --c-surface:  #ffffff;
  --c-border:   #e2e0d8;
  --c-text:     #1a1917;
  --c-muted:    #6b6860;
  --c-accent:   #2a52c9;
  --c-accent2:  #e8533c;
  --c-ok:       #1e8a5e;
  --c-warn:     #c47a1a;
  --c-tag-bg:   #eef1fb;
  --c-tag:      #2a52c9;
  --radius:     10px;
  --shadow:     0 1px 4px rgba(0,0,0,.08), 0 4px 16px rgba(0,0,0,.05);
  --font-serif: 'DM Serif Display', Georgia, serif;
  --font-sans:  'Inter', system-ui, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --c-bg:       #141412;
    --c-surface:  #1e1d1b;
    --c-border:   #2e2d2a;
    --c-text:     #f0ede6;
    --c-muted:    #8a8780;
    --c-accent:   #6b89f0;
    --c-accent2:  #f0705a;
    --c-ok:       #3dbb88;
    --c-warn:     #e0952e;
    --c-tag-bg:   #1e2340;
    --c-tag:      #6b89f0;
    --shadow:     0 1px 4px rgba(0,0,0,.3), 0 4px 16px rgba(0,0,0,.2);
  }
}

html { font-size: 16px; scroll-behavior: smooth; }
body {
  font-family: var(--font-sans);
  background: var(--c-bg);
  color: var(--c-text);
  line-height: 1.6;
  min-height: 100vh;
}
a { color: var(--c-accent); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; display: block; }

/* =====================================================
   LAYOUT
   ===================================================== */
.container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 24px;
}
.grid-2col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 32px;
  align-items: start;
}
@media (max-width: 768px) {
  .grid-2col { grid-template-columns: 1fr; }
}

/* =====================================================
   HEADER & NAV
   ===================================================== */
.site-header {
  background: var(--c-surface);
  border-bottom: 1px solid var(--c-border);
  position: sticky;
  top: 0;
  z-index: 100;
}
.site-header .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 58px;
}
.site-logo {
  font-family: var(--font-serif);
  font-size: 1.3rem;
  color: var(--c-text);
  display: flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
}
.logo-dot {
  width: 10px; height: 10px;
  background: var(--c-accent);
  border-radius: 50%;
  display: inline-block;
}
.site-nav { display: flex; gap: 4px; }
.nav-link {
  padding: 6px 12px;
  border-radius: 6px;
  font-size: .875rem;
  font-weight: 500;
  color: var(--c-muted);
  transition: background .15s, color .15s;
  text-decoration: none;
}
.nav-link:hover, .nav-link.active {
  background: var(--c-tag-bg);
  color: var(--c-accent);
  text-decoration: none;
}
.nav-link--admin { color: var(--c-accent2); }
.nav-link--admin:hover { background: #fdf0ee; color: var(--c-accent2); }

/* =====================================================
   HERO
   ===================================================== */
.hero {
  padding: 64px 0 48px;
  background: var(--c-surface);
  border-bottom: 1px solid var(--c-border);
}
.hero-title {
  font-family: var(--font-serif);
  font-size: clamp(2rem, 5vw, 3.4rem);
  line-height: 1.15;
  margin-bottom: 16px;
}
.hero-title em { color: var(--c-accent); font-style: italic; }
.hero-sub {
  color: var(--c-muted);
  font-size: 1.1rem;
  max-width: 520px;
}

/* =====================================================
   STATS BAR
   ===================================================== */
.stats-bar {
  background: var(--c-text);
  color: #fff;
  padding: 12px 0;
}
.stats-bar__inner {
  display: flex;
  align-items: center;
  gap: 32px;
  flex-wrap: wrap;
}
.stat-item { display: flex; flex-direction: column; gap: 2px; }
.stat-label { font-size: .7rem; text-transform: uppercase; letter-spacing: .08em; opacity: .55; }
.stat-value { font-size: .95rem; font-weight: 600; }
.stat-value--ok   { color: #4ade80; }
.stat-value--warn { color: #facc15; }

.refresh-btn {
  margin-left: auto;
  background: rgba(255,255,255,.12);
  border: none;
  color: #fff;
  width: 30px; height: 30px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
  transition: background .15s, transform .3s;
}
.refresh-btn:hover { background: rgba(255,255,255,.22); }
.refresh-btn:active { transform: rotate(180deg); }

/* =====================================================
   MAIN CONTENT
   ===================================================== */
.main-content { padding: 48px 0 64px; }
.section-title {
  font-family: var(--font-serif);
  font-size: 1.5rem;
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  gap: 10px;
}

/* Page link cards */
.page-links { display: flex; flex-direction: column; gap: 14px; }
.page-card {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  padding: 18px 20px;
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  text-decoration: none;
  color: var(--c-text);
  transition: border-color .15s, transform .15s, box-shadow .15s;
}
.page-card:hover {
  border-color: var(--c-accent);
  transform: translateY(-2px);
  box-shadow: 0 4px 20px rgba(42,82,201,.12);
  text-decoration: none;
}
.page-card__icon { font-size: 1.6rem; flex-shrink: 0; }
.page-card__body h3 { font-size: 1rem; font-weight: 600; margin-bottom: 4px; }
.page-card__body p { font-size: .85rem; color: var(--c-muted); }
.page-card__badge {
  display: inline-block;
  margin-top: 8px;
  padding: 2px 8px;
  background: var(--c-tag-bg);
  color: var(--c-tag);
  border-radius: 20px;
  font-size: .72rem;
  font-weight: 600;
  letter-spacing: .03em;
}

/* Live data panel */
.live-data-panel {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--radius);
  overflow: hidden;
  min-height: 120px;
}
.data-row {
  display: flex;
  align-items: center;
  padding: 10px 16px;
  border-bottom: 1px solid var(--c-border);
  gap: 12px;
}
.data-row:last-child { border-bottom: none; }
.data-key  { font-weight: 600; font-size: .85rem; flex: 1; }
.data-val  { font-family: monospace; font-size: .9rem; color: var(--c-accent); }
.data-meta { font-size: .72rem; color: var(--c-muted); white-space: nowrap; }
.data-note { font-size: .8rem; color: var(--c-muted); margin-top: 10px; }
.empty-msg { padding: 24px 16px; color: var(--c-muted); font-size: .9rem; }

/* Loading */
.loading-spinner { padding: 28px; text-align: center; color: var(--c-muted); font-size: .9rem; }

/* Pulse dot */
.pulse-dot {
  width: 8px; height: 8px;
  background: var(--c-ok);
  border-radius: 50%;
  display: inline-block;
}
.pulse-active { animation: pulse-anim .5s ease; }
@keyframes pulse-anim {
  0%   { transform: scale(1);   opacity: 1; }
  50%  { transform: scale(2.5); opacity: .4; }
  100% { transform: scale(1);   opacity: 1; }
}

/* =====================================================
   FOOTER
   ===================================================== */
.site-footer {
  border-top: 1px solid var(--c-border);
  padding: 20px 0;
  font-size: .8rem;
  color: var(--c-muted);
  text-align: center;
}

/* =====================================================
   CALENDAR PAGE
   ===================================================== */
.cal-controls {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}
.cal-controls input, .cal-controls select {
  padding: 7px 12px;
  border: 1px solid var(--c-border);
  border-radius: 7px;
  background: var(--c-surface);
  color: var(--c-text);
  font-size: .875rem;
}
.cal-status {
  margin-left: auto;
  font-size: .8rem;
  color: var(--c-muted);
}

.day-section { margin-bottom: 40px; }
.day-label {
  font-family: var(--font-serif);
  font-size: 1.4rem;
  margin-bottom: 16px;
  border-bottom: 2px solid var(--c-border);
  padding-bottom: 8px;
}
.day-label span { font-size: .8rem; font-family: var(--font-sans); color: var(--c-muted); margin-left: 8px; font-style: normal; }

.timeline-wrap {
  position: relative;
  display: grid;
  grid-template-columns: 52px 1fr;
  gap: 0;
}
.time-gutter {
  display: flex;
  flex-direction: column;
}
.time-tick {
  height: 60px;
  font-size: .72rem;
  color: var(--c-muted);
  text-align: right;
  padding-right: 10px;
  padding-top: 2px;
  flex-shrink: 0;
}
.time-col {
  position: relative;
  border-left: 1px solid var(--c-border);
}
.time-row-line {
  height: 60px;
  border-bottom: 1px solid var(--c-border);
  opacity: .4;
}
.events-col {
  position: absolute;
  inset: 0;
  padding: 0 4px;
}
.cal-event {
  position: absolute;
  left: 6px; right: 6px;
  border-radius: 7px;
  padding: 6px 10px;
  font-size: .8rem;
  overflow: hidden;
  cursor: pointer;
  transition: filter .15s, transform .1s;
  border-left: 3px solid transparent;
}
.cal-event:hover { filter: brightness(1.08); transform: scale(1.01); }
.cal-event__title { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cal-event__time  { font-size: .72rem; opacity: .75; margin-top: 2px; }
.cal-event__loc   { font-size: .72rem; opacity: .65; margin-top: 1px; }

/* Event palette */
.ev-blue   { background: #dbeafe; border-color: #3b82f6; color: #1e3a8a; }
.ev-green  { background: #d1fae5; border-color: #10b981; color: #064e3b; }
.ev-amber  { background: #fef3c7; border-color: #f59e0b; color: #78350f; }
.ev-red    { background: #fee2e2; border-color: #ef4444; color: #7f1d1d; }
.ev-purple { background: #ede9fe; border-color: #8b5cf6; color: #2e1065; }
.ev-teal   { background: #ccfbf1; border-color: #14b8a6; color: #042f2e; }
@media (prefers-color-scheme: dark) {
  .ev-blue   { background: #1e3a6e; color: #bfdbfe; }
  .ev-green  { background: #064e3b; color: #a7f3d0; }
  .ev-amber  { background: #78350f; color: #fde68a; }
  .ev-red    { background: #7f1d1d; color: #fecaca; }
  .ev-purple { background: #2e1065; color: #ddd6fe; }
  .ev-teal   { background: #042f2e; color: #99f6e4; }
}

.no-events { padding: 20px; color: var(--c-muted); font-size: .9rem; text-align: center; }

/* =====================================================
   ADMIN PAGE
   ===================================================== */
.admin-wrap { max-width: 640px; margin: 0 auto; }
.admin-card {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--radius);
  padding: 28px;
  margin-bottom: 24px;
  box-shadow: var(--shadow);
}
.admin-card h2 { font-family: var(--font-serif); font-size: 1.2rem; margin-bottom: 18px; }
.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-size: .8rem; font-weight: 600; margin-bottom: 5px; text-transform: uppercase; letter-spacing: .04em; color: var(--c-muted); }
.form-group input, .form-group textarea, .form-group select {
  width: 100%;
  padding: 9px 13px;
  border: 1px solid var(--c-border);
  border-radius: 7px;
  background: var(--c-bg);
  color: var(--c-text);
  font-size: .9rem;
  font-family: var(--font-sans);
  transition: border-color .15s;
}
.form-group input:focus, .form-group textarea:focus {
  outline: none;
  border-color: var(--c-accent);
}
.form-group textarea { min-height: 80px; resize: vertical; }

.btn {
  padding: 9px 22px;
  border: none;
  border-radius: 7px;
  font-size: .875rem;
  font-weight: 600;
  cursor: pointer;
  transition: opacity .15s, transform .1s;
}
.btn:active { transform: scale(.97); }
.btn-primary { background: var(--c-accent); color: #fff; }
.btn-danger  { background: var(--c-accent2); color: #fff; }
.btn-ghost   { background: var(--c-bg); border: 1px solid var(--c-border); color: var(--c-text); }
.btn:hover   { opacity: .88; }
.btn-row     { display: flex; gap: 10px; flex-wrap: wrap; }

.alert {
  padding: 10px 14px;
  border-radius: 7px;
  font-size: .875rem;
  margin-top: 14px;
}
.alert-ok  { background: #d1fae5; color: #064e3b; }
.alert-err { background: #fee2e2; color: #7f1d1d; }

/* data table */
.data-table { width: 100%; border-collapse: collapse; font-size: .875rem; }
.data-table th, .data-table td { padding: 9px 12px; border-bottom: 1px solid var(--c-border); text-align: left; }
.data-table th { font-size: .75rem; text-transform: uppercase; letter-spacing: .05em; color: var(--c-muted); }
.data-table td:last-child { text-align: right; }
.action-btn { background: none; border: none; cursor: pointer; color: var(--c-accent2); font-size: .85rem; padding: 2px 6px; }

/* =====================================================
   PAGE HEADER (sub-pages)
   ===================================================== */
.page-header {
  background: var(--c-surface);
  border-bottom: 1px solid var(--c-border);
  padding: 36px 0 28px;
  margin-bottom: 36px;
}
.page-header h1 {
  font-family: var(--font-serif);
  font-size: 2rem;
  margin-bottom: 6px;
}
.page-header p { color: var(--c-muted); font-size: .95rem; }
.breadcrumb { font-size: .8rem; color: var(--c-muted); margin-bottom: 12px; }
.breadcrumb a { color: var(--c-muted); }
.breadcrumb a:hover { color: var(--c-accent); }

/* =====================================================
   STATUS PAGE
   ===================================================== */
.status-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px;
  margin-bottom: 32px;
}
.status-card {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
}
.status-card__label { font-size: .75rem; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; color: var(--c-muted); margin-bottom: 6px; }
.status-card__value { font-size: 1.6rem; font-weight: 700; font-family: monospace; color: var(--c-accent); }
.status-card__meta  { font-size: .72rem; color: var(--c-muted); margin-top: 6px; }

/* API docs */
.api-doc {
  background: var(--c-text);
  color: #f0ede6;
  border-radius: var(--radius);
  padding: 24px;
  font-size: .85rem;
  line-height: 1.7;
}
.api-doc code {
  background: rgba(255,255,255,.1);
  padding: 2px 6px;
  border-radius: 4px;
  font-family: monospace;
}
.api-doc pre {
  background: rgba(0,0,0,.35);
  padding: 14px;
  border-radius: 7px;
  overflow-x: auto;
  margin: 12px 0;
  font-family: monospace;
  font-size: .82rem;
}
