:root {
  --bg: #0f1117;
  --surface: #1a1d27;
  --border: #2a2d3a;
  --text: #e2e8f0;
  --muted: #64748b;
  --accent: #6366f1;
  --ok: #22c55e;
  --warn: #f59e0b;
  --err: #ef4444;
  --none: #475569;
}

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

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

/* ── header ── */
header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 24px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 100;
}
.site-title { font-size: 16px; font-weight: 700; color: var(--accent); letter-spacing: -.3px; }
.header-right { display: flex; align-items: center; gap: 12px; }
.user-name { color: var(--muted); font-size: 13px; }
.btn-logout {
  color: var(--muted); font-size: 12px; text-decoration: none;
  padding: 4px 10px; border: 1px solid var(--border); border-radius: 4px;
  transition: color .15s, border-color .15s;
}
.btn-logout:hover { color: var(--text); border-color: var(--muted); }

/* ── layout ── */
main { padding: 24px; max-width: 1400px; margin: 0 auto; }

.toolbar {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 14px;
}
.toolbar h2 { font-size: 15px; font-weight: 600; }
.toolbar-right { display: flex; align-items: center; gap: 8px; }

/* ── grid ── */
.automations-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 10px;
  margin-bottom: 32px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--border);
  border-radius: 8px;
  padding: 12px 14px;
  display: flex; flex-direction: column; gap: 8px;
}
.card.lvl-error { border-left-color: var(--err); }
.card.lvl-warn  { border-left-color: var(--warn); }
.card.lvl-info  { border-left-color: var(--ok); }

.card-header { display: flex; align-items: center; justify-content: space-between; gap: 6px; }
.card-name { font-weight: 600; font-size: 13px; }

.dot {
  width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0;
}
.dot-ok   { background: var(--ok); }
.dot-warn { background: var(--warn); }
.dot-err  { background: var(--err); box-shadow: 0 0 6px var(--err); }
.dot-none { background: var(--none); }

.card-meta { display: flex; flex-direction: column; gap: 2px; }
.card-schedule { font-size: 11px; color: var(--muted); }
.card-lastrun  { font-size: 11px; color: var(--muted); }

.card-actions { display: flex; gap: 6px; }

/* ── buttons ── */
button, .btn {
  cursor: pointer; border: 1px solid var(--border);
  border-radius: 4px; background: transparent; color: var(--text);
  padding: 4px 10px; font-size: 12px;
  transition: background .12s, border-color .12s, color .12s;
  font-family: inherit;
}
button:hover { background: rgba(255,255,255,.05); }
button:disabled { opacity: .45; cursor: not-allowed; }

.btn-on  { color: var(--ok);  border-color: rgba(34,197,94,.4); }
.btn-off { color: var(--none); }
.btn-run { min-width: 32px; text-align: center; }
.btn-run.success { color: var(--ok); }
.btn-run.fail    { color: var(--err); }

select {
  background: var(--surface); color: var(--text);
  border: 1px solid var(--border); border-radius: 4px;
  padding: 4px 8px; font-size: 12px; cursor: pointer;
  font-family: inherit;
}

#last-updated { font-size: 11px; color: var(--muted); }

/* ── log section ── */
.log-section { margin-top: 8px; }

.log-output {
  background: #0a0c10;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 12px;
  height: 380px;
  overflow-y: auto;
  font-family: 'Menlo', 'Consolas', 'Courier New', monospace;
  font-size: 12px;
  line-height: 1.6;
}
.log-line { white-space: pre-wrap; word-break: break-all; padding: 1px 0; }
.log-error { color: #ff6b6b; }
.log-warn  { color: #ffd166; }
.log-info  { color: #5a6478; }
.log-auto  { color: #818cf8; font-weight: 600; }
.log-empty { color: var(--muted); text-align: center; padding: 24px; }

/* ── error panel ── */
.errors-panel {
  background: var(--surface); border: 1px solid rgba(239,68,68,.3);
  border-radius: 8px; padding: 14px; margin-bottom: 24px;
}
.errors-panel h3 { font-size: 13px; color: var(--err); margin-bottom: 10px; }
.error-item {
  border-top: 1px solid var(--border); padding: 8px 0;
  font-size: 12px;
}
.error-item:first-child { border-top: none; }
.error-auto { color: var(--accent); font-weight: 600; margin-right: 6px; }
.error-ts   { color: var(--muted); margin-right: 6px; }
.error-msg  { color: #fca5a5; }

/* ── login ── */
.login-body {
  display: flex; align-items: center; justify-content: center; min-height: 100vh;
}
.login-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 12px; padding: 40px; text-align: center; width: 320px;
}
.logo { font-size: 26px; font-weight: 700; color: var(--accent); margin-bottom: 4px; }
.login-sub { font-size: 13px; color: var(--muted); margin-bottom: 28px; }
.alert-error {
  background: rgba(239,68,68,.1); border: 1px solid rgba(239,68,68,.3);
  color: #fca5a5; border-radius: 6px; padding: 10px; font-size: 13px;
  margin-bottom: 16px;
}
.btn-google {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  background: #fff; color: #3c4043; border: 1px solid #ddd;
  border-radius: 6px; padding: 11px 20px; text-decoration: none;
  font-size: 14px; font-weight: 500; width: 100%;
  transition: background .12s, box-shadow .12s;
}
.btn-google:hover { background: #f7f7f7; box-shadow: 0 1px 4px rgba(0,0,0,.2); }
