/* ===================================================
   OAKTRACK
   Fonts: Bricolage Grotesque (display) + Manrope (body) + JetBrains Mono (code)
   Layout: Collapsible left sidebar + main content
   =================================================== */

@import url('https://fonts.googleapis.com/css2?family=Bricolage+Grotesque:opsz,wght@12..96,300;12..96,500;12..96,700&family=JetBrains+Mono:wght@400;500&family=Manrope:wght@300;400;500;600;700&display=swap');

/* --- Theme: Dark (default) --- */
:root {
  --bg: #09090b;
  --bg-subtle: #0f0f11;
  --surface: #141416;
  --surface-2: #1c1c1f;
  --surface-hover: #242428;
  --border: #232328;
  --border-strong: #333338;
  --text: #fafafa;
  --text-secondary: #a1a1aa;
  --muted: #63636e;
  --accent: #3b82f6;
  --accent-hover: #60a5fa;
  --accent-glow: rgba(59, 130, 246, 0.20);
  --accent-subtle: rgba(59, 130, 246, 0.08);
  --shadow: 0 16px 64px rgba(0, 0, 0, 0.5);
  --shadow-sm: 0 2px 12px rgba(0, 0, 0, 0.3);
  --success: #34d399;
  --success-bg: rgba(52, 211, 153, 0.08);
  --warning: #fbbf24;
  --warning-bg: rgba(251, 191, 36, 0.08);
  --error: #f87171;
  --error-bg: rgba(248, 113, 113, 0.08);
  --delta-drop: #34d399;
  --delta-rise: #f87171;
  --sidebar-w: 64px;
  --sidebar-w-open: 228px;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-pill: 999px;
  --font-display: 'Bricolage Grotesque', system-ui, sans-serif;
  --font-body: 'Manrope', system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
  --ease: cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

/* --- Theme: Light --- */
[data-theme="light"] {
  --bg: #fafafa;
  --bg-subtle: #f4f4f5;
  --surface: #ffffff;
  --surface-2: #f4f4f5;
  --surface-hover: #e4e4e7;
  --border: #e4e4e7;
  --border-strong: #d4d4d8;
  --text: #09090b;
  --text-secondary: #52525b;
  --muted: #a1a1aa;
  --accent: #2563eb;
  --accent-hover: #3b82f6;
  --accent-glow: rgba(37, 99, 235, 0.15);
  --accent-subtle: rgba(37, 99, 235, 0.06);
  --shadow: 0 16px 64px rgba(0, 0, 0, 0.06);
  --shadow-sm: 0 2px 12px rgba(0, 0, 0, 0.04);
  --success: #059669;
  --success-bg: rgba(5, 150, 105, 0.06);
  --warning: #d97706;
  --warning-bg: rgba(217, 119, 6, 0.06);
  --error: #dc2626;
  --error-bg: rgba(220, 38, 38, 0.06);
  --delta-drop: #059669;
  --delta-rise: #dc2626;
}

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

html {
  scrollbar-gutter: stable;
}

body {
  margin: 0;
  color: var(--text);
  font-family: var(--font-body);
  font-weight: 400;
  font-size: 0.875rem;
  line-height: 1.6;
  background: var(--bg);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--accent);
  text-decoration: none;
  transition: color 150ms var(--ease);
}
a:hover { color: var(--accent-hover); }

h1, h2, h3, h4 {
  font-family: var(--font-display);
  font-weight: 500;
  line-height: 1.25;
  margin: 0;
  letter-spacing: -0.02em;
}
h1 { font-size: 1.75rem; }
h2 { font-size: 1.4rem; }
h3 { font-size: 1.1rem; }

h1 a, h3 a { color: var(--text); }
h1 a:hover, h3 a:hover { color: var(--accent); }

p { margin: 0; }

/* ==============================
   SIDEBAR
   ============================== */

.app-layout {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: var(--sidebar-w);
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  z-index: 100;
  transition: width 250ms var(--ease);
  overflow: hidden;
}

.sidebar.is-open {
  width: var(--sidebar-w-open);
}

.sidebar-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1.15rem;
  min-height: 60px;
}

.sidebar-toggle {
  flex-shrink: 0;
  width: 34px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  background: transparent;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 0;
  transition: background 150ms var(--ease), color 150ms var(--ease);
}

.sidebar-toggle:hover {
  background: var(--surface-hover);
  color: var(--text);
  box-shadow: none;
  transform: none;
}

.sidebar-toggle svg {
  width: 18px;
  height: 18px;
}

.sidebar-logo {
  font-family: var(--font-display);
  font-size: 1.15rem;
  color: var(--text);
  white-space: nowrap;
  opacity: 0;
  transition: opacity 200ms var(--ease);
  text-decoration: none;
}

.sidebar-logo:hover { color: var(--text); }

.sidebar.is-open .sidebar-logo {
  opacity: 1;
}

.sidebar-nav {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 0.5rem 0.75rem;
}

.sidebar-bottom {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding: 0.75rem;
  border-top: 1px solid var(--border);
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.55rem 0.65rem;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 0.82rem;
  font-weight: 500;
  white-space: nowrap;
  text-decoration: none;
  transition: all 150ms var(--ease);
  cursor: pointer;
  background: none;
  border: none;
  font-family: var(--font-body);
  width: 100%;
  text-align: left;
}

.sidebar-link:hover {
  background: var(--surface-hover);
  color: var(--text);
  box-shadow: none;
  transform: none;
}

.sidebar-link svg {
  flex-shrink: 0;
  width: 18px;
  height: 18px;
  opacity: 0.7;
}

.sidebar-link:hover svg { opacity: 1; }

.sidebar-link span {
  overflow: hidden;
  opacity: 0;
  transition: opacity 200ms var(--ease);
}

.sidebar.is-open .sidebar-link span {
  opacity: 1;
}

.sidebar-link.active,
.sidebar-link.nav-active {
  background: var(--accent-subtle);
  color: var(--accent);
}

.sidebar-link.active svg,
.sidebar-link.nav-active svg { opacity: 1; }

/* New target CTA */
.sidebar-cta {
  background: var(--accent) !important;
  color: #fff !important;
  font-weight: 600;
  margin-top: 0.5rem;
  box-shadow: 0 0 0 0 var(--accent-glow);
  transition: all 200ms var(--ease);
}

.sidebar-cta:hover {
  background: var(--accent-hover) !important;
  box-shadow: 0 0 20px var(--accent-glow) !important;
  transform: none;
}

.sidebar-cta svg { opacity: 1 !important; }

.sidebar-user {
  font-size: 0.78rem;
  color: var(--muted);
  cursor: default;
  align-items: flex-start;
}

.sidebar-user:hover {
  background: transparent;
  color: var(--muted);
}

.sidebar-account,
.sidebar-user-actions {
  display: grid;
  gap: 0.35rem;
}

.sidebar-user-copy {
  display: grid;
  gap: 0.1rem;
  line-height: 1.3;
}

.sidebar-user-name {
  color: var(--text);
  font-weight: 600;
}

.sidebar-user-role {
  color: var(--muted);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.sidebar-logout-form {
  margin: 0;
}

.sidebar-link--danger {
  color: var(--error);
}

.sidebar-link--danger:hover {
  background: var(--error-bg);
  color: var(--error);
}

.sidebar-link--danger svg {
  opacity: 1;
}

/* ==============================
   MAIN CONTENT
   ============================== */

.main-wrap {
  flex: 1;
  margin-left: var(--sidebar-w);
  transition: margin-left 250ms var(--ease);
  min-width: 0;
}

.sidebar.is-open ~ .main-wrap {
  margin-left: var(--sidebar-w-open);
}

.main-content {
  max-width: 960px;
  margin: 0 auto;
  padding: 2rem 2rem 5rem;
}

/* --- Auth layout (no sidebar) --- */

.auth-layout {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 2rem;
}

.auth-panel {
  width: 100%;
  max-width: 400px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  padding: 2.5rem;
}

/* ==============================
   BUTTONS
   ============================== */

button,
.button-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--text);
  cursor: pointer;
  font-family: var(--font-body);
  font-weight: 500;
  font-size: 0.82rem;
  padding: 0.55rem 1rem;
  text-decoration: none;
  transition: all 150ms var(--ease);
}

button:hover,
.button-link:hover {
  background: var(--surface-hover);
  border-color: var(--border-strong);
  box-shadow: none;
  transform: none;
}

button:active,
.button-link:active {
  transform: scale(0.98);
}

.btn-primary,
.button-link.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.btn-primary:hover,
.button-link.primary:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
  box-shadow: 0 0 20px var(--accent-glow);
}

.button-link.ghost {
  background: transparent;
  border-color: var(--border);
  color: var(--text-secondary);
}

.button-link.ghost:hover {
  background: var(--surface-hover);
  color: var(--text);
  border-color: var(--border-strong);
}

.danger-button {
  color: var(--error);
  border-color: rgba(248, 113, 113, 0.35);
  background: transparent;
}

.danger-button:hover {
  background: var(--error-bg);
  color: var(--error);
  border-color: rgba(248, 113, 113, 0.5);
}

/* ==============================
   INPUTS
   ============================== */

input, select, textarea {
  width: 100%;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--bg-subtle);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 0.85rem;
  padding: 0.6rem 0.8rem;
  transition: border-color 150ms var(--ease), box-shadow 150ms var(--ease);
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 5 5-5' stroke='%2363636e' stroke-width='1.5' fill='none'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.8rem center;
  padding-right: 2.2rem;
}

input[type="checkbox"] {
  width: auto;
  accent-color: var(--accent);
}

/* ==============================
   PAGE HEADER (within main content)
   ============================== */

.page-title {
  margin-bottom: 2rem;
}

.page-title .eyebrow {
  margin-bottom: 0.35rem;
}

.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
  min-width: 0;
}

.section-heading > div {
  min-width: 0;
}

.button-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.view-switch {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.2rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg-subtle);
}

.view-switch-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 3.8rem;
  padding: 0.4rem 0.7rem;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 0.76rem;
  font-weight: 600;
}

.view-switch-link:hover {
  color: var(--text);
}

.view-switch-link--active {
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-sm);
}

/* ==============================
   BREADCRUMBS
   ============================== */

.breadcrumbs {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  margin-bottom: 1.5rem;
  font-size: 0.8rem;
  color: var(--muted);
}

.breadcrumbs a { color: var(--muted); }
.breadcrumbs a:hover { color: var(--accent); }
.breadcrumbs .sep { opacity: 0.35; }

/* ==============================
   PANELS
   ============================== */

.page-content {
  display: grid;
  gap: 1.25rem;
  min-width: 0;
}

.panel {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  padding: 1.5rem;
  min-width: 0;
}

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ==============================
   CARD GRID
   ============================== */

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 0.75rem;
}

.card-grid--list {
  grid-template-columns: 1fr;
}

.target-card {
  position: relative;
  display: block;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
  padding: 1.15rem;
  transition: all 200ms var(--ease);
  color: inherit;
  text-decoration: none;
}

.target-card-media {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 3.35rem;
  height: 3.35rem;
  border-radius: 1rem;
  overflow: hidden;
  margin-bottom: 0.95rem;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
}

.target-card-media--placeholder {
  font-family: var(--font-display);
  font-size: 1.1rem;
  color: var(--muted);
}

.target-card-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.target-card:hover {
  border-color: var(--border-strong);
  background: var(--surface-2);
}

.target-card:hover h3 {
  color: var(--accent);
}

.target-card:focus-visible {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.target-card--paused { opacity: 0.45; }

.target-card h3 { margin: 0.5rem 0 0.25rem; }

.card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.95rem;
}

.card-badge-stack {
  display: inline-flex;
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 0.35rem;
}

.card-main {
  display: grid;
  gap: 0.95rem;
}

.card-copy {
  min-width: 0;
}

.uptime-card-summary {
  display: grid;
  gap: 0.35rem;
  margin: 0.65rem 0;
}

.card-grid--list .target-card {
  padding: 1rem 1.15rem;
}

.card-grid--list .card-main {
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 1rem;
}

.card-grid--list .card-main > :only-child {
  grid-column: 1 / -1;
}

.card-grid--list .target-card-media {
  margin-bottom: 0;
}

.card-grid--list .card-footer {
  justify-content: flex-start;
  gap: 1rem;
}

.card-url {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.78rem;
  color: var(--muted);
  font-family: var(--font-mono);
}

.card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 0.75rem;
  padding-top: 0.6rem;
  border-top: 1px solid var(--border);
  font-size: 0.75rem;
  color: var(--muted);
}

.target-card--unread-warning {
  border-color: rgba(251, 191, 36, 0.45);
  background: linear-gradient(180deg, rgba(251, 191, 36, 0.13), rgba(251, 191, 36, 0.05));
}

.target-card--unread-warning:hover {
  border-color: rgba(251, 191, 36, 0.6);
  background: linear-gradient(180deg, rgba(251, 191, 36, 0.18), rgba(251, 191, 36, 0.07));
}

.target-card--unread-warning .card-footer {
  border-top-color: rgba(251, 191, 36, 0.24);
}

.target-card--unread-danger {
  border-color: rgba(248, 113, 113, 0.48);
  background: linear-gradient(180deg, rgba(248, 113, 113, 0.14), rgba(248, 113, 113, 0.05));
}

.target-card--unread-danger:hover {
  border-color: rgba(248, 113, 113, 0.62);
  background: linear-gradient(180deg, rgba(248, 113, 113, 0.2), rgba(248, 113, 113, 0.07));
}

.target-card--unread-danger .card-footer {
  border-top-color: rgba(248, 113, 113, 0.24);
}

/* ==============================
   BADGES & PILLS
   ============================== */

.mode-badge {
  font-family: var(--font-body);
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 0.15rem 0.5rem;
  border-radius: var(--radius-pill);
  border: 1px solid transparent;
}

.mode-content {
  background: var(--accent-subtle);
  color: var(--accent);
  border-color: rgba(59, 130, 246, 0.15);
}

.mode-price {
  background: var(--warning-bg);
  color: var(--warning);
  border-color: rgba(251, 191, 36, 0.15);
}

.mode-keyword {
  background: var(--success-bg);
  color: var(--success);
  border-color: rgba(52, 211, 153, 0.18);
}

.mode-uptime {
  background: rgba(45, 212, 191, 0.12);
  color: #2dd4bf;
  border-color: rgba(45, 212, 191, 0.22);
}

.mode-performance {
  background: rgba(249, 115, 22, 0.12);
  color: #fb923c;
  border-color: rgba(249, 115, 22, 0.22);
}

.mode-tls_endpoint {
  background: rgba(244, 114, 182, 0.12);
  color: #f472b6;
  border-color: rgba(244, 114, 182, 0.22);
}

.mode-tls_offline {
  background: rgba(148, 163, 184, 0.12);
  color: #cbd5e1;
  border-color: rgba(148, 163, 184, 0.22);
}

.paused-badge {
  font-size: 0.6rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  background: var(--surface-2);
  padding: 0.1rem 0.4rem;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border);
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  border-radius: var(--radius-pill);
  padding: 0.25rem 0.6rem;
  text-transform: uppercase;
  font-family: var(--font-body);
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.06em;
}

.status-pill::before {
  content: '';
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: currentColor;
}

.status-ok {
  background: var(--success-bg);
  color: var(--success);
}

.status-ok::before {
  box-shadow: 0 0 6px currentColor;
  animation: pulse 2.5s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

.status-changed {
  background: var(--warning-bg);
  color: var(--warning);
}

.status-failed {
  background: var(--error-bg);
  color: var(--error);
}

.status-pending {
  background: var(--surface-2);
  color: var(--muted);
}

/* ==============================
   DETAIL GRID
   ============================== */

.detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 0.5rem;
  margin: 0;
}

.detail-grid div {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg-subtle);
  padding: 0.85rem;
  min-width: 0;
}

.detail-grid dt {
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 0.3rem;
}

.detail-grid dd {
  margin: 0;
  font-size: 0.88rem;
  color: var(--text-secondary);
  min-width: 0;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.detail-grid dd a {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  word-break: break-all;
}

.detail-grid--stacked {
  grid-template-columns: 1fr;
}

.detail-grid--stacked dd {
  overflow-wrap: anywhere;
  word-break: break-word;
}

.target-heading {
  display: flex;
  align-items: center;
  gap: 1rem;
  min-width: 0;
}

.target-detail-icon {
  width: 4.5rem;
  height: 4.5rem;
  border-radius: 1.2rem;
  object-fit: cover;
  border: 1px solid var(--border);
  background: var(--bg-subtle);
  flex-shrink: 0;
}

.target-detail-icon--placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-size: 1.35rem;
  color: var(--muted);
}

.target-config-note {
  margin-top: 0.35rem;
}

/* ==============================
   FORMS
   ============================== */

.field {
  display: grid;
  gap: 0.35rem;
}

.field--hidden {
  display: none;
}

.field > span {
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--text-secondary);
}

.field-heading {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
}

.required-indicator {
  color: var(--error);
  font-weight: 700;
}

.field--required .field-heading::after,
.field:has(input[required], select[required], textarea[required]) .field-heading::after {
  content: "*";
  color: var(--error);
  font-weight: 700;
}

.field--invalid .field-heading,
.field--invalid .muted {
  color: var(--error);
}

.field:has(.errorlist) .field-heading,
.field:has(.errorlist) .muted {
  color: var(--error);
}

.field--invalid input,
.field--invalid select,
.field--invalid textarea,
.field--invalid .toggle-control {
  border-color: rgba(248, 113, 113, 0.5);
  box-shadow: 0 0 0 3px rgba(248, 113, 113, 0.08);
}

.field:has(.errorlist) input,
.field:has(.errorlist) select,
.field:has(.errorlist) textarea,
.field:has(.errorlist) .toggle-control {
  border-color: rgba(248, 113, 113, 0.5);
  box-shadow: 0 0 0 3px rgba(248, 113, 113, 0.08);
}

.field--managed {
  opacity: 0.78;
}

.field--managed input:disabled,
.field--managed select:disabled {
  color: var(--text-secondary);
  background: var(--surface-2);
  border-color: var(--border-strong);
  cursor: not-allowed;
  opacity: 1;
}

.config-managed-hint {
  display: none;
  color: var(--warning);
}

.field--managed .config-managed-hint {
  display: block;
}

.stacked-form {
  display: grid;
  gap: 0.85rem;
  margin-top: 1rem;
}

.form-group {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 1.15rem;
  margin: 0;
  display: grid;
  gap: 0.75rem;
  background: var(--bg-subtle);
  transition: opacity 250ms var(--ease), max-height 300ms var(--ease);
}

.form-group-legend {
  font-family: var(--font-display);
  font-size: 1.05rem;
  color: var(--text);
  padding: 0;
}

.form-group-hint {
  font-size: 0.75rem;
  margin: 0;
  color: var(--muted);
}

.config-summary {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
  padding: 0.95rem 1rem;
}

.config-summary-title {
  font-size: 0.76rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-secondary);
  margin-bottom: 0.75rem;
}

.config-summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 0.55rem;
  margin: 0;
}

.config-summary-grid div {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg-subtle);
  padding: 0.75rem;
}

.config-summary-grid dt {
  color: var(--muted);
  font-size: 0.66rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 0.3rem;
}

.config-summary-grid dd {
  margin: 0;
  color: var(--text-secondary);
  font-size: 0.8rem;
  word-break: break-word;
}

.mode-guidance {
  display: grid;
  gap: 0.45rem;
  padding: 0.95rem 1rem;
  border: 1px solid rgba(59, 130, 246, 0.22);
  border-radius: var(--radius-md);
  background: linear-gradient(180deg, rgba(59, 130, 246, 0.08), rgba(59, 130, 246, 0.03));
}

.mode-guidance-title {
  margin: 0;
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text);
}

.mode-guidance-list {
  margin: 0;
  padding-left: 1rem;
  color: var(--text-secondary);
  font-size: 0.8rem;
}

.mode-family-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 0.75rem;
}

.mode-family-card {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
  padding: 0.9rem 1rem;
}

.mode-family-card strong {
  display: block;
  margin-bottom: 0.35rem;
}

.selector-tester {
  display: grid;
  gap: 0.85rem;
  border: 1px solid rgba(59, 130, 246, 0.22);
  border-radius: var(--radius-md);
  background: linear-gradient(180deg, var(--surface), var(--bg-subtle));
  padding: 1rem;
}

.selector-tester-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.85rem;
}

.selector-tester-actions {
  flex-shrink: 0;
}

.selector-tester-inline-hint {
  display: grid;
  gap: 0.2rem;
  padding: 0.8rem 0.9rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: rgba(59, 130, 246, 0.06);
}

.selector-tester-status {
  min-height: 1.3rem;
  font-size: 0.8rem;
}

.selector-tester-status--muted {
  color: var(--muted);
}

.selector-tester-status--success {
  color: var(--success);
}

.selector-tester-status--error {
  color: var(--error);
}

.selector-tester-results {
  display: grid;
  gap: 0.7rem;
}

.selector-suggestion-card,
.selector-suggestion-empty {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
  padding: 0.9rem;
}

.selector-suggestion-title-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.7rem;
  margin-bottom: 0.45rem;
}

.selector-suggestion-selector {
  display: block;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--text);
  white-space: normal;
  word-break: break-word;
}

.selector-suggestion-rank {
  flex-shrink: 0;
  padding: 0.15rem 0.5rem;
  border-radius: var(--radius-pill);
  background: var(--accent-subtle);
  color: var(--accent);
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.08em;
}

.selector-suggestion-meta,
.selector-suggestion-preview,
.selector-suggestion-reason {
  margin: 0;
}

.selector-suggestion-meta {
  color: var(--muted);
  font-size: 0.75rem;
}

.selector-suggestion-preview {
  margin-top: 0.45rem;
  color: var(--text-secondary);
}

.selector-suggestion-reason {
  margin-top: 0.35rem;
  color: var(--warning);
  font-size: 0.78rem;
}

.selector-suggestion-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.75rem;
}

.selector-suggestion-managed {
  color: var(--muted);
  font-size: 0.76rem;
}

.inline-danger-form {
  margin-top: 0.75rem;
}

.toggle-field {
  gap: 0.55rem;
}

.toggle-control {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 0.8rem;
  width: 100%;
  max-width: 24rem;
  min-height: 3rem;
  padding: 0.7rem 0.85rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
  cursor: pointer;
  transition: border-color 160ms var(--ease), background 160ms var(--ease);
}

.toggle-control:hover {
  border-color: var(--border-strong);
  background: var(--surface-2);
}

.toggle-control--compact {
  max-width: none;
  min-height: 2.75rem;
  padding: 0.55rem 0.75rem;
}

.toggle-control input[type="checkbox"] {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
  margin: 0;
}

.toggle-switch {
  position: relative;
  width: 2.9rem;
  height: 1.65rem;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border-strong);
  background: var(--surface-2);
  transition: background 160ms var(--ease), border-color 160ms var(--ease), box-shadow 160ms var(--ease);
}

.toggle-switch::after {
  content: "";
  position: absolute;
  top: 0.16rem;
  left: 0.16rem;
  width: 1.15rem;
  height: 1.15rem;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
  transition: transform 160ms var(--ease);
}

.toggle-control input[type="checkbox"]:focus-visible + .toggle-switch {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.toggle-control input[type="checkbox"]:checked + .toggle-switch {
  background: var(--accent);
  border-color: var(--accent);
}

.toggle-control input[type="checkbox"]:checked + .toggle-switch::after {
  transform: translateX(1.24rem);
}

.toggle-copy {
  display: inline-flex;
  gap: 0.4rem;
  font-size: 0.82rem;
  color: var(--muted);
  font-weight: 600;
}

.toggle-copy-on {
  display: none;
}

.toggle-control input[type="checkbox"]:checked + .toggle-switch + .toggle-copy .toggle-copy-on {
  display: inline;
  color: var(--text);
}

.toggle-control input[type="checkbox"]:checked + .toggle-switch + .toggle-copy .toggle-copy-off {
  display: none;
}

.threshold-row {
  display: grid;
  gap: 0.9rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 1rem;
  background: var(--surface);
}

.threshold-value-field {
  transition: opacity 160ms var(--ease);
}

.threshold-value-field.is-disabled {
  opacity: 0.55;
}

.threshold-toggle .toggle-control {
  max-width: none;
}

.form-group--hidden {
  opacity: 0.25;
  pointer-events: none;
  max-height: 3.5rem;
  overflow: hidden;
}

.field.form-group--hidden {
  display: none;
}

.bulk-category-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: end;
}

.field--compact {
  min-width: 12rem;
}

.category-chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1.35rem;
}

.category-chip {
  display: inline-flex;
  align-items: center;
  padding: 0.35rem 0.75rem;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-secondary);
  font-size: 0.75rem;
}

.category-chip--active {
  background: var(--accent-subtle);
  border-color: rgba(59, 130, 246, 0.35);
  color: var(--accent);
}

.bulk-category-form {
  display: grid;
  gap: 1rem;
}

.card-grid--editable {
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
}

.target-card--selectable {
  cursor: default;
}

.target-card-select {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.76rem;
  color: var(--text-secondary);
  margin-bottom: 0.85rem;
}

.target-card-select input {
  accent-color: var(--accent);
}

.channel-switch-list {
  display: grid;
  gap: 0.55rem;
}

.channel-switch-row {
  display: block;
}

.channel-switch-form {
  display: grid;
  gap: 0.35rem;
}

.channel-switch-control {
  max-width: none;
}

.channel-switch-list--detail {
  margin-top: 1rem;
}

.channel-switch-copy {
  color: var(--text);
  font-size: 0.82rem;
  font-weight: 600;
}

.channel-route-copy {
  flex-direction: column;
  align-items: flex-start;
  gap: 0.1rem;
}

.channel-route-meta {
  margin-left: 3.75rem;
}

.empty-state--inline {
  padding: 0;
  border: none;
  background: transparent;
}

.button-link--tiny {
  padding: 0.35rem 0.65rem;
  font-size: 0.72rem;
}

.detail-grid--summary {
  margin-top: 1rem;
}

.chart-container--double {
  min-height: 20rem;
}

.inline-delete-form {
  margin-top: 1rem;
}

.detail-inline-toggle-form {
  margin: 0;
}

.detail-inline-toggle-form.is-pending,
.channel-switch-form.is-pending {
  opacity: 0.72;
}

/* ==============================
   MESSAGES
   ============================== */

.message-list {
  list-style: none;
  margin: 0 0 1rem;
  padding: 0;
  display: grid;
  gap: 0.4rem;
}

.message-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  border-radius: var(--radius-sm);
  padding: 0.65rem 0.9rem;
  font-size: 0.82rem;
  animation: fadeUp 300ms var(--ease) both;
  transition: opacity 250ms var(--ease), transform 250ms var(--ease);
}

.message-success {
  background: var(--success-bg);
  color: var(--success);
  border: 1px solid rgba(52, 211, 153, 0.12);
}

.message-error {
  background: var(--error-bg);
  color: var(--error);
  border: 1px solid rgba(248, 113, 113, 0.12);
}

.message-warning {
  background: var(--warning-bg);
  color: var(--warning);
  border: 1px solid rgba(251, 191, 36, 0.12);
}

.message-info, .message-debug {
  background: var(--accent-subtle);
  color: var(--accent);
  border: 1px solid rgba(59, 130, 246, 0.12);
}

.message-dismiss {
  background: transparent;
  border: none;
  color: inherit;
  font-size: 1.1rem;
  cursor: pointer;
  padding: 0;
  opacity: 0.5;
  line-height: 1;
  box-shadow: none;
  transition: opacity 150ms;
}

.message-dismiss:hover {
  opacity: 1;
  box-shadow: none;
  background: transparent;
  transform: none;
}

/* ==============================
   TYPOGRAPHY UTILITIES
   ============================== */

.eyebrow {
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 0.65rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent);
  margin: 0 0 0.4rem;
}

.meta-row {
  color: var(--muted);
  font-size: 0.78rem;
}

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

/* ==============================
   HISTORY
   ============================== */

.history-list {
  display: grid;
  gap: 0.5rem;
}

.history-card {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg-subtle);
  padding: 0.85rem 1rem;
  transition: border-color 150ms var(--ease);
  min-width: 0;
  overflow: hidden;
}

.history-card:hover {
  border-color: var(--border-strong);
}

.history-card .section-heading { margin-bottom: 0.35rem; }
.history-card .muted,
.history-card .meta-row { font-size: 0.78rem; }

.config-card-actions {
  margin-top: 0.85rem;
  padding-top: 0.85rem;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
}

/* ==============================
   TABLES
   ============================== */

.table-shell, .chart-shell {
  overflow-x: auto;
  margin-top: 0.75rem;
}

.chart-container {
  position: relative;
  width: 100%;
  max-width: 100%;
  height: 280px;
  margin-top: 0.75rem;
  min-width: 0;
}

.chart-container canvas {
  display: block;
  max-width: 100%;
  border-radius: var(--radius-md);
}

/* Fallback static chart */
.chart-image {
  width: 100%;
  min-width: 420px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg-subtle);
}

.capture-preview {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
  background: var(--bg-subtle);
  max-width: 100%;
  min-width: 0;
}

.capture-image {
  display: block;
  width: 100%;
  max-width: 100%;
  height: auto;
}

.failure-panel {
  border-color: rgba(248, 113, 113, 0.35);
}

.failure-message {
  margin-top: 0.75rem;
  padding: 0.9rem 1rem;
  border-radius: var(--radius-md);
  border: 1px solid rgba(248, 113, 113, 0.28);
  background: rgba(248, 113, 113, 0.08);
  color: var(--text-secondary);
  line-height: 1.55;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.failure-message--inline {
  margin-top: 0.55rem;
  padding: 0.7rem 0.85rem;
  font-size: 0.8rem;
}

.heartbeat-block {
  display: grid;
  gap: 0.65rem;
  margin-top: 1rem;
}

.heartbeat-block-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.uptime-heartbeat-strip,
.uptime-heartbeat-row-cells {
  display: grid;
  grid-template-columns: repeat(24, minmax(0, 1fr));
  gap: 0.2rem;
}

.uptime-heartbeat-strip--card {
  margin-top: 0.1rem;
}

.uptime-heartbeat-grid {
  display: grid;
  gap: 0.25rem;
  overflow-x: auto;
}

.uptime-heartbeat-row {
  display: grid;
  grid-template-columns: 4.5rem minmax(18rem, 1fr);
  gap: 0.55rem;
  align-items: center;
}

.uptime-heartbeat-label {
  color: var(--muted);
  font-size: 0.75rem;
  font-family: var(--font-mono);
}

.uptime-heartbeat-cell {
  display: block;
  width: 100%;
  min-height: 0.75rem;
  border-radius: 0.35rem;
  background: var(--surface-2);
  border: 1px solid transparent;
}

.uptime-heartbeat-cell--success {
  background: rgba(52, 211, 153, 0.7);
}

.uptime-heartbeat-cell--warning {
  background: rgba(251, 191, 36, 0.72);
}

.uptime-heartbeat-cell--danger {
  background: rgba(248, 113, 113, 0.78);
}

.history-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
}

.history-table th, .history-table td {
  border-bottom: 1px solid var(--border);
  padding: 0.7rem 0.6rem;
  text-align: left;
}

.history-table th {
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.history-table tbody tr {
  transition: background 150ms var(--ease);
}

.history-table tbody tr:hover {
  background: var(--surface-hover);
}

/* ==============================
   DELTA COLORS
   ============================== */

.delta-drop {
  color: var(--delta-drop);
  font-weight: 600;
  font-family: var(--font-mono);
  font-size: 0.85rem;
}

.delta-rise {
  color: var(--delta-rise);
  font-weight: 600;
  font-family: var(--font-mono);
  font-size: 0.85rem;
}

/* ==============================
   DIFF VIEWER
   ============================== */

.diff-block {
  overflow-x: auto;
  border-radius: var(--radius-md);
  background: #09090b;
  border: 1px solid var(--border);
  padding: 0.35rem 0;
  margin-top: 0.75rem;
}

[data-theme="light"] .diff-block {
  background: #1e1e1e;
}

.diff-line {
  padding: 0.15rem 0.85rem;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  white-space: pre-wrap;
  word-break: break-all;
  color: var(--text-secondary);
  line-height: 1.7;
  border-left: 3px solid transparent;
}

.diff-add {
  background: rgba(52, 211, 153, 0.06);
  color: #34d399;
  border-left-color: #34d399;
}

.diff-del {
  background: rgba(248, 113, 113, 0.06);
  color: #f87171;
  border-left-color: #f87171;
}

.diff-hunk {
  color: var(--muted);
  font-style: italic;
  padding-top: 0.5rem;
}

.diff-meta {
  color: var(--muted);
  opacity: 0.5;
}

/* ==============================
   EMPTY STATES
   ============================== */

.empty-state {
  margin: 1rem 0;
  padding: 2rem 1.25rem;
  text-align: center;
  color: var(--muted);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-md);
  font-size: 0.85rem;
}

/* ==============================
   SPINNER
   ============================== */

.spinner {
  display: inline-block;
  width: 13px;
  height: 13px;
  border: 2px solid var(--border-strong);
  border-top-color: var(--text);
  border-radius: 50%;
  animation: spin 0.5s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ==============================
   RESPONSIVE
   ============================== */

@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
    width: var(--sidebar-w-open) !important;
    box-shadow: var(--shadow);
  }

  .sidebar.is-open {
    transform: translateX(0);
  }

  .main-wrap {
    margin-left: 0 !important;
  }

  .mobile-toggle {
    display: flex !important;
  }

  .sidebar-overlay {
    display: block !important;
  }

  .section-heading,
  .button-row {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.5rem;
  }

  .card-grid { grid-template-columns: 1fr; }
  .detail-grid { grid-template-columns: 1fr; }
  .uptime-heartbeat-row { grid-template-columns: 1fr; }
  .uptime-heartbeat-label { margin-bottom: 0.15rem; }

  .panel {
    border-radius: var(--radius-md);
    padding: 1rem;
  }

  .main-content {
    padding: 1rem 1rem 3rem;
  }

  .diff-line { font-size: 0.72rem; }
  .chart-image { min-width: 100%; }
}

.mobile-toggle {
  display: none;
  position: fixed;
  top: 0.85rem;
  left: 0.85rem;
  z-index: 99;
  width: 36px;
  height: 36px;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  padding: 0;
  cursor: pointer;
}

.mobile-toggle svg {
  width: 18px;
  height: 18px;
}

.mobile-toggle:hover {
  box-shadow: none;
  transform: none;
}

.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 99;
  opacity: 0;
  transition: opacity 200ms;
}

.sidebar-overlay.is-visible {
  opacity: 1;
}

@media (max-width: 480px) {
  .main-content { padding: 0.75rem 0.75rem 2rem; }
  h1 { font-size: 1.4rem; }
  h2 { font-size: 1.15rem; }
}
