/* ── Custom Properties ─────────────────────────────────────── */
:root {
  --bg:          #0f1117;
  --surface:     #1a1d27;
  --card:        #1e2130;
  --border:      #2a2d3e;
  --border-light:#323650;
  --accent:      #6366f1;
  --accent-dim:  rgba(99,102,241,.15);
  --green:       #10b981;
  --red:         #ef4444;
  --amber:       #f59e0b;
  --blue:        #3b82f6;
  --text-1:      #e2e8f0;
  --text-2:      #94a3b8;
  --text-3:      #4a5568;
  --shadow:      0 4px 24px rgba(0,0,0,.35);
  --radius:      12px;
  --radius-sm:   8px;
  --transition:  .18s ease;
}

[data-theme="light"] {
  --bg:          #f1f5f9;
  --surface:     #e8edf5;
  --card:        #ffffff;
  --border:      #e2e8f0;
  --border-light:#cbd5e1;
  --accent:      #6366f1;
  --accent-dim:  rgba(99,102,241,.1);
  --text-1:      #0f172a;
  --text-2:      #475569;
  --text-3:      #94a3b8;
  --shadow:      0 4px 24px rgba(0,0,0,.08);
}

/* ── Reset ─────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-font-smoothing: antialiased; }
body {
  font-family: 'Inter', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text-1);
  min-height: 100vh;
  transition: background var(--transition), color var(--transition);
}
a { color: var(--accent); text-decoration: none; }
button { cursor: pointer; border: none; background: none; font-family: inherit; }
input, select { font-family: inherit; }

/* ── Header ────────────────────────────────────────────────── */
.header {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 32px;
  height: 64px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}
.header-left  { display: flex; align-items: center; gap: 12px; }
.header-right { display: flex; align-items: center; gap: 8px; }

.logo {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.header-title {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -.3px;
  color: var(--text-1);
  line-height: 1.2;
}
.header-subtitle {
  font-size: 11px;
  font-weight: 400;
  color: var(--text-2);
  text-transform: uppercase;
  letter-spacing: .6px;
}

.live-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 100px;
  background: var(--card);
  border: 1px solid var(--border);
  font-size: 12px;
  font-weight: 500;
  color: var(--text-2);
}
.live-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--text-3);
  flex-shrink: 0;
}
.live-badge.connected .live-dot {
  background: var(--green);
  box-shadow: 0 0 0 3px rgba(16,185,129,.2);
  animation: pulse 2s infinite;
}
.live-badge.connected { color: var(--text-1); }
.live-badge.error .live-dot { background: var(--red); }

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

.icon-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: var(--radius-sm);
  color: var(--text-2);
  transition: background var(--transition), color var(--transition);
}
.icon-btn:hover { background: var(--accent-dim); color: var(--accent); }
.icon-btn.spinning svg { animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Main ──────────────────────────────────────────────────── */
.main {
  max-width: 1280px;
  margin: 0 auto;
  padding: 32px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

/* ── Config Warning ─────────────────────────────────────────── */
.config-warning {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  background: rgba(245,158,11,.1);
  border: 1px solid rgba(245,158,11,.3);
  color: var(--amber);
  font-size: 13px;
  line-height: 1.5;
}
.config-warning code {
  background: rgba(245,158,11,.15);
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 12px;
}
.config-warning strong { font-weight: 600; }

/* ── Stats Grid ─────────────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
}

.stat-card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 20px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: border-color var(--transition), box-shadow var(--transition);
}
.stat-card:hover { border-color: var(--border-light); box-shadow: var(--shadow); }

.stat-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 10px;
  flex-shrink: 0;
}
.stat-icon--total   { background: rgba(99,102,241,.15); color: var(--accent); }
.stat-icon--bug     { background: rgba(239,68,68,.15);  color: var(--red); }
.stat-icon--feature { background: rgba(139,92,246,.15); color: #8b5cf6; }
.stat-icon--new     { background: rgba(245,158,11,.15); color: var(--amber); }

.stat-body { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.stat-label {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-2);
  text-transform: uppercase;
  letter-spacing: .5px;
}
.stat-value {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -1px;
  color: var(--text-1);
  line-height: 1;
}

/* ── Cards ─────────────────────────────────────────────────── */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px 0;
}
.card-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-1);
  letter-spacing: -.2px;
}

/* ── Charts Grid ─────────────────────────────────────────────── */
.charts-grid {
  display: grid;
  grid-template-columns: 300px 1fr;
  gap: 16px;
}

.chart-card--donut {
  display: flex;
  flex-direction: column;
  padding-bottom: 20px;
}
.donut-wrap {
  position: relative;
  padding: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.donut-wrap canvas { max-width: 200px; max-height: 200px; }
.donut-center {
  position: absolute;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}
.donut-total {
  font-size: 28px;
  font-weight: 700;
  color: var(--text-1);
  letter-spacing: -1px;
  line-height: 1;
}
.donut-label {
  font-size: 11px;
  color: var(--text-2);
  text-transform: uppercase;
  letter-spacing: .5px;
}
.donut-legend {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 0 24px;
}
.legend-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 13px;
}
.legend-left { display: flex; align-items: center; gap: 8px; color: var(--text-2); }
.legend-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.legend-count { font-weight: 600; color: var(--text-1); }
.legend-pct { font-size: 11px; color: var(--text-3); margin-left: 4px; }

.chart-card--line { padding-bottom: 20px; }
.line-wrap {
  padding: 20px 24px 4px;
  height: 260px;
}
.line-wrap canvas { width: 100% !important; height: 100% !important; }

.chart-range-btns {
  display: flex;
  gap: 4px;
}
.range-btn {
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-2);
  transition: background var(--transition), color var(--transition);
}
.range-btn:hover  { background: var(--accent-dim); color: var(--accent); }
.range-btn.active { background: var(--accent-dim); color: var(--accent); }

/* ── Table Section ──────────────────────────────────────────── */
.table-section { overflow: visible; }

.table-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
}
.table-controls {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.search-wrap { position: relative; }
.search-icon {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-3);
  pointer-events: none;
}
.search-input {
  width: 220px;
  padding: 7px 12px 7px 30px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-1);
  font-size: 13px;
  outline: none;
  transition: border-color var(--transition);
}
.search-input::placeholder { color: var(--text-3); }
.search-input:focus { border-color: var(--accent); }

.filter-chips { display: flex; gap: 4px; }
.chip {
  padding: 5px 12px;
  border-radius: 100px;
  font-size: 12px;
  font-weight: 500;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-2);
  transition: background var(--transition), color var(--transition), border-color var(--transition);
}
.chip:hover  { border-color: var(--accent); color: var(--accent); }
.chip.active { background: var(--accent-dim); border-color: var(--accent); color: var(--accent); }
.chip--bug.active    { background: rgba(239,68,68,.1); border-color: var(--red); color: var(--red); }
.chip--feature.active{ background: rgba(139,92,246,.1); border-color: #8b5cf6; color: #8b5cf6; }
.chip--other.active  { background: rgba(59,130,246,.1); border-color: var(--blue); color: var(--blue); }

.select-input {
  padding: 6px 28px 6px 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-1);
  font-size: 12px;
  outline: none;
  appearance: none;
  -webkit-appearance: none;
  cursor: pointer;
  transition: border-color var(--transition);
  background-image: url("data:image/svg+xml,%3Csvg width='10' height='6' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%2394a3b8' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
}
.select-input:focus { border-color: var(--accent); }

/* ── Skeleton ───────────────────────────────────────────────── */
.skeleton-wrap { display: flex; flex-direction: column; gap: 1px; }
.skeleton-row {
  height: 52px;
  background: linear-gradient(90deg, var(--surface) 25%, var(--border) 50%, var(--surface) 75%);
  background-size: 400% 100%;
  animation: shimmer 1.6s ease infinite;
  width: var(--w, 100%);
}
.skeleton-row:first-child { border-radius: 0; }
@keyframes shimmer { to { background-position: -400% 0; } }

/* ── Empty State ─────────────────────────────────────────────── */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 60px 20px;
  color: var(--text-3);
}
.empty-state p { font-size: 14px; color: var(--text-2); }
.btn-ghost {
  padding: 7px 16px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  color: var(--accent);
  background: var(--accent-dim);
  transition: opacity var(--transition);
}
.btn-ghost:hover { opacity: .8; }

/* ── Data Table ─────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.data-table thead th {
  padding: 10px 16px;
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-2);
  text-transform: uppercase;
  letter-spacing: .5px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  white-space: nowrap;
}
.data-table thead th.sortable { cursor: pointer; user-select: none; }
.data-table thead th.sortable:hover { color: var(--text-1); }
.sort-arrow { color: var(--accent); margin-left: 4px; font-size: 10px; }

.data-table tbody tr {
  border-bottom: 1px solid var(--border);
  transition: background var(--transition);
  cursor: pointer;
}
.data-table tbody tr:last-child { border-bottom: none; }
.data-table tbody tr:hover { background: var(--accent-dim); }

.data-table td { padding: 14px 16px; vertical-align: middle; }
.col-date    { width: 120px; }
.col-name    { width: 130px; }
.col-type    { width: 90px; }
.col-status  { width: 90px; }
.col-message { max-width: 0; }

.date-cell { color: var(--text-2); font-size: 12px; white-space: nowrap; }
.name-cell {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-1);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 130px;
}
.message-cell {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 400px;
  color: var(--text-1);
}
.no-value { color: var(--text-3); }

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border-radius: 100px;
  font-size: 11px;
  font-weight: 600;
  text-transform: capitalize;
  white-space: nowrap;
}
.badge--bug              { background: rgba(239,68,68,.15);  color: var(--red); }
.badge--feature          { background: rgba(139,92,246,.15); color: #8b5cf6; }
.badge--other            { background: rgba(59,130,246,.15); color: var(--blue); }
.badge--unknown          { background: var(--surface);       color: var(--text-2); }
.badge--status-new       { background: rgba(245,158,11,.15); color: var(--amber); }
.badge--status-reviewed  { background: rgba(59,130,246,.15); color: var(--blue); }
.badge--status-resolved  { background: rgba(16,185,129,.15); color: var(--green); }

/* ── Pagination ─────────────────────────────────────────────── */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 16px;
  border-top: 1px solid var(--border);
}
.page-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-2);
  transition: all var(--transition);
}
.page-btn:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); background: var(--accent-dim); }
.page-btn:disabled { opacity: .35; cursor: not-allowed; }
.page-info { font-size: 13px; color: var(--text-2); }

/* ── Modal ──────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.55);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: fade-in .15s ease;
}
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
.modal {
  background: var(--card);
  border: 1px solid var(--border-light);
  border-radius: 16px;
  width: 100%;
  max-width: 540px;
  box-shadow: 0 24px 64px rgba(0,0,0,.4);
  animation: slide-up .18s ease;
  overflow: hidden;
}
@keyframes slide-up { from { transform: translateY(12px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}
.modal-meta { display: flex; align-items: center; gap: 8px; }
.modal-details {
  padding: 16px 20px 0;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.detail-row { display: flex; flex-direction: column; gap: 2px; }
.detail-label { font-size: 10px; font-weight: 600; color: var(--text-3); text-transform: uppercase; letter-spacing: .5px; }
.detail-value { font-size: 13px; color: var(--text-1); word-break: break-all; }
.modal-message-wrap {
  margin: 16px 20px 20px;
  padding: 14px;
  background: var(--surface);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}
.modal-message-label {
  display: block;
  font-size: 10px;
  font-weight: 600;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: .5px;
  margin-bottom: 8px;
}
.modal-message {
  font-size: 14px;
  color: var(--text-1);
  line-height: 1.7;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 240px;
  overflow-y: auto;
}

/* ── Responsive ─────────────────────────────────────────────── */
@media (max-width: 900px) {
  .main { padding: 20px 16px; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .charts-grid { grid-template-columns: 1fr; }
  .chart-card--donut { flex-direction: row; align-items: center; }
  .donut-legend { padding-top: 24px; flex: 1; }
}
@media (max-width: 600px) {
  .header { padding: 0 16px; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .table-controls { flex-direction: column; align-items: flex-start; }
  .col-name, .col-status { display: none; }
  .search-input { width: 100%; }
  .modal-details { grid-template-columns: 1fr; }
}
@media (max-width: 420px) {
  .stats-grid { grid-template-columns: 1fr; }
}

/* ════════════════════════════════════════════════════════════
   Sign-in gate
   ════════════════════════════════════════════════════════════ */
.auth-gate {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: var(--bg, #0f172a);
}

/* Revealed only once auth state is known, to avoid a flash of the
   gate for an already-signed-in admin. */
.auth-gate[hidden],
.auth-gate.is-hidden { display: none !important; }

.auth-card {
  width: 100%;
  max-width: 360px;
  padding: 40px 32px;
  text-align: center;
  background: var(--surface, #1e293b);
  border: 1px solid var(--border, rgba(255, 255, 255, .08));
  border-radius: 16px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, .35);
}

.auth-title {
  margin: 18px 0 6px;
  font-size: 20px;
  font-weight: 600;
  color: var(--text, #f1f5f9);
}

.auth-subtitle {
  margin: 0 0 28px;
  font-size: 14px;
  line-height: 1.5;
  color: var(--text-muted, #94a3b8);
}

.auth-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  padding: 11px 18px;
  font-family: inherit;
  font-size: 14px;
  font-weight: 500;
  color: #1f2937;
  background: #fff;
  border: 1px solid rgba(0, 0, 0, .1);
  border-radius: 8px;
  cursor: pointer;
  transition: transform .12s ease, box-shadow .12s ease;
}

.auth-btn:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 6px 18px rgba(0, 0, 0, .25);
}

.auth-btn:disabled { opacity: .6; cursor: default; }

.auth-error {
  min-height: 18px;
  margin: 16px 0 0;
  font-size: 13px;
  line-height: 1.45;
  color: #ef4444;
}

/* ════════════════════════════════════════════════════════════
   Filtered-view caption
   ════════════════════════════════════════════════════════════ */
.stats-note {
  margin: -8px 0 20px;
  font-size: 12.5px;
  color: var(--text-muted, #94a3b8);
}

/* ════════════════════════════════════════════════════════════
   Modal status control
   ════════════════════════════════════════════════════════════ */
.modal-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-top: 22px;
  padding-top: 18px;
  border-top: 1px solid var(--border, rgba(255, 255, 255, .08));
}

.modal-actions-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--text-muted, #94a3b8);
}

.status-buttons { display: flex; gap: 6px; }

.status-btn {
  padding: 6px 13px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted, #94a3b8);
  background: transparent;
  border: 1px solid var(--border, rgba(255, 255, 255, .12));
  border-radius: 7px;
  cursor: pointer;
  transition: background .12s ease, color .12s ease, border-color .12s ease;
}

.status-btn:hover:not(:disabled):not(.is-active) {
  color: var(--text, #f1f5f9);
  border-color: var(--text-muted, #94a3b8);
}

.status-btn.is-active {
  color: #fff;
  background: #6366f1;
  border-color: #6366f1;
}

.status-btn:disabled { opacity: .55; cursor: default; }

.status-msg {
  margin-left: auto;
  font-size: 12.5px;
  color: var(--text-muted, #94a3b8);
}

.status-msg.is-error { color: #ef4444; }
