/* LeadClean — professional dashboard theme */
:root {
  --navy-950: #0f1729;
  --navy-900: #151f38;
  --navy-800: #1a2744;
  --navy-700: #243356;
  --accent: #3d5a80;
  --accent-bright: #5b7cfa;
  --bg-page: #e8ecf4;
  --bg-elevated: #ffffff;
  --text: #0f172a;
  --text-secondary: #5c6578;
  --text-muted: #8b94a7;
  --border: #e1e6ef;
  --border-strong: #cfd6e6;
  --success: #0d9f4c;
  --success-soft: #e6f7ee;
  --danger: #c81e1e;
  --danger-soft: #fdecec;
  --warning: #c26a00;
  --warning-soft: #fff4e5;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.05);
  --shadow-md: 0 4px 16px rgba(15, 23, 42, 0.07);
  --shadow-lg: 0 12px 40px rgba(15, 23, 42, 0.1);
  --radius-sm: 10px;
  --radius-md: 14px;
  --radius-lg: 18px;
  --sidebar-width: 268px;
  --font: "DM Sans", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-font-smoothing: antialiased;
}

body {
  margin: 0;
  background: var(--bg-page);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
}

button,
input {
  font: inherit;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  font-size: clamp(1.65rem, 2.2vw, 2.15rem);
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-bottom: 0;
  color: var(--text);
}

h2,
h3 {
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--text);
}

/* —— Layout —— */
.app-shell {
  display: grid;
  grid-template-columns: var(--sidebar-width) 1fr;
  min-height: 100vh;
}

/* —— Sidebar —— */
.sidebar {
  background: linear-gradient(180deg, var(--navy-900) 0%, var(--navy-950) 100%);
  color: #e8ecf8;
  padding: 28px 22px;
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  border-right: 1px solid rgba(255, 255, 255, 0.06);
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 36px;
}

.brand-mark {
  width: 44px;
  height: 44px;
  border-radius: 14px;
  background: linear-gradient(135deg, #5b7cfa 0%, #7c5cfa 100%);
  display: grid;
  place-items: center;
  color: #fff;
  flex-shrink: 0;
  box-shadow: 0 6px 20px rgba(91, 124, 250, 0.35);
}

.brand-text strong {
  display: block;
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: #fff;
}

.brand-text small {
  display: block;
  font-size: 0.78rem;
  color: rgba(232, 236, 248, 0.55);
  margin-top: 2px;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 12px;
  color: rgba(232, 236, 248, 0.72);
  text-decoration: none;
  padding: 12px 14px;
  border-radius: var(--radius-md);
  font-size: 0.92rem;
  font-weight: 500;
  transition: background 0.15s ease, color 0.15s ease;
}

.nav-link:hover {
  background: rgba(255, 255, 255, 0.06);
  color: #fff;
}

.nav-link.active {
  background: rgba(91, 124, 250, 0.22);
  color: #fff;
  box-shadow: inset 0 0 0 1px rgba(91, 124, 250, 0.35);
}

.nav-icon {
  display: flex;
  opacity: 0.85;
}

.sidebar-card {
  margin-top: auto;
  padding: 18px 16px;
  border-radius: var(--radius-lg);
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.sidebar-card-label {
  display: block;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: rgba(147, 180, 255, 0.9);
  margin-bottom: 8px;
}

.sidebar-card-title {
  display: block;
  font-size: 0.95rem;
  font-weight: 600;
  color: #fff;
  margin-bottom: 8px;
}

.sidebar-card p {
  margin: 0;
  font-size: 0.82rem;
  line-height: 1.45;
  color: rgba(232, 236, 248, 0.58);
}

/* —— Main —— */
.main {
  padding: 28px 32px 40px;
  min-width: 0;
}

.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 8px;
}

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

.page-kicker {
  margin: 0 0 6px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-muted);
}

/* —— Stats —— */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 18px;
  margin: 26px 0 28px;
}

.stat-card {
  background: var(--bg-elevated);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  padding: 20px 22px;
  position: relative;
  overflow: hidden;
}

.stat-card::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 4px;
  background: var(--border-strong);
  border-radius: 4px 0 0 4px;
}

.stat-card--success::before {
  background: linear-gradient(180deg, #22c55e, #0d9f4c);
}

.stat-card--danger::before {
  background: linear-gradient(180deg, #f87171, #c81e1e);
}

.stat-label {
  display: block;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.stat-value {
  display: block;
  margin-top: 8px;
  font-size: 1.85rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  color: var(--text);
  line-height: 1.1;
}

/* —— Cards —— */
.card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  padding: 22px 24px;
}

.card--split {
  display: grid;
  grid-template-columns: minmax(200px, 1fr) minmax(280px, 2fr);
  gap: 28px;
  align-items: center;
  margin-bottom: 22px;
}

.card--column {
  min-height: 120px;
}

.card-head,
.panel-header,
.detail-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 4px;
}

.section-kicker {
  margin: 0 0 6px;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent-bright);
}

.section-title {
  font-size: 1.25rem;
  font-weight: 600;
  margin: 0 0 8px;
}

.section-title--sm {
  font-size: 1.1rem;
  margin-bottom: 0;
}

.section-desc {
  margin: 0;
  font-size: 0.88rem;
  color: var(--text-secondary);
  max-width: 28rem;
  line-height: 1.45;
}

.create-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* —— Buttons —— */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: var(--radius-md);
  padding: 11px 18px;
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  transition: background 0.15s ease, box-shadow 0.15s ease, transform 0.1s ease;
  white-space: nowrap;
}

.btn:active {
  transform: scale(0.98);
}

.btn-primary {
  background: linear-gradient(180deg, var(--navy-700) 0%, var(--navy-800) 100%);
  color: #fff;
  box-shadow: 0 2px 8px rgba(26, 39, 68, 0.25);
}

.btn-primary:hover {
  background: linear-gradient(180deg, #2d4570 0%, var(--navy-700) 100%);
}

.btn-secondary {
  background: #fff;
  color: var(--text);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}

.btn-secondary:hover {
  background: #f8fafc;
  border-color: var(--border-strong);
}

.btn-ghost,
a.btn-ghost {
  background: #fff;
  color: var(--text);
  border: 1px solid var(--border);
  text-decoration: none;
  font-weight: 600;
}

.btn-ghost:hover {
  background: #f8fafc;
}

.btn-sm {
  padding: 8px 14px;
  font-size: 0.82rem;
}

.btn-danger-ghost {
  background: var(--danger-soft);
  color: var(--danger);
  border: 1px solid rgba(200, 30, 30, 0.2);
  font-weight: 600;
}

.btn-danger-ghost:hover {
  background: #fcd4d4;
}

.btn-muted {
  background: #f1f4f9;
  color: var(--text-secondary);
  border: 1px solid var(--border);
  font-weight: 600;
}

.btn-muted:hover {
  background: #e8ecf4;
}

input[type="text"],
input[type="file"] {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: #f8fafc;
  padding: 12px 14px;
  outline: none;
  color: var(--text);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

input[type="text"]::placeholder {
  color: var(--text-muted);
}

input[type="text"]:focus {
  border-color: var(--accent-bright);
  box-shadow: 0 0 0 3px rgba(91, 124, 250, 0.15);
  background: #fff;
}

/* —— Content grid —— */
.content-grid {
  display: grid;
  grid-template-columns: minmax(320px, 0.95fr) minmax(480px, 1.05fr);
  gap: 22px;
  align-items: start;
}

.campaign-grid {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-top: 18px;
}

.campaign-card {
  padding: 18px 18px 16px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: #fafbfd;
  cursor: pointer;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.campaign-card:hover {
  border-color: var(--border-strong);
  box-shadow: var(--shadow-sm);
}

.campaign-card.active {
  border-color: var(--accent-bright);
  background: #fff;
  box-shadow: 0 0 0 1px rgba(91, 124, 250, 0.25), var(--shadow-md);
}

.campaign-card-title {
  margin: 14px 0 6px;
  font-size: 1.05rem;
}

.card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.bulk-wrap {
  display: flex;
  align-items: center;
  cursor: pointer;
}

.bulk-check {
  width: 16px;
  height: 16px;
  accent-color: var(--navy-700);
}

.status-chip {
  border-radius: 999px;
  padding: 5px 11px;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  background: #eef2ff;
  color: #4338ca;
}

.status-chip.completed,
.status-chip.ready_for_instantly {
  color: #0d6e3a;
  background: var(--success-soft);
}

.status-chip.failed {
  color: #9b1c1c;
  background: var(--danger-soft);
}

.status-chip.processing,
.status-chip.uploading_to_instantly,
.status-chip.paused {
  color: #9a5f00;
  background: var(--warning-soft);
}

.status-chip.uploaded,
.status-chip.created {
  color: var(--text-secondary);
  background: #eef1f7;
}

.mini-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin: 14px 0 10px;
}

.mini-stats span {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  padding: 10px 10px;
  font-size: 0.78rem;
  text-align: center;
}

.mini-stats strong {
  display: block;
  color: var(--text);
  font-size: 1.05rem;
  font-weight: 700;
}

.upload-status {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.muted {
  color: var(--text-secondary);
  font-size: 0.88rem;
}

.detail-subline {
  font-size: 0.84rem;
  line-height: 1.5;
  max-width: 42rem;
  color: var(--text-secondary);
  margin-top: 8px;
}

.detail-subline strong {
  color: var(--text);
}

.detail-head h2,
#campaignDetail .panel-header h2 {
  font-size: 1.42rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin: 0 0 4px;
}

/* Detail panel inner */
.detail-panel .detail-head,
#campaignDetail .detail-head,
#campaignDetail .panel-header {
  margin-bottom: 0;
}

.detail-section {
  margin-top: 22px;
  padding-top: 22px;
  border-top: 1px solid var(--border);
}

.detail-section:first-of-type,
.detail-section.pipeline-block {
  border-top: 0;
  padding-top: 0;
  margin-top: 18px;
}

.pipeline-block {
  margin-top: 20px;
}

.pipeline-progress-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.pipeline-pct {
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text);
}

.pipeline-label {
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  color: var(--text-muted);
}

.progress {
  width: 100%;
  height: 10px;
  overflow: hidden;
  background: #e8ecf4;
  border-radius: 999px;
}

.progress span {
  display: block;
  height: 100%;
  width: 0%;
  border-radius: inherit;
  background: linear-gradient(90deg, #22c55e, #16a34a);
  transition: width 0.35s ease;
}

.detail-section h3 {
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 12px;
}

.detail-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
}

.detail-actions h3 {
  margin: 0;
  align-self: center;
  flex-shrink: 0;
}

.detail-actions > div {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.upload-form,
.instantly-form {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: stretch;
}

.upload-form .btn,
.instantly-form .btn {
  align-self: center;
}

.log-toolbar,
.file-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.log-toolbar h3,
.file-toolbar h3 {
  margin-bottom: 0;
}

.log-toolbar-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.files-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.file-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 14px 16px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: #fafbfd;
}

.file-row strong {
  display: block;
  font-size: 0.95rem;
  color: var(--text);
}

.file-row small {
  display: block;
  margin-top: 4px;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.logs-panel {
  max-height: 300px;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-right: 4px;
}

.log-item {
  border-left: 3px solid var(--accent-bright);
  background: #f6f8fc;
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-left-width: 3px;
}

.log-item strong {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text);
}

.log-item small {
  display: block;
  margin-top: 4px;
  font-size: 0.76rem;
  color: var(--text-muted);
}

.empty-state {
  min-height: 280px;
  display: grid;
  place-items: center;
  text-align: center;
  color: var(--text-muted);
  padding: 24px;
}

.empty-inner {
  max-width: 360px;
}

.empty-inner p {
  margin: 0;
  line-height: 1.55;
}

/* FAB */
.fab {
  position: fixed;
  right: 28px;
  bottom: 28px;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  border: 0;
  cursor: pointer;
  display: grid;
  place-items: center;
  color: #fff;
  background: linear-gradient(135deg, var(--navy-700), #1e3a5f);
  box-shadow: var(--shadow-lg);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  z-index: 40;
}

.fab:hover {
  transform: scale(1.05);
  box-shadow: 0 16px 48px rgba(15, 23, 42, 0.18);
}

.toast {
  position: fixed;
  right: 24px;
  bottom: 96px;
  padding: 14px 18px;
  border-radius: var(--radius-md);
  color: #fff;
  background: var(--navy-900);
  box-shadow: var(--shadow-lg);
  font-size: 0.9rem;
  font-weight: 500;
  z-index: 50;
  max-width: 320px;
}

/* Legacy class aliases (detail HTML from app.js) */
.panel-header,
.detail-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.eyebrow {
  margin: 0 0 6px;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent-bright);
}

.button {
  border: 0;
  border-radius: var(--radius-md);
  padding: 11px 16px;
  cursor: pointer;
  font-weight: 600;
  font-size: 0.88rem;
  transition: 0.15s ease;
}

.button.primary,
a.button.primary {
  background: linear-gradient(180deg, var(--navy-700), var(--navy-800));
  color: #fff;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.button.primary:hover {
  filter: brightness(1.06);
}

.button.ghost,
a.button.ghost {
  background: #fff;
  color: var(--text);
  border: 1px solid var(--border);
  text-decoration: none;
}

.button.subtle {
  background: #f1f4f9;
  color: var(--text-secondary);
  border: 1px solid var(--border);
}

.button.danger.subtle {
  color: var(--danger);
  background: var(--danger-soft);
  border-color: rgba(200, 30, 30, 0.2);
}

@media (max-width: 1100px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    gap: 16px;
  }

  .sidebar-nav {
    flex-direction: row;
    flex-wrap: wrap;
  }

  .sidebar-card {
    margin-top: 0;
    flex: 1;
    min-width: 200px;
  }

  .stats-grid,
  .content-grid,
  .card--split {
    grid-template-columns: 1fr;
  }

  .fab {
    right: 18px;
    bottom: 18px;
  }
}

@media (max-width: 720px) {
  .main {
    padding: 18px;
  }

  .topbar,
  .topbar-actions,
  .detail-actions,
  .create-form,
  .upload-form,
  .instantly-form {
    flex-direction: column;
    align-items: stretch;
  }
}

/* —— Dashboard login —— */
.login-gate {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: linear-gradient(165deg, var(--navy-950) 0%, var(--navy-800) 45%, var(--bg-page) 100%);
}

.login-gate[hidden] {
  display: none !important;
}

.app-shell[hidden] {
  display: none !important;
}

.login-card {
  width: 100%;
  max-width: 400px;
  background: var(--bg-elevated);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
  padding: 28px 28px 26px;
}

.login-brand {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 8px;
}

.login-brand .brand-mark {
  display: flex;
  color: var(--accent-bright);
}

.login-brand strong {
  display: block;
  font-size: 1.15rem;
}

.login-brand small {
  color: var(--text-muted);
  font-size: 0.82rem;
}

.login-hint {
  font-size: 0.85rem;
  margin: 0 0 20px;
}

.login-hint code {
  font-size: 0.78rem;
  background: var(--bg-page);
  padding: 2px 6px;
  border-radius: 6px;
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.login-label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.login-label input {
  padding: 11px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: #fbfcfe;
}

.login-label input:focus {
  outline: 2px solid rgba(91, 124, 250, 0.35);
  border-color: var(--accent-bright);
}

.login-error {
  margin: 0;
  font-size: 0.86rem;
  color: var(--danger);
}

.btn-block {
  width: 100%;
  justify-content: center;
}
