/* ══════════════════════════════════════════════════
   Jejo.ai Mission Control — Design System (design-26)
   GitHub-inspired component CSS
   ══════════════════════════════════════════════════ */

:root {
  --color-bg: #f6f8fa;
  --color-white: #ffffff;
  --color-border: #d1d9e0;
  --color-border-muted: #e8ecf0;
  --color-nav-bg: #24292f;
  --color-nav-text: #ffffff;
  --color-text: #1f2328;
  --color-text-secondary: #656d76;
  --color-text-tertiary: #8b949e;
  --color-link: #0969da;
  --color-green: #1a7f37;
  --color-green-bg: #dafbe1;
  --color-red: #cf222e;
  --color-red-bg: #ffebe9;
  --color-yellow: #9a6700;
  --color-yellow-bg: #fff8c5;
  --color-blue: #0969da;
  --color-blue-bg: #ddf4ff;
  --color-purple: #8250df;
  --color-purple-bg: #fbefff;
  --color-tab-active: #fd8c73;
  --font-stack: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans", Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji";
  --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  --radius: 6px;
  --shadow-sm: 0 1px 0 rgba(27,31,36,0.04);
  --shadow-md: 0 3px 6px rgba(140,149,159,0.15);
}

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

body {
  font-family: var(--font-stack);
  background: var(--color-bg);
  color: var(--color-text);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* ── Top Nav ── */

.top-nav {
  background: var(--color-nav-bg);
  height: 48px;
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 24px;
  position: sticky;
  top: 0;
  z-index: 100;
}

.nav-logo {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--color-nav-text);
  font-weight: 600;
  font-size: 16px;
  text-decoration: none;
  flex-shrink: 0;
}

.nav-logo svg {
  width: 28px;
  height: 28px;
  fill: var(--color-nav-text);
}

.nav-links {
  display: flex;
  gap: 4px;
  list-style: none;
}

.nav-links a {
  color: rgba(255,255,255,0.7);
  text-decoration: none;
  padding: 6px 12px;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 500;
  transition: background 0.15s, color 0.15s;
}

.nav-links a:hover {
  background: rgba(255,255,255,0.1);
  color: var(--color-nav-text);
}

.nav-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 16px;
}

.nav-server {
  font-size: 12px;
  color: rgba(255,255,255,0.5);
  font-family: var(--font-mono);
}

.nav-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: #6e7781;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}

/* ── Tab Bar ── */

.tab-bar {
  background: var(--color-white);
  border-bottom: 1px solid var(--color-border);
  padding: 0 24px;
  display: flex;
  gap: 0;
  overflow-x: auto;
}

.tab-item {
  padding: 12px 16px;
  font-size: 14px;
  font-weight: 500;
  color: var(--color-text-secondary);
  text-decoration: none;
  border-bottom: 2px solid transparent;
  white-space: nowrap;
  transition: color 0.15s, border-color 0.15s;
  display: flex;
  align-items: center;
  gap: 6px;
}

.tab-item:hover {
  color: var(--color-text);
  border-bottom-color: var(--color-border-muted);
}

.tab-item.active {
  color: var(--color-text);
  border-bottom-color: var(--color-tab-active);
  font-weight: 600;
}

.tab-count {
  background: rgba(175,184,193,0.2);
  color: var(--color-text-secondary);
  font-size: 12px;
  font-weight: 600;
  padding: 0 6px;
  border-radius: 10px;
  min-width: 20px;
  text-align: center;
  line-height: 20px;
}

.tab-item.active .tab-count {
  background: rgba(9,105,218,0.1);
  color: var(--color-blue);
}

/* ── Main Content ── */

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

/* ── Page Header ── */

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

.page-title {
  font-size: 20px;
  font-weight: 600;
  color: var(--color-text);
}

.page-subtitle {
  font-size: 14px;
  color: var(--color-text-secondary);
  margin-top: 2px;
}

/* ── Buttons ── */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 16px;
  font-size: 14px;
  font-weight: 500;
  font-family: var(--font-stack);
  border-radius: var(--radius);
  border: 1px solid rgba(27,31,36,0.15);
  cursor: pointer;
  text-decoration: none;
  transition: background 0.15s;
  line-height: 20px;
}

.btn-primary {
  background: var(--color-green);
  color: #fff;
  border-color: rgba(27,31,36,0.15);
}

.btn-primary:hover { background: #15803d; }

.btn-default {
  background: var(--color-bg);
  color: var(--color-text);
}

.btn-default:hover { background: #e8ecf0; }

.btn-danger {
  background: var(--color-red);
  color: #fff;
  border-color: rgba(27,31,36,0.15);
}

.btn-danger:hover { background: #a40e26; }

/* ── Metric Cards ── */

.metrics-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 20px;
}

.metric-card {
  background: var(--color-white);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow-sm);
}

.metric-label {
  font-size: 12px;
  font-weight: 500;
  color: var(--color-text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 4px;
}

.metric-value {
  font-size: 28px;
  font-weight: 600;
  color: var(--color-text);
  line-height: 1.2;
}

.metric-detail {
  font-size: 12px;
  color: var(--color-text-tertiary);
  margin-top: 4px;
}

.metric-value .metric-unit {
  font-size: 14px;
  font-weight: 500;
  color: var(--color-text-secondary);
}

.metric-trend-up {
  color: var(--color-green);
  font-size: 12px;
  font-weight: 500;
}

.metric-trend-neutral {
  color: var(--color-text-tertiary);
  font-size: 12px;
  font-weight: 500;
}

/* ── Tables ── */

.table-container {
  background: var(--color-white);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 20px;
  box-shadow: var(--shadow-sm);
}

.table-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--color-border);
  background: var(--color-bg);
}

.table-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--color-text);
  display: flex;
  align-items: center;
  gap: 8px;
}

.table-title .count-badge {
  background: rgba(175,184,193,0.2);
  color: var(--color-text-secondary);
  font-size: 12px;
  font-weight: 600;
  padding: 0 6px;
  border-radius: 10px;
  line-height: 20px;
}

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

.search-input {
  padding: 4px 12px;
  font-size: 13px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  background: var(--color-white);
  color: var(--color-text);
  font-family: var(--font-stack);
  width: 240px;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.search-input:focus {
  border-color: var(--color-blue);
  box-shadow: 0 0 0 3px rgba(9,105,218,0.12);
}

.search-input::placeholder { color: var(--color-text-tertiary); }

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

thead th {
  text-align: left;
  padding: 8px 16px;
  font-size: 12px;
  font-weight: 600;
  color: var(--color-text-secondary);
  background: var(--color-bg);
  border-bottom: 1px solid var(--color-border);
  white-space: nowrap;
  user-select: none;
}

thead th.sortable {
  cursor: pointer;
}

thead th.sortable:hover {
  color: var(--color-text);
}

tbody tr {
  border-bottom: 1px solid var(--color-border-muted);
}

tbody tr:nth-child(even) {
  background: var(--color-bg);
}

tbody tr:hover {
  background: #eef1f5;
}

tbody td {
  padding: 10px 16px;
  vertical-align: middle;
  white-space: nowrap;
}

/* ── Badges / Labels ── */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 500;
  line-height: 18px;
  white-space: nowrap;
}

.badge-green {
  background: var(--color-green-bg);
  color: var(--color-green);
}

.badge-red {
  background: var(--color-red-bg);
  color: var(--color-red);
}

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

.badge-blue {
  background: var(--color-blue-bg);
  color: var(--color-blue);
}

.badge-purple {
  background: var(--color-purple-bg);
  color: var(--color-purple);
}

.badge-muted {
  background: rgba(175,184,193,0.2);
  color: var(--color-text-secondary);
}

.badge-outline {
  background: transparent;
  border: 1px solid var(--color-border);
  color: var(--color-text-secondary);
  padding: 1px 7px;
}

/* ── Status Dots ── */

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

.status-dot-green { background: var(--color-green); }
.status-dot-red { background: var(--color-red); }
.status-dot-yellow { background: #d4a72c; }

/* ── Label Pills ── */

.label-pill {
  display: inline-flex;
  padding: 0 7px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 500;
  line-height: 20px;
  border: 1px solid transparent;
  margin-right: 4px;
  margin-bottom: 2px;
}

.label-browser {
  background: #ddf4ff;
  color: #0969da;
  border-color: rgba(9,105,218,0.2);
}

.label-email {
  background: #fbefff;
  color: #8250df;
  border-color: rgba(130,80,223,0.2);
}

.label-qmd {
  background: #dafbe1;
  color: #1a7f37;
  border-color: rgba(26,127,55,0.2);
}

.label-sales {
  background: #fff8c5;
  color: #9a6700;
  border-color: rgba(154,103,0,0.2);
}

.label-support {
  background: #ffebe9;
  color: #cf222e;
  border-color: rgba(207,34,46,0.2);
}

/* ── Text Helpers ── */

.client-name {
  font-weight: 600;
  color: var(--color-link);
  text-decoration: none;
}

.client-name:hover { text-decoration: underline; }

.agent-name {
  font-weight: 500;
  color: var(--color-text);
}

.url-link {
  color: var(--color-text-tertiary);
  font-family: var(--font-mono);
  font-size: 12px;
  text-decoration: none;
}

.url-link:hover {
  color: var(--color-link);
  text-decoration: underline;
}

.mono {
  font-family: var(--font-mono);
  font-size: 12px;
}

/* ── Two-Column Layout ── */

.two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 20px;
}

/* ── Cards ── */

.card {
  background: var(--color-white);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.card-header {
  padding: 12px 16px;
  border-bottom: 1px solid var(--color-border);
  background: var(--color-bg);
  font-size: 14px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
}

.card-body {
  padding: 0;
}

.card-body-padded {
  padding: 16px;
}

/* ── Key-Value Table ── */

.kv-table {
  width: 100%;
}

.kv-table tr {
  border-bottom: 1px solid var(--color-border-muted);
}

.kv-table tr:last-child {
  border-bottom: none;
}

.kv-table td {
  padding: 8px 16px;
  font-size: 13px;
  vertical-align: middle;
}

.kv-table td:first-child {
  color: var(--color-text-secondary);
  font-weight: 500;
  width: 140px;
  white-space: nowrap;
}

.kv-table td:last-child {
  color: var(--color-text);
}

/* ── Progress Bar ── */

.progress-bar {
  width: 100%;
  height: 8px;
  background: var(--color-border-muted);
  border-radius: 4px;
  overflow: hidden;
  display: inline-block;
}

.progress-fill {
  height: 100%;
  border-radius: 4px;
  transition: width 0.3s;
}

.progress-fill-green { background: var(--color-green); }
.progress-fill-blue { background: var(--color-blue); }
.progress-fill-yellow { background: #d4a72c; }
.progress-fill-red { background: var(--color-red); }

.progress-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.progress-row .progress-bar {
  flex: 1;
  max-width: 120px;
}

.progress-value {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--color-text);
  min-width: 36px;
  text-align: right;
}

/* ── Activity Feed ── */

.activity-feed {
  list-style: none;
}

.activity-item {
  display: flex;
  gap: 12px;
  padding: 10px 16px;
  font-size: 13px;
  border-bottom: 1px solid var(--color-border-muted);
  position: relative;
}

.activity-item:last-child {
  border-bottom: none;
}

.activity-dot-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  flex-shrink: 0;
  padding-top: 4px;
  position: relative;
}

.activity-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  border: 2px solid var(--color-border);
  background: var(--color-white);
  z-index: 1;
  flex-shrink: 0;
}

.activity-dot-green {
  border-color: var(--color-green);
  background: var(--color-green-bg);
}

.activity-dot-red {
  border-color: var(--color-red);
  background: var(--color-red-bg);
}

.activity-dot-blue {
  border-color: var(--color-blue);
  background: var(--color-blue-bg);
}

.activity-dot-yellow {
  border-color: #d4a72c;
  background: var(--color-yellow-bg);
}

.activity-line {
  width: 2px;
  flex: 1;
  background: var(--color-border-muted);
  margin-top: 4px;
}

.activity-content {
  flex: 1;
  min-width: 0;
}

.activity-text {
  color: var(--color-text);
  line-height: 1.4;
}

.activity-text strong {
  font-weight: 600;
}

.activity-time {
  color: var(--color-text-tertiary);
  font-size: 12px;
  margin-top: 2px;
}

/* ── Backup Rows ── */

.backup-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  border-bottom: 1px solid var(--color-border-muted);
}

.backup-row:last-child { border-bottom: none; }

.backup-info {
  display: flex;
  align-items: center;
  gap: 10px;
}

.backup-name {
  font-weight: 500;
  font-size: 13px;
}

.backup-time {
  font-size: 12px;
  color: var(--color-text-tertiary);
  font-family: var(--font-mono);
}

/* ── Modal ── */

.modal-backdrop {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(27,31,36,0.5);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal {
  background: var(--color-white);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  width: 480px;
  max-width: 90vw;
  max-height: 85vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--color-border);
  background: var(--color-bg);
}

.modal-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--color-text);
}

.modal-close {
  background: none;
  border: none;
  font-size: 18px;
  color: var(--color-text-secondary);
  cursor: pointer;
  padding: 4px;
  line-height: 1;
  border-radius: var(--radius);
  transition: background 0.15s;
}

.modal-close:hover {
  background: rgba(175,184,193,0.2);
  color: var(--color-text);
}

.modal-body {
  padding: 16px;
  overflow-y: auto;
  font-size: 14px;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 12px 16px;
  border-top: 1px solid var(--color-border);
  background: var(--color-bg);
}

/* ── Footer ── */

.footer {
  text-align: center;
  padding: 24px;
  font-size: 12px;
  color: var(--color-text-tertiary);
  border-top: 1px solid var(--color-border);
  margin-top: 16px;
}

.footer a {
  color: var(--color-link);
  text-decoration: none;
}

.footer a:hover { text-decoration: underline; }

/* ── Responsive ── */

@media (max-width: 900px) {
  .metrics-row { grid-template-columns: repeat(2, 1fr); }
  .two-col { grid-template-columns: 1fr; }
}

@media (max-width: 600px) {
  .metrics-row { grid-template-columns: 1fr; }
  .top-nav { padding: 0 12px; }
  .main { padding: 16px; }
  .nav-links { display: none; }
  table { font-size: 12px; }
  thead th, tbody td { padding: 8px 10px; }
}
