:root {
  color-scheme: dark;
  --bg: #0b0d12;
  --bg-2: #11141b;
  --panel: #141821;
  --panel-2: #1b2030;
  --line: #262d3b;
  --text: #e9edf6;
  --muted: #8b95a9;
  --faint: #626d82;
  --accent: #9db2ff;
  --accent-2: #7f8ff0;
  --ok: #7ee2a8;
  --warn: #f5b95f;
  --bad: #ff7f8f;
  --radius: 16px;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html { background: var(--bg); -webkit-text-size-adjust: 100%; }

body {
  min-height: 100dvh;
  margin: 0;
  background:
    radial-gradient(1100px 520px at 15% -10%, rgba(157, 178, 255, .14), transparent 60%),
    radial-gradient(900px 500px at 110% 0%, rgba(157, 178, 255, .08), transparent 55%),
    var(--bg);
  color: var(--text);
  font: 14px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

.shell {
  width: min(100%, 900px);
  margin: 0 auto;
  padding: clamp(24px, 6vh, 60px) 16px 40px;
}

.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 22px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--text);
  font-size: 16px;
  font-weight: 700;
  text-decoration: none;
}

.mark {
  width: 11px;
  height: 11px;
  border-radius: 3px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  box-shadow: 0 0 0 4px rgba(157, 178, 255, .1);
}

.slash {
  color: var(--faint);
  font-weight: 400;
}

.muted { color: var(--muted); font-weight: 500; }

.top-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.user {
  color: var(--muted);
  font-size: 12px;
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  padding: 0;
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 9px;
  color: var(--muted);
}

.icon-btn:hover { color: var(--text); }
.icon-btn svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 18px 50px rgba(0, 0, 0, .16);
}

.login {
  width: 100%;
  max-width: 380px;
  margin: 0 auto;
  padding: 28px 24px;
  background: linear-gradient(180deg, var(--panel), var(--bg-2));
  border: 1px solid var(--line);
  border-radius: 20px;
  box-shadow: 0 18px 50px rgba(0, 0, 0, .35);
}

.hint {
  margin: 0 0 20px;
  color: var(--muted);
  font-size: 14px;
}

h1 {
  margin: 0;
  font-size: 21px;
  letter-spacing: -.02em;
}

body.login-mode .shell {
  display: none;
}

.field {
  display: block;
  margin-bottom: 14px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
}

.field input {
  display: block;
  width: 100%;
  height: 46px;
  margin-top: 7px;
  padding: 0 14px;
  background: #0a0e0c;
  border: 1px solid var(--line);
  border-radius: 11px;
  color: var(--text);
  font: inherit;
  font-size: 16px;
  outline: none;
}

.field input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(157, 178, 255, .13); }

.field input:-webkit-autofill,
.field input:-webkit-autofill:hover,
.field input:-webkit-autofill:focus {
  -webkit-box-shadow: 0 0 0 1000px #0a0e0c inset !important;
  -webkit-text-fill-color: var(--text) !important;
  caret-color: var(--text);
  transition: background-color 9999s ease-out;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  padding: 0 13px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 9px;
  color: var(--text);
  font: inherit;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
}

.btn:hover { border-color: #3a4357; }
.btn:disabled { opacity: .5; cursor: default; }
.btn.primary {
  min-height: 42px;
  background: linear-gradient(180deg, var(--accent), var(--accent-2));
  border-color: transparent;
  color: #0a0f1f;
}

.login .btn.primary {
  width: 100%;
  min-height: 42px;
  padding: 0 16px;
  border-radius: 11px;
  font-size: 14px;
}
.btn.danger { background: rgba(255, 127, 143, .12); border-color: rgba(255, 127, 143, .35); color: #ffc4cc; }
.btn.small { min-height: 32px; padding: 0 9px; font-size: 11.5px; }

.error { min-height: 20px; margin: 10px 0 0; color: var(--bad); font-size: 12px; }

.head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.eyebrow {
  color: var(--faint);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .12em;
  text-transform: uppercase;
}

.head h1 { margin-top: 4px; font-size: 26px; }

.dash-note {
  min-height: 18px;
  margin: -6px 0 10px;
  font-size: 12px;
  color: var(--muted);
}

.dash-note.ok { color: var(--ok); }
.dash-note.bad { color: var(--bad); }

.services {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.service { padding: 16px; }

.service-top {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.service-top .dot { width: 7px; height: 7px; }

.service-name {
  flex: 1;
  min-width: 0;
  font-size: 14px;
  font-weight: 650;
}

.service-name span {
  margin-left: 4px;
  color: var(--faint);
  font-size: 11px;
  font-weight: 500;
}

.state {
  color: var(--muted);
  font-size: 11px;
  white-space: nowrap;
}

.state.ok { color: #b9f5d2; }
.state.bad { color: #ffc4cc; }
.state.wait { color: #ffe0ae; }

.service-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 5px 14px;
  margin-top: 10px;
  color: var(--faint);
  font-size: 11px;
}

.service-meta b { color: var(--muted); font-weight: 600; }

.service-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 14px;
}

.logs {
  margin-top: 12px;
  overflow: hidden;
}

.logs-head {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
}

.log-tabs { display: flex; gap: 4px; }

.log-tab {
  min-height: 28px;
  padding: 0 9px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 7px;
  color: var(--faint);
  font: inherit;
  font-size: 11.5px;
  font-weight: 600;
  cursor: pointer;
}

.log-tab.active { background: rgba(157, 178, 255, .1); border-color: rgba(157, 178, 255, .3); color: var(--accent); }

.auto {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin-left: auto;
  color: var(--faint);
  font-size: 11px;
}

.auto input { accent-color: var(--accent); }

#logText {
  min-height: 220px;
  max-height: 48dvh;
  margin: 0;
  padding: 13px;
  overflow: auto;
  background: #090c12;
  color: #c9d2e5;
  font: 11.5px/1.55 ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
  white-space: pre-wrap;
  word-break: break-word;
}

.dot {
  display: inline-block;
  flex: 0 0 auto;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--warn);
}

.dot.ok { background: var(--ok); box-shadow: 0 0 0 3px rgba(126, 226, 168, .1); }
.dot.bad { background: var(--bad); box-shadow: 0 0 0 3px rgba(255, 127, 143, .1); }
.dot.wait { background: var(--warn); box-shadow: 0 0 0 3px rgba(245, 185, 95, .1); }

.overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(5, 7, 10, .8);
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
}

.confirm {
  width: 100%;
  max-width: 400px;
  padding: 18px;
}

.confirm h2 { margin: 0 0 6px; font-size: 17px; }
.confirm p { margin: 0; color: var(--muted); font-size: 13px; }

.confirm-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 18px;
}

@media (max-width: 720px) {
  body.login-mode .top {
    top: calc(20px + env(safe-area-inset-top, 0px));
    left: 16px;
    right: 16px;
  }
}

@media (max-width: 620px) {
  .shell { padding-top: calc(20px + env(safe-area-inset-top, 0px)); }
  .services { grid-template-columns: minmax(0, 1fr); }
  .head { align-items: flex-start; flex-direction: column; gap: 10px; }
  .head h1 { font-size: 23px; }
  .login { margin: 0 auto; }

  body.login-mode .top {
    top: calc(20px + env(safe-area-inset-top, 0px));
    left: 16px;
    right: 16px;
  }
  .logs-head { gap: 8px; }
  .auto { margin-left: 0; }
  #logText { max-height: 42dvh; }
}


/* auth layout */
.x-auth {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100dvh;
  padding: calc(24px + var(--safe-t)) 18px calc(24px + var(--safe-b));
}

.x-auth-card {
  width: 100%;
  max-width: 380px;
  padding: 28px 24px;
  background: linear-gradient(180deg, var(--panel), var(--bg-2));
  border: 1px solid var(--line);
  border-radius: 20px;
  box-shadow: var(--shadow);
}

.x-auth-brand {
  position: fixed;
  top: calc(30px + var(--safe-t));
  left: 32px;
}

.x-auth-brand .x-logo {
  font-size: 16px;
}

.x-logo {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: .2px;
  white-space: nowrap;
}

.x-logo::before {
  content: "";
  width: 11px;
  height: 11px;
  border-radius: 3px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  box-shadow: 0 0 0 4px rgba(var(--accent-rgb), .12);
}

.x-logo a {
  color: inherit;
  text-decoration: none;
}

.x-logo-sep {
  color: var(--faint);
  font-weight: 400;
}

.x-logo-muted {
  color: var(--muted);
  font-weight: 500;
}

.x-hint {
  margin: 0 0 20px;
  color: var(--muted);
  font-size: 14px;
}

.x-field {
  display: block;
  margin-bottom: 14px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
}

.x-field input {
  display: block;
  width: 100%;
  height: 46px;
  margin-top: 7px;
  padding: 0 14px;
  background: #090c12;
  border: 1px solid var(--line);
  border-radius: 11px;
  color: var(--text);
  font-size: 16px;
  outline: none;
}

.x-field input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(var(--accent-rgb), .16);
}

.x-field input:-webkit-autofill:focus {
  -webkit-box-shadow: 0 0 0 1000px #0a0e0c inset !important;
  -webkit-text-fill-color: var(--text) !important;
  caret-color: var(--text);
  transition: background-color 9999s ease-out;
}

.x-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 42px;
  padding: 0 16px;
  border: 1px solid transparent;
  border-radius: 11px;
  background: var(--panel-2);
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
  line-height: 1;
  white-space: nowrap;
  transition: background .15s ease, border-color .15s ease, transform .08s ease;
}

.x-btn:active {
  transform: scale(.98);
}

.x-primary {
  background: linear-gradient(180deg, var(--accent), var(--accent-2));
  color: #0a0f1f;
}

.x-primary:hover {
  filter: brightness(1.06);
}

.x-wide {
  width: 100%;
}

.x-error {
  min-height: 20px;
  margin: 12px 0 0;
  color: var(--danger);
  font-size: 13px;
}

.x-auth {
  font-size: 15px;
  line-height: 1.45;
}

.x-field input:-webkit-autofill,
.x-field input:-webkit-autofill:hover,
.x-field input:-webkit-autofill:focus {
  -webkit-box-shadow: 0 0 0 1000px #0a0e0c inset !important;
  -webkit-text-fill-color: var(--text) !important;
  caret-color: var(--text);
  transition: background-color 9999s ease-out;
}

@media (max-width: 720px) {
  .x-auth-brand {
    top: calc(20px + var(--safe-t));
    left: 16px;
  }
}
