@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&family=JetBrains+Mono:wght@400;500&display=swap');

:root {
  --bg: #090c13;
  --bg-grid: radial-gradient(circle at 15% 0%, rgba(110, 168, 254, 0.12), transparent 45%),
             radial-gradient(circle at 85% 10%, rgba(167, 139, 250, 0.10), transparent 40%),
             #090c13;
  --surface: #11151f;
  --surface-2: #171c29;
  --surface-3: #1e2534;
  --border: #232a3b;
  --border-soft: #1b2130;
  --text: #f3f5fa;
  --text-dim: #9aa3b8;
  --text-faint: #5e6780;
  --accent: #6ea8fe;
  --accent-2: #a78bfa;
  --accent-grad: linear-gradient(135deg, #6ea8fe, #a78bfa);
  --good: #34d399;
  --good-bg: rgba(52, 211, 153, 0.12);
  --warn: #fbbf24;
  --warn-bg: rgba(251, 191, 36, 0.12);
  --bad: #f87171;
  --bad-bg: rgba(248, 113, 113, 0.14);
  --radius: 16px;
  --radius-sm: 10px;
  --shadow-card: 0 1px 0 rgba(255,255,255,0.03) inset, 0 20px 40px -24px rgba(0,0,0,0.6);
  --font: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  background: var(--bg-grid);
  background-attachment: fixed;
  color: var(--text);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
}

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--surface-3); border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: var(--border); }

a { color: inherit; }

/* ---------- Topbar ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 28px;
  border-bottom: 1px solid var(--border-soft);
  background: rgba(9, 12, 19, 0.72);
  backdrop-filter: blur(16px) saturate(140%);
  position: sticky;
  top: 0;
  z-index: 20;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 17px;
  font-weight: 800;
  letter-spacing: -0.01em;
}
.brand-mark {
  width: 30px; height: 30px; border-radius: 9px;
  background: var(--accent-grad);
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 6px 16px -6px rgba(110, 168, 254, 0.55);
  font-size: 15px;
}
.brand span { color: var(--text-dim); font-weight: 600; }

.topbar nav { display: flex; align-items: center; gap: 10px; }

.pill-link {
  display: inline-flex; align-items: center; gap: 6px;
  color: var(--text-dim); text-decoration: none; font-size: 13px; font-weight: 500;
  padding: 7px 13px; border-radius: 999px;
  border: 1px solid var(--border-soft);
  background: var(--surface);
  transition: all .15s ease;
}
.pill-link:hover { color: var(--text); border-color: var(--accent); background: var(--surface-2); }
button.pill-link { font-family: var(--font); cursor: pointer; }
button.pill-link.active { color: var(--warn); border-color: var(--warn); }

.meta { color: var(--text-faint); font-size: 12px; margin-top: 12px; line-height: 1.6; }
.meta.warn { color: var(--warn); }

.status-pill {
  display: inline-flex; align-items: center; gap: 7px;
  font-size: 12.5px; font-weight: 600;
  padding: 6px 12px; border-radius: 999px;
  border: 1px solid var(--border-soft);
  background: var(--surface);
}
.status-pill .dot { width: 7px; height: 7px; border-radius: 50%; }
.status-pill.ok { color: var(--good); }
.status-pill.ok .dot { background: var(--good); box-shadow: 0 0 0 0 rgba(52,211,153,.6); animation: pulse-good 2s infinite; }
.status-pill.warn { color: var(--warn); }
.status-pill.warn .dot { background: var(--warn); box-shadow: 0 0 0 0 rgba(251,191,36,.6); animation: pulse-warn 1.6s infinite; }
.status-pill.bad { color: var(--bad); }
.status-pill.bad .dot { background: var(--bad); box-shadow: 0 0 0 0 rgba(248,113,113,.6); animation: pulse-bad 1s infinite; }

@keyframes pulse-good { 70% { box-shadow: 0 0 0 6px rgba(52,211,153,0); } }
@keyframes pulse-warn { 70% { box-shadow: 0 0 0 6px rgba(251,191,36,0); } }
@keyframes pulse-bad  { 70% { box-shadow: 0 0 0 6px rgba(248,113,113,0); } }

.conn-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--warn);
  transition: background .3s;
}
.conn-dot.ok { background: var(--good); }
.conn-dot.bad { background: var(--bad); }

.logout-form button {
  background: none; border: 1px solid var(--border-soft); color: var(--text-dim);
  padding: 7px 13px; border-radius: 999px; cursor: pointer; font-size: 13px; font-weight: 500;
  font-family: var(--font);
  transition: all .15s ease;
}
.logout-form button:hover { color: var(--bad); border-color: var(--bad); }

/* ---------- Layout ---------- */
main.shell {
  max-width: 1360px;
  margin: 0 auto;
  padding: 28px;
}

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

.grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}

.card {
  background: linear-gradient(180deg, var(--surface) 0%, var(--surface) 100%);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 22px;
  box-shadow: var(--shadow-card);
  animation: rise .5s ease both;
}
.card.wide { grid-column: 1 / -1; }

@keyframes rise {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.card-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 16px;
}
.card-head h2 {
  margin: 0; font-size: 13px; font-weight: 700; color: var(--text-dim);
  text-transform: uppercase; letter-spacing: 0.06em;
  display: flex; align-items: center; gap: 8px;
}
.card-head h2 svg { width: 15px; height: 15px; opacity: .8; }
.card-head .meta-tag {
  font-size: 11.5px; color: var(--text-faint); font-family: var(--mono);
}

/* ---------- KPI tiles (hero) ---------- */
.kpi-tile {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  box-shadow: var(--shadow-card);
  position: relative;
  overflow: hidden;
  animation: rise .5s ease both;
}
.kpi-tile .kpi-top {
  display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 2px;
}
.kpi-label {
  font-size: 12px; font-weight: 600; color: var(--text-dim);
  text-transform: uppercase; letter-spacing: 0.05em;
}
.kpi-value {
  font-size: 30px; font-weight: 800; letter-spacing: -0.02em;
  font-family: var(--mono);
}
.kpi-value.good { color: var(--good); }
.kpi-value.warn { color: var(--warn); }
.kpi-value.bad { color: var(--bad); }
.kpi-sub { font-size: 12px; color: var(--text-faint); margin-top: 2px; }
.kpi-spark { width: 100%; height: 36px; margin-top: 10px; display: block; }
.kpi-spark path.area { fill: url(#sparkFillGrad); opacity: .5; }
.kpi-spark path.line { fill: none; stroke-width: 1.8; }

/* ---------- Bars ---------- */
.bars { display: flex; flex-direction: column; gap: 10px; }
.bar-row { display: flex; align-items: center; gap: 12px; font-size: 13px; }
.bar-row .label {
  width: 150px; color: var(--text-dim); overflow: hidden; text-overflow: ellipsis;
  white-space: nowrap; font-family: var(--mono); font-size: 12.5px;
}
.bar-track { flex: 1; background: var(--surface-2); border-radius: 8px; height: 8px; overflow: hidden; }
.bar-fill { height: 100%; border-radius: 8px; background: var(--accent-grad); transition: width .4s ease; }
.bar-fill.warn { background: linear-gradient(135deg, #fbbf24, #f59e0b); }
.bar-fill.bad { background: linear-gradient(135deg, #f87171, #ef4444); }
.bar-pct { width: 46px; text-align: right; color: var(--text-dim); font-family: var(--mono); font-size: 12.5px; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th {
  text-align: left; color: var(--text-faint); font-weight: 600; padding: 8px 10px;
  border-bottom: 1px solid var(--border-soft); font-size: 11.5px;
  text-transform: uppercase; letter-spacing: 0.04em;
}
td { padding: 10px; border-bottom: 1px solid var(--border-soft); font-family: var(--mono); font-size: 12.5px; }
tr:last-child td { border-bottom: none; }
tr { transition: background .15s; }
tr:hover td { background: var(--surface-2); }

.badge {
  padding: 3px 10px; border-radius: 999px; font-size: 11px; font-weight: 700;
  font-family: var(--font); letter-spacing: 0.02em; display: inline-flex; align-items: center; gap: 5px;
}
.badge.running { background: var(--good-bg); color: var(--good); }
.badge.exited, .badge.dead { background: var(--bad-bg); color: var(--bad); }
.badge.created, .badge.restarting, .badge.paused { background: var(--warn-bg); color: var(--warn); }

/* ---------- Lists ---------- */
.stack { display: flex; flex-direction: column; gap: 10px; max-height: 420px; overflow-y: auto; padding-right: 4px; }
.repo-item, .project-item, .event-item {
  background: var(--surface-2);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  font-size: 13px;
  transition: border-color .15s, transform .15s;
  animation: slide-in .35s ease both;
}
.repo-item:hover, .project-item:hover, .event-item:hover { border-color: var(--border); }

@keyframes slide-in {
  from { opacity: 0; transform: translateX(-6px); }
  to { opacity: 1; transform: translateX(0); }
}

.repo-item .repo-head, .project-item .project-head, .event-item .event-head {
  display: flex; justify-content: space-between; gap: 10px; font-weight: 600; align-items: center;
}
.repo-item .repo-head > span:first-child, .project-item .project-head > span:first-child {
  display: flex; align-items: center; gap: 8px; font-family: var(--mono); font-size: 12.5px;
}
.repo-item .repo-meta, .project-item .project-meta, .event-item .event-meta {
  color: var(--text-faint); font-size: 12px; margin-top: 6px; line-height: 1.5;
}
.event-item .event-meta { list-style: none; padding: 0; margin: 6px 0 0; }
.count-chip {
  font-size: 11px; color: var(--text-dim); background: var(--surface-3);
  padding: 2px 8px; border-radius: 999px; font-family: var(--font); font-weight: 600;
}

.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.dot.good { background: var(--good); box-shadow: 0 0 8px rgba(52,211,153,.5); }
.dot.warn { background: var(--warn); box-shadow: 0 0 8px rgba(251,191,36,.5); }
.dot.bad { background: var(--bad); box-shadow: 0 0 8px rgba(248,113,113,.5); }

.timestamp { font-family: var(--mono); font-size: 11.5px; color: var(--text-faint); white-space: nowrap; }

.empty {
  color: var(--text-faint); font-size: 13px; padding: 18px 0; text-align: center;
  display: flex; flex-direction: column; align-items: center; gap: 6px;
}
.empty svg { width: 28px; height: 28px; opacity: .4; }

@media (max-width: 1000px) {
  .hero-row { grid-template-columns: repeat(2, 1fr); }
  .grid { grid-template-columns: 1fr; }
  main.shell { padding: 16px; }
  .topbar { padding: 12px 16px; flex-wrap: wrap; }
}
@media (max-width: 560px) {
  .hero-row { grid-template-columns: 1fr; }
}

/* ---------- Login ---------- */
.login-body {
  display: flex; align-items: center; justify-content: center; height: 100vh;
  background: var(--bg-grid);
}
.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 36px 32px;
  width: 340px;
  display: flex; flex-direction: column; gap: 16px;
  box-shadow: var(--shadow-card);
  animation: rise .5s ease both;
}
.login-card .brand-mark { margin-bottom: 4px; }
.login-card h1 { margin: 0; font-size: 21px; font-weight: 800; letter-spacing: -0.01em; }
.login-card h1 span { color: var(--text-dim); font-weight: 600; }
.login-card .subtitle { margin: -8px 0 0; color: var(--text-faint); font-size: 13px; }
.login-card label { display: flex; flex-direction: column; gap: 6px; font-size: 12.5px; color: var(--text-dim); font-weight: 500; }
.login-card input {
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px;
  padding: 11px 13px; color: var(--text); font-size: 14px; font-family: var(--font);
  transition: border-color .15s;
}
.login-card input:focus { outline: none; border-color: var(--accent); }
.login-card button {
  background: var(--accent-grad); border: none; color: #071019; font-weight: 700;
  padding: 11px 13px; border-radius: 10px; cursor: pointer; font-size: 14px; margin-top: 4px;
  font-family: var(--font);
  box-shadow: 0 8px 20px -8px rgba(110, 168, 254, 0.5);
  transition: transform .1s ease;
}
.login-card button:hover { transform: translateY(-1px); }
.login-error { background: var(--bad-bg); color: var(--bad); padding: 9px 12px; border-radius: 10px; font-size: 13px; }

/* ---------- Assistente ---------- */
.assistant-fab {
  position: fixed; bottom: 24px; right: 24px; z-index: 40;
  width: 56px; height: 56px; border-radius: 50%;
  background: var(--accent-grad); border: none; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  color: #071019; box-shadow: 0 10px 28px -8px rgba(110, 168, 254, 0.6);
  transition: transform .15s ease;
}
.assistant-fab:hover { transform: scale(1.06); }
.assistant-fab svg { width: 26px; height: 26px; }

.assistant-panel {
  position: fixed; bottom: 92px; right: 24px; z-index: 41;
  width: 380px; max-width: calc(100vw - 32px);
  height: 560px; max-height: calc(100vh - 140px);
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 18px; box-shadow: var(--shadow-card);
  display: flex; flex-direction: column; overflow: hidden;
  animation: rise .25s ease both;
}
.assistant-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px; border-bottom: 1px solid var(--border-soft);
  font-weight: 700; font-size: 14px;
}
.assistant-header button {
  background: none; border: none; color: var(--text-dim); cursor: pointer; font-size: 15px;
}
.assistant-messages {
  flex: 1; overflow-y: auto; padding: 14px 16px; display: flex; flex-direction: column; gap: 10px;
}
.assistant-msg {
  font-size: 13.5px; line-height: 1.5; padding: 10px 13px; border-radius: 12px;
  max-width: 88%; white-space: pre-wrap; animation: slide-in .2s ease both;
}
.assistant-msg-user {
  align-self: flex-end; background: var(--accent-grad); color: #071019; font-weight: 500;
}
.assistant-msg-bot { align-self: flex-start; background: var(--surface-2); color: var(--text); }
.assistant-msg-error { align-self: flex-start; background: var(--bad-bg); color: var(--bad); }
.assistant-msg-loading { align-self: flex-start; color: var(--text-faint); font-size: 13px; }

.assistant-pending {
  margin: 0 16px 12px; padding: 12px 14px; border-radius: 12px;
  background: var(--warn-bg); border: 1px solid rgba(251,191,36,0.35);
  font-size: 13px;
}
.assistant-pending .pending-title { font-weight: 700; color: var(--warn); margin-bottom: 6px; }
.assistant-pending .pending-actions { display: flex; gap: 8px; margin-top: 10px; }
.assistant-pending button {
  flex: 1; padding: 8px; border-radius: 8px; border: none; cursor: pointer;
  font-family: var(--font); font-weight: 600; font-size: 13px;
}
.assistant-pending .confirm-btn { background: var(--good); color: #071019; }
.assistant-pending .cancel-btn { background: var(--surface-3); color: var(--text-dim); }

.assistant-form { display: flex; gap: 8px; padding: 12px 16px; border-top: 1px solid var(--border-soft); }
.assistant-form input {
  flex: 1; background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px;
  padding: 9px 12px; color: var(--text); font-size: 13.5px; font-family: var(--font);
}
.assistant-form input:focus { outline: none; border-color: var(--accent); }
.assistant-form button {
  background: var(--accent-grad); border: none; color: #071019; font-weight: 700;
  padding: 9px 14px; border-radius: 10px; cursor: pointer; font-size: 13.5px;
}

@media (max-width: 460px) {
  .assistant-panel { right: 16px; left: 16px; width: auto; bottom: 84px; }
}
