:root {
  color-scheme: light;
  --ink: #111827;
  --muted: #667085;
  --line: #d9dee7;
  --surface: #ffffff;
  --canvas: #f3f5f7;
  --green: #16825d;
  --green-soft: #e9f7f1;
  --red: #bd2c2c;
  --red-soft: #fff0ef;
  --amber: #a15c00;
  --shadow: 0 18px 50px rgba(17, 24, 39, .12);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--canvas); color: var(--ink); min-height: 100vh; }
button, input, textarea, select { font: inherit; letter-spacing: 0; }
button { cursor: pointer; }
button:disabled { cursor: wait; opacity: .58; }
.hidden { display: none !important; }
.eyebrow { margin: 0 0 8px; color: var(--muted); font-size: 11px; font-weight: 800; letter-spacing: 0; }

.login-shell { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: #111827; }
.login-panel { width: min(100%, 380px); color: #f8fafc; }
.brand-mark { width: 48px; height: 48px; display: grid; place-items: center; background: #fff; color: var(--ink); border-radius: 6px; margin-bottom: 30px; }
.brand-mark svg { width: 24px; height: 24px; }
.login-panel h1 { font-size: 34px; line-height: 1.1; margin: 0; letter-spacing: 0; }
.login-copy { margin: 10px 0 34px; color: #9aa4b2; }
label { display: grid; gap: 8px; margin: 0 0 18px; font-size: 13px; font-weight: 700; }
input, select { width: 100%; min-height: 44px; padding: 10px 12px; border: 1px solid #cbd2dc; border-radius: 5px; background: #fff; color: var(--ink); outline: none; }
input:focus, select:focus { border-color: #3b82f6; box-shadow: 0 0 0 3px rgba(59, 130, 246, .16); }
textarea { width: 100%; resize: vertical; min-height: 170px; padding: 12px; border: 1px solid #cbd2dc; border-radius: 5px; color: var(--ink); background: #fff; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 13px; line-height: 1.5; }
textarea:focus { outline: none; border-color: #3b82f6; box-shadow: 0 0 0 3px rgba(59, 130, 246, .16); }
.login-panel input { border-color: #364152; background: #1f2937; color: #fff; }

.primary, .secondary, .danger, .action-button { min-height: 40px; border: 1px solid transparent; border-radius: 5px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 9px 14px; font-weight: 750; }
.primary { background: var(--ink); color: #fff; }
.login-panel .primary { background: #f8fafc; color: var(--ink); }
.secondary { border-color: var(--line); background: #fff; color: var(--ink); }
.danger { background: var(--red); color: #fff; }
.wide { width: 100%; }
button svg { width: 17px; height: 17px; }
.busy svg { animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.topbar { min-height: 64px; padding: 0 clamp(18px, 4vw, 56px); display: flex; align-items: center; justify-content: space-between; background: var(--ink); color: #fff; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; }
.topbar nav { display: flex; align-items: center; gap: 8px; }
.provider-statuses { display: flex; align-items: center; }
.icon-button { width: 38px; height: 38px; display: inline-grid; place-items: center; border: 1px solid transparent; border-radius: 5px; background: transparent; color: inherit; }
.topbar .icon-button:hover { background: #263244; }
.status-pill { min-height: 32px; display: inline-flex; align-items: center; gap: 8px; padding: 5px 10px; color: #d0d5dd; font-size: 12px; font-weight: 700; }
.status-dot, .state-dot { width: 9px; height: 9px; border-radius: 50%; background: #98a2b3; flex: none; }
.status-pill.online .status-dot, .state-dot.running { background: #2fc68f; box-shadow: 0 0 0 4px rgba(47, 198, 143, .13); }
.status-pill.offline .status-dot, .state-dot.error { background: #ef5b5b; }

.content { width: min(1180px, calc(100% - 36px)); margin: 0 auto; padding: 54px 0 70px; }
.section-heading { display: flex; align-items: end; justify-content: space-between; gap: 16px; margin-bottom: 22px; }
.section-heading h1 { margin: 0; font-size: 28px; letter-spacing: 0; }
.section-tools { display: flex; align-items: center; gap: 10px; }
.search-field { width: min(300px, 34vw); min-height: 40px; position: relative; display: block; margin: 0; }
.search-field svg { position: absolute; left: 12px; top: 12px; width: 16px; height: 16px; color: var(--muted); pointer-events: none; }
.search-field input { min-height: 40px; padding: 8px 12px 8px 36px; }
.service-list { border-top: 1px solid var(--line); }
.service-row { min-height: 150px; display: grid; grid-template-columns: minmax(220px, 1fr) 170px minmax(490px, 1.8fr); align-items: center; gap: 24px; border-bottom: 1px solid var(--line); background: var(--surface); padding: 26px 28px; }
.service-identity { display: flex; align-items: center; gap: 16px; min-width: 0; }
.server-icon { width: 44px; height: 44px; display: grid; place-items: center; border: 1px solid var(--line); border-radius: 6px; color: #344054; flex: none; }
.service-identity h2 { margin: 0 0 6px; font-size: 17px; letter-spacing: 0; overflow-wrap: anywhere; }
.service-identity p { margin: 0; color: var(--muted); font-size: 12px; }
.provider-badge { display: inline-flex; padding: 2px 5px; border: 1px solid #cbd2dc; border-radius: 4px; color: #344054; background: #f8fafc; font-size: 10px; font-weight: 800; }
.service-endpoint { display: flex; flex-wrap: wrap; gap: 6px 10px; align-items: center; margin-top: 10px; }
.service-endpoint strong { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 13px; }
.service-endpoint span { color: var(--muted); font-size: 11px; }
.service-state { display: flex; align-items: center; gap: 12px; }
.service-state div { display: grid; gap: 3px; }
.state-label { color: var(--muted); font-size: 11px; }
.service-state strong { font-size: 13px; overflow-wrap: anywhere; }
.state-dot.stopped { background: #f59e0b; }
.state-dot.pending { animation: pulse 1.4s infinite; }
@keyframes pulse { 50% { opacity: .35; } }
.actions { display: grid; grid-template-columns: repeat(6, minmax(72px, 1fr)); gap: 8px; }
.action-button { min-height: 64px; flex-direction: column; border-color: var(--line); background: #fff; color: #344054; padding: 8px 6px; font-size: 12px; }
.action-button:hover { border-color: #98a2b3; background: #f8fafc; }
.action-button.critical { color: var(--red); border-color: #efc3c0; background: #fffafa; }

dialog { width: min(520px, calc(100% - 28px)); border: 0; border-radius: 7px; padding: 28px; box-shadow: var(--shadow); color: var(--ink); }
dialog::backdrop { background: rgba(15, 23, 42, .62); backdrop-filter: blur(2px); }
dialog h2 { margin: 14px 0 8px; font-size: 21px; letter-spacing: 0; }
dialog p { color: var(--muted); line-height: 1.55; margin: 0 0 22px; }
.dialog-hint { margin-top: -8px; font-size: 12px; }
.dialog-icon { width: 40px; height: 40px; display: grid; place-items: center; border-radius: 6px; background: #edf2f7; color: #344054; }
.dialog-icon.warning { color: var(--amber); background: #fff7e8; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 26px; }
.check-row { grid-template-columns: 20px 1fr; align-items: start; font-weight: 600; line-height: 1.4; }
.check-row input { min-height: auto; width: 17px; height: 17px; margin-top: 1px; accent-color: var(--ink); }
.captcha-line { display: flex; align-items: center; gap: 8px; margin-bottom: 18px; }
.file-picker { min-height: 44px; display: flex; grid-template-columns: none; flex-direction: row; align-items: center; justify-content: center; gap: 8px; border: 1px dashed #98a2b3; border-radius: 5px; color: #344054; cursor: pointer; }
.file-picker input { display: none; }
.file-picker svg { width: 17px; height: 17px; }
#captcha-image { width: 150px; height: 52px; object-fit: contain; border: 1px solid var(--line); background: #f4f6f8; }
#captcha-image.loading { opacity: .35; }
.wide-dialog { width: min(760px, calc(100% - 28px)); }
.dialog-head { display: flex; justify-content: space-between; align-items: start; }
.dialog-head h2 { margin-top: 0; }
.audit-list { max-height: 55vh; overflow: auto; border-top: 1px solid var(--line); }
.audit-entry { display: grid; grid-template-columns: 125px minmax(150px, .8fr) 1fr; gap: 14px; padding: 13px 4px; border-bottom: 1px solid #eceff3; font-size: 12px; }
.audit-entry time, .audit-entry span { color: var(--muted); }
.account-create-form { display: grid; grid-template-columns: 1fr 1.15fr 1.15fr auto; align-items: end; gap: 10px; padding: 20px 0 24px; border-bottom: 1px solid var(--line); }
.account-create-form label { margin: 0; }
.account-create-form .primary { min-height: 44px; }
.account-list-head { display: flex; align-items: center; justify-content: space-between; padding: 20px 2px 10px; font-size: 13px; }
.account-list-head span { color: var(--muted); font-size: 12px; }
.user-list { border-top: 1px solid var(--line); max-height: 42vh; overflow: auto; }
.user-row { min-height: 68px; display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 11px 2px; border-bottom: 1px solid #eceff3; }
.user-identity { display: flex; align-items: center; gap: 12px; min-width: 0; }
.user-avatar { width: 38px; height: 38px; display: grid; place-items: center; border: 1px solid var(--line); border-radius: 5px; color: #344054; flex: none; }
.user-avatar svg { width: 17px; height: 17px; }
.user-identity div { display: grid; gap: 3px; min-width: 0; }
.user-identity strong { font-size: 13px; overflow-wrap: anywhere; }
.user-identity span { color: var(--muted); font-size: 11px; }
.user-actions { display: flex; align-items: center; gap: 4px; }
.user-actions .icon-button { color: #344054; }
.user-actions .icon-button:hover { background: #f1f3f6; }
.user-actions .user-delete { color: var(--red); }
.protected-label { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: 11px; }
.protected-label svg { width: 14px; height: 14px; }
.empty { padding: 24px 0; }
.toast { position: fixed; z-index: 20; top: 18px; left: 50%; transform: translate(-50%, -20px); opacity: 0; pointer-events: none; max-width: min(520px, calc(100% - 28px)); padding: 11px 15px; border-radius: 5px; background: var(--ink); color: #fff; box-shadow: var(--shadow); font-size: 13px; transition: .2s ease; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.success { background: var(--green); }
.toast.error { background: var(--red); }

@media (max-width: 900px) {
  .service-row { grid-template-columns: 1fr auto; }
  .actions { grid-column: 1 / -1; }
}

@media (max-width: 620px) {
  .topbar { padding: 0 12px; }
  .status-pill span:last-child { display: none; }
  .provider-statuses { gap: 2px; }
  .provider-statuses .status-pill { padding-inline: 4px; }
  .content { width: min(100% - 20px, 1180px); padding-top: 34px; }
  .section-heading { align-items: center; }
  .section-tools { flex: 1; justify-content: flex-end; }
  .search-field { width: min(100%, 240px); }
  .section-heading .secondary span { display: none; }
  .service-row { grid-template-columns: 1fr; gap: 20px; padding: 22px 18px; }
  .service-state { grid-row: 2; }
  .actions { grid-column: auto; grid-template-columns: repeat(3, 1fr); }
  .action-button { min-height: 58px; }
  dialog { padding: 22px 18px; }
  .dialog-actions { display: grid; grid-template-columns: 1fr 1fr; }
  .audit-entry { grid-template-columns: 1fr 1fr; }
  .audit-entry span { grid-column: 1 / -1; }
  .account-create-form { grid-template-columns: 1fr; }
  .user-list { max-height: 38vh; }
}
