:root {
  --bg: #0d0d0f;
  --card: #1a1a1d;
  --card-border: #2a2a2e;
  --text: #f2f2f2;
  --muted: #9a9a9f;
  --accent: #4f8cff;
  --orange: #c98a2e;
  --orange-bg: #3a2c14;
  --green: #3fae6a;
  --red: #d1554a;
  --radius: 12px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

.hidden { display: none !important; }
.muted { color: var(--muted); margin: 4px 0 0; }
.small { font-size: 0.85rem; }
.error { color: var(--red); }

/* ---------- Login ---------- */

.login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.login-card {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  padding: 32px 24px;
  width: 100%;
  max-width: 360px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.login-card h1 { margin: 0; font-size: 1.6rem; }

.login-card input {
  background: #111113;
  border: 1px solid var(--card-border);
  color: var(--text);
  border-radius: 8px;
  padding: 12px 14px;
  font-size: 1rem;
}

/* ---------- Layout ---------- */

.app {
  max-width: 720px;
  margin: 0 auto;
  padding: 20px 16px 60px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 20px;
}

.topbar h1 { margin: 0; font-size: 1.6rem; }

.stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 20px;
}

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

.stat-value { font-size: 1.8rem; font-weight: 700; }
.stat-label { color: var(--muted); font-size: 0.85rem; margin-top: 4px; }

.tabs {
  display: flex;
  gap: 6px;
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  padding: 4px;
  margin-bottom: 20px;
  overflow-x: auto;
}

.tab-btn {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--muted);
  padding: 10px 8px;
  border-radius: 8px;
  font-size: 0.9rem;
  cursor: pointer;
  white-space: nowrap;
}

.tab-btn.active { background: #2a2a2e; color: var(--text); }

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

/* ---------- Cards ---------- */

.card-list { display: flex; flex-direction: column; gap: 10px; margin-bottom: 20px; }

.agent-card, .schedule-card {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  padding: 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  cursor: pointer;
}

.agent-card .name { font-weight: 600; }
.agent-card .kpi { color: var(--muted); font-size: 0.85rem; margin-top: 2px; }

.badge {
  font-size: 0.75rem;
  padding: 4px 10px;
  border-radius: 999px;
  white-space: nowrap;
}

.badge.probation { background: var(--orange-bg); color: var(--orange); }
.badge.active { background: #16331f; color: var(--green); }

/* ---------- Feedback ---------- */

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

.feedback-card h3 { margin: 0 0 10px; font-size: 1rem; }

textarea {
  width: 100%;
  min-height: 70px;
  background: #111113;
  border: 1px solid var(--card-border);
  color: var(--text);
  border-radius: 8px;
  padding: 12px;
  font-family: inherit;
  font-size: 0.95rem;
  resize: vertical;
  margin-bottom: 10px;
}

button { font-family: inherit; cursor: pointer; }

.primary-btn {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 10px 16px;
  font-size: 0.9rem;
}

.ghost-btn {
  background: transparent;
  border: 1px solid var(--card-border);
  color: var(--text);
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 0.85rem;
}

.ghost-btn.disabled { color: var(--muted); cursor: not-allowed; }

.quick-actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0; }

/* ---------- Agent detail / file viewer ---------- */

.agent-detail {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  padding: 16px;
}

.file-viewer {
  background: #111113;
  border: 1px solid var(--card-border);
  border-radius: 8px;
  padding: 14px;
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 0.8rem;
  max-height: 420px;
  overflow: auto;
}

/* ---------- Tasks ---------- */

.chip-row {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  margin-bottom: 14px;
}

.chip {
  background: var(--card);
  border: 1px solid var(--card-border);
  color: var(--muted);
  border-radius: 999px;
  padding: 6px 14px;
  font-size: 0.85rem;
  white-space: nowrap;
}

.chip.active { background: var(--accent); color: #fff; border-color: var(--accent); }

.body-links { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }

.link-chip {
  text-decoration: none;
  color: var(--accent);
  border-color: var(--accent);
  font-size: 0.75rem;
  padding: 4px 10px;
}

.task-section { margin-bottom: 18px; }
.task-section h4 { margin: 0 0 8px; font-size: 0.95rem; color: var(--muted); }

.task-item {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 8px;
}

.task-item .id { color: var(--accent); font-weight: 600; }
.task-item .title { font-weight: 600; }
.task-item .body { color: var(--muted); font-size: 0.85rem; margin-top: 6px; }
.task-item .status { font-size: 0.75rem; color: var(--muted); margin-top: 6px; }
.task-item.checked .title { text-decoration: line-through; opacity: 0.6; }

.task-actions { display: flex; gap: 8px; margin-top: 10px; }

.approve-btn, .reject-btn {
  border: none;
  border-radius: 8px;
  padding: 8px 14px;
  font-size: 0.85rem;
  color: #fff;
}

.approve-btn { background: var(--green); }
.reject-btn { background: var(--red); }

/* ---------- Digest ---------- */

.digest-content {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  padding: 16px;
  font-size: 0.9rem;
  line-height: 1.5;
}

.digest-content h1, .digest-content h2, .digest-content h3 { margin-top: 0; }
.digest-content ul { padding-left: 20px; }

@media (min-width: 640px) {
  .stats-grid { grid-template-columns: repeat(4, 1fr); }
}
