/* ShieldReplay — light design system (system fonts — no external CDN) */

:root {
  color-scheme: light;
  --font-sans: system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --font-mono: ui-monospace, 'Cascadia Code', 'SF Mono', 'Segoe UI Mono', Consolas, monospace;

  --bg: #f4f6fb;
  --bg-subtle: #eef1f8;
  --surface: #ffffff;
  --surface-raised: #ffffff;
  --surface-dim: #e8ecf4;
  --surface-inset: #f8fafc;

  --text: #0f172a;
  --text-secondary: #334155;
  --muted: #64748b;
  --line: #e2e8f0;
  --line-strong: #cbd5e1;

  --accent: #4f46e5;
  --accent-hover: #4338ca;
  --accent-soft: #eef2ff;
  --accent-muted: #c7d2fe;

  --danger: #dc2626;
  --danger-soft: #fef2f2;
  --danger-border: #fecaca;

  --warn: #d97706;
  --warn-soft: #fffbeb;
  --warn-border: #fde68a;

  --success: #059669;
  --success-soft: #ecfdf5;
  --success-border: #a7f3d0;

  --purple: #7c3aed;
  --purple-soft: #f5f3ff;

  --shadow-xs: 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow-sm: 0 1px 3px rgba(15, 23, 42, 0.06), 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow-md: 0 4px 12px rgba(15, 23, 42, 0.08);
  --shadow-lg: 0 12px 32px rgba(15, 23, 42, 0.1);

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-full: 999px;

  --sidebar-width: 252px;

  --sidebar-surface: #12141c;
  --glass-bg: rgba(255, 255, 255, 0.72);
  --glass-border: rgba(226, 232, 240, 0.85);

  --focus-ring: 0 0 0 3px var(--accent-soft);

  /* Player-matched shell aliases (used across admin, WAF, automations, replay) */
  --shell-bg: var(--bg);
  --shell-elevated: var(--surface-inset);
  --shell-panel: var(--surface);
  --shell-border: var(--line);
  --shell-border-strong: var(--line-strong);
  --shell-text: var(--text);
  --shell-text-secondary: var(--text-secondary);
  --shell-muted: var(--muted);
  --shell-hover: var(--bg-subtle);
  --shell-active: var(--accent-soft);
  --shell-accent: var(--accent);
  --header-height: 48px;
}

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

body {
  margin: 0;
  font-family: var(--font-sans);
  background: var(--shell-bg);
  color: var(--shell-text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-feature-settings: 'kern' 1, 'liga' 1;
  letter-spacing: -0.011em;
}

body::before {
  display: none;
}

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

code {
  font-family: var(--font-mono);
  font-size: 0.85em;
  background: var(--surface-inset);
  padding: 2px 6px;
  border-radius: 4px;
  border: 1px solid var(--line);
}

/* ── Buttons ── */
.btn, button.primary-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 7px 12px;
  font-family: inherit;
  font-size: 0.78rem;
  font-weight: 600;
  border: none;
  border-radius: var(--radius-sm);
  background: var(--shell-accent);
  color: #fff;
  cursor: pointer;
  text-decoration: none;
  box-shadow: none;
  transition: background 0.12s, opacity 0.12s;
}
.btn:hover, button.primary-btn:hover {
  background: var(--accent-hover);
}
.btn:active { transform: scale(0.98); }

.btn.secondary, button.secondary {
  background: var(--shell-panel);
  color: var(--shell-text-secondary);
  border: 1px solid var(--shell-border);
  box-shadow: none;
}
.btn.secondary:hover, button.secondary:hover {
  background: var(--shell-hover);
  border-color: var(--shell-border-strong);
  color: var(--shell-text);
}

.btn.ghost {
  background: transparent;
  border: none;
  box-shadow: none;
  color: var(--muted);
}
.btn.ghost:hover { background: var(--bg-subtle); color: var(--text); }

.btn.sm {
  padding: 6px 11px;
  font-size: 0.78rem;
  border-radius: var(--radius-sm);
}

.btn.ghost.sm {
  padding: 6px 11px;
  font-size: 0.78rem;
}

.watch-btn.is-disabled {
  opacity: 0.45;
  cursor: not-allowed;
  pointer-events: none;
}

/* ── Badges ── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 9px;
  border-radius: var(--radius-full);
  font-size: 0.7rem;
  font-weight: 600;
  border: 1px solid var(--line);
  background: var(--surface-inset);
  color: var(--text-secondary);
  margin-right: 4px;
  white-space: nowrap;
}
.badge.replay { color: var(--success); background: var(--success-soft); border-color: var(--success-border); }
.badge.no-replay { color: var(--muted); }
.badge.incident { color: var(--danger); background: var(--danger-soft); border-color: var(--danger-border); }
.badge.rage { color: var(--warn); background: var(--warn-soft); border-color: var(--warn-border); }
.badge.dead { color: var(--purple); background: var(--purple-soft); border-color: #ddd6fe; }
.badge.probe { color: var(--purple); background: var(--purple-soft); border-color: #ddd6fe; }
.badge.friction-high { color: var(--danger); background: var(--danger-soft); border-color: var(--danger-border); }
.badge.friction-mid { color: var(--warn); background: var(--warn-soft); border-color: var(--warn-border); }
.badge.friction-low { color: var(--success); background: var(--success-soft); border-color: var(--success-border); }
.badge.status-open { color: var(--danger); background: var(--danger-soft); border-color: var(--danger-border); }
.badge.status-acknowledged { color: var(--warn); background: var(--warn-soft); border-color: var(--warn-border); }
.badge.status-resolved { color: var(--success); background: var(--success-soft); border-color: var(--success-border); }
.badge.trend-worse { color: var(--danger); background: var(--danger-soft); border-color: var(--danger-border); }
.badge.trend-better { color: var(--success); background: var(--success-soft); border-color: var(--success-border); }
.badge.trend-stable { color: var(--muted); }

.pill {
  display: inline-block;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  font-size: 0.72rem;
  font-weight: 600;
  background: var(--accent-soft);
  color: var(--accent);
}

/* ── Cards & panels (player-style flat surfaces) ── */
.card, .panel {
  background: var(--shell-panel);
  border: 1px solid var(--shell-border);
  border-radius: var(--radius-sm);
  box-shadow: none;
}
.panel { padding: 14px; margin-bottom: 12px; }
.panel h2 {
  margin: 0 0 4px;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--shell-text);
}
.panel p { margin: 0; color: var(--shell-muted); font-size: 0.72rem; line-height: 1.45; }

/* Shared page patterns */
.sr-panel {
  background: var(--shell-panel);
  border: 1px solid var(--shell-border);
  border-radius: var(--radius-sm);
  padding: 14px;
  margin-bottom: 12px;
  box-shadow: none;
}

.sr-panel-head {
  margin-bottom: 12px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--shell-border);
}

.sr-panel-head h2,
.sr-panel-head h3 {
  margin: 0 0 3px;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--shell-text);
}

.sr-panel-head p {
  margin: 0;
  font-size: 0.72rem;
  color: var(--shell-muted);
  line-height: 1.45;
}

.sr-hero {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
  margin-bottom: 14px;
  padding: 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--shell-border);
  background: var(--shell-panel);
  box-shadow: none;
}

.sr-hero-text h2 {
  margin: 0 0 4px;
  font-size: 0.84rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--shell-text);
}

.sr-hero-text p {
  margin: 0;
  font-size: 0.72rem;
  color: var(--shell-muted);
  line-height: 1.45;
  max-width: 560px;
}

.sr-stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.sr-stat-card {
  padding: 10px 12px;
  border: 1px solid var(--shell-border);
  border-radius: var(--radius-sm);
  background: var(--shell-panel);
  min-width: 0;
}

.sr-stat-label {
  display: block;
  font-size: 0.64rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--shell-muted);
  margin-bottom: 4px;
}

.sr-stat-value {
  display: block;
  font-size: 0.88rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--shell-text);
}

.sr-status-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--shell-border);
  background: var(--shell-panel);
  font-size: 0.76rem;
  color: var(--shell-text-secondary);
  line-height: 1.45;
}

.sr-status-banner::before {
  content: '';
  flex-shrink: 0;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--shell-muted);
}

.sr-status-banner.is-on::before { background: var(--success); box-shadow: 0 0 0 3px var(--success-soft); }
.sr-status-banner.is-off::before { background: var(--warn); box-shadow: 0 0 0 3px var(--warn-soft); }
.sr-status-banner.is-saved::before { background: var(--shell-accent); box-shadow: 0 0 0 3px var(--shell-active); }
.sr-status-banner.is-error::before { background: var(--danger); box-shadow: 0 0 0 3px var(--danger-soft); }

/* Global form fields */
input:not([type='checkbox']):not([type='radio']):not([type='range']):not([type='color']),
textarea {
  font-family: inherit;
  font-size: 0.78rem;
  color: var(--shell-text);
  background: var(--shell-panel);
  border: 1px solid var(--shell-border);
  border-radius: var(--radius-sm);
  transition: border-color 0.12s, box-shadow 0.12s;
}

input:not([type='checkbox']):not([type='radio']):not([type='range']):focus,
textarea:focus {
  outline: none;
  border-color: var(--accent-muted);
  box-shadow: var(--focus-ring);
}

textarea {
  padding: 12px 14px;
  line-height: 1.5;
  resize: vertical;
}

/* Scrollbars (webkit) */
* {
  scrollbar-width: thin;
  scrollbar-color: var(--line-strong) transparent;
}
*::-webkit-scrollbar { width: 8px; height: 8px; }
*::-webkit-scrollbar-thumb {
  background: var(--line-strong);
  border-radius: var(--radius-full);
}
*::-webkit-scrollbar-thumb:hover { background: var(--muted); }

/* ── Skeleton ── */
.skeleton {
  position: relative;
  overflow: hidden;
  background: var(--surface-dim);
  border-radius: var(--radius-sm);
  min-height: 18px;
}
.skeleton::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.6), transparent);
  animation: shimmer 1.2s infinite;
}
@keyframes shimmer {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(100%); }
}

@keyframes livePulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.5; transform: scale(0.85); }
}

.empty, .loading, .error-box {
  text-align: center;
  padding: 48px 20px;
  color: var(--muted);
}
.error-box { color: var(--danger); }

/* ── Select / dropdown ── */
:root {
  --select-chevron: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2.25' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  --select-chevron-accent: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%234f46e5' stroke-width='2.25' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
}

select.sr-select,
select:not([multiple]):not([size]) {
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  display: inline-block;
  min-height: 38px;
  padding: 8px 36px 8px 12px;
  font-family: inherit;
  font-size: 0.875rem;
  font-weight: 500;
  line-height: 1.35;
  color: var(--text);
  background-color: var(--surface);
  background-image: var(--select-chevron);
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-xs);
  cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s, background-color 0.15s;
}

select.sr-select:hover:not(:disabled),
select:not([multiple]):not([size]):hover:not(:disabled) {
  border-color: var(--line-strong);
  background-color: var(--surface-inset);
}

select.sr-select:focus,
select:not([multiple]):not([size]):focus {
  outline: none;
  border-color: var(--accent-muted);
  box-shadow: 0 0 0 3px var(--accent-soft);
  background-image: var(--select-chevron-accent);
}

select.sr-select:disabled,
select:not([multiple]):not([size]):disabled {
  opacity: 0.55;
  cursor: not-allowed;
  background-color: var(--surface-inset);
}

.sr-select-field {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.sr-select-label {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  white-space: nowrap;
}

.sr-select-field--toolbar select,
.site-select-wrap select {
  min-width: 148px;
  font-weight: 600;
  border-radius: var(--radius-full);
  padding-left: 14px;
  padding-right: 34px;
  background-color: var(--surface-inset);
}

.sr-select-field--toolbar select:focus,
.site-select-wrap select:focus {
  background-color: var(--surface);
}

.sr-select-compact {
  min-height: 32px !important;
  padding: 5px 30px 5px 10px !important;
  font-size: 0.8rem !important;
  background-position: right 8px center !important;
}
