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

:root {
  --navy: #0f172a;
  --navy-light: #1e293b;
  --blue: #2563eb;
  --blue-light: #eff6ff;
  --green: #16a34a;
  --amber: #d97706;
  --red: #dc2626;
  --red-light: #fef2f2;
  --slate: #64748b;
  --slate-light: #f8fafc;
  --border: #e2e8f0;
  --text: #1e293b;
  --text-muted: #64748b;
  --radius: 8px;
  --shadow: 0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.05);
}

body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; font-size: 14px; color: var(--text); background: #f1f5f9; }

/* ── Layout ── */
.layout { display: flex; min-height: 100vh; }

.sidebar {
  width: 220px; min-height: 100vh; background: var(--navy);
  display: flex; flex-direction: column; padding-top: 24px; flex-shrink: 0;
}
.sidebar-brand {
  font-size: 16px; font-weight: 700; color: #fff; padding: 0 20px 24px;
  border-bottom: 1px solid rgba(255,255,255,.1); margin-bottom: 12px;
  line-height: 1.3;
}
.sidebar-brand span { color: #94a3b8; font-weight: 400; font-size: 13px; }
.sidebar-spacer { flex: 1; }

.nav-link {
  display: flex; align-items: center; gap: 10px; padding: 10px 20px;
  color: #94a3b8; text-decoration: none; font-size: 13px; font-weight: 500;
  border-radius: 0; transition: background .15s, color .15s;
}
.nav-link:hover { background: rgba(255,255,255,.06); color: #e2e8f0; }
.nav-link.active { background: rgba(255,255,255,.1); color: #fff; border-right: 3px solid var(--blue); }
.nav-link svg { flex-shrink: 0; opacity: .7; }
.nav-link.active svg { opacity: 1; }

.btn-logout {
  width: 100%; padding: 8px 12px; background: rgba(255,255,255,.06); border: 1px solid rgba(255,255,255,.1);
  color: #94a3b8; font-size: 12px; border-radius: 6px; cursor: pointer; text-align: left;
}
.btn-logout:hover { background: rgba(255,255,255,.1); color: #e2e8f0; }

.content { flex: 1; padding: 32px; overflow: auto; }

/* ── Login ── */
.login-page { background: #f1f5f9; display: flex; align-items: center; justify-content: center; min-height: 100vh; }
.login-card { background: #fff; border-radius: 12px; padding: 40px; width: 360px; box-shadow: var(--shadow); }
.login-brand { font-size: 20px; font-weight: 700; color: var(--navy); margin-bottom: 4px; }
.login-sub { font-size: 13px; color: var(--slate); margin-bottom: 24px; }

/* ── Page headers ── */
.page-header { margin-bottom: 28px; }
.page-title { font-size: 22px; font-weight: 700; color: var(--navy); }
.page-sub { font-size: 13px; color: var(--slate); margin-top: 4px; }
.back-link { font-size: 13px; color: var(--blue); text-decoration: none; display: block; margin-bottom: 8px; }
.back-link:hover { text-decoration: underline; }

/* ── Stats cards ── */
.stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 32px; }
.stat-card { background: #fff; border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); }
.stat-card--alert { border-left: 3px solid var(--red); }
.stat-value { font-size: 28px; font-weight: 700; color: var(--navy); }
.stat-card--alert .stat-value { color: var(--red); }
.stat-label { font-size: 12px; color: var(--slate); margin-top: 4px; text-transform: uppercase; letter-spacing: .5px; }

/* ── Sections ── */
.section { background: #fff; border-radius: var(--radius); padding: 24px; box-shadow: var(--shadow); margin-bottom: 20px; }
.section-title { font-size: 15px; font-weight: 600; color: var(--navy); margin-bottom: 16px; }

/* ── Tables ── */
.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th { text-align: left; padding: 10px 12px; font-size: 11px; font-weight: 600; color: var(--slate); text-transform: uppercase; letter-spacing: .5px; border-bottom: 2px solid var(--border); }
.table td { padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tr:last-child td { border-bottom: none; }
.table tr:hover td { background: var(--slate-light); }
.error-cell { max-width: 260px; font-size: 12px; color: var(--red); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ── Forms ── */
.field { display: flex; flex-direction: column; gap: 6px; }
.field--wide { flex: 1; }
.field label { font-size: 12px; font-weight: 500; color: var(--slate); }
.field input { padding: 8px 12px; border: 1px solid var(--border); border-radius: 6px; font-size: 13px; outline: none; }
.field input:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(37,99,235,.1); }
.inline-form { display: flex; }
.field-row { display: flex; align-items: flex-end; gap: 12px; width: 100%; flex-wrap: wrap; }

/* ── Buttons ── */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 8px 16px; border-radius: 6px; font-size: 13px; font-weight: 500; cursor: pointer; border: none; text-decoration: none; }
.btn-primary { background: var(--blue); color: #fff; }
.btn-primary:hover { background: #1d4ed8; }
.btn-outline { background: transparent; color: var(--blue); border: 1px solid var(--blue); }
.btn-outline:hover { background: var(--blue-light); }
.btn-danger { background: transparent; color: var(--red); border: 1px solid var(--red); }
.btn-danger:hover { background: var(--red-light); }
.btn-full { width: 100%; justify-content: center; }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-xs { padding: 3px 8px; font-size: 11px; }
.btn-disabled { background: var(--border); color: var(--slate); cursor: default; }
.btn-add { align-self: flex-end; white-space: nowrap; }

/* ── Badges & Status dots ── */
.badge { display: inline-block; padding: 2px 8px; border-radius: 10px; font-size: 11px; font-weight: 600; }
.badge-pending { background: #f1f5f9; color: #475569; }
.badge-running { background: #eff6ff; color: #1d4ed8; }
.badge-completed { background: #f0fdf4; color: #15803d; }
.badge-failed { background: #fef2f2; color: #dc2626; }

.dot { display: inline-block; width: 14px; height: 14px; border-radius: 50%; font-size: 8px; font-weight: 700; color: #fff; text-align: center; line-height: 14px; }
.dot-grey { background: #cbd5e1; }
.dot.badge-pending { background: #94a3b8; }
.dot.badge-running { background: var(--blue); }
.dot.badge-completed { background: var(--green); }
.dot.badge-failed { background: var(--red); }

.job-dots { display: flex; align-items: center; gap: 12px; }
.dot-group { display: flex; align-items: center; gap: 3px; }
.dot-label { font-size: 10px; color: var(--slate); margin-left: 2px; }
.legend { display: flex; align-items: center; gap: 4px; font-size: 12px; color: var(--slate); margin-bottom: 16px; flex-wrap: wrap; }

/* ── Alerts ── */
.alert { padding: 10px 14px; border-radius: 6px; font-size: 13px; margin-bottom: 16px; }
.alert-error { background: var(--red-light); color: #991b1b; border: 1px solid #fecaca; }
.alert-success { background: #f0fdf4; color: #166534; border: 1px solid #bbf7d0; }
.alert-warning { background: #fffbeb; color: #92400e; border: 1px solid #fde68a; }

/* ── Misc ── */
.empty-state { padding: 48px; text-align: center; color: var(--slate); background: #fff; border-radius: var(--radius); }
.code-id { font-family: monospace; font-size: 11px; background: var(--slate-light); padding: 2px 6px; border-radius: 4px; color: var(--slate); }
.report-container { border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }

/* Preview send bar */
.preview-send-bar { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.preview-send-form { display: flex; align-items: center; gap: 8px; }
.preview-send-input { width: 260px; }
.preview-send-feedback { font-size: 13px; }
.preview-send-ok { color: #16a34a; }
.preview-send-error { color: var(--red); }
