* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --bg: #0f1117;
  --surface: #1a1d27;
  --border: #2a2d3a;
  --text: #e4e4e7;
  --text-dim: #8b8d98;
  --accent: #3b82f6;
  --green: #22c55e;
  --red: #ef4444;
  --amber: #f59e0b;
  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --mono: 'SF Mono', 'Cascadia Code', 'Consolas', monospace;
}

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

header {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px 24px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}

header h1 {
  font-size: 16px;
  font-weight: 600;
  white-space: nowrap;
}

nav { display: flex; gap: 4px; flex: 1; }

.nav-btn {
  background: none;
  border: none;
  color: var(--text-dim);
  font: inherit;
  font-size: 13px;
  padding: 6px 12px;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s;
}

.nav-btn:hover { color: var(--text); background: rgba(255,255,255,0.05); }
.nav-btn.active { color: var(--accent); background: rgba(59,130,246,0.1); }

#notification-bell {
  position: relative;
  cursor: pointer;
  padding: 6px;
  font-size: 18px;
}
#notification-bell::before { content: '\1F514'; }
#notification-count {
  position: absolute;
  top: 0; right: 0;
  background: var(--red);
  color: #fff;
  font-size: 10px;
  padding: 1px 5px;
  border-radius: 10px;
  min-width: 16px;
  text-align: center;
}

main { padding: 24px; max-width: 1400px; margin: 0 auto; }

.tab { display: none; }
.tab.active { display: block; }

.tab-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

h2 { font-size: 18px; font-weight: 600; margin-bottom: 16px; }
h3 { font-size: 14px; font-weight: 600; margin-bottom: 12px; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px;
  margin-bottom: 12px;
}

.btn {
  background: var(--accent);
  color: #fff;
  border: none;
  padding: 8px 16px;
  border-radius: 6px;
  font: inherit;
  font-size: 13px;
  cursor: pointer;
  transition: opacity 0.15s;
}
.btn:hover { opacity: 0.85; }
.btn-secondary { background: var(--border); color: var(--text); }
.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn-danger { background: var(--red); }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

th, td {
  text-align: left;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
}

th {
  font-weight: 600;
  color: var(--text-dim);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

tr:hover td { background: rgba(255,255,255,0.02); }

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
}
.badge-green { background: rgba(34,197,94,0.15); color: var(--green); }
.badge-red { background: rgba(239,68,68,0.15); color: var(--red); }
.badge-amber { background: rgba(245,158,11,0.15); color: var(--amber); }
.badge-blue { background: rgba(59,130,246,0.15); color: var(--accent); }

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px;
}

.stat-card .label {
  font-size: 11px;
  color: var(--text-dim);
  text-transform: uppercase;
  margin-bottom: 4px;
}

.stat-card .value {
  font-size: 24px;
  font-weight: 700;
  font-family: var(--mono);
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.form-grid label {
  display: flex;
  flex-direction: column;
  font-size: 12px;
  color: var(--text-dim);
  gap: 4px;
}

input, select {
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 8px 12px;
  border-radius: 6px;
  font: inherit;
  font-size: 13px;
}

input:focus, select:focus {
  outline: none;
  border-color: var(--accent);
}

.form-actions { display: flex; gap: 8px; }

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

.hidden { display: none !important; }

.settings-group {
  margin-bottom: 24px;
}

.settings-group h3 {
  text-transform: capitalize;
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}

.settings-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 8px;
}

.settings-row label {
  flex: 0 0 200px;
  font-size: 13px;
}

.settings-row input,
.settings-row select {
  flex: 1;
  max-width: 400px;
}

.settings-row .help {
  font-size: 11px;
  color: var(--text-dim);
}

#notification-panel {
  position: fixed;
  right: 16px;
  top: 60px;
  width: 360px;
  max-height: 400px;
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px;
  z-index: 200;
  box-shadow: 0 8px 32px rgba(0,0,0,0.4);
}

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

.notification-item {
  padding: 8px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}

.notification-item .time {
  font-size: 11px;
  color: var(--text-dim);
}

.score {
  font-family: var(--mono);
  font-weight: 700;
  font-size: 16px;
}

.score-high { color: var(--green); }
.score-mid { color: var(--amber); }
.score-low { color: var(--red); }

/* Test results */
.test-result {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-radius: 6px;
  margin-bottom: 4px;
  font-size: 13px;
  background: var(--surface);
  border: 1px solid var(--border);
}

.test-pass { border-left: 3px solid var(--green); }
.test-fail { border-left: 3px solid var(--red); }

.test-indicator {
  font-weight: 700;
  font-size: 16px;
  width: 20px;
  text-align: center;
}

.test-pass .test-indicator { color: var(--green); }
.test-fail .test-indicator { color: var(--red); }

.test-ms {
  margin-left: auto;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-dim);
}

/* Sync logs */
.sync-logs {
  background: #0d0f14;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 16px;
  margin-bottom: 16px;
  max-height: 300px;
  overflow-y: auto;
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1.6;
}

.log-line {
  white-space: pre-wrap;
  word-break: break-all;
}

.log-ts {
  color: var(--text-dim);
  margin-right: 8px;
}

.log-info { color: var(--text); }
.log-error { color: var(--red); }

/* Link icons in tables */
.links-cell { white-space: nowrap; }

.link-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 4px;
  font-size: 16px;
  text-decoration: none;
  color: var(--accent);
  background: rgba(59,130,246,0.08);
  transition: background 0.15s, color 0.15s;
}
.link-icon:hover { background: rgba(59,130,246,0.2); color: #fff; }
.link-external { color: var(--text-dim); background: rgba(255,255,255,0.04); }
.link-external:hover { color: var(--accent); background: rgba(59,130,246,0.15); }

/* xBid single page */
.xbid-header { margin-bottom: 16px; }
.xbid-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 12px 0 8px;
}

#version-footer {
  text-align: center;
  padding: 16px;
  font-size: 11px;
  color: var(--text-dim);
  font-family: var(--mono);
  opacity: 0.6;
}

@media (max-width: 768px) {
  header { flex-wrap: wrap; padding: 8px 12px; }
  nav { order: 3; width: 100%; overflow-x: auto; }
  main { padding: 12px; }
  .form-grid { grid-template-columns: 1fr; }
  .stat-grid { grid-template-columns: 1fr 1fr; }
}
