:root {
  --bg: #f6f6f4;
  --surface: #ffffff;
  --surface-2: #f1f1ee;
  --text: #171717;
  --muted: #6b6b66;
  --line: #e4e4df;
  --accent: #171717;
  --accent-text: #ffffff;
  --ok: #1f7a4d;
  --ok-bg: #e6f4ec;
  --warn: #8a5a00;
  --warn-bg: #fdf1d8;
  --bad: #b42318;
  --bad-bg: #fdecea;
  --info: #1d4ed8;
  --info-bg: #e8eefc;
  --radius: 10px;
  --font: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111110;
    --surface: #1a1a19;
    --surface-2: #232321;
    --text: #ededea;
    --muted: #9a9a94;
    --line: #2e2e2b;
    --accent: #ededea;
    --accent-text: #111110;
    --ok: #5fd39a;
    --ok-bg: #12321f;
    --warn: #f0b84b;
    --warn-bg: #33270d;
    --bad: #ff8a80;
    --bad-bg: #3a1714;
    --info: #8fb0ff;
    --info-bg: #16213f;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--text); font: 14px/1.5 var(--font); -webkit-font-smoothing: antialiased; }
h1, h2, h3 { margin: 0; letter-spacing: -0.01em; }
h2 { font-size: 20px; font-weight: 650; }
h3 { font-size: 15px; font-weight: 650; margin-bottom: 4px; }
code { font-family: var(--mono); font-size: 12.5px; background: var(--surface-2); padding: 1px 5px; border-radius: 5px; }
a { color: inherit; }
.muted { color: var(--muted); }
[hidden] { display: none !important; }

/* buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 36px; padding: 0 14px; border-radius: 8px; border: 1px solid var(--line); background: var(--surface); color: var(--text); font: inherit; font-weight: 550; cursor: pointer; text-decoration: none; white-space: nowrap; }
.btn:hover { background: var(--surface-2); }
.btn:focus-visible, input:focus-visible, select:focus-visible, button:focus-visible { outline: 2px solid var(--info); outline-offset: 2px; }
.btn-primary { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
.btn-primary:hover { opacity: .88; background: var(--accent); }
.btn-danger { color: var(--bad); }
.btn-danger:hover { background: var(--bad-bg); }
.btn-ghost { background: transparent; }
.btn-sm { height: 30px; padding: 0 10px; font-size: 13px; }
.btn-block { width: 100%; }
.btn[disabled] { opacity: .45; cursor: not-allowed; }

/* login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card { width: 100%; max-width: 380px; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 32px 28px; display: grid; gap: 14px; }
.login-card h1 { font-size: 22px; }
.login-card p { margin: 0; }
.fine { font-size: 12px; color: var(--muted); }
.alert { background: var(--bad-bg); color: var(--bad); padding: 10px 12px; border-radius: 8px; }
.mark { width: 40px; height: 40px; border-radius: 9px; background: var(--accent); color: var(--accent-text); display: grid; place-items: center; font-weight: 750; font-size: 14px; letter-spacing: .02em; }
.mark.sm { width: 26px; height: 26px; font-size: 10.5px; border-radius: 6px; }

/* top bar */
.topbar { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 24px; padding: 0 24px; height: 56px; background: var(--surface); border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 650; }
.tabs { display: flex; gap: 2px; height: 100%; }
.tabs button { position: relative; background: none; border: 0; padding: 0 12px; font: inherit; color: var(--muted); cursor: pointer; font-weight: 550; display: flex; align-items: center; gap: 6px; }
.tabs button[aria-selected="true"] { color: var(--text); }
.tabs button[aria-selected="true"]::after { content: ""; position: absolute; left: 10px; right: 10px; bottom: -1px; height: 2px; background: var(--text); border-radius: 2px; }
.count { background: var(--info-bg); color: var(--info); border-radius: 99px; padding: 0 7px; font-size: 11.5px; font-weight: 650; }
.me { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.me img { width: 26px; height: 26px; border-radius: 50%; }
.me-email { color: var(--muted); font-size: 13px; }
.me form { margin: 0; }

.wrap { max-width: 1180px; margin: 0 auto; padding: 28px 24px 64px; }
.panel-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; margin-bottom: 16px; flex-wrap: wrap; }
.panel-head p { margin: 2px 0 0; }
.filters { display: flex; gap: 8px; }
input, select { height: 36px; border: 1px solid var(--line); background: var(--surface); color: var(--text); border-radius: 8px; padding: 0 10px; font: inherit; }
#search { width: 280px; }

/* table */
.table-wrap { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: auto; }
.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; padding: 10px 14px; border-bottom: 1px solid var(--line); background: var(--surface); position: sticky; top: 0; }
.table td { padding: 10px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: var(--surface-2); }
.right { text-align: right; }
.empty { text-align: center; color: var(--muted); padding: 40px !important; }
.person { display: flex; align-items: center; gap: 10px; min-width: 220px; }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--surface-2); display: grid; place-items: center; font-size: 12px; font-weight: 650; color: var(--muted); flex: none; overflow: hidden; }
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.person .name { font-weight: 600; }
.person .email { color: var(--muted); font-size: 12.5px; font-family: var(--mono); }
.actions { display: flex; gap: 6px; justify-content: flex-end; }
.ou { font-family: var(--mono); font-size: 12.5px; color: var(--muted); }

.pill { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 99px; background: var(--surface-2); color: var(--muted); white-space: nowrap; }
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pill.ok { background: var(--ok-bg); color: var(--ok); }
.pill.warn { background: var(--warn-bg); color: var(--warn); }
.pill.bad { background: var(--bad-bg); color: var(--bad); }
.pill.info { background: var(--info-bg); color: var(--info); }
.tag { font-size: 11px; font-weight: 650; padding: 1px 6px; border-radius: 4px; background: var(--surface-2); color: var(--muted); margin-left: 6px; }

/* jobs */
.jobs { display: grid; gap: 12px; }
.job { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; }
.job-top { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; flex-wrap: wrap; }
.job-title { font-weight: 650; }
.job-meta { color: var(--muted); font-size: 12.5px; }
.job-step { margin: 10px 0 0; }
.bar { height: 6px; background: var(--surface-2); border-radius: 99px; overflow: hidden; margin-top: 10px; }
.bar > i { display: block; height: 100%; background: var(--info); border-radius: 99px; transition: width .4s; }
.bar.indeterminate > i { width: 30%; animation: slide 1.4s ease-in-out infinite; }
@keyframes slide { 0% { transform: translateX(-100%); } 100% { transform: translateX(340%); } }
@media (prefers-reduced-motion: reduce) { .bar.indeterminate > i { animation: none; width: 100%; opacity: .4; } }
.exports { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 10px; }
.job details { margin-top: 10px; }
.job summary { cursor: pointer; color: var(--muted); font-size: 13px; }
.log { margin: 8px 0 0; padding: 10px 12px; background: var(--surface-2); border-radius: 8px; font-family: var(--mono); font-size: 12px; max-height: 260px; overflow: auto; display: grid; gap: 3px; }
.log .error { color: var(--bad); }
.job-links { display: flex; gap: 8px; align-items: center; }

/* settings */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; margin-bottom: 14px; max-width: 720px; }
.card p { margin: 4px 0 12px; }
.row { display: flex; gap: 8px; }
.row input { flex: 1; }
.current { font-weight: 600; }
.field-msg { min-height: 18px; font-size: 13px; margin: 8px 0 0 !important; }
.field-msg.err { color: var(--bad); }
.field-msg.ok { color: var(--ok); }
.steps { margin: 8px 0 12px; padding-left: 20px; display: grid; gap: 4px; }

#banner .alert { margin-bottom: 16px; }

/* dialog */
dialog { border: 1px solid var(--line); border-radius: 14px; padding: 0; width: min(480px, calc(100vw - 32px)); background: var(--surface); color: var(--text); }
dialog::backdrop { background: rgba(0,0,0,.35); }
dialog form { padding: 22px; display: grid; gap: 12px; }
dialog p { margin: 0; }
fieldset { border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; margin: 0; display: grid; gap: 6px; }
legend { font-size: 12px; color: var(--muted); padding: 0 4px; }
fieldset label { display: flex; gap: 8px; align-items: center; }
.stack { display: grid; gap: 6px; }
.danger-note { background: var(--bad-bg); color: var(--bad); padding: 10px 12px; border-radius: 8px; font-size: 13px; }
.dlg-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 4px; }

@media (max-width: 760px) {
  .topbar { padding: 0 16px; gap: 12px; }
  .brand span:last-child, .me-email { display: none; }
  .wrap { padding: 20px 16px 48px; }
  .filters { width: 100%; }
  #search { flex: 1; width: auto; }
  .table th:nth-child(2), .table td:nth-child(2), .table th:nth-child(3), .table td:nth-child(3) { display: none; }
  .actions { flex-direction: column; align-items: stretch; }
}
.btn-danger-solid { background: var(--bad); border-color: var(--bad); color: #fff; }
.btn-danger-solid:hover { background: var(--bad); opacity: .9; }

.checks { display: grid; gap: 6px; margin: 4px 0 12px; }
.checks .row-check { display: flex; gap: 8px; align-items: baseline; font-size: 13px; }
.checks .err { color: var(--bad); font-size: 12.5px; }
.setup { margin-top: 12px; }
.setup summary { cursor: pointer; color: var(--muted); font-size: 13px; }
.setup pre { white-space: pre-wrap; word-break: break-all; font-family: var(--mono); font-size: 12px; background: var(--surface-2); padding: 8px 10px; border-radius: 8px; }
label.check { display: flex; gap: 8px; align-items: flex-start; font-size: 13px; }
label.check input { margin-top: 3px; }
