/* GradedLeads shared design tokens + app chrome (Step 0 — no visual change) */

:root {
  --bg-primary: #0f172a;
  --bg-card: #1e293b;
  --bg-input: #334155;
  --bg-hover: #475569;
  --accent: #3b82f6;
  --accent-hover: #2563eb;
  --success: #22c55e;
  --warning: #f59e0b;
  --danger: #ef4444;
  --text-primary: #f1f5f9;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --border: #334155;
  --radius: 8px;
  --radius-sm: 4px;
  --header-h: 56px;
}

/* Login page: preserve its distinct palette (zero visual change) */
body.page-login {
  --bg-primary: #0f1117;
  --bg-card: #1a1d27;
  --bg-input: #252830;
  --border: #2d3340;
  --radius: 10px;
  /* Legacy aliases used by login.html inline styles */
  --bg: var(--bg-primary);
  --card: var(--bg-card);
  --input: var(--bg-input);
  --text: var(--text-primary);
  --muted: var(--text-secondary);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, 'Segoe UI', sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.5;
  min-height: 100vh;
}

/* ——— Header / top bar ——— */
.top-bar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--header-h);
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.25rem;
  z-index: 100;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  font-weight: 700;
  font-size: 1.15rem;
}

.brand a {
  color: inherit;
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 0.65rem;
}

.version {
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--text-muted);
  background: var(--bg-input);
  padding: 0.15rem 0.45rem;
  border-radius: 999px;
  border: 1px solid var(--border);
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.nav-links a {
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 500;
}

.nav-links a:hover { color: var(--text-primary); }
.nav-links a.active { color: var(--accent); }

.user-menu-wrap { position: relative; }

.user-menu-trigger {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.35rem 0.65rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-input);
  color: var(--text-primary);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  max-width: 220px;
}

.user-menu-trigger .user-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-dropdown {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  min-width: 210px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
  padding: 0.35rem;
  z-index: 120;
}

.user-dropdown a,
.user-dropdown button {
  display: block;
  width: 100%;
  text-align: left;
  padding: 0.45rem 0.55rem;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-size: 0.88rem;
  cursor: pointer;
  border-radius: 4px;
  text-decoration: none;
  font-family: inherit;
}

.user-dropdown a:hover,
.user-dropdown button:hover {
  background: var(--bg-input);
  color: var(--text-primary);
}

.icon-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--bg-input);
  color: var(--text-secondary);
  cursor: pointer;
  transition: background 150ms ease, color 150ms ease, border-color 150ms ease;
  text-decoration: none;
}

.icon-btn:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

/* ——— Layout ——— */
main {
  padding: calc(var(--header-h) + 1.25rem) 1.25rem 2rem;
  max-width: 1280px;
  margin: 0 auto;
}

.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem 1.5rem;
  margin-bottom: 1.25rem;
}

.card h2 {
  margin: 0 0 1rem;
  font-size: 1.05rem;
  font-weight: 600;
}

/* ——— Forms & buttons ——— */
label.lbl {
  display: block;
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin-bottom: 0.35rem;
}

input[type="text"],
input[type="number"],
input[type="password"],
textarea,
select {
  width: 100%;
  padding: 0.55rem 0.65rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-input);
  color: var(--text-primary);
  font-size: 0.9rem;
  transition: border-color 150ms ease;
}

input:focus,
textarea:focus,
select:focus {
  outline: none;
  border-color: var(--accent);
}

label.inline {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.88rem;
  color: var(--text-primary);
}

.btn-primary {
  padding: 0.65rem 1.5rem;
  border: none;
  border-radius: var(--radius);
  background: var(--accent);
  color: #fff;
  font-weight: 700;
  cursor: pointer;
  font-size: 0.9rem;
  transition: background 150ms ease;
}

.btn-primary:hover { background: var(--accent-hover); }
.btn-primary:disabled { opacity: 0.45; cursor: not-allowed; }

.btn-secondary {
  padding: 0.65rem 1.5rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-input);
  color: var(--text-primary);
  font-weight: 600;
  cursor: pointer;
  font-size: 0.9rem;
}

.btn-secondary:hover { background: var(--bg-hover); }

.hint {
  color: var(--text-muted);
  font-size: 0.82rem;
  margin-top: 0.35rem;
}

.hidden { display: none !important; }

/* ——— Tables (shared base) ——— */
.table-scroll { overflow-x: auto; }

table.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
}

.data-table th,
.data-table td {
  text-align: left;
  padding: 0.55rem 0.45rem;
  border-bottom: 1px solid var(--border);
}

.data-table tbody tr:nth-child(even) { background: rgba(51, 65, 85, 0.25); }
.data-table tbody tr:hover { background: rgba(71, 85, 105, 0.35); }

.data-table th {
  color: var(--text-secondary);
  font-weight: 600;
  user-select: none;
}

.data-table th.sortable { cursor: pointer; }
.data-table th.sortable:hover { color: var(--accent); }

/* ——— Icons ——— */
.icon {
  width: 18px;
  height: 18px;
  display: inline-block;
  vertical-align: middle;
}

.icon-sm { width: 14px; height: 14px; }
.icon-lg { width: 24px; height: 24px; }

/* ——— Light theme ——— */
body.light-theme {
  --bg-primary: #f1f5f9;
  --bg-card: #ffffff;
  --bg-input: #e2e8f0;
  --bg-hover: #cbd5e1;
  --accent: #3b82f6;
  --accent-hover: #2563eb;
  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #94a3b8;
  --border: #cbd5e1;
}

body.light-theme .data-table tbody tr:nth-child(even) {
  background: #f8fafc;
}

body.light-theme .data-table tbody tr:hover {
  background: #e2e8f0;
}
