/* ── Reset & Base ───────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:        #f1f5f9;
  --surface:   #ffffff;
  --surface2:  #f8fafc;
  --border:    #e2e8f0;
  --text:      #0f172a;
  --muted:     #64748b;
  --accent:    #D94420;
  --accent-dim:#D9442015;
  --blue:      #1E2D4D;
  --green:     #15803d;
  --red:       #ef4444;
  --radius:    14px;
  --shadow:    0 4px 24px rgba(0,0,0,0.08);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

/* ── Logo ───────────────────────────────────────────────────── */
.logo {
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.5px;
  color: var(--text);
}
.logo .dot { color: var(--accent); margin: 0 2px; }

/* ── LOGIN VIEW ─────────────────────────────────────────────── */
#login-view {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 24px;
  background: var(--bg);
}

.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 48px 40px;
  width: 100%;
  max-width: 400px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
}
.login-card > * { width: 100%; }
.login-card img { width: auto; height: 36px; }

.login-subtitle {
  color: var(--muted);
  font-size: 0.875rem;
  margin-top: -8px;
}

.input-group input {
  width: 100%;
  background: var(--bg);
  border: 1.5px solid var(--border);
  border-radius: 8px;
  padding: 12px 16px;
  color: var(--text);
  font-size: 0.9375rem;
  outline: none;
  transition: border-color 0.2s;
}
.input-group input:focus { border-color: var(--accent); }
.input-group input::placeholder { color: var(--muted); }

#login-btn {
  background: var(--accent);
  color: white;
  border: none;
  border-radius: 8px;
  padding: 12px;
  font-size: 0.9375rem;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.2s;
}
#login-btn:hover  { opacity: 0.9; }
#login-btn:disabled { opacity: 0.5; cursor: not-allowed; }

.error-msg {
  color: var(--red);
  font-size: 0.8125rem;
  min-height: 18px;
  text-align: center;
}

/* ── HUB VIEW ───────────────────────────────────────────────── */
#hub-view {
  display: none;
  flex-direction: column;
  min-height: 100vh;
}

/* Header */
.hub-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 32px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  box-shadow: 0 1px 4px rgba(0,0,0,0.06);
  position: sticky;
  top: 0;
  z-index: 10;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 20px;
}

.last-update {
  color: var(--muted);
  font-size: 0.8125rem;
}

.btn-logout {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--muted);
  padding: 6px 14px;
  border-radius: 6px;
  font-size: 0.8125rem;
  cursor: pointer;
  transition: all 0.2s;
}
.btn-logout:hover { border-color: var(--red); color: var(--red); }

/* Main */
.hub-main {
  flex: 1;
  padding: 40px 32px;
  max-width: 1280px;
  width: 100%;
  margin: 0 auto;
}

.section-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 32px;
}

.section-title {
  font-size: 1.375rem;
  font-weight: 700;
  color: var(--blue);
}

.section-sub {
  color: var(--muted);
  font-size: 0.875rem;
  margin-top: 4px;
}

.badge {
  background: #1E2D4D15;
  color: var(--blue);
  border: 1px solid #1E2D4D40;
  border-radius: 20px;
  padding: 4px 14px;
  font-size: 0.8125rem;
  font-weight: 600;
  white-space: nowrap;
}

/* Grid */
.bots-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 24px;
}

/* ── BOT CARD ───────────────────────────────────────────────── */
.bot-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  transition: border-color 0.2s, transform 0.2s;
}
.bot-card:hover {
  border-color: var(--accent)60;
  transform: translateY(-2px);
}

/* Card Header */
.card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.card-identity {
  display: flex;
  align-items: center;
  gap: 14px;
}

.bot-avatar {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  border: 1px solid;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.375rem;
  flex-shrink: 0;
}

.bot-name {
  font-size: 1.0625rem;
  font-weight: 700;
  color: var(--text);
}

.bot-client {
  font-size: 0.8125rem;
  color: var(--muted);
  margin-top: 2px;
}

/* Status badge */
.status-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 600;
  border: 1px solid var(--border);
  background: var(--surface2);
  white-space: nowrap;
  flex-shrink: 0;
}
.status-badge.online  { border-color: #15803d50; background: #14532d15; color: var(--green); }
.status-badge.offline { border-color: var(--red)50;   background: #ef444415; color: var(--red); }

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
}
.status-badge.online  .status-dot { animation: pulse 2s infinite; }

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.4; }
}

/* Tags */
.card-tags {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.tag {
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--muted);
  border-radius: 6px;
  padding: 3px 10px;
  font-size: 0.75rem;
}

/* Metrics */
.metrics-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1px;
  background: var(--border);
  border-radius: 10px;
  overflow: hidden;
}

.metric {
  background: var(--surface2);
  padding: 14px 10px;
  text-align: center;
}

.metric-value {
  font-size: 1.1875rem;
  font-weight: 700;
  color: var(--text);
}

.metric-label {
  font-size: 0.6875rem;
  color: var(--muted);
  margin-top: 3px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

/* Actions */
.card-actions {
  display: flex;
  gap: 10px;
}

.btn-panel {
  flex: 1;
  background: var(--accent);
  color: white;
  border: none;
  border-radius: 8px;
  padding: 10px 16px;
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  text-align: center;
  text-decoration: none;
  transition: opacity 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}
.btn-panel:hover { opacity: 0.88; }

/* Footer */
.hub-footer {
  text-align: center;
  padding: 20px;
  color: var(--muted);
  font-size: 0.75rem;
  border-top: 1px solid var(--border);
}

/* ── SEARCH ─────────────────────────────────────────────────── */
.search-wrap { position: relative; }
.search-wrap input {
  background: var(--surface2);
  border: 1.5px solid var(--border);
  border-radius: 8px;
  padding: 8px 12px 8px 30px;
  color: var(--text);
  font-size: 0.85rem;
  outline: none;
  width: 280px;
  transition: border-color 0.2s;
}
.search-wrap input:focus { border-color: var(--accent); }
.search-wrap input::placeholder { color: var(--muted); }

/* ── CLIENTS GRID ───────────────────────────────────────────── */
.clients-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(400px, 1fr));
  gap: 20px;
}
.empty-state {
  grid-column: 1/-1;
  text-align: center;
  color: var(--muted);
  padding: 3rem;
  font-size: 0.9rem;
}

/* ── CLIENT CARD ────────────────────────────────────────────── */
.client-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  transition: border-color 0.2s, transform 0.15s;
  overflow: hidden;
}
.client-card:hover { border-color: var(--accent)60; transform: translateY(-2px); }

.cc-top {
  padding: 1rem 1.2rem 0.8rem;
  border-bottom: 1px solid var(--border);
}
.cc-identity {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 0.6rem;
}
.cc-names { display: flex; flex-direction: column; gap: 2px; }
.cc-botname { font-size: 1rem; font-weight: 700; color: var(--text); }
.cc-biz     { font-size: 0.8rem; color: var(--muted); }

.cc-status {
  display: flex; align-items: center; gap: 5px;
  font-size: 0.72rem; font-weight: 700;
  padding: 4px 10px; border-radius: 99px;
  border: 1px solid currentColor;
  white-space: nowrap;
}
.cc-status.online  { color: var(--green); background: #14532d12; }
.cc-status.offline { color: var(--red);   background: #ef444412; }
.cc-status.warn    { color: #92400e;      background: #fef3c712; }
.cc-status.info    { color: #1e40af;      background: #eff6ff;   }
.cc-status.stopped { color: var(--muted); background: var(--surface2); }

.dot-sm {
  width: 6px; height: 6px; border-radius: 50%;
  background: currentColor; display: inline-block;
}
.dot-online { animation: pulse 2s infinite; }

.cc-meta { display: flex; flex-wrap: wrap; gap: 6px; }

/* Card body: 3 columnas */
.cc-body {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  border-bottom: 1px solid var(--border);
  flex: 1;
}
.cc-section {
  padding: 0.8rem 1rem;
  border-right: 1px solid var(--border);
}
.cc-section:last-child { border-right: none; }
.cc-section-title {
  font-size: 0.6rem; font-weight: 700; letter-spacing: 1px;
  text-transform: uppercase; color: var(--muted); margin-bottom: 0.5rem;
}
.cc-field {
  font-size: 0.75rem; color: var(--text); margin-bottom: 0.25rem;
  display: flex; gap: 0.3rem; align-items: baseline; word-break: break-all;
}
.cc-field span { color: var(--muted); flex-shrink: 0; }

.trial-days { font-size: 1.5rem; font-weight: 800; line-height: 1; color: var(--text); }
.trial-lbl  { font-size: 0.7rem; color: var(--muted); margin-bottom: 0.5rem; }
.trial-bar-wrap { background: var(--border); border-radius: 99px; height: 5px; overflow: hidden; }
.trial-bar  { height: 100%; border-radius: 99px; transition: width 0.5s; }

.stat-row { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 0.25rem; }
.stat-val  { font-size: 0.85rem; font-weight: 700; color: var(--accent); }
.stat-lbl  { font-size: 0.68rem; color: var(--muted); }

.cc-footer {
  padding: 0.7rem 1.2rem;
  display: flex; align-items: center; justify-content: space-between;
}
.btn-client-panel {
  background: var(--accent); color: white; border: none; border-radius: 6px;
  padding: 6px 14px; font-size: 0.8rem; font-weight: 600;
  text-decoration: none; cursor: pointer;
  transition: opacity 0.2s;
}
.btn-client-panel:hover { opacity: 0.88; }
.cc-tone { font-size: 0.7rem; color: var(--muted); }

/* ── Responsive ─────────────────────────────────────────────── */
@media (max-width: 700px) {
  .cc-body { grid-template-columns: 1fr 1fr; }
  .clients-grid { grid-template-columns: 1fr; }
}
@media (max-width: 600px) {
  .hub-header  { padding: 16px 20px; }
  .hub-main    { padding: 24px 20px; }
  .bots-grid   { grid-template-columns: 1fr; }
  .metrics-grid { grid-template-columns: repeat(2, 1fr); }
  .last-update  { display: none; }
  .search-wrap input { width: 200px; }
}
