:root {
  color-scheme: light;
  --ink: #1d2422;
  --muted: #68716e;
  --line: #dfe4e1;
  --line-strong: #c9d0cc;
  --canvas: #f5f7f6;
  --paper: #ffffff;
  --accent: #18765e;
  --accent-dark: #105b48;
  --accent-soft: #e8f3ef;
  --gold: #a76516;
  --gold-soft: #f8efe1;
  --danger: #b33d38;
  --danger-soft: #faeceb;
  --shadow: 0 16px 40px rgba(29, 36, 34, 0.14);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  color: var(--ink);
  background: var(--canvas);
  font-size: 14px;
  line-height: 1.5;
}

button, input, textarea, select { font: inherit; letter-spacing: 0; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: 0.55; }
strong { font-weight: 700; }
code, pre { font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  height: 64px;
  padding: 0 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.96);
}

.brand-block { display: flex; align-items: center; gap: 11px; min-width: 0; }
.brand-block h1 { margin: 0; font-size: 15px; line-height: 1.2; }
.brand-block p { margin: 2px 0 0; color: var(--muted); font-size: 9px; font-weight: 750; }
.brand-mark {
  position: relative;
  width: 34px;
  height: 34px;
  flex: 0 0 34px;
  display: block;
  overflow: hidden;
  border-radius: 7px;
  background: var(--ink);
}
.brand-mark.large { width: 46px; height: 46px; border-radius: 8px; }
.brand-mark i, .brand-mark b {
  position: absolute;
  display: block;
  border: 2px solid #fff;
  border-radius: 50%;
}
.brand-mark i { inset: 8px 13px 8px 7px; border-right-color: transparent; }
.brand-mark b { inset: 8px 7px 8px 13px; border-left-color: transparent; }
.brand-mark.large i { inset: 11px 17px 11px 9px; }
.brand-mark.large b { inset: 11px 9px 11px 17px; }

.header-actions { display: flex; align-items: center; gap: 9px; }
.service-state { display: inline-flex; align-items: center; gap: 7px; margin-right: 5px; color: var(--muted); font-size: 12px; }
.service-state i { width: 7px; height: 7px; flex: 0 0 7px; border-radius: 50%; background: var(--gold); }
.service-state.ready i { background: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

main { min-height: calc(100vh - 64px); }
.login-view { min-height: calc(100vh - 64px); display: grid; place-items: center; padding: 32px 20px; }
.login-form {
  width: min(380px, 100%);
  padding: 32px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
  box-shadow: var(--shadow);
}
.login-brand { display: grid; place-items: center; margin-bottom: 20px; }
.login-form .button { width: 100%; margin-top: 20px; }

.workspace { min-height: calc(100vh - 64px); display: grid; grid-template-columns: 220px minmax(0, 1fr); }
.sidebar {
  position: sticky;
  top: 64px;
  height: calc(100vh - 64px);
  padding: 22px 14px 16px;
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--line);
  background: var(--paper);
}
.nav-list { display: grid; gap: 4px; }
.nav-item {
  width: 100%;
  min-height: 40px;
  padding: 8px 11px;
  display: flex;
  align-items: center;
  gap: 10px;
  border: 0;
  border-radius: 6px;
  color: #58615e;
  background: transparent;
  text-align: left;
  font-weight: 650;
}
.nav-item > span { width: 18px; color: #88918e; font-size: 17px; line-height: 1; text-align: center; }
.nav-item:hover { color: var(--ink); background: var(--canvas); }
.nav-item.active { color: var(--accent-dark); background: var(--accent-soft); }
.nav-item.active > span { color: var(--accent); }
.sidebar-meta { margin-top: auto; padding: 14px 10px 0; display: grid; gap: 4px; border-top: 1px solid var(--line); color: var(--muted); font-size: 11px; }
.sidebar-meta code { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.content-area { min-width: 0; background: var(--paper); }
.view { width: 100%; min-height: calc(100vh - 64px); }
.page-heading {
  min-height: 112px;
  padding: 28px 34px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  border-bottom: 1px solid var(--line);
}
.page-heading h2 { margin: 3px 0 0; font-size: 24px; line-height: 1.25; }
.section-heading { margin-bottom: 20px; }
.section-heading h2, .section-heading h3 { margin: 2px 0 0; font-size: 18px; line-height: 1.3; }
.section-heading.centered { text-align: center; }
.section-heading.split-heading { display: flex; align-items: end; justify-content: space-between; gap: 16px; }
.eyebrow { margin: 0; color: var(--accent); font-size: 9px; font-weight: 800; }

.metrics-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  border-bottom: 1px solid var(--line);
}
.metric { min-width: 0; min-height: 118px; padding: 24px 28px; display: flex; flex-direction: column; justify-content: center; }
.metric + .metric { border-left: 1px solid var(--line); }
.metric span { color: var(--muted); font-size: 11px; }
.metric strong { margin: 4px 0 1px; overflow-wrap: anywhere; font-size: 25px; line-height: 1.25; }
.metric small { color: #8a9390; font-size: 11px; }

.section-band { padding: 30px 34px 36px; border-bottom: 1px solid var(--line); }
.section-band.table-band { padding-top: 10px; }
.muted-band { background: var(--canvas); }
.endpoint-strip {
  min-height: 72px;
  padding: 15px 34px;
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--canvas);
}
.endpoint-strip > div { min-width: 0; flex: 1; display: grid; gap: 3px; }
.endpoint-strip span { color: var(--muted); font-size: 10px; }
.endpoint-strip code { overflow-wrap: anywhere; font-size: 12px; }

.filter-row, .integration-switch { padding: 18px 34px; display: flex; align-items: center; gap: 5px; border-bottom: 1px solid var(--line); }
.filter {
  min-height: 34px;
  padding: 6px 12px;
  border: 1px solid transparent;
  border-radius: 5px;
  color: var(--muted);
  background: transparent;
  font-weight: 650;
}
.filter:hover { background: var(--canvas); }
.filter.active { color: var(--ink); border-color: var(--line-strong); background: var(--paper); }

.table-wrap { width: 100%; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 13px 11px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; white-space: nowrap; }
th { color: #7b8481; font-size: 9px; font-weight: 800; }
td { font-size: 12px; }
td strong { display: block; max-width: 220px; overflow: hidden; text-overflow: ellipsis; }
td small { display: block; margin-top: 2px; color: var(--muted); font-size: 10px; }
td.truncate { max-width: 230px; overflow: hidden; text-overflow: ellipsis; }
th:last-child, td.actions-cell { text-align: right; }
.accounts-table th:nth-child(4), .accounts-table td:nth-child(4) { max-width: 220px; }
.accounts-table th:nth-child(5), .accounts-table td:nth-child(5) { max-width: 220px; }
.muted-row { opacity: 0.62; }
.empty-state { margin: 0; padding: 36px 10px; color: var(--muted); text-align: center; }
.empty-inline { margin: 0; padding: 10px 0; color: var(--muted); }

.status-pill, .type-label { display: inline-flex; align-items: center; gap: 6px; font-size: 11px; font-weight: 700; }
.status-pill i { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.status-pill.healthy { color: var(--accent); }
.status-pill.error { color: var(--danger); }
.status-pill.unknown { color: var(--gold); }
.status-pill.disabled { color: #8a9390; }
.type-label { min-height: 24px; padding: 3px 7px; border: 1px solid var(--line); border-radius: 4px; color: #565f5c; background: var(--canvas); }
.type-label.mirasim { color: #37606d; background: #edf4f6; border-color: #d6e5e9; }
.type-label.anthropic { color: #81572d; background: #f8f0e7; border-color: #ead9c5; }
.actions-cell { min-width: 170px; }
.table-action { padding: 4px 6px; border: 0; color: var(--accent); background: transparent; font-size: 11px; font-weight: 700; }
.table-action:hover { text-decoration: underline; }
.table-action.danger { color: var(--danger); }

.button {
  min-height: 38px;
  padding: 8px 14px;
  border: 1px solid transparent;
  border-radius: 6px;
  white-space: nowrap;
  font-weight: 700;
}
.button.primary { color: #fff; background: var(--accent); border-color: var(--accent); }
.button.primary:hover { background: var(--accent-dark); border-color: var(--accent-dark); }
.button.secondary { color: var(--ink); background: var(--paper); border-color: var(--line-strong); }
.button.secondary:hover, .button.ghost:hover { background: var(--canvas); }
.button.ghost { min-height: 32px; padding: 5px 9px; color: var(--muted); background: transparent; border-color: transparent; }
.button.full { width: 100%; }
.text-button { padding: 3px 0; border: 0; color: var(--accent); background: transparent; font-weight: 700; }
.icon-button {
  width: 34px;
  height: 34px;
  padding: 0;
  display: inline-grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: #5e6864;
  background: var(--paper);
  font-size: 18px;
  line-height: 1;
}
.icon-button:hover { color: var(--ink); background: var(--canvas); }
.icon-button.compact { width: 29px; height: 29px; font-size: 15px; }
.icon-button.spinning { animation: spin 700ms linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

label { min-width: 0; display: flex; flex-direction: column; gap: 6px; }
label > span, .field-note { color: var(--muted); font-size: 11px; }
input, textarea, select {
  width: 100%;
  min-height: 40px;
  padding: 9px 11px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  color: var(--ink);
  background: var(--paper);
  outline: none;
}
textarea { resize: vertical; font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 12px; }
input:focus, textarea:focus, select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(24, 118, 94, 0.12); }
input::placeholder, textarea::placeholder { color: #9ba3a0; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-grid.one-column { grid-template-columns: 1fr; }
.wide { grid-column: 1 / -1; }
.switch-row { min-height: 34px; flex-direction: row; align-items: center; gap: 8px; }
.switch-row input { width: 17px; min-height: 17px; accent-color: var(--accent); }
.switch-row span { color: var(--ink); }
.inline-fields { display: flex; align-items: end; gap: 9px; }
.grow { flex: 1; }
.align-end { align-self: end; }
.form-error { min-height: 20px; margin: 10px 0 0; color: var(--danger); font-size: 11px; }

.segmented { margin: 0 0 20px; padding: 3px; display: grid; grid-template-columns: 1fr 1fr; gap: 3px; border: 1px solid var(--line); border-radius: 7px; background: var(--canvas); }
.segmented.three { grid-template-columns: repeat(3, 1fr); }
.segmented label { display: block; }
.segmented input { position: absolute; opacity: 0; pointer-events: none; }
.segmented span { min-height: 34px; padding: 7px 10px; display: grid; place-items: center; border-radius: 5px; color: var(--muted); font-weight: 700; cursor: pointer; }
.segmented input:checked + span { color: var(--ink); background: var(--paper); box-shadow: 0 1px 3px rgba(29, 36, 34, 0.12); }
.segmented input:disabled + span { cursor: default; }
.account-pane { margin-top: 18px; padding-top: 18px; border-top: 1px solid var(--line); }
.alternate-action { margin-top: 16px; padding-top: 16px; display: flex; align-items: center; justify-content: space-between; gap: 16px; border-top: 1px solid var(--line); color: var(--muted); font-size: 12px; }
.login-method-pane { display: grid; gap: 16px; }
.member-picker { margin: 20px 0 0; padding: 14px; border: 1px solid var(--line); border-radius: 6px; }
.member-picker legend { padding: 0 5px; color: var(--muted); font-size: 11px; }
#group-account-options { max-height: 220px; overflow-y: auto; display: grid; gap: 2px; }
.member-option { min-height: 46px; padding: 6px 8px; flex-direction: row; align-items: center; gap: 10px; border-radius: 5px; }
.member-option:hover { background: var(--canvas); }
.member-option input { width: 16px; min-height: 16px; accent-color: var(--accent); }
.member-option span { display: grid; color: var(--ink); }
.member-option small { color: var(--muted); }

dialog { width: min(640px, calc(100% - 28px)); max-height: calc(100vh - 32px); padding: 0; border: 0; border-radius: 8px; background: var(--paper); box-shadow: var(--shadow); }
dialog::backdrop { background: rgba(20, 27, 25, 0.55); }
.dialog-shell { padding: 26px; }
.dialog-heading { margin-bottom: 22px; display: flex; align-items: start; justify-content: space-between; gap: 16px; }
.dialog-heading h2 { margin: 2px 0 0; font-size: 19px; }
.dialog-heading .icon-button { border-color: transparent; }
.dialog-actions { margin-top: 20px; display: flex; justify-content: end; gap: 8px; }
.secret-output { padding: 14px; border: 1px solid var(--line); border-radius: 6px; background: var(--canvas); overflow-wrap: anywhere; }

.integration-panel { border-bottom: 1px solid var(--line); }
.config-list { margin: 0; border-top: 1px solid var(--line); }
.config-list > div { min-height: 56px; display: grid; grid-template-columns: 150px minmax(0, 1fr); align-items: center; border-bottom: 1px solid var(--line); }
.config-list dt { color: var(--muted); font-size: 12px; }
.config-list dd { min-width: 0; margin: 0; display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.config-list code { overflow-wrap: anywhere; font-size: 12px; }
.code-block { position: relative; margin: 24px 0 0; padding: 18px 52px 18px 18px; overflow-x: auto; border: 1px solid #2f3936; border-radius: 6px; color: #e8eeeb; background: #222a28; font-size: 12px; line-height: 1.65; }
.code-copy { position: absolute; top: 10px; right: 10px; color: #d8e0dc; border-color: #495451; background: #2c3533; }
.model-list { display: flex; flex-wrap: wrap; gap: 7px; }
.model-list code { padding: 6px 9px; border: 1px solid var(--line); border-radius: 4px; color: #46504d; background: var(--paper); font-size: 11px; }

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 100;
  max-width: min(440px, calc(100vw - 40px));
  padding: 11px 14px;
  border-radius: 6px;
  color: #fff;
  background: var(--ink);
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateY(8px);
  pointer-events: none;
  transition: 160ms ease;
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast.error { background: var(--danger); }

@media (max-width: 980px) {
  .workspace { grid-template-columns: 180px minmax(0, 1fr); }
  .metrics-grid { grid-template-columns: 1fr 1fr; }
  .metric:nth-child(3) { border-left: 0; border-top: 1px solid var(--line); }
  .metric:nth-child(4) { border-top: 1px solid var(--line); }
  .page-heading, .section-band, .filter-row, .integration-switch { padding-left: 24px; padding-right: 24px; }
}

@media (max-width: 720px) {
  .topbar { padding: 0 14px; }
  .brand-block p { display: none; }
  .service-state span { display: none; }
  .workspace { display: block; }
  .sidebar { position: sticky; top: 64px; z-index: 15; width: 100%; height: auto; padding: 0; display: block; overflow-x: auto; border-right: 0; border-bottom: 1px solid var(--line); }
  .nav-list { min-width: 550px; padding: 0 12px; display: flex; gap: 3px; }
  .nav-item { width: auto; min-height: 48px; padding: 8px 10px; border-radius: 0; }
  .nav-item > span { display: none; }
  .nav-item.active { border-bottom: 2px solid var(--accent); background: transparent; }
  .sidebar-meta { display: none; }
  .view { min-height: calc(100vh - 113px); }
  .page-heading { min-height: 92px; padding: 20px 16px; }
  .page-heading h2 { font-size: 21px; }
  .metrics-grid { grid-template-columns: 1fr 1fr; }
  .metric { min-height: 102px; padding: 18px 16px; }
  .metric strong { font-size: 21px; }
  .section-band { padding: 24px 16px 28px; }
  .section-band.table-band { padding: 4px 8px 24px; }
  .filter-row, .integration-switch { padding: 12px 16px; overflow-x: auto; }
  .endpoint-strip { padding: 14px 16px; }
  .form-grid { grid-template-columns: 1fr; }
  .wide { grid-column: auto; }
  .config-list > div { padding: 11px 0; grid-template-columns: 1fr; gap: 3px; }
  .config-list dd { align-items: start; }
  .dialog-shell { padding: 21px 18px; }
  .inline-fields { align-items: stretch; flex-direction: column; }
  .align-end { align-self: stretch; }
  .alternate-action { align-items: stretch; flex-direction: column; }
  .dialog-actions .button { flex: 1; }
}

@media (max-width: 420px) {
  .metrics-grid { grid-template-columns: 1fr; }
  .metric + .metric { border-left: 0; border-top: 1px solid var(--line); }
  .segmented.three span { padding-left: 5px; padding-right: 5px; font-size: 12px; }
  .page-heading { align-items: stretch; flex-direction: column; }
  .page-heading .button { width: 100%; }
}
