:root {
  --bg: #0c1118;
  --panel: #151c27;
  --fg: #e8edf4;
  --muted: #8b9aaf;
  --line: #243044;
  --accent: #3dd6c7;
  --ok: #3dd6a0;
  --down: #e07a7a;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
html { background: #0c1118; }
body {
  font-family: ui-sans-serif, system-ui, sans-serif;
  background: var(--bg);
  color: var(--fg);
  display: flex;
  flex-direction: column;
}
body.booting:not(.login-page) > * {
  visibility: hidden;
}

.bar {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 0.85rem;
  padding: 0.7rem 1.25rem;
  background: #0a0e14;
  border-bottom: 1px solid var(--line);
  flex-shrink: 0;
}

.bar-start {
  justify-self: start;
  display: flex;
  align-items: center;
  gap: 0.65rem;
  min-width: 0;
}

.session {
  margin: 0;
  color: var(--muted);
  font-size: 0.82rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.session strong { color: var(--fg); font-weight: 700; }
.session-switch {
  appearance: none;
  flex-shrink: 0;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--fg);
  font: inherit;
  font-size: 0.78rem;
  font-weight: 650;
  padding: 0.32rem 0.65rem;
  border-radius: 8px;
  cursor: pointer;
}
.session-switch:hover { border-color: var(--accent); color: var(--accent); }
.session-logout {
  appearance: none;
  flex-shrink: 0;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 0.78rem;
  font-weight: 650;
  padding: 0.32rem 0.65rem;
  border-radius: 8px;
  cursor: pointer;
}
.session-logout:hover { border-color: var(--down); color: var(--down); }

.back {
  appearance: none;
  justify-self: start;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--fg);
  font: inherit;
  font-weight: 650;
  padding: 0.4rem 0.75rem;
  border-radius: 8px;
  cursor: pointer;
}
.back:hover { border-color: var(--accent); color: var(--accent); }

.brand {
  display: flex;
  align-items: center;
  justify-self: center;
  grid-column: 2;
  gap: 0.5rem;
  font-size: 1.05rem;
  letter-spacing: 0.04em;
}
.mark {
  width: 1.6rem;
  height: 1.6rem;
  border-radius: 7px;
  background: var(--accent);
  color: #06221f;
  display: grid;
  place-items: center;
  font-weight: 800;
}
.bar-end {
  justify-self: end;
  grid-column: 3;
  display: flex;
  align-items: center;
  gap: 0.65rem;
}
.current {
  color: var(--muted);
  font-size: 0.9rem;
}

.settings {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 0;
  background: var(--panel);
  color: var(--fg);
  max-width: 28rem;
  width: calc(100% - 2rem);
}
.settings::backdrop {
  background: rgba(6, 10, 16, 0.72);
}
.settings-panel { padding: 1.15rem 1.2rem 1.05rem; }
.settings-panel h2 { margin: 0; font-size: 1.05rem; }
.settings-lede {
  margin: 0.45rem 0 1rem;
  color: var(--muted);
  font-size: 0.86rem;
}
.session-field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-size: 0.82rem;
  font-weight: 650;
  color: var(--muted);
}
.session-field input,
.session-field select {
  appearance: none;
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--fg);
  font: inherit;
  font-weight: 500;
  padding: 0.5rem 0.65rem;
  border-radius: 8px;
}
.settings-actions { display: flex; justify-content: flex-end; margin-top: 1rem; }
.settings-done {
  appearance: none;
  border: 1px solid var(--accent);
  background: transparent;
  color: var(--accent);
  font: inherit;
  font-weight: 650;
  padding: 0.4rem 0.85rem;
  border-radius: 8px;
  cursor: pointer;
}
.settings-done:hover { background: rgba(61, 214, 199, 0.12); }

.home {
  flex: 1;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 2rem 1.25rem 2.75rem;
}
.home-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  width: min(56rem, 100%);
  margin: 0 0 1.25rem;
}
.lede { color: var(--muted); margin: 0; flex: 1; }
.refresh {
  appearance: none;
  flex-shrink: 0;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--fg);
  font: inherit;
  font-size: 0.82rem;
  font-weight: 650;
  padding: 0.4rem 0.75rem;
  border-radius: 8px;
  cursor: pointer;
}
.refresh:hover { border-color: var(--accent); color: var(--accent); }
.refresh:disabled { opacity: 0.6; cursor: wait; }

.grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(12rem, 1fr));
  gap: 0.85rem;
  width: min(56rem, 100%);
}

.automate {
  margin: 1.4rem 0 0;
  padding: 0.75rem 0.9rem;
  border: 1px dashed var(--line);
  border-radius: 10px;
  color: var(--muted);
  font-size: 0.88rem;
  width: min(56rem, 100%);
}
@media (max-width: 40rem) {
  .grid { grid-template-columns: 1fr; }
}
.automate a { color: var(--accent); }
.automate strong { color: var(--fg); font-weight: 650; }

.accounts {
  margin: 1.4rem 0 0;
  padding: 0.9rem 1rem 1rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
  width: min(72rem, 100%);
}
.accounts h2 {
  margin: 0 0 0.75rem;
  font-size: 0.95rem;
}
.accounts table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.84rem;
}
.accounts th,
.accounts td {
  text-align: left;
  padding: 0.4rem 0.45rem;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}
.accounts th {
  color: var(--muted);
  font-weight: 650;
}
.accounts td:nth-child(2),
.accounts td:nth-child(3) {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
.accounts input {
  width: 100%;
  min-width: 6rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.35rem 0.45rem;
  font: inherit;
  background: #0c1118;
  color: var(--fg);
}
.accounts .row-action {
  appearance: none;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--fg);
  font: inherit;
  font-size: 0.78rem;
  font-weight: 650;
  padding: 0.28rem 0.55rem;
  border-radius: 8px;
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
}
.accounts a.row-action {
  color: var(--accent);
  border-color: rgba(61, 214, 199, 0.45);
}
.accounts .row-action:hover {
  border-color: var(--accent);
}
.accounts .row-action:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}
.accounts .row-delete {
  color: #fecaca;
  border-color: rgba(224, 122, 122, 0.45);
}

.app {
  text-align: left;
  appearance: none;
  border: 1px solid var(--line);
  background: var(--panel);
  color: inherit;
  border-radius: 12px;
  padding: 1.1rem 1rem 1rem;
  cursor: pointer;
  min-height: 8.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}
.app:hover { border-color: var(--accent); }
.app:disabled { opacity: 0.45; cursor: not-allowed; }
.app h2 { margin: 0; font-size: 1.05rem; }
.app p { margin: 0; color: var(--muted); font-size: 0.88rem; flex: 1; }
.dot {
  width: 0.55rem;
  height: 0.55rem;
  border-radius: 50%;
  background: var(--muted);
  display: inline-block;
  margin-right: 0.35rem;
}
.dot.up { background: var(--ok); }
.dot.down { background: var(--down); }
.status { font-size: 0.75rem; color: var(--muted); }

.stage {
  flex: 1;
  min-height: 0;
  display: none;
}
.stage iframe {
  width: 100%;
  height: 100%;
  border: 0;
  background: #fff;
}

body.app-open { overflow: hidden; }
body.app-open .home { display: none !important; }
body.app-open .stage {
  display: flex;
  flex: 1;
  min-height: 0;
}

body.login-page {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  min-height: 100vh;
}

.login-wrap {
  width: 100%;
  max-width: 440px;
  margin: 0 auto;
  padding: 1.5rem 1.25rem;
}

.login-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 1.75rem 1.5rem 1.5rem;
}

.login-mark {
  width: 2.2rem;
  height: 2.2rem;
  border-radius: 9px;
  background: var(--accent);
  color: #06221f;
  display: grid;
  place-items: center;
  font-weight: 800;
  margin: 0 auto 0.85rem;
}

.login-card h2 {
  margin: 0 0 1.15rem;
  font-size: 1.65rem;
  text-align: center;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.login-card label {
  display: block;
  margin-bottom: 0.9rem;
}

.login-card label span {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 0.35rem;
}

.login-card input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.7rem 0.85rem;
  font-size: 1rem;
  background: #0c1118;
  color: var(--fg);
}

.login-card input:focus {
  outline: 2px solid rgba(61, 214, 199, 0.35);
  border-color: var(--accent);
}

.login-submit {
  width: 100%;
  margin-top: 0.35rem;
  appearance: none;
  border: 1px solid var(--accent);
  background: var(--accent);
  color: #06221f;
  font: inherit;
  font-weight: 700;
  padding: 0.7rem 0.85rem;
  border-radius: 10px;
  cursor: pointer;
}

.login-submit:hover { filter: brightness(1.05); }
.login-submit:disabled { opacity: 0.65; cursor: wait; }

.login-error {
  color: #fecaca;
  background: rgba(224, 122, 122, 0.12);
  border: 1px solid rgba(224, 122, 122, 0.45);
  border-radius: 8px;
  padding: 0.55rem 0.75rem;
  font-size: 0.88rem;
  margin: 0 0 0.85rem;
}

.login-error[hidden] {
  display: none !important;
}

body.login-page {
  justify-content: center;
}
body.login-page .login-wrap {
  flex: 1;
  display: flex;
  align-items: center;
}
