:root {
  --bg: #0f1419;
  --surface: #1a2332;
  --border: #2d3a4f;
  --text: #e7ecf3;
  --muted: #8b9cb3;
  --accent: #3b82f6;
  --accent-hover: #2563eb;
  --success: #22c55e;
  --error: #ef4444;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: "Segoe UI", system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

.nav {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  padding: 0.75rem 1.5rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.nav a { color: var(--muted); text-decoration: none; font-size: 0.9rem; }
.nav a:hover, .nav .brand { color: var(--text); }
.nav .brand { font-weight: 700; margin-right: auto; }
.nav .logout { margin-left: auto; }
.bot-status {
  border-radius: 10px;
  padding: 1rem 1.25rem;
  margin-bottom: 1.5rem;
  border: 2px solid var(--border);
  background: var(--surface);
}
.bot-status-running { border-color: var(--success); }
.bot-status-idle { border-color: var(--border); }
.bot-status-error { border-color: var(--error); }
.bot-status-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.5rem;
}
.bot-status-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--muted);
  flex-shrink: 0;
}
.bot-status-running .bot-status-dot { background: var(--success); }
.bot-status-error .bot-status-dot { background: var(--error); }
.bot-status-dot.pulse {
  animation: bot-pulse 1.2s ease-in-out infinite;
}
@keyframes bot-pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.5; transform: scale(1.2); }
}
.bot-status-current {
  margin-bottom: 0.75rem;
  font-size: 0.95rem;
}
.bot-status-companies {
  margin-bottom: 0.75rem;
  font-size: 0.88rem;
  line-height: 1.45;
  color: var(--muted);
}
.companies-cell {
  max-width: 280px;
  font-size: 0.85rem;
  color: var(--muted);
}
.bot-progress-wrap {
  height: 8px;
  background: var(--bg);
  border-radius: 4px;
  overflow: hidden;
  margin-bottom: 0.5rem;
}
.bot-progress-bar {
  height: 100%;
  background: var(--accent);
  transition: width 0.4s ease;
}
.bot-status-running .bot-progress-bar { background: var(--success); }

.auto-refresh-clock {
  font-size: 0.75rem;
  color: var(--success);
  padding: 0.2rem 0.5rem;
  border: 1px solid var(--success);
  border-radius: 4px;
}
.auto-refresh-clock.live-on {
  color: var(--success);
  border-color: var(--success);
  font-weight: 600;
}
.auto-refresh-clock.live-running {
  animation: bot-pulse 1.2s ease-in-out infinite;
}

.bot-activity-feed {
  list-style: none;
  margin: 0 0 1.5rem;
  padding: 0;
  max-height: 220px;
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
}
.bot-activity-feed li {
  padding: 0.45rem 0.85rem;
  border-bottom: 1px solid var(--border);
  font-size: 0.88rem;
}
.bot-activity-feed li:last-child { border-bottom: none; }
.bot-activity-time {
  color: var(--muted);
  font-size: 0.8rem;
  margin-right: 0.5rem;
}
.bot-activity-text { color: var(--text); }

tr.row-new td {
  animation: row-highlight 2.5s ease-out;
}
@keyframes row-highlight {
  0% { background: rgba(34, 197, 94, 0.35); }
  100% { background: transparent; }
}

.locale-badge {
  font-size: 0.75rem;
  color: var(--muted);
  padding: 0.2rem 0.5rem;
  border: 1px solid var(--border);
  border-radius: 4px;
}

.container { max-width: 1200px; margin: 0 auto; padding: 1.5rem; }
h1 { font-size: 1.75rem; margin-top: 0; }
h2 { font-size: 1.15rem; margin: 1.5rem 0 0.75rem; color: var(--muted); }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 1rem; margin-bottom: 2rem; }
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1.25rem;
  text-align: center;
}
.stat-num { display: block; font-size: 2rem; font-weight: 700; color: var(--accent); }
.stat-label { font-size: 0.85rem; color: var(--muted); }

table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
th, td { padding: 0.6rem 0.75rem; text-align: left; border-bottom: 1px solid var(--border); }
th { color: var(--muted); font-weight: 600; }
tr:hover td { background: rgba(255,255,255,0.02); }

.badge { padding: 0.2rem 0.5rem; border-radius: 4px; font-size: 0.75rem; text-transform: uppercase; }
.badge-completed, .badge-sent { background: rgba(34,197,94,0.2); color: var(--success); }
.badge-failed { background: rgba(239,68,68,0.2); color: var(--error); }
.badge-running, .badge-pending { background: rgba(59,130,246,0.2); color: var(--accent); }

.card, .login-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1.25rem;
  margin-bottom: 1.5rem;
}
.login-box { max-width: 360px; margin: 4rem auto; }

label { display: block; margin-bottom: 0.75rem; font-size: 0.9rem; color: var(--muted); }
input, select, textarea, button {
  display: block;
  width: 100%;
  margin-top: 0.35rem;
  padding: 0.55rem 0.75rem;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-size: 0.95rem;
}
button, .btn-primary {
  width: auto;
  cursor: pointer;
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  font-weight: 600;
  margin-top: 0.5rem;
}
button:hover { background: var(--accent-hover); }
.inline-form { display: inline-block; margin-bottom: 1rem; margin-right: 0.5rem; }
.btn-secondary {
  width: auto;
  cursor: pointer;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  padding: 0.55rem 0.75rem;
  border-radius: 6px;
  font-size: 0.95rem;
}
.btn-secondary:hover { border-color: var(--accent); color: var(--accent); }

.checkbox { display: flex; align-items: center; gap: 0.5rem; }
.checkbox input { width: auto; margin: 0; }
.checkbox.inline { display: inline-flex; margin-right: 1rem; margin-bottom: 0.5rem; }

.filters { display: flex; flex-wrap: wrap; gap: 0.75rem; margin-bottom: 1rem; align-items: flex-end; }
.filters input, .filters select { width: auto; min-width: 180px; }
.filters button { margin-top: 0; }

.success { color: var(--success); }
.error, .error-cell { color: var(--error); font-size: 0.85rem; }
.meta, .hint { color: var(--muted); font-size: 0.85rem; }
code { background: var(--bg); padding: 0.1rem 0.35rem; border-radius: 4px; font-size: 0.85em; }
.source-list { list-style: none; padding: 0; }
.source-list li { padding: 0.35rem 0; }
.pagination { margin-top: 1rem; }
.pagination a { color: var(--accent); margin-right: 1rem; }

fieldset { border: 1px solid var(--border); border-radius: 8px; padding: 1rem; margin: 1rem 0; }
legend { color: var(--muted); padding: 0 0.5rem; }
