/* EndpointRelay — modern UI, single stylesheet, no framework. */

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

:root {
  --bg: #f8fafc;
  --bg-deep: #f1f5f9;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --text: #0f172a;
  --text-muted: #64748b;
  --text-faint: #94a3b8;
  --border: #e2e8f0;
  --border-strong: #cbd5e1;

  --primary: #7c3aed;
  --primary-hover: #6d28d9;
  --primary-soft: #ede9fe;
  --primary-soft-text: #5b21b6;

  --success: #16a34a;
  --success-soft: #dcfce7;
  --success-soft-text: #166534;
  --danger: #dc2626;
  --danger-soft: #fee2e2;
  --danger-soft-text: #991b1b;
  --warning: #d97706;
  --warning-soft: #fed7aa;
  --warning-soft-text: #9a3412;
  --info: #2563eb;
  --info-soft: #dbeafe;
  --info-soft-text: #1e40af;

  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow-md: 0 4px 16px rgba(15, 23, 42, 0.06), 0 1px 3px rgba(15, 23, 42, 0.05);
  --shadow-lg: 0 10px 40px rgba(15, 23, 42, 0.08);

  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 14px;

  --sidebar-w: 240px;
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a { color: var(--primary); text-decoration: none; transition: color 0.15s; }
a:hover { color: var(--primary-hover); }

/* ============ Layout (sidebar + main) ============ */
.app-shell {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  min-height: 100vh;
}
.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}
.sidebar .brand {
  padding: 22px 22px 18px;
  display: flex;
  align-items: center;
  gap: 10px;
  border-bottom: 1px solid var(--border);
}
.sidebar .brand .logo {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: linear-gradient(135deg, #8b5cf6, #7c3aed);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: 700;
  font-size: 14px;
  box-shadow: 0 2px 8px rgba(124, 58, 237, 0.3);
}
.sidebar .brand .name {
  font-weight: 700;
  font-size: 15px;
  color: var(--text);
  letter-spacing: -0.01em;
}
.sidebar nav {
  flex: 1;
  padding: 12px 12px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.sidebar nav a {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-weight: 500;
  font-size: 13.5px;
  transition: all 0.15s;
}
.sidebar nav a:hover { background: var(--bg-deep); color: var(--text); }
.sidebar nav a.active { background: var(--primary-soft); color: var(--primary-soft-text); font-weight: 600; }
.sidebar nav a svg { flex-shrink: 0; }
.sidebar .user-panel {
  padding: 14px 16px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 10px;
}
.sidebar .user-panel .avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: linear-gradient(135deg, #8b5cf6, #6d28d9);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 12px;
  flex-shrink: 0;
}
.sidebar .user-panel .who { flex: 1; min-width: 0; }
.sidebar .user-panel .email {
  font-size: 12px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sidebar .user-panel .link {
  background: none; border: none; color: var(--text-muted);
  cursor: pointer; font-size: 12px; padding: 0;
  text-decoration: underline; font-family: inherit;
}
.sidebar .user-panel .link:hover { color: var(--danger); }

main { padding: 28px 36px; max-width: 1400px; margin: 0 auto; width: 100%; }

/* ============ Headings ============ */
.page-head { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 22px; gap: 16px; flex-wrap: wrap; }
.page-head .titles { display: flex; flex-direction: column; gap: 4px; }
.page-head h1 { margin: 0; font-size: 22px; font-weight: 700; letter-spacing: -0.02em; color: var(--text); }
.page-head .subtitle { font-size: 13px; color: var(--text-muted); }
.page-head .actions { display: flex; gap: 8px; align-items: center; }

/* ============ Cards ============ */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 22px;
  margin-bottom: 16px;
  box-shadow: var(--shadow-sm);
}
.card h2 {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin: 0 0 14px;
  font-weight: 600;
  display: flex; align-items: center; gap: 8px;
}
.card h2 svg { width: 14px; height: 14px; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 16px; }
.grid-2 .card { margin-bottom: 0; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-bottom: 16px; }
.grid-3 .card { margin-bottom: 0; }
@media (max-width: 900px) { .grid-2, .grid-3 { grid-template-columns: 1fr; } }

/* ============ Stats ============ */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 10px; }
.stat { background: var(--surface-2); padding: 12px 14px; border-radius: var(--radius-sm); border: 1px solid var(--border); }
.stat .label { font-size: 10.5px; text-transform: uppercase; color: var(--text-muted); letter-spacing: 0.06em; font-weight: 600; }
.stat .value { font-size: 24px; font-weight: 700; color: var(--text); margin-top: 2px; letter-spacing: -0.02em; }

/* ============ Tables ============ */
.data-table { width: 100%; border-collapse: collapse; }
.data-table th, .data-table td { padding: 11px 14px; text-align: left; border-bottom: 1px solid var(--border); }
.data-table th { font-size: 10.5px; text-transform: uppercase; color: var(--text-muted); letter-spacing: 0.06em; font-weight: 600; background: var(--surface-2); }
.data-table tr:last-child td { border-bottom: none; }
.data-table td { vertical-align: middle; font-size: 13.5px; }
.data-table tr:hover td { background: var(--surface-2); }

/* ============ Buttons ============ */
.btn {
  background: white; border: 1px solid var(--border-strong); color: var(--text);
  padding: 8px 14px; border-radius: var(--radius-sm); cursor: pointer;
  font-size: 13.5px; font-weight: 500; font-family: inherit;
  display: inline-flex; align-items: center; gap: 6px;
  transition: all 0.15s;
}
.btn:hover { background: var(--surface-2); border-color: var(--text-muted); }
.btn.primary {
  background: var(--primary); border-color: var(--primary); color: white;
  box-shadow: 0 1px 3px rgba(124, 58, 237, 0.3);
}
.btn.primary:hover {
  background: var(--primary-hover); border-color: var(--primary-hover);
  box-shadow: 0 4px 12px rgba(124, 58, 237, 0.4);
  transform: translateY(-1px);
}
.btn.danger { color: var(--danger); border-color: var(--danger-soft); }
.btn.danger:hover { background: var(--danger); color: white; border-color: var(--danger); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--surface-2); border-color: var(--border); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; box-shadow: none; }
.btn svg { width: 14px; height: 14px; }

/* ============ Forms ============ */
.form-row { display: flex; flex-wrap: wrap; gap: 14px; align-items: flex-end; margin-bottom: 12px; }
.form-row label { display: flex; flex-direction: column; gap: 5px; font-size: 12.5px; color: var(--text-muted); font-weight: 500; }
input[type="text"], input[type="email"], input[type="password"], input[type="number"], select {
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  padding: 8px 11px; font-size: 13.5px; font-family: inherit;
  background: white; min-width: 180px; color: var(--text); transition: all 0.15s;
}
input:focus, select:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }

/* ============ Badges ============ */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 9px; font-size: 11px; font-weight: 600;
  border-radius: 999px; text-transform: uppercase; letter-spacing: 0.04em; white-space: nowrap;
}
.badge::before { content: ''; width: 5px; height: 5px; border-radius: 50%; background: currentColor; }
.badge.queued, .badge.pending { background: var(--info-soft); color: var(--info-soft-text); }
.badge.dialing, .badge.running, .badge.enabled { background: var(--success-soft); color: var(--success-soft-text); }
.badge.success { background: var(--success-soft); color: var(--success-soft-text); }
.badge.failed { background: var(--danger-soft); color: var(--danger-soft-text); }
.badge.pending_agents, .badge.waiting { background: var(--warning-soft); color: var(--warning-soft-text); }
.badge.skipped, .badge.paused, .badge.completed, .badge.disabled { background: var(--bg-deep); color: var(--text-muted); }
.badge.available { background: var(--success-soft); color: var(--success-soft-text); }
.badge.unavailable { background: var(--danger-soft); color: var(--danger-soft-text); }

/* ============ Login ============ */
.login-body {
  display: flex; align-items: center; justify-content: center; min-height: 100vh;
  background: linear-gradient(135deg, #f5f3ff 0%, #ede9fe 50%, #f8fafc 100%);
  padding: 20px;
}
.login-card {
  background: white; padding: 40px 38px; border-radius: var(--radius-lg);
  box-shadow: 0 24px 64px rgba(15, 23, 42, 0.08), 0 8px 24px rgba(15, 23, 42, 0.04);
  width: 100%; max-width: 380px; border: 1px solid var(--border);
}
.login-card .brand-row { display: flex; align-items: center; gap: 10px; margin-bottom: 4px; }
.login-card .logo {
  width: 38px; height: 38px; border-radius: 10px;
  background: linear-gradient(135deg, #8b5cf6, #7c3aed);
  display: flex; align-items: center; justify-content: center;
  color: white; font-weight: 700; font-size: 16px;
  box-shadow: 0 4px 12px rgba(124, 58, 237, 0.3);
}
.login-card h1 { margin: 0; font-size: 18px; letter-spacing: -0.01em; }
.login-card .muted { margin: 6px 0 22px; }
.login-card form { display: flex; flex-direction: column; gap: 14px; }
.login-card label { display: flex; flex-direction: column; gap: 6px; font-size: 12.5px; color: var(--text-muted); font-weight: 500; }
.login-card input { font-size: 14px; padding: 10px 12px; }
.login-card button { margin-top: 6px; padding: 11px; font-size: 14px; justify-content: center; }
.login-card .error {
  background: var(--danger-soft); color: var(--danger-soft-text);
  padding: 9px 12px; border-radius: var(--radius-sm); font-size: 12.5px;
  margin-top: 14px; border: 1px solid #fecaca;
}

/* ============ Misc ============ */
.muted { color: var(--text-muted); }
.faint { color: var(--text-faint); }
.error { color: var(--danger); }
.success-text { color: var(--success); }

.steps { list-style: none; padding: 0; margin: 0; display: flex; gap: 32px; flex-wrap: wrap; }
.steps li { color: var(--text-muted); font-size: 13px; }

.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); margin-bottom: 16px; }
.tab {
  background: none; border: none; padding: 9px 14px; cursor: pointer;
  color: var(--text-muted); border-bottom: 2px solid transparent;
  font-size: 13.5px; font-family: inherit; font-weight: 500; transition: all 0.15s;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 600; }

code {
  background: var(--bg-deep); padding: 2px 7px; border-radius: 4px;
  font-size: 12px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; color: var(--text);
}

.progress { background: var(--bg-deep); height: 6px; border-radius: 999px; overflow: hidden; min-width: 100px; }
.progress > div { height: 100%; background: linear-gradient(90deg, var(--primary) 0%, #a78bfa 100%); transition: width 0.4s ease; border-radius: 999px; }

.banner {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 16px; border-radius: var(--radius);
  font-size: 13.5px; border: 1px solid; margin-bottom: 16px;
}
.banner.warn { background: var(--warning-soft); color: var(--warning-soft-text); border-color: #fdba74; }
.banner.info { background: var(--info-soft); color: var(--info-soft-text); border-color: #bfdbfe; }
.banner.danger { background: var(--danger-soft); color: var(--danger-soft-text); border-color: #fecaca; }
.banner.success { background: var(--success-soft); color: var(--success-soft-text); border-color: #bbf7d0; }
.banner svg { width: 18px; height: 18px; flex-shrink: 0; }

.status-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; }
.status-dot.green { background: var(--success); box-shadow: 0 0 0 3px rgba(22, 163, 74, 0.15); animation: pulse-green 2s infinite; }
.status-dot.red { background: var(--danger); }
.status-dot.amber { background: var(--warning); animation: pulse-amber 1.5s infinite; }

@keyframes pulse-green {
  0%, 100% { box-shadow: 0 0 0 3px rgba(22, 163, 74, 0.15); }
  50% { box-shadow: 0 0 0 6px rgba(22, 163, 74, 0.05); }
}
@keyframes pulse-amber {
  0%, 100% { box-shadow: 0 0 0 3px rgba(217, 119, 6, 0.15); }
  50% { box-shadow: 0 0 0 6px rgba(217, 119, 6, 0.05); }
}

.empty { text-align: center; padding: 40px 20px; color: var(--text-muted); font-size: 13.5px; }
.empty svg { width: 40px; height: 40px; opacity: 0.4; margin-bottom: 8px; }
