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

:root {
  --primary:    #4f46e5;
  --primary-dk: #3730a3;
  --teal:       #0891b2;
  --teal-dk:    #0e7490;
  --success:    #059669;
  --warn:       #d97706;
  --danger:     #dc2626;
  --bg:         #f1f5f9;
  --surface:    #ffffff;
  --border:     #e2e8f0;
  --text:       #1e293b;
  --muted:      #64748b;
  --radius:     8px;
}

body {
  font-family: system-ui, -apple-system, sans-serif;
  font-size: 14px;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

/* ── Nav ── */
nav {
  background: linear-gradient(135deg, #312e81 0%, #4f46e5 100%);
  padding: 0 1.5rem;
  display: flex;
  align-items: center;
  gap: 2rem;
  height: 52px;
  box-shadow: 0 2px 8px rgba(79,70,229,.35);
}
.nav-brand {
  color: #fff;
  font-weight: 700;
  font-size: 15px;
  letter-spacing: .5px;
  white-space: nowrap;
}
.nav-links { display: flex; gap: 1.5rem; flex: 1; }
.nav-links a { color: #c7d2fe; text-decoration: none; font-weight: 500; font-size: 13px; padding: 0.25rem 0; border-bottom: 2px solid transparent; transition: color .15s, border-color .15s; }
.nav-links a:hover { color: #fff; border-bottom-color: #818cf8; }
.nav-user { display: flex; align-items: center; gap: 0.75rem; }
.nav-email { color: #a5b4fc; font-size: 12px; }
.btn-logout { background: rgba(255,255,255,.12); color: #e0e7ff; border: 1px solid rgba(255,255,255,.2); border-radius: 5px; padding: 0.3rem 0.7rem; font-size: 12px; cursor: pointer; transition: background .15s; }
.btn-logout:hover { background: rgba(255,255,255,.22); }

/* ── Layout ── */
main { padding: 1.5rem 2rem; max-width: 1280px; }
h1 { font-size: 1.5rem; font-weight: 700; margin-bottom: 1.25rem; color: var(--text); }
h2 { font-size: 1rem; font-weight: 600; margin: 0 0 0.75rem; color: var(--text); }

section {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 1.25rem 1.5rem;
  margin-bottom: 1.25rem;
  box-shadow: 0 1px 4px rgba(0,0,0,.07), 0 0 0 1px var(--border);
}

/* ── Tables ── */
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 0.55rem 0.75rem; border-bottom: 1px solid var(--border); }
th { background: #f8fafc; font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); }
tr:last-child td { border-bottom: none; }
tr:hover td { background: #f8fafc; }
.row-error td { background: #fff5f5; }
.row-warn  td { background: #fffbeb; }
.muted { color: var(--muted); font-size: 12px; }
.mono-small { font-family: monospace; font-size: 12px; }
.detail { font-size: 12px; color: var(--muted); max-width: 280px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.log-count { font-size: 12px; color: var(--muted); margin-top: 0.5rem; text-align: right; }
.empty-state { color: var(--muted); font-style: italic; padding: 0.5rem 0; }

/* ── Forms ── */
input, select, textarea {
  display: block;
  width: 100%;
  padding: 0.45rem 0.7rem;
  border: 1.5px solid var(--border);
  border-radius: 6px;
  font-size: 13px;
  margin-top: 0.25rem;
  transition: border-color .15s, box-shadow .15s;
  background: #fff;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(79,70,229,.12);
}
textarea { font-family: monospace; resize: vertical; }
label { display: block; margin-bottom: 0.75rem; font-weight: 500; color: #374151; font-size: 13px; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 0.75rem 1rem; margin-bottom: 0.75rem; }

.inline-form { display: flex; gap: 0.75rem; align-items: flex-end; flex-wrap: wrap; }
.inline-form input { margin-top: 0; width: auto; flex: 1; min-width: 160px; }
.inline-form button { flex-shrink: 0; }

.filter-bar { display: flex; gap: 1rem; align-items: flex-end; flex-wrap: wrap; }
.filter-bar label { margin-bottom: 0; }
.filter-bar select { margin-top: 0.2rem; width: auto; min-width: 120px; }
.filter-actions { display: flex; gap: 0.5rem; align-items: center; margin-top: 1.1rem; }

/* ── Buttons ── */
button, .btn-sm {
  padding: 0.4rem 0.85rem;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  text-decoration: none;
  display: inline-block;
  transition: background .15s, transform .08s;
  white-space: nowrap;
}
button:hover, .btn-sm:hover { background: var(--primary-dk); }
button:active { transform: scale(.97); }
.btn-danger  { background: var(--danger); }
.btn-danger:hover  { background: #b91c1c; }
.btn-warn    { background: var(--warn); }
.btn-warn:hover    { background: #b45309; }
.btn-secondary { background: #e2e8f0; color: var(--text); }
.btn-secondary:hover { background: #cbd5e1; }
a.btn-sm { line-height: 1.6; }

/* ── Flash ── */
.flash { padding: 0.65rem 1rem; border-radius: 6px; margin-bottom: 1rem; font-weight: 500; font-size: 13px; border-left: 4px solid; }
.flash--success { background: #ecfdf5; color: #065f46; border-color: var(--success); }
.flash--error   { background: #fef2f2; color: #991b1b; border-color: var(--danger); }

/* ── Badges ── */
.badge { display: inline-flex; align-items: center; gap: 3px; padding: 0.2rem 0.55rem; border-radius: 20px; font-size: 11px; font-weight: 600; letter-spacing: .3px; }
.badge--ok     { background: #d1fae5; color: #065f46; }
.badge--warn   { background: #fef3c7; color: #92400e; }
.badge--error  { background: #fee2e2; color: #991b1b; }
.badge--info   { background: #dbeafe; color: #1e40af; }
.badge--idle   { background: #f1f5f9; color: var(--muted); }
.badge--teal   { background: #cffafe; color: #164e63; }
.badge--blue   { background: #dbeafe; color: #1e40af; }
.badge--purple { background: #ede9fe; color: #5b21b6; }
.badge--gray   { background: #f1f5f9; color: var(--muted); }

/* ── Scheduler bar ── */
.scheduler-bar {
  display: flex; align-items: center; gap: 0.75rem;
  background: linear-gradient(135deg, #eef2ff 0%, #f0fdfa 100%);
  border: 1px solid #c7d2fe;
  border-radius: var(--radius);
  padding: 0.65rem 1rem;
  margin-bottom: 1.25rem;
  font-size: 13px;
  flex-wrap: wrap;
}
.scheduler-bar strong { color: var(--primary); }
.sep { color: #c7d2fe; }

/* ── Links ── */
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
.link-strong { font-weight: 600; color: var(--primary); }

/* ── Helpers ── */
p { margin: 0.5rem 0; }
small { color: var(--muted); font-size: 12px; display: block; }
code { background: #f1f5f9; padding: 0.1rem 0.35rem; border-radius: 4px; font-family: monospace; font-size: 12px; }
.hint { font-size: 11px; color: var(--muted); margin-top: 2px; }
.hint--error { color: var(--danger); }

.help { display: block; margin-top: 0.25rem; font-size: 12px; color: var(--muted); font-weight: 400; line-height: 1.5; }
.help code { background: #f1f5f9; }

.edit-section { border: 2px solid var(--primary); }
.row-editing td { background: #eef2ff; }

/* ── Connect form ── */
.connect-details summary { cursor: pointer; list-style: none; }
.connect-details summary::-webkit-details-marker { display: none; }
.connect-form { margin-top: 0.75rem; padding: 1rem; background: #f8fafc; border: 1px solid var(--border); border-radius: var(--radius); min-width: 320px; display: flex; flex-direction: column; gap: 0.5rem; }
.connect-form label { font-size: 13px; }
.connect-form button { align-self: flex-start; margin-top: 0.25rem; }

/* ── Login page ── */
.login-body {
  background: linear-gradient(135deg, #312e81 0%, #4f46e5 60%, #0891b2 100%);
  display: flex; align-items: center; justify-content: center; min-height: 100vh;
}
.login-card {
  background: #fff; border-radius: 16px; padding: 2.5rem 2rem;
  width: 100%; max-width: 380px;
  box-shadow: 0 20px 60px rgba(0,0,0,.25);
  text-align: center;
}
.login-logo { margin-bottom: 1rem; }
.login-card h1 { font-size: 1.3rem; color: var(--text); margin-bottom: 0.25rem; }
.login-subtitle { color: var(--muted); font-size: 13px; margin-bottom: 1.5rem; }
.login-error { background: #fef2f2; color: #991b1b; border: 1px solid #fecaca; border-radius: 6px; padding: 0.6rem 0.75rem; margin-bottom: 1rem; font-size: 13px; }
.login-form { text-align: left; }
.login-form label { margin-bottom: 1rem; font-size: 13px; font-weight: 500; }
.login-form input { font-size: 14px; padding: 0.6rem 0.8rem; }
.login-btn { width: 100%; margin-top: 0.5rem; padding: 0.65rem; font-size: 14px; font-weight: 600; background: linear-gradient(135deg, #4f46e5, #0891b2); border-radius: 8px; }
.login-btn:hover { background: linear-gradient(135deg, #3730a3, #0e7490); }
