/* Agent Monitor — dark admin theme (brand: #0b1f16 / #3ed65c) */
:root {
  --bg: #0b1f16;
  --panel: #10291d;
  --panel2: #0e2418;
  --border: #1d3c2c;
  --text: #e8f5ec;
  --muted: #8fb3a0;
  --accent: #3ed65c;
  --accent-dark: #2ba644;
  --amber: #f5a623;
  --red: #ef4444;
  --blue: #38bdf8;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
}

/* ---------- Layout ---------- */
.app { display: flex; min-height: 100vh; }

.sidebar {
  width: 228px;
  min-width: 228px;
  background: var(--panel2);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 18px 12px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.brand {
  font-size: 17px;
  letter-spacing: .3px;
  padding: 0 8px 16px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 14px;
  white-space: nowrap;
}
.brand-dot {
  display: inline-block;
  width: 10px; height: 10px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 10px var(--accent);
  margin-right: 7px;
}
.brand.center { text-align: center; border-bottom: none; }

.nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: 8px;
  color: var(--muted);
  text-decoration: none;
  transition: background .15s, color .15s;
}
.nav-item:hover { background: rgba(62, 214, 92, .08); color: var(--text); }
.nav-item.active { background: rgba(62, 214, 92, .15); color: var(--accent); font-weight: 600; }
.nav-ico { width: 20px; text-align: center; }

.side-user {
  border-top: 1px solid var(--border);
  padding-top: 12px;
}
.su-name { font-weight: 600; font-size: 13px; word-break: break-all; }
.side-user .badge { margin: 4px 0 8px; }

.main { flex: 1; min-width: 0; padding: 22px 26px 40px; }
.topbar {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
}
.topbar h1 { font-size: 22px; font-weight: 700; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.mt { margin-top: 8px; }
.w100 { width: 100%; }
.r { text-align: right; }
.nowrap { white-space: nowrap; }
.center { text-align: center; }

/* ---------- Cards ---------- */
.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}
.cards-inline { grid-template-columns: repeat(3, 1fr); margin-bottom: 0; }
.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
}
.stat-label { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .6px; margin-bottom: 6px; }
.stat { font-size: 28px; font-weight: 800; }
.stat.sm { font-size: 18px; margin-bottom: 6px; }
.stat.warn { color: var(--amber); }
.stat-sub { color: var(--muted); font-size: 12px; margin-top: 4px; }
.mini-card { background: var(--panel2); border: 1px solid var(--border); border-radius: 10px; padding: 12px; }
.mini-num { font-size: 20px; font-weight: 700; }
.mini-label { color: var(--muted); font-size: 11px; }

/* ---------- Panels ---------- */
.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 18px;
  margin-bottom: 18px;
}
.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}
.panel-head h3 { font-size: 15px; }
.sub { margin: 14px 0 8px; font-size: 13px; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; }
.link { color: var(--accent); text-decoration: none; }
.link:hover { text-decoration: underline; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
@media (max-width: 1000px) { .grid-2 { grid-template-columns: 1fr; } }

/* ---------- Tables ---------- */
.tbl { width: 100%; border-collapse: collapse; }
.tbl th {
  text-align: left;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .6px;
  color: var(--muted);
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
}
.tbl td { padding: 9px 10px; border-bottom: 1px solid rgba(29, 60, 44, .55); vertical-align: top; }
.tbl tr:last-child td { border-bottom: none; }
.tbl tr:hover td { background: rgba(62, 214, 92, .03); }
.preview { max-width: 320px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.scroll-x { overflow-x: auto; }

/* ---------- Badges ---------- */
.badge {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  background: rgba(56, 189, 248, .15);
  color: var(--blue);
}
.badge-stage { background: rgba(245, 166, 35, .15); color: var(--amber); }
.badge-source { background: rgba(139, 92, 246, .18); color: #c4b5fd; }
.badge-ready { background: rgba(62, 214, 92, .15); color: var(--accent); }
.badge-pending { background: rgba(245, 166, 35, .15); color: var(--amber); }
.role-admin { background: rgba(239, 68, 68, .18); color: #fca5a5; }
.role-uploader { background: rgba(62, 214, 92, .18); color: var(--accent); }
.role-viewer { background: rgba(139, 148, 158, .2); color: #cbd5e1; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-block;
  border: 1px solid var(--border);
  background: var(--panel2);
  color: var(--text);
  padding: 8px 14px;
  border-radius: 8px;
  font-size: 13px;
  cursor: pointer;
  text-decoration: none;
  transition: all .15s;
}
.btn:hover { border-color: var(--accent); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #06210f; font-weight: 700; }
.btn-primary:hover { background: var(--accent-dark); border-color: var(--accent-dark); }
.btn-danger { background: rgba(239, 68, 68, .12); border-color: rgba(239, 68, 68, .4); color: #fca5a5; }
.btn-danger:hover { background: rgba(239, 68, 68, .25); border-color: var(--red); }
.btn-ghost { background: transparent; }
.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn-block { display: block; width: 100%; text-align: center; }
.btn-lg { padding: 13px 18px; font-size: 15px; }

/* ---------- Forms ---------- */
input, select {
  background: var(--panel2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 8px;
  padding: 9px 12px;
  font-size: 13px;
  outline: none;
}
input:focus, select:focus { border-color: var(--accent); }
.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.filters input[type="text"], .filters input[type="email"] { min-width: 220px; flex: 1; }
.filters select { min-width: 130px; }
.form-stack { display: flex; flex-direction: column; gap: 8px; max-width: 520px; }
.form-stack label { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .5px; margin-top: 8px; }
.inline { display: inline-block; margin-right: 6px; }
.upload-form { display: flex; flex-direction: column; gap: 12px; max-width: 620px; }
.upload-form input[type="file"] { padding: 10px; }
.upload-meta { margin-top: -4px; }
code { background: var(--panel2); border: 1px solid var(--border); padding: 1px 6px; border-radius: 5px; font-size: 12px; }

/* ---------- Flash ---------- */
.flash {
  padding: 11px 15px;
  border-radius: 10px;
  margin-bottom: 16px;
  font-weight: 500;
  border: 1px solid;
}
.flash-ok { background: rgba(62, 214, 92, .12); border-color: rgba(62, 214, 92, .4); color: var(--accent); }
.flash-err { background: rgba(239, 68, 68, .12); border-color: rgba(239, 68, 68, .4); color: #fca5a5; }

/* ---------- Charts ---------- */
.chart { background: var(--panel2); border: 1px solid var(--border); border-radius: 10px; padding: 10px; }
.trend { width: 100%; height: auto; }
.trend .grid { stroke: rgba(143, 179, 160, .15); stroke-width: 1; }
.trend .tick { fill: var(--muted); font-size: 10px; }
.trend .line-in { fill: none; stroke: var(--blue); stroke-width: 2; }
.trend .line-out { fill: none; stroke: var(--accent); stroke-width: 2; }
.legend { margin-top: 8px; font-size: 12px; color: var(--muted); }
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin: 0 4px 0 10px; vertical-align: middle; }
.dot-in { background: var(--blue); }
.dot-out { background: var(--accent); }

.hbar-row { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.hbar-label { width: 150px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; color: var(--muted); }
.hbar-track { flex: 1; background: var(--panel2); border-radius: 6px; height: 10px; overflow: hidden; }
.hbar-fill { height: 100%; background: linear-gradient(90deg, var(--accent-dark), var(--accent)); border-radius: 6px; }
.hbar-val { width: 70px; text-align: right; font-size: 12px; font-weight: 600; }

/* ---------- Pager / seg ---------- */
.pager { display: flex; gap: 10px; align-items: center; justify-content: center; margin-top: 14px; }
.seg { display: flex; gap: 4px; }
.seg-btn {
  padding: 6px 12px;
  border-radius: 7px;
  border: 1px solid var(--border);
  color: var(--muted);
  text-decoration: none;
  font-size: 12px;
  background: var(--panel2);
}
.seg-btn.active { background: var(--accent); color: #06210f; border-color: var(--accent); font-weight: 700; }

/* ---------- Bubbles ---------- */
.bubble {
  background: var(--panel2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px;
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 13px;
}
.bubble-reply { border-left: 3px solid var(--accent); }

/* ---------- Login ---------- */
.login-body {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: radial-gradient(1000px 500px at 50% -10%, rgba(62, 214, 92, .12), transparent), var(--bg);
}
.login-card {
  width: 380px;
  max-width: 92vw;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 34px 30px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, .4);
}
.login-card .brand { margin-bottom: 8px; }
.login-card p { margin: 12px 0; }
.errbox {
  background: rgba(239, 68, 68, .1);
  border: 1px solid rgba(239, 68, 68, .35);
  color: #fca5a5;
  border-radius: 10px;
  padding: 13px 15px;
  font-size: 13px;
  line-height: 1.6;
}

/* ---------- Responsive ---------- */
@media (max-width: 860px) {
  .app { flex-direction: column; }
  .sidebar { width: 100%; min-width: 0; height: auto; position: static; flex-direction: row; flex-wrap: wrap; align-items: center; padding: 10px; }
  .nav { flex-direction: row; flex-wrap: wrap; }
  .side-user { border-top: none; padding-top: 0; margin-left: auto; }
  .main { padding: 16px; }
}
