:root {
  color-scheme: dark;
  --bg: #0d0f0e;
  --panel: #151816;
  --panel-2: #1d211e;
  --line: #303730;
  --text: #e7eee8;
  --muted: #9aa79d;
  --muted-2: #718075;
  --accent: #a6ff5e;
  --accent-2: #35d8b5;
  --danger: #ff6f61;
  --warning: #f2c14e;
  --code: #101210;
  --focus: rgba(166, 255, 94, 0.35);
  font-family: "IBM Plex Sans", "Noto Sans SC", "Microsoft YaHei", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  background:
    linear-gradient(90deg, rgba(166, 255, 94, 0.03) 1px, transparent 1px),
    linear-gradient(rgba(166, 255, 94, 0.025) 1px, transparent 1px),
    var(--bg);
  background-size: 32px 32px;
  color: var(--text);
  overflow: hidden;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.shell {
  width: 100vw;
  height: 100vh;
  display: flex;
  flex-direction: column;
}

.login-view,
.workspace-view,
.admin-view {
  width: 100%;
  height: 100%;
}

.workspace-view {
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.admin-view {
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.login-view {
  display: grid;
  place-items: center;
}

[hidden] {
  display: none !important;
}

.login-panel {
  width: 520px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(21, 24, 22, 0.96);
  padding: 34px;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.34);
}

.login-panel h1 {
  margin-bottom: 28px;
}

.topbar {
  min-height: 96px;
  padding: 22px 32px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(13, 15, 14, 0.92);
  backdrop-filter: blur(16px);
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--accent);
  font-family: "IBM Plex Mono", "SFMono-Regular", Consolas, monospace;
  font-size: 12px;
  letter-spacing: 0;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: 34px;
  line-height: 1.1;
  font-weight: 700;
}

.health {
  min-width: 78px;
  height: 32px;
  border: 1px solid var(--line);
  color: var(--muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 12px;
  border-radius: 6px;
  background: var(--panel);
  font-size: 13px;
}

.health.ok {
  color: var(--accent);
  border-color: rgba(166, 255, 94, 0.45);
}

.health.bad {
  color: var(--danger);
  border-color: rgba(255, 111, 97, 0.45);
}

.user-menu-wrap {
  position: relative;
}

.user-button {
  height: 36px;
  min-width: 150px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 12px;
  background: var(--panel);
  color: var(--text);
}

.user-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  z-index: 30;
  width: 160px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(21, 24, 22, 0.98);
  padding: 6px;
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.35);
}

.user-menu button {
  width: 100%;
  height: 34px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--text);
  text-align: left;
  padding: 0 10px;
}

.user-menu button:hover {
  background: var(--panel-2);
}

.layout {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: clamp(360px, 17vw, 440px) minmax(0, 1fr);
}

.sidebar {
  min-height: 0;
  padding: 20px;
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 16px;
  overflow: auto;
  background: rgba(13, 15, 14, 0.84);
}

.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(21, 24, 22, 0.94);
  padding: 18px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 7px;
  margin-bottom: 13px;
}

label,
.panel-head h2 {
  color: var(--muted);
  font-size: 14px;
  font-weight: 600;
}

.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}

.panel-head h2 {
  margin: 0;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  background: var(--code);
  color: var(--text);
  border-radius: 6px;
  outline: none;
}

input,
select {
  height: 44px;
  padding: 0 12px;
}

textarea {
  min-height: 124px;
  resize: vertical;
  padding: 10px;
  line-height: 1.5;
}

.hint {
  margin: -5px 0 0;
  color: var(--muted-2);
  font-size: 12px;
  line-height: 1.4;
}

input:focus,
select:focus,
textarea:focus,
button:focus-visible {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--focus);
}

.segmented {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin: 4px 0 14px;
}

.segmented input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.segmented span {
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  background: var(--code);
}

.segmented input:checked + span {
  color: #071007;
  border-color: var(--accent);
  background: var(--accent);
}

.primary,
.ghost,
.icon-button,
.tab {
  height: 44px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--text);
  background: var(--panel-2);
}

.primary {
  width: 100%;
  border-color: var(--accent);
  background: var(--accent);
  color: #071007;
  font-weight: 700;
}

.primary:disabled {
  cursor: wait;
  opacity: 0.65;
}

.ghost {
  height: 32px;
  padding: 0 10px;
  color: var(--muted);
  background: transparent;
}

.action-back {
  height: 36px;
}

.form-error {
  border: 1px solid rgba(255, 111, 97, 0.45);
  border-radius: 6px;
  margin: 0 0 12px;
  padding: 10px 12px;
  color: var(--danger);
  background: rgba(255, 111, 97, 0.08);
  font-size: 13px;
}

.candidate-list,
.error-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.candidate,
.server-error,
.server-ok {
  width: 100%;
  min-height: 46px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--code);
  color: var(--text);
  padding: 9px 10px;
  text-align: left;
}

.candidate {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
}

.candidate code {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.candidate.active {
  border-color: var(--accent);
  background: rgba(166, 255, 94, 0.08);
}

.count {
  color: var(--accent-2);
  font-size: 12px;
}

.server-error {
  border-color: rgba(255, 111, 97, 0.45);
  color: var(--danger);
}

.server-ok {
  color: var(--muted);
}

.empty {
  color: var(--muted-2);
  font-size: 14px;
}

.viewer {
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  background: rgba(10, 12, 11, 0.82);
}

.viewer-toolbar {
  min-height: 72px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.trace-meta {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 12px;
}

.trace-meta span {
  color: var(--muted);
  font-size: 13px;
}

.trace-meta strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-family: "IBM Plex Mono", "SFMono-Regular", Consolas, monospace;
  font-size: 14px;
}

.tools {
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}

.tools input {
  width: 240px;
}

.tools select {
  width: 132px;
}

.tabs {
  display: flex;
  gap: 4px;
}

.tab {
  min-width: 76px;
  padding: 0 10px;
  color: var(--muted);
}

.tab.active {
  color: #071007;
  border-color: var(--accent);
  background: var(--accent);
}

.icon-button {
  min-width: 54px;
  padding: 0 10px;
  color: var(--muted);
}

.log-output {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 18px;
}

.admin-layout {
  flex: 1;
  min-height: 0;
  padding: 20px;
  overflow: auto;
}

.admin-panel {
  min-height: 100%;
}

.admin-head {
  margin-bottom: 18px;
}

.admin-head .hint {
  margin-top: 6px;
}

.admin-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.save-users {
  width: 128px;
}

.user-table {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.user-row {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) minmax(260px, 1fr) 180px 104px;
  gap: 10px;
  align-items: center;
}

.user-row-head {
  min-height: 34px;
  padding: 0 4px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.password-cell {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 72px;
  gap: 8px;
}

.mini-button {
  height: 44px;
  border: 1px solid var(--line);
}

.danger-button {
  height: 44px;
  border: 1px solid rgba(255, 111, 97, 0.35);
  color: var(--danger);
}

.compact {
  min-height: 180px;
}

.empty-state {
  min-height: 100%;
  border: 1px dashed var(--line);
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 24px;
}

.empty-state h2 {
  margin-bottom: 8px;
  font-size: 22px;
}

.empty-state p {
  margin-bottom: 0;
  color: var(--muted);
}

.timeline {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.log-entry {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(16, 18, 16, 0.96);
  overflow: hidden;
}

.entry-head {
  min-height: 40px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--line);
  display: grid;
  grid-template-columns: 220px 92px minmax(0, 1fr) 180px auto;
  gap: 12px;
  align-items: center;
  color: var(--muted);
  font-family: "IBM Plex Mono", "SFMono-Regular", Consolas, monospace;
  font-size: 12px;
}

.level {
  justify-self: start;
  min-width: 54px;
  height: 22px;
  padding: 0 8px;
  border-radius: 5px;
  border: 1px solid var(--line);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
}

.level.error {
  color: var(--danger);
  border-color: rgba(255, 111, 97, 0.5);
}

.level.warn,
.level.warning {
  color: var(--warning);
  border-color: rgba(242, 193, 78, 0.5);
}

.level.info {
  color: var(--accent-2);
  border-color: rgba(53, 216, 181, 0.45);
}

.message {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.host {
  color: var(--muted-2);
}

.pretty-toggle {
  height: 28px;
  min-width: 86px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel-2);
  color: var(--muted);
  font-family: "IBM Plex Sans", "Noto Sans SC", "Microsoft YaHei", sans-serif;
  font-size: 12px;
}

.pretty-toggle:hover {
  border-color: var(--accent);
  color: var(--accent);
}

pre {
  margin: 0;
  padding: 12px 14px;
  color: #d8e4db;
  font-family: "IBM Plex Mono", "SFMono-Regular", Consolas, monospace;
  font-size: 14px;
  line-height: 1.52;
  white-space: pre-wrap;
  word-break: break-word;
}

.raw-pre,
.pretty-pre,
.raw-line,
.pretty-line {
  min-height: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--code);
}

.raw-line,
.pretty-line {
  min-height: 0;
  border: 0;
  border-radius: 0;
}

.raw-line {
  white-space: pre;
  overflow-x: auto;
  word-break: normal;
}

mark {
  color: #071007;
  background: var(--accent);
  padding: 0 2px;
}

body.fullscreen-active {
  overflow: hidden;
}

body.fullscreen-active .viewer {
  position: fixed;
  inset: 0;
  z-index: 20;
  height: 100vh;
  width: 100vw;
  background: var(--bg);
}

@media (max-width: 980px) {
  .layout {
    grid-template-columns: 1fr;
  }

  .sidebar {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .viewer {
    min-height: 70vh;
  }

  .viewer-toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .tools {
    justify-content: flex-start;
  }

  .tools input,
  .tools select {
    width: 100%;
  }

  .tabs {
    width: 100%;
  }

  .tab {
    flex: 1;
  }

  .entry-head {
    grid-template-columns: 1fr 72px;
  }

  .message,
  .host,
  .pretty-toggle {
    grid-column: 1 / -1;
    white-space: normal;
  }
}
