/* ── Fonts ───────────────────────────────────────────── */
@font-face {
  font-family: 'AF Neue Berlin';
  src: url('/fonts/AFNeueBerlin-Regular.otf') format('opentype');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'AF Neue Berlin';
  src: url('/fonts/AFNeueBerlin-Medium.otf') format('opentype');
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'AF Neue Berlin';
  src: url('/fonts/AFNeueBerlin-SemiBold.otf') format('opentype');
  font-weight: 600;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'AF Neue Berlin';
  src: url('/fonts/AFNeueBerlin-Bold.otf') format('opentype');
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

/* ── Tokens ──────────────────────────────────────────── */
:root {
  --bg-primary: #0a0a0f;
  --bg-card: #12121a;
  --bg-card-hover: #1a1a25;
  --bg-input: #1a1a25;
  --border: #1e1e2e;
  --border-hover: #2e2e42;
  --text-primary: #e4e4e7;
  --text-secondary: #71717a;
  --text-muted: #52525b;
  --accent: #6366f1;
  --accent-hover: #818cf8;
  --accent-dim: rgba(99, 102, 241, 0.15);
  --green: #22c55e;
  --green-dim: rgba(34, 197, 94, 0.15);
  --red: #ef4444;
  --red-dim: rgba(239, 68, 68, 0.15);
  --yellow: #eab308;
  --yellow-dim: rgba(234, 179, 8, 0.15);
  --radius: 12px;
  --radius-sm: 8px;
  --font: 'IBM Plex Mono', monospace;
  --font-display: 'AF Neue Berlin', sans-serif;
}

/* ── Reset ───────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  background: var(--bg-primary);
  color: var(--text-primary);
  font-family: var(--font);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); }

/* ── Buttons ─────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  border: none;
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
}
.btn-primary:hover { background: var(--accent-hover); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border);
}
.btn-ghost:hover {
  color: var(--text-primary);
  border-color: var(--border-hover);
  background: var(--bg-card);
}

.btn-close {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 24px;
  cursor: pointer;
  padding: 4px 8px;
  line-height: 1;
  border-radius: var(--radius-sm);
}
.btn-close:hover { color: var(--text-primary); background: var(--bg-card-hover); }

/* ── Screens ─────────────────────────────────────────── */
.screen {
  min-height: 100vh;
  animation: fadeIn 0.4s ease;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* ── Login ───────────────────────────────────────────── */
.screen-login {
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-primary);
}

.login-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 48px 40px;
  width: 100%;
  max-width: 400px;
  text-align: center;
  animation: scaleIn 0.5s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes scaleIn {
  from { opacity: 0; transform: scale(0.92) translateY(10px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

.login-logo { margin-bottom: 24px; }

.login-card h1 {
  font-family: var(--font-display);
  font-size: 24px;
  font-weight: 700;
  margin-bottom: 32px;
}

.login-subtitle {
  color: var(--text-secondary);
  font-size: 14px;
  margin-bottom: 32px;
}

.login-card input[type="text"],
.login-card input[type="password"] {
  width: 100%;
  padding: 12px 16px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: var(--font);
  font-size: 14px;
  margin-bottom: 12px;
  outline: none;
  transition: border-color 0.15s;
}
.login-card input[type="text"]:focus,
.login-card input[type="password"]:focus {
  border-color: var(--accent);
}

.login-card .btn-primary {
  width: 100%;
  justify-content: center;
  padding: 12px;
  font-size: 15px;
}

.login-hint {
  color: var(--text-muted);
  font-size: 12px;
  margin-top: 12px;
}

.error {
  color: var(--red);
  font-size: 13px;
  margin-top: 16px;
}

.icon-fp { flex-shrink: 0; }

/* ── Dashboard Header ────────────────────────────────── */
.dash-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 32px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-card);
  position: sticky;
  top: 0;
  z-index: 100;
}

.dash-header-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.dash-header-left h1 {
  font-family: var(--font-display);
  font-size: 17px;
  font-weight: 600;
}

.dash-header-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ── Dashboard Main ──────────────────────────────────── */
.dash-main {
  display: flex;
  min-height: calc(100vh - 73px);
}

/* ── Sites Grid ──────────────────────────────────────── */
.sites-grid {
  flex: 1;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
  padding: 24px 32px;
  align-content: start;
}

.site-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  cursor: pointer;
  position: relative;
  transition: border-color 0.3s ease, box-shadow 0.3s ease, transform 0.3s ease;
  animation: cardIn 0.4s cubic-bezier(0.16, 1, 0.3, 1) backwards;
  will-change: transform;
  display: flex;
  flex-direction: column;
  min-height: 220px;
  --text-secondary: rgba(255, 255, 255, 0.5);
  --text-muted: rgba(255, 255, 255, 0.3);
  --border: rgba(255, 255, 255, 0.08);
  --border-hover: rgba(255, 255, 255, 0.2);
}


.site-card:nth-child(1) { animation-delay: 0s; }
.site-card:nth-child(2) { animation-delay: 0.05s; }
.site-card:nth-child(3) { animation-delay: 0.1s; }
.site-card:nth-child(4) { animation-delay: 0.15s; }
.site-card:nth-child(5) { animation-delay: 0.2s; }
.site-card:nth-child(6) { animation-delay: 0.25s; }

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

.site-card::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0);
  transition: background 0.3s ease;
  pointer-events: none;
}

.site-card:hover {
  border-color: var(--border-hover);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.35);
  transform: translateY(-2px);
}

.site-card:hover::after {
  background: rgba(255, 255, 255, 0.04);
}

.site-card:active {
  box-shadow: none;
  transition-duration: 0.1s;
}

.site-card.drag-ready {
  animation: pulse 0.3s ease;
}

@keyframes pulse {
  0% { transform: scale(1); }
  50% { transform: scale(1.02); }
  100% { transform: scale(1); }
}

.site-card.dragging {
  opacity: 0.85;
  transform: scale(1.04);
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.5);
  z-index: 10;
  cursor: grabbing;
  transition: opacity 0.2s, box-shadow 0.2s;
}

.site-card.drag-over {
  border-color: var(--accent);
  background: var(--bg-card-hover);
  transform: scale(0.97);
  transition: transform 0.2s ease, border-color 0.2s ease;
}

/* ── New Card Layout ─────────────────────────────────── */
.card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.card-status-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.card-sep {
  color: var(--text-muted);
  font-size: 12px;
}

.card-center {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.site-name-large {
  font-family: 'AF Neue Berlin', sans-serif;
  font-size: 42px;
  font-weight: 500;
  line-height: 1.05;
}

.site-name-large::after {
  content: '→';
  margin-left: 12px;
  opacity: 0;
  transform: translateX(-6px);
  display: inline-block;
  transition: opacity 0.3s ease, transform 0.3s ease;
}

.site-card:hover .site-name-large::after {
  opacity: 1;
  transform: translateX(0);
}

.card-tech-icons {
  display: flex;
  align-items: center;
  gap: 10px;
}

.tech-sep {
  display: inline-block;
  width: 1px;
  height: 12px;
  background: rgba(255, 255, 255, 0.25);
  align-self: center;
}

.tech-icon-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.tech-icon-wrap::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0, 0, 0, 0.85);
  color: #fff;
  font-size: 11px;
  font-family: var(--font);
  padding: 3px 8px;
  border-radius: 5px;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s ease;
}

.tech-icon-wrap:hover::after {
  opacity: 1;
}

.tech-icon-flat {
  width: 16px;
  height: 16px;
  object-fit: contain;
  opacity: 0.85;
}

.card-url-bar {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: var(--radius-sm);
  margin-top: auto;
  cursor: pointer;
  transition: border-color 0.2s;
  background: rgba(255, 255, 255, 0.06);
  backdrop-filter: blur(20px) saturate(140%);
  -webkit-backdrop-filter: blur(20px) saturate(140%);
  overflow: hidden;
}

.card-url-bar::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(
    135deg,
    transparent 0%,
    rgba(255, 255, 255, 0.02) 40%,
    rgba(255, 255, 255, 0.13) 100%
  );
  background-size: 200% 200%;
  background-position: 0% 0%;
  pointer-events: none;
  border-radius: inherit;
  transition: background-position 0.3s ease, filter 0.3s ease;
}

.card-url-bar:hover::before {
  background-position: 100% 100%;
  filter: brightness(2.5);
}

.card-url-icon {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

.card-url-icon img {
  width: 16px;
  height: 16px;
  object-fit: contain;
  border-radius: 3px;
}

.card-url-text {
  flex: 1;
  font-size: 13px;
  color: var(--text-secondary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  transition: color 0.3s ease;
}

.card-url-bar:hover .card-url-text { color: #ffffff; }

.card-url-arrow {
  color: var(--text-muted);
  font-size: 15px;
  flex-shrink: 0;
  transition: transform 0.3s ease, color 0.3s ease;
}

.card-url-bar:hover .card-url-arrow {
  color: #ffffff;
  transform: translateX(5px);
}

.site-favicon {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  object-fit: contain;
  background: rgba(255, 255, 255, 0.08);
  padding: 4px;
  flex-shrink: 0;
}

.site-favicon-fallback {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.08);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  flex-shrink: 0;
}

.site-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.status-indicator {
  display: flex;
  align-items: center;
  gap: 8px;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.status-dot.up { background: var(--green); box-shadow: 0 0 8px var(--green); }
.status-dot.down { background: var(--red); box-shadow: 0 0 8px var(--red); }
.status-dot.unknown { background: var(--text-muted); }

.status-label {
  font-size: 12px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.status-label.up { color: var(--green); }
.status-label.down { color: var(--red); }
.status-label.unknown { color: var(--text-muted); }

.response-time {
  font-size: 12px;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

.site-title-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 4px;
}

.site-name {
  font-size: 16px;
  font-weight: 600;
}

.site-url {
  font-size: 13px;
  color: var(--text-secondary);
  display: block;
  margin-bottom: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.site-url:hover { color: var(--accent); }

.site-badges {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.badge {
  display: inline-block;
  padding: 3px 8px;
  font-size: 11px;
  font-weight: 500;
  border-radius: 6px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.brand-icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  transition: transform 0.15s ease;
}

.brand-icon:hover {
  transform: scale(1.2);
}

.badge-cat {
  background: var(--yellow-dim);
  color: var(--yellow);
}

.site-checked {
  font-size: 11px;
  color: var(--text-muted);
}

/* ── Detail Panel ────────────────────────────────────── */
.site-detail {
  display: flex;
  width: 480px;
  min-width: 480px;
  background: var(--bg-card);
  border-left: 1px solid var(--border);
  padding: 24px;
  flex-direction: column;
  gap: 24px;
  overflow-y: auto;
  position: fixed;
  right: 0;
  top: 73px;
  bottom: 0;
  z-index: 50;
  transform: translateX(100%);
  opacity: 0;
  pointer-events: none;
  transition: transform 0.35s cubic-bezier(0.16, 1, 0.3, 1),
              opacity 0.25s ease;
}

.site-detail.open {
  transform: translateX(0);
  opacity: 1;
  pointer-events: auto;
}

.detail-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
}

.detail-header h2 {
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 600;
  margin-bottom: 4px;
}

.detail-url {
  font-size: 13px;
  color: var(--text-secondary);
}
.detail-url:hover { color: var(--accent); }

.detail-period select {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: var(--font);
  font-size: 13px;
  padding: 8px 12px;
  outline: none;
  cursor: pointer;
}
.detail-period select:focus { border-color: var(--accent); }

.stat-card {
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 16px;
  text-align: center;
  animation: fadeUp 0.4s cubic-bezier(0.16, 1, 0.3, 1) both;
}

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

.stat-value {
  display: block;
  font-size: 24px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  margin-bottom: 4px;
}

.stat-label {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* ── Stats Row ───────────────────────────────────────── */
.stats-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

.stat-card--alert .stat-value { color: var(--red); }

/* ── Web Vitals ──────────────────────────────────────── */
.vitals-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
}

.vital-card {
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px;
  text-align: center;
}

.vital-value {
  display: block;
  font-size: 18px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  margin-bottom: 4px;
}

.vital-label {
  font-size: 10px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.top-label--error {
  color: var(--red);
  opacity: 0.85;
}

/* ── Chart ───────────────────────────────────────────── */
.chart-section h3,
.top-block h3 {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 12px;
}

.chart-bars {
  display: flex;
  align-items: flex-end;
  gap: 4px;
  height: 120px;
  padding: 0;
}

.bar-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  height: 100%;
  justify-content: flex-end;
}

.bar {
  width: 100%;
  min-width: 8px;
  background: var(--accent);
  border-radius: 4px 4px 0 0;
  transition: height 0.3s ease;
}

.bar-value {
  font-size: 10px;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

.bar-label {
  font-size: 9px;
  color: var(--text-muted);
  white-space: nowrap;
}

.chart-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: var(--text-muted);
  font-size: 13px;
}

/* ── Top Lists ───────────────────────────────────────── */
.top-section {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.top-list {
  list-style: none;
}

.top-list li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}

.top-list li:last-child { border-bottom: none; }

.top-label {
  color: var(--text-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 70%;
}

.top-count {
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
  font-weight: 500;
}

.top-list li.empty {
  color: var(--text-muted);
  justify-content: center;
  border: none;
}

/* ── Spinner ─────────────────────────────────────────── */
.spinner {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

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

/* ── Responsive ──────────────────────────────────────── */
@media (max-width: 960px) {
  .dash-main { flex-direction: column; }

  .site-detail {
    width: 100%;
    min-width: 0;
    border-left: none;
    border-top: 1px solid var(--border);
    top: 0;
    bottom: 0;
  }

  .sites-grid {
    grid-template-columns: 1fr;
    padding: 16px;
  }

  .dash-header { padding: 16px; }
}

@media (max-width: 480px) {
  .login-card { padding: 32px 24px; margin: 16px; }
  .stats-row { grid-template-columns: 1fr; }
}
