:root {
  --bg: #0f172a;
  --bg-soft: #111827;
  --panel: #ffffff;
  --panel-soft: #f8fafc;
  --border: #e5e7eb;
  --text: #0f172a;
  --muted: #64748b;
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --danger: #dc2626;
  --success: #16a34a;
  --warning: #d97706;
  --shadow: 0 18px 50px rgba(15, 23, 42, 0.12);
  --radius: 24px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: 'Inter', system-ui, sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(37,99,235,0.12), transparent 34%),
    linear-gradient(180deg, #eff6ff 0%, #f8fafc 30%, #eef2ff 100%);
  min-height: 100vh;
}
body.modal-open { overflow: hidden; }

a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; }

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 18px;
  padding: 18px 24px;
  position: sticky;
  top: 0;
  z-index: 20;
  backdrop-filter: blur(16px);
  background: rgba(255,255,255,0.86);
  border-bottom: 1px solid rgba(226,232,240,0.9);
}
.brand-wrap { display: flex; align-items: center; gap: 14px; }
.brand-badge {
  width: 48px; height: 48px; border-radius: 16px;
  display: grid; place-items: center;
  background: linear-gradient(135deg, var(--primary), #8b5cf6);
  color: #fff; font-weight: 800; letter-spacing: 0.04em;
  box-shadow: var(--shadow);
}
.brand-title { font-weight: 800; font-size: 1.05rem; }
.brand-subtitle { color: var(--muted); font-size: 0.92rem; }
.topnav { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.topnav > a { color: var(--muted); font-weight: 600; }
.user-chip {
  display: inline-flex; align-items: center; gap: 10px;
  background: #f8fafc; border: 1px solid var(--border);
  padding: 8px 12px; border-radius: 999px;
}
.user-chip img { width: 28px; height: 28px; border-radius: 50%; }

.page-shell {
  width: min(1200px, calc(100% - 32px));
  margin: 28px auto 40px;
}

.auth-card, .calendar-card, .panel-card {
  background: rgba(255,255,255,0.94);
  border: 1px solid rgba(226,232,240,0.9);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.auth-card { padding: 28px; }
.narrow-card { max-width: 760px; margin-inline: auto; }

.hero-grid {
  display: grid;
  grid-template-columns: 1.35fr 0.9fr;
  gap: 24px;
  align-items: center;
}
.hero-grid h1 { font-size: clamp(2rem, 3vw, 3rem); margin: 8px 0 14px; line-height: 1.05; }
.hero-grid p { font-size: 1.04rem; color: #334155; margin: 0 0 20px; }
.hero-card {
  min-height: 320px;
  background: linear-gradient(180deg, #0f172a 0%, #111827 100%);
  border-radius: 28px;
  padding: 22px;
  color: #fff;
  display: flex;
  flex-direction: column;
  gap: 12px;
  justify-content: center;
}
.mini-card {
  margin-top: 8px;
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 20px;
  padding: 18px;
}

.kicker {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: #dbeafe;
  color: #1d4ed8;
  border-radius: 999px;
  padding: 8px 12px;
  font-weight: 700;
  font-size: 0.84rem;
}
.feature-list { display: grid; gap: 10px; margin: 18px 0 22px; }
.feature-item {
  background: var(--panel-soft);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 12px 14px;
  color: #334155;
}

.dashboard-head {
  display: flex; justify-content: space-between; align-items: end; gap: 16px; margin-bottom: 18px;
}
.dashboard-head h1 { margin: 10px 0 8px; font-size: clamp(1.7rem, 2.5vw, 2.4rem); }
.dashboard-head p { margin: 0; color: var(--muted); }
.head-actions { display: flex; gap: 10px; }

.legend-wrap {
  display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 18px;
}
.legend-item {
  background: rgba(255,255,255,0.85);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 10px 14px;
  color: #334155;
  font-weight: 600;
}
.dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; margin-right: 8px; }
.red { background: #fee2e2; color: #991b1b; }
.amber { background: #fef3c7; color: #92400e; }
.green { background: #dcfce7; color: #166534; }
.dot.red { background: #dc2626; }
.dot.amber { background: #d97706; }
.dot.green { background: #16a34a; }
.status-pill {
  display: inline-flex; align-self: start; padding: 8px 12px; border-radius: 999px; font-weight: 700;
}

.calendar-card { padding: 18px; }
#calendar { min-height: 680px; }
.fc .fc-toolbar-title { font-size: 1.25rem; }
.fc .fc-button {
  border-radius: 12px !important;
  padding: 0.6em 0.9em !important;
  border: 0 !important;
  background: #e2e8f0 !important;
  color: #0f172a !important;
  box-shadow: none !important;
}
.fc .fc-button.fc-button-active,
.fc .fc-button:hover { background: #cbd5e1 !important; }
.fc .fc-daygrid-event,
.fc .fc-list-event {
  border-radius: 12px !important;
  padding: 4px 8px !important;
  font-weight: 600;
  cursor: pointer;
}
.fc-daygrid-event-harness {
	cursor: pointer;
}
.fc-theme-standard td,
.fc-theme-standard th,
.fc-theme-standard .fc-scrollgrid { border-color: #e2e8f0 !important; }

.grid-two {
  display: grid;
  grid-template-columns: 1fr 0.9fr;
  gap: 18px;
  margin-bottom: 18px;
}
.panel-card { padding: 22px; }
.table-wrap { overflow: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 12px 10px; border-bottom: 1px solid var(--border); text-align: left; font-size: 0.95rem; }
th { color: var(--muted); font-size: 0.85rem; text-transform: uppercase; letter-spacing: 0.05em; }
.table-head { display: flex; justify-content: space-between; gap: 14px; align-items: center; margin-bottom: 12px; }
.table-note { color: var(--muted); font-size: 0.92rem; }
.info-box, .install-box {
  background: #f8fafc; border: 1px solid var(--border); border-radius: 18px; padding: 16px;
}

.stack-form { display: grid; gap: 14px; }
.stack-form label { display: grid; gap: 8px; }
.stack-form span { font-weight: 700; font-size: 0.95rem; }
input, select, textarea {
  width: 100%;
  border: 1px solid #cbd5e1;
  border-radius: 14px;
  padding: 13px 14px;
  background: #fff;
  color: var(--text);
  outline: none;
}
input:focus, select:focus, textarea:focus {
  border-color: #93c5fd;
  box-shadow: 0 0 0 4px rgba(147,197,253,0.25);
}
textarea { resize: vertical; min-height: 120px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 0; cursor: pointer; text-decoration: none;
  border-radius: 16px; padding: 12px 18px; font-weight: 700;
}
.btn-primary { background: linear-gradient(135deg, var(--primary), #3b82f6); color: #fff; }
.btn-primary:hover { background: linear-gradient(135deg, var(--primary-dark), var(--primary)); }
.btn-ghost { background: #eef2ff; color: #3730a3; }
.btn-danger { background: #fee2e2; color: #991b1b; }
.btn-google { background: #111827; color: #fff; }
.btn-small { padding: 8px 12px; border-radius: 12px; font-size: 0.9rem; }
.icon-btn {
  width: 42px; height: 42px; border: 0; border-radius: 12px; cursor: pointer; background: #f1f5f9;
}

.modal-backdrop {
  position: fixed; inset: 0; background: rgba(15, 23, 42, 0.55); display: grid; place-items: center; padding: 16px; z-index: 50;
}
.modal-sheet {
  width: min(680px, 100%);
  max-height: calc(100vh - 32px);
  overflow: auto;
  background: #fff;
  border-radius: 28px;
  padding: 22px;
  box-shadow: 0 30px 80px rgba(15,23,42,0.32);
}
.modal-header {
  display: flex; align-items: start; justify-content: space-between; gap: 12px; margin-bottom: 18px;
}
.modal-header h2 { margin: 8px 0 0; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; flex-wrap: wrap; }

.alert {
  border-radius: 16px; padding: 14px 16px; margin: 12px 0 18px; font-weight: 600;
}
.alert.success { background: #dcfce7; color: #166534; }
.alert.error { background: #fee2e2; color: #991b1b; }

.toast {
  position: fixed; right: 18px; bottom: 18px; min-width: 280px; max-width: calc(100vw - 36px);
  background: #0f172a; color: #fff; padding: 14px 16px; border-radius: 16px;
  box-shadow: var(--shadow); opacity: 0; transform: translateY(12px); pointer-events: none;
  transition: opacity .2s ease, transform .2s ease; z-index: 80;
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast.error { background: #991b1b; }
.toast.success { background: #166534; }

code {
  background: #e2e8f0; padding: 2px 6px; border-radius: 8px;
}

@media (max-width: 960px) {
  .hero-grid, .grid-two { grid-template-columns: 1fr; }
  .dashboard-head { align-items: start; flex-direction: column; }
  .page-shell { width: min(100% - 20px, 1200px); }
  .topbar { padding: 14px; }
}

@media (max-width: 640px) {
  .auth-card, .panel-card, .calendar-card { padding: 16px; }
  .topbar { flex-direction: column; align-items: stretch; }
  .topnav { justify-content: space-between; }
  .modal-sheet { padding: 16px; border-radius: 22px; }
  .modal-actions { flex-direction: column-reverse; }
  .btn, .icon-btn { width: 100%; }
  .icon-btn { width: 42px; }
}

.theme-toggle-btn {
  white-space: nowrap;
}

html[data-theme="dark"] body {
  color: #e5e7eb;
  background:
    radial-gradient(circle at top left, rgba(59,130,246,0.16), transparent 34%),
    linear-gradient(180deg, #020617 0%, #0f172a 35%, #111827 100%);
}

html[data-theme="dark"] .topbar {
  background: rgba(15,23,42,0.88);
  border-bottom-color: rgba(51,65,85,0.95);
}

html[data-theme="dark"] .brand-subtitle,
html[data-theme="dark"] .topnav > a,
html[data-theme="dark"] .dashboard-head p,
html[data-theme="dark"] .table-note,
html[data-theme="dark"] th {
  color: #94a3b8;
}

html[data-theme="dark"] .auth-card,
html[data-theme="dark"] .calendar-card,
html[data-theme="dark"] .panel-card,
html[data-theme="dark"] .modal-sheet {
  background: rgba(15,23,42,0.9);
  border-color: rgba(51,65,85,0.95);
  color: #e5e7eb;
}

html[data-theme="dark"] .user-chip,
html[data-theme="dark"] .feature-item,
html[data-theme="dark"] .info-box,
html[data-theme="dark"] .install-box,
html[data-theme="dark"] .legend-item,
html[data-theme="dark"] code,
html[data-theme="dark"] .icon-btn,
html[data-theme="dark"] .btn-ghost {
  background: #0f172a;
  border-color: #334155;
  color: #e5e7eb;
}

html[data-theme="dark"] .hero-grid p,
html[data-theme="dark"] .feature-item,
html[data-theme="dark"] .info-box,
html[data-theme="dark"] .install-box,
html[data-theme="dark"] td,
html[data-theme="dark"] .table-wrap,
html[data-theme="dark"] .modal-header h2,
html[data-theme="dark"] .stack-form span {
  color: #cbd5e1;
}

html[data-theme="dark"] .kicker {
  background: rgba(37,99,235,0.18);
  color: #bfdbfe;
}

html[data-theme="dark"] input,
html[data-theme="dark"] select,
html[data-theme="dark"] textarea {
  background: #020617;
  border-color: #334155;
  color: #e5e7eb;
}

html[data-theme="dark"] input:focus,
html[data-theme="dark"] select:focus,
html[data-theme="dark"] textarea:focus {
  border-color: #3b82f6;
  box-shadow: 0 0 0 4px rgba(59,130,246,0.2);
}

html[data-theme="dark"] th,
html[data-theme="dark"] td {
  border-bottom-color: #334155;
}

html[data-theme="dark"] .fc {
  color: #e5e7eb;
}

html[data-theme="dark"] .fc .fc-button {
  background: #1e293b !important;
  color: #e5e7eb !important;
}

html[data-theme="dark"] .fc .fc-button.fc-button-active,
html[data-theme="dark"] .fc .fc-button:hover {
  background: #334155 !important;
}

html[data-theme="dark"] .fc-theme-standard td,
html[data-theme="dark"] .fc-theme-standard th,
html[data-theme="dark"] .fc-theme-standard .fc-scrollgrid {
  border-color: #334155 !important;
}

html[data-theme="dark"] .fc .fc-col-header-cell-cushion,
html[data-theme="dark"] .fc .fc-daygrid-day-number,
html[data-theme="dark"] .fc .fc-list-day-text,
html[data-theme="dark"] .fc .fc-list-day-side-text,
html[data-theme="dark"] .fc .fc-list-event-time,
html[data-theme="dark"] .fc .fc-list-event-title {
  color: #e5e7eb !important;
}

html[data-theme="dark"] .fc .fc-daygrid-day.fc-day-today {
  background: rgba(59,130,246,0.12) !important;
}

html[data-theme="dark"] .fc .fc-list,
html[data-theme="dark"] .fc .fc-list-table,
html[data-theme="dark"] .fc .fc-scrollgrid,
html[data-theme="dark"] .fc-theme-standard .fc-list-day-cushion {
  background: transparent !important;
}

html[data-theme="dark"] .modal-backdrop {
  background: rgba(2, 6, 23, 0.7);
}

.modal-backdrop[hidden] {
  display: none !important;
}

html[data-theme="dark"] .fc-theme-standard .fc-list-day-cushion,
html[data-theme="dark"] .fc .fc-list-table tr.fc-list-day > th {
  background: #1e293b !important;
  color: #e5e7eb !important;
}

html[data-theme="dark"] .fc .fc-list-day-cushion a,
html[data-theme="dark"] .fc .fc-list-day-text,
html[data-theme="dark"] .fc .fc-list-day-side-text {
  color: #e5e7eb !important;
}

html[data-theme="dark"] .fc .fc-list-event:hover td,
html[data-theme="dark"] .fc .fc-list-event.fc-event-forced-url:hover a {
  background: #172033 !important;
  color: #ffffff !important;
}

html[data-theme="dark"] .fc .fc-list-event:hover .fc-list-event-time,
html[data-theme="dark"] .fc .fc-list-event:hover .fc-list-event-title,
html[data-theme="dark"] .fc .fc-list-event:hover .fc-list-event-title a {
  color: #ffffff !important;
}

html[data-theme="dark"] .fc .fc-popover {
  background: #0f172a !important;
  border-color: #334155 !important;
  color: #e5e7eb !important;
}

html[data-theme="dark"] .fc .fc-popover-header {
  background: #1e293b !important;
  color: #e5e7eb !important;
}

html[data-theme="dark"] .fc .fc-more-popover .fc-popover-body {
  background: #0f172a !important;
}
