:root {
  color-scheme: light;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: #171a21;
  background: #f5f6f7;
  --ink: #171a21;
  --muted: #656971;
  --line: #dcdee3;
  --panel: #ffffff;
  --green: #0B5AE8;
  --green-dark: #0840B0;
  --amber: #ad6b12;
  --red: #a33b37;
  --blue: #2b5f9e;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
.current-user { font-size: 13px; overflow-wrap: anywhere; max-width: 150px; }
body { margin: 0; min-width: 320px; background: #f5f6f7; }
button, input, select, textarea { font: inherit; letter-spacing: 0; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .48; }

.topbar { height: 64px; padding: 0 22px; display: flex; align-items: center; gap: 24px; background: #fff; border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 10; }
.brand { display: flex; align-items: center; gap: 10px; color: inherit; text-decoration: none; min-width: 210px; }
.brand-mark { width: 36px; height: 36px; display: grid; place-items: center; background: linear-gradient(140deg, #1A46E8 0%, #0FB4F5 52%, #9A2BF0 100%); color: #fff; font-weight: 800; border-radius: 10px; box-shadow: 0 5px 15px rgba(15, 90, 232, .35), inset 0 1px 0 rgba(255, 255, 255, .4); }
.brand strong, .brand small { display: block; }
.brand strong { font-size: 17px; font-weight: 800; letter-spacing: .05em; background: linear-gradient(100deg, #1A46E8, #0FC0FF 48%, #9A2BF0 96%); -webkit-background-clip: text; background-clip: text; color: transparent; }
.brand small { color: var(--muted); font-size: 11px; margin-top: 1px; }
.brand small i { font-style: italic; font-weight: 700; color: #0B5AE8; }
.server-state { margin-left: auto; display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 13px; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: #9a9ea5; }
.dot.ok { background: #1D6BF5; box-shadow: 0 0 0 3px #D6E4FA; }
.dot.error { background: var(--red); box-shadow: 0 0 0 3px #f7dfdd; }

.shell { display: grid; grid-template-columns: 220px minmax(0, 1fr); min-height: calc(100vh - 64px); }
.sidebar { background: #eeeff2; border-right: 1px solid var(--line); padding: 18px 12px; display: flex; flex-direction: column; gap: 5px; }
.nav-button { border: 0; background: transparent; color: #535760; min-height: 42px; padding: 0 12px; display: flex; align-items: center; gap: 10px; border-radius: 6px; text-align: left; }
.nav-button:hover { background: #e2e4e9; color: var(--ink); }
.nav-button.active { background: #dce1ea; color: var(--green-dark); font-weight: 650; }
.nav-button svg { width: 18px; height: 18px; }

main { width: 100%; max-width: 1480px; padding: 28px 34px 60px; }
.view { display: none; }
.view.active { display: block; }
.page-heading, .section-heading { display: flex; align-items: center; justify-content: space-between; gap: 18px; }
.page-heading { margin-bottom: 24px; }
h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 5px; font-size: 25px; line-height: 1.25; }
h2 { margin-bottom: 0; font-size: 16px; }
.page-heading p, .section-heading span { margin-bottom: 0; color: var(--muted); font-size: 13px; }

.metrics { display: grid; grid-template-columns: repeat(4, minmax(140px, 1fr)); border: 1px solid var(--line); background: #fff; margin-bottom: 22px; }
.metrics > div { min-height: 104px; padding: 20px; border-right: 1px solid var(--line); }
.metrics > div:last-child { border-right: 0; }
.metrics span, .metrics strong { display: block; }
.metrics span { color: var(--muted); font-size: 12px; }
.metrics strong { margin-top: 11px; font-size: 28px; }

.band { background: var(--panel); border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); margin-top: 22px; }
.band .section-heading { min-height: 54px; padding: 0 16px; border-bottom: 1px solid var(--line); }
.empty { color: var(--muted); padding: 24px 16px; margin: 0; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { color: #666a73; font-size: 11px; text-transform: uppercase; font-weight: 700; background: #fafafb; }
th, td { padding: 11px 14px; border-bottom: 1px solid #e7e9ec; text-align: left; vertical-align: middle; white-space: nowrap; }
tbody tr:last-child td { border-bottom: 0; }
td.wrap { white-space: normal; min-width: 180px; }
.status { display: inline-flex; align-items: center; gap: 6px; padding: 3px 7px; border-radius: 4px; background: #edeef1; color: #4e525b; font-size: 11px; font-weight: 700; }
.status.online, .status.succeeded { color: var(--green-dark); background: #dfe5f1; }
.status.awaiting_approval { color: #83500c; background: #f8ead4; }
.status.failed { color: #8d2c28; background: #f6dddb; }
.status.queued, .status.leased { color: #244f84; background: #deeafa; }

.icon-button { width: 36px; height: 36px; display: inline-grid; place-items: center; border: 1px solid var(--line); background: #fff; color: #444851; border-radius: 6px; }
.icon-button:hover { background: #f1f2f5; }
.icon-button svg { width: 17px; height: 17px; }
.primary-button, .secondary-button, .link-button { min-height: 38px; padding: 0 14px; border-radius: 6px; display: inline-flex; align-items: center; justify-content: center; gap: 7px; }
.primary-button { border: 1px solid var(--green-dark); background: var(--green); color: #fff; font-weight: 650; }
.primary-button:hover { background: var(--green-dark); }
.primary-button[aria-disabled="true"] { background: #666a73; border-color: #666a73; cursor: not-allowed; pointer-events: none; }
.primary-button svg { width: 16px; height: 16px; }
.secondary-button { border: 1px solid var(--line); background: #fff; color: var(--ink); }
.link-button { min-height: 32px; border: 0; background: transparent; color: var(--green); padding: 0 4px; }
.small-button { min-height: 30px; padding: 0 9px; border-radius: 5px; border: 1px solid var(--line); background: #fff; color: var(--ink); font-size: 12px; }
.small-button.approve { color: #fff; border-color: var(--amber); background: var(--amber); }
.small-button.reject { color: var(--red); border-color: #e6b9b6; background: #fff; }

.notice { border-left: 4px solid var(--blue); background: #e8f0fa; color: #234d7f; padding: 11px 14px; margin-bottom: 20px; }
.notice.error { border-color: var(--red); background: #f8e7e5; color: #7d2b27; }
.upload-zone { min-height: 190px; border: 1px dashed #aaaeb7; background: #fff; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; padding: 24px; }
.upload-zone > svg { width: 32px; height: 32px; color: var(--green); }
.upload-zone label { font-weight: 700; }
.upload-zone span { color: var(--muted); font-size: 12px; }
.upload-zone input { max-width: 100%; }
.upload-zone button { margin-top: 8px; }

.composer { padding: 18px; background: #fff; border: 1px solid var(--line); }
.composer form { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.composer label, dialog label { display: flex; flex-direction: column; gap: 6px; color: #585c64; font-size: 12px; font-weight: 650; }
.composer .wide { grid-column: 1 / -1; }
.composer h2 { margin-bottom: 16px; }
#jobReviewDialog { width: min(680px, calc(100vw - 32px)); }
#jobReviewPayload { font-size: 12px; white-space: pre-wrap; overflow-wrap: anywhere; max-height: 50vh; overflow: auto; }
input, select, textarea { width: 100%; border: 1px solid #cdd0d6; background: #fff; color: var(--ink); border-radius: 5px; padding: 9px 10px; }
textarea { resize: vertical; font-family: ui-monospace, SFMono-Regular, Consolas, monospace; }
input:focus, select:focus, textarea:focus { outline: 2px solid #b5c1d8; border-color: var(--green); }
.form-actions { grid-column: 1 / -1; display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; }

.pairing-panel { display: grid; grid-template-columns: minmax(260px, .8fr) minmax(360px, 1.2fr); gap: 18px; padding: 18px; background: #e8ebf2; border: 1px solid #bdc6d7; }
.pairing-panel > div:first-child span, .pairing-panel strong, .pairing-panel small { display: block; }
.pairing-panel strong { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 30px; letter-spacing: 3px; margin: 7px 0; color: var(--green-dark); }
.pairing-panel small, .pairing-panel span { color: #5c616a; }
.install-command { align-self: center; display: flex; align-items: center; gap: 8px; background: #131720; color: #e9edf5; padding: 10px; min-width: 0; }
.install-command code { overflow-x: auto; white-space: nowrap; flex: 1; font-size: 12px; }
.install-command .icon-button { background: #242a35; border-color: #454b57; color: #fff; flex: 0 0 auto; }

dialog { width: min(420px, calc(100vw - 32px)); border: 1px solid var(--line); padding: 0; border-radius: 7px; box-shadow: 0 24px 70px #181c2333; }
dialog::backdrop { background: #171a2180; }
dialog form { padding: 24px; display: flex; flex-direction: column; gap: 16px; }
.dialog-brand { display: flex; align-items: center; gap: 10px; margin-bottom: 4px; }
.dialog-brand strong, .dialog-brand small { display: block; }
.dialog-brand small { color: var(--muted); font-size: 11px; }
.error-text { color: var(--red); min-height: 18px; margin: 0; font-size: 12px; }
.connect-box { display: grid; grid-template-columns: 32px 1fr; gap: 10px 12px; padding: 15px; border: 1px solid #bdc6d7; background: #eef1f7; }
.connect-box > svg { width: 24px; height: 24px; color: var(--green); margin-top: 2px; }
.connect-box strong, .connect-box span { display: block; }
.connect-box span { margin-top: 3px; color: var(--muted); font-size: 12px; }
.connect-box .primary-button { grid-column: 1 / -1; text-decoration: none; }
.dialog-divider { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 11px; }
.dialog-divider::before, .dialog-divider::after { content: ''; height: 1px; background: var(--line); flex: 1; }

@media (max-width: 820px) {
  .topbar { padding: 0 14px; }
  .brand { min-width: 0; }
  .brand small { display: none; }
  .server-state { font-size: 0; }
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: sticky; top: 64px; z-index: 9; display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; padding: 6px; border-right: 0; border-bottom: 1px solid var(--line); }
  .nav-button { justify-content: center; padding: 0; min-width: 0; }
  .nav-button span { display: none; }
  main { padding: 20px 14px 50px; }
  .metrics { grid-template-columns: 1fr 1fr; }
  .metrics > div:nth-child(2) { border-right: 0; }
  .metrics > div:nth-child(-n+2) { border-bottom: 1px solid var(--line); }
  .composer form { grid-template-columns: 1fr; }
  .composer .wide, .form-actions { grid-column: 1; }
  .pairing-panel { grid-template-columns: 1fr; }
  .page-heading { align-items: flex-start; }
}
