:root {
  /* accent */
  --accent: #5a78e8;
  --accent-hover: #4a68d8;

  /* dark sidebar */
  --side-bg: #141a23;
  --side-border: #20272f;
  --side-title: #5a6475;
  --side-text: #8a94a6;
  --side-active-bg: #5a78e8;

  /* dark sign-in */
  --dk-bg: #0e1116;
  --dk-card: #161c25;
  --dk-border: #232c39;
  --dk-input: #1c2430;
  --dk-input-border: #2a323d;
  --dk-text: #eef2f8;
  --dk-muted: #8a94a6;
  --dk-faint: #6a7585;

  /* light content */
  --bg: #fbfbfc;
  --card: #ffffff;
  --border: #e9ebf1;
  --line: #eef1f5;
  --heading: #1a2230;
  --text: #3a4250;
  --muted: #6a7585;
  --faint: #8a94a6;

  /* status */
  --green: #1f9d57; --green-bg: #e7f6ec;
  --amber: #b7791f; --amber-bg: #fbf0db; --amber-border: #f0dca8;
  --red: #e5484d; --red-bg: #fceced;
  --info: #3a64d8; --info-bg: #eaf0fe;
  --dot-green: #35c46a;

  --r-card: 13px;
  --r: 8px;
  --mono: 'IBM Plex Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--text); font-family: var(--sans); font-size: 13px; line-height: 1.5; -webkit-font-smoothing: antialiased; }
.mono { font-family: var(--mono); }
a { color: var(--accent); text-decoration: none; }
h1, h2, h3 { color: var(--heading); }

/* ============================ App shell ============================ */
.app-shell { display: flex; min-height: 100vh; }

.sidebar {
  width: 252px; flex-shrink: 0;
  background: var(--side-bg);
  border-right: 1px solid var(--side-border);
  padding: 16px 12px 14px;
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh;
}
.brand { display: flex; align-items: center; gap: 9px; padding: 2px 6px 16px; }
.brand-tile { width: 30px; height: 30px; border-radius: 8px; background: linear-gradient(135deg, #5a78e8, #7c93ee); display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.brand-name { color: #fff; font-weight: 600; font-size: 13px; line-height: 1.15; }
.brand-sub { color: var(--side-faint, #5a6475); font-family: var(--mono); font-size: 9.5px; color: #5a6475; margin-top: 2px; }

.nav-group { margin-top: 14px; }
.nav-group-title { color: var(--side-title); font-size: 9.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .12em; padding: 0 8px 7px; }
.nav-item {
  display: flex; align-items: center; gap: 9px;
  padding: 7px 8px; margin-bottom: 2px; border-radius: 7px;
  color: var(--side-text); font-size: 12.5px; cursor: pointer; position: relative;
  background: none; border: 0; width: 100%; text-align: left; font-family: var(--sans);
}
.nav-item:hover { background: #1b222d; color: #c3cad6; text-decoration: none; }
.nav-item.active { background: var(--side-active-bg); color: #fff; }
.nav-item.active:hover { background: var(--side-active-bg); color: #fff; }
.nav-item .ico { width: 17px; height: 17px; display: inline-flex; flex-shrink: 0; }
.nav-item .label { flex: 1; }
.nav-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--dot-green); flex-shrink: 0; }
.nav-badge { background: var(--red); color: #fff; font-size: 10px; font-weight: 600; min-width: 16px; height: 16px; border-radius: 8px; display: inline-flex; align-items: center; justify-content: center; padding: 0 4px; }

.side-spacer { flex: 1; }
.side-foot { border-top: 1px solid var(--side-border); padding-top: 10px; }
.run-status { display: flex; align-items: center; gap: 7px; color: var(--side-text); font-family: var(--mono); font-size: 10.5px; padding: 2px 6px 9px; }
.run-status .pulse { width: 7px; height: 7px; border-radius: 50%; background: var(--dot-green); flex-shrink: 0; }
.lock-btn { display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%; padding: 8px; border: 1px solid var(--side-border); border-radius: 8px; background: none; color: var(--side-text); font-family: var(--sans); font-size: 12px; cursor: pointer; }
.lock-btn:hover { background: #1b222d; color: #c3cad6; }

/* ============================ Content ============================ */
.content { flex: 1; padding: 26px 40px 60px; max-width: 1060px; }
.page-title { font-size: 22px; font-weight: 700; margin: 0 0 4px; letter-spacing: -.01em; }
.page-sub { color: var(--muted); margin: 0 0 22px; font-size: 12.5px; }

/* ============================ Cards & grid ============================ */
.grid { display: grid; gap: 13px; }
.grid.cols-3 { grid-template-columns: repeat(3, 1fr); }
@media (max-width: 760px) { .grid.cols-3 { grid-template-columns: 1fr; } }

.card { background: var(--card); border: 1px solid var(--border); border-radius: var(--r-card); padding: 16px 18px; }
.card.pad-lg { padding: 18px 20px; }

/* metric card */
.metric .m-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.metric .m-label { color: var(--faint); font-size: 10.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .07em; }
.metric .m-value { font-size: 22px; font-weight: 700; color: var(--heading); display: flex; align-items: center; gap: 8px; }
.metric .m-value.red { color: var(--red); }
.metric .m-sub { color: var(--muted); font-family: var(--mono); font-size: 11.5px; margin-top: 6px; }
.dot-accent { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); display: inline-block; }

/* run-config rows */
.cfg-title { font-size: 13.5px; font-weight: 600; margin: 0 0 14px; }
.cfg-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 48px; }
.cfg-row { display: flex; justify-content: space-between; align-items: center; padding: 9px 0; border-bottom: 1px solid var(--line); }
.cfg-row .k { color: var(--muted); font-size: 12.5px; }
.cfg-row .v { color: var(--heading); font-weight: 700; font-family: var(--mono); font-size: 12.5px; }

/* key/value 2-col rows (connection pages) */
.kv-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 48px; padding-top: 4px; }
.kv-row { display: flex; justify-content: space-between; align-items: baseline; padding: 9px 0; border-top: 1px solid var(--line); gap: 16px; }
.kv-row .k { color: var(--muted); font-size: 12px; white-space: nowrap; }
.kv-row .v { color: var(--heading); font-family: var(--mono); font-size: 12px; font-weight: 600; text-align: right; }
.kv-row .v.green { color: var(--green); }
.kv-row .v.red { color: var(--red); }

/* ============================ Pills, dots, tags ============================ */
.pill { display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: 999px; font-size: 11px; font-weight: 600; line-height: 1.6; }
.pill.green { color: var(--green); background: var(--green-bg); }
.pill.amber { color: var(--amber); background: var(--amber-bg); }
.pill.red { color: var(--red); background: var(--red-bg); }
.pill.info { color: var(--info); background: var(--info-bg); }
.pill.muted { color: var(--muted); background: #f0f2f6; }
.tag-rule { color: var(--accent); font-weight: 700; font-size: 12px; }
.reach-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--dot-green); display: inline-block; margin-right: 6px; }

/* ============================ Buttons ============================ */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border-radius: var(--r); padding: 9px 16px; font-family: var(--sans); font-size: 12.5px; font-weight: 600; cursor: pointer; border: 1px solid transparent; }
.btn.primary { background: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-hover); text-decoration: none; }
.btn.dark { background: #1a2230; color: #fff; }
.btn.dark:hover { background: #2a3441; }
.btn.outline { background: #fff; color: var(--heading); border-color: var(--border); }
.btn.outline:hover { background: #f6f7fa; }
.btn.outline.amber { color: var(--amber); border-color: var(--amber-border); background: #fffaf0; }
.btn.sm { padding: 6px 13px; font-size: 12px; }

/* ============================ Forms ============================ */
.field { margin-bottom: 14px; }
.field label, .form-label { display: block; color: var(--faint); font-size: 10.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; margin-bottom: 6px; }
.input, select.input { width: 100%; background: #fff; border: 1px solid var(--border); color: var(--heading); border-radius: var(--r); padding: 9px 12px; font-family: var(--mono); font-size: 12.5px; }
.input:focus { outline: none; border-color: var(--accent); }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

/* stepper (thresholds) */
.stepper { display: inline-flex; align-items: center; gap: 8px; }
.stepper .step-btn { width: 30px; height: 32px; border: 1px solid var(--border); background: #fff; border-radius: 7px; color: var(--muted); font-size: 16px; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; }
.stepper .step-btn:hover { background: #f6f7fa; }
.stepper .step-val { width: 56px; height: 32px; border: 1px solid var(--border); border-radius: 7px; text-align: center; font-family: var(--mono); font-weight: 700; color: var(--heading); font-size: 13px; }
.stepper .step-unit { color: var(--muted); font-size: 12px; min-width: 48px; }

/* ============================ Tables ============================ */
.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; color: var(--faint); font-weight: 600; font-size: 10px; text-transform: uppercase; letter-spacing: .06em; padding: 9px 12px; border-bottom: 1px solid var(--border); }
.table td { padding: 11px 12px; border-bottom: 1px solid var(--line); color: var(--heading); font-size: 12.5px; vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table .mono { font-family: var(--mono); color: var(--muted); }
.table .chev { color: var(--faint); text-align: right; }
.row-click { cursor: pointer; }
.row-click:hover td { background: #fafbfd; }
.detail-row td { background: #fafbfd; padding: 0; }
.detail-box { padding: 14px 18px; }
.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 48px; margin-bottom: 12px; }
.detail-grid .k { color: var(--muted); font-size: 11.5px; }
.detail-grid .v { color: var(--heading); font-family: var(--mono); font-size: 11.5px; font-weight: 600; text-align: right; }
.notes-label { color: var(--faint); font-size: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; margin-bottom: 6px; }
.notes-box { background: #fff; border: 1px solid var(--border); border-radius: 8px; padding: 12px 14px; font-family: var(--mono); font-size: 11.5px; color: var(--text); }

/* filters */
.filters { display: inline-flex; gap: 6px; background: #f0f2f6; padding: 4px; border-radius: 9px; margin-bottom: 18px; }
.filter { padding: 6px 16px; border-radius: 7px; color: var(--muted); font-size: 12.5px; font-weight: 600; cursor: pointer; }
.filter.active { background: var(--accent); color: #fff; }
.filter:hover:not(.active) { color: var(--heading); text-decoration: none; }

/* ============================ Errors cards ============================ */
.err-card { background: var(--card); border: 1px solid var(--border); border-radius: var(--r-card); border-left-width: 4px; padding: 14px 18px; margin-bottom: 13px; }
.err-card.permanent { border-left-color: var(--red); }
.err-card.transient { border-left-color: var(--amber); }
.err-card.warning { border-left-color: var(--accent); }
.err-head { display: flex; align-items: center; gap: 9px; }
.err-head .grow { flex: 1; }
.err-title { font-weight: 600; color: var(--heading); font-size: 13px; }
.err-body { color: var(--muted); font-size: 12.5px; margin: 8px 0 9px; }
.err-meta { font-family: var(--mono); font-size: 11px; color: var(--faint); }
.err-actions { display: flex; gap: 8px; }

/* banner (info / amber) */
.banner { display: flex; align-items: center; gap: 9px; border-radius: 9px; padding: 10px 14px; font-size: 12px; margin: 16px 0; }
.banner.amber { background: var(--amber-bg); border: 1px solid var(--amber-border); color: var(--amber); }
.banner.green { background: var(--green-bg); border: 1px solid #bce5cb; color: var(--green); }

/* public URL bar */
.url-bar { display: flex; align-items: center; justify-content: space-between; border: 1px solid var(--border); border-radius: var(--r); padding: 10px 14px; margin-bottom: 18px; background: #fff; }
.url-bar .u { font-family: var(--mono); font-size: 12px; color: var(--heading); }
.url-bar .u .lbl { color: var(--faint); font-weight: 600; margin-right: 10px; text-transform: uppercase; font-size: 10px; letter-spacing: .06em; }

.header-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.section-gap { margin-top: 14px; }
.foot-note { color: var(--faint); font-family: var(--mono); font-size: 11.5px; margin-top: 14px; }
.empty { text-align: center; color: var(--muted); padding: 56px 0; }
.empty .big { font-size: 15px; color: var(--heading); margin-bottom: 6px; font-weight: 600; }

/* connection header card */
.conn-head { display: flex; align-items: center; gap: 12px; }
.conn-icon { width: 38px; height: 38px; border-radius: 9px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.conn-icon.monday { background: #eef0ff; color: var(--accent); }
.conn-icon.sage { background: var(--green-bg); color: var(--green); }
.conn-title { font-weight: 700; font-size: 14px; color: var(--heading); display: flex; align-items: center; gap: 9px; }
.conn-sub { color: var(--muted); font-family: var(--mono); font-size: 11.5px; margin-top: 3px; }

/* ============================ Modal (OAuth connecting) ============================ */
.modal-overlay { position: fixed; inset: 0; background: rgba(14,17,22,0.55); display: flex; align-items: center; justify-content: center; z-index: 50; }
.modal { background: #fff; border-radius: 14px; width: 420px; max-width: 90vw; padding: 24px; box-shadow: 0 20px 60px rgba(0,0,0,0.3); }
.modal-head { display: flex; align-items: center; gap: 11px; margin-bottom: 18px; }
.modal-icon { width: 34px; height: 34px; border-radius: 8px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.modal-title { font-weight: 700; font-size: 15px; color: var(--heading); }
.modal-subtitle { color: var(--muted); font-family: var(--mono); font-size: 11.5px; margin-top: 2px; }
.modal-step { display: flex; align-items: center; gap: 10px; padding: 7px 0; font-size: 12.5px; color: var(--heading); }
.modal-step .check { width: 18px; height: 18px; border-radius: 50%; background: var(--green); color: #fff; display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; }
.modal-step.pending { color: var(--faint); }
.modal-step.pending .check { background: #e3e6ec; color: #e3e6ec; }
.modal-done { width: 100%; margin-top: 16px; background: #2faa5a; color: #fff; border: 0; border-radius: 9px; padding: 12px; font-weight: 600; font-family: var(--sans); font-size: 13px; cursor: pointer; }
.modal-done:hover { background: #279150; }

/* ============================ Sign-in (dark) ============================ */
.signin-page { background: var(--dk-bg); min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.signin-brand { display: flex; align-items: center; gap: 11px; width: 380px; max-width: 90vw; margin-bottom: 14px; }
.signin-brand .brand-name { color: var(--dk-text); font-size: 15px; }
.signin-brand .brand-sub { color: var(--dk-muted); }
.signin-card { width: 380px; max-width: 90vw; background: var(--dk-card); border: 1px solid var(--dk-border); border-radius: 13px; padding: 26px; }
.signin-card h1 { color: var(--dk-text); font-size: 20px; font-weight: 700; margin: 0 0 8px; }
.signin-card .sub { color: var(--dk-muted); font-size: 12.5px; margin-bottom: 20px; line-height: 1.5; }
.signin-card .form-label { color: var(--dk-faint); }
.signin-card .dk-input { width: 100%; background: var(--dk-input); border: 1px solid var(--dk-input-border); color: var(--dk-text); border-radius: var(--r); padding: 11px 13px; font-family: var(--mono); font-size: 13px; letter-spacing: .12em; }
.signin-card .dk-input:focus { outline: none; border-color: var(--accent); }
.signin-card .unlock { width: 100%; margin-top: 4px; background: var(--accent); color: #fff; border: 0; border-radius: var(--r); padding: 12px; font-weight: 700; font-family: var(--sans); font-size: 13.5px; cursor: pointer; }
.signin-card .unlock:hover { background: var(--accent-hover); }
.signin-divider { border-top: 1px solid var(--dk-border); margin: 20px 0 14px; }
.signin-note { color: var(--dk-faint); font-family: var(--mono); font-size: 11.5px; }
.signin-error { color: #ff8a80; font-size: 12.5px; margin-bottom: 12px; }
