:root {
  color-scheme: dark;
  --bg: #000000;
  --panel: #0a0a0a;
  --panel-2: #1a1a1a;
  --line: #262626;
  --line-strong: #333333;
  --text: #fafafa;
  --muted: #a3a3a3;
  --soft: #e5e5e5;
  --green: #20d706;
  --green-soft: rgba(32, 215, 6, 0.15);
  --amber: #f59e0b;
  --amber-soft: rgba(232, 184, 77, 0.14);
  --red: #ef4444;
  --red-soft: rgba(239, 68, 68, 0.14);
  --cyan: #20d706;
  --cyan-soft: rgba(109, 183, 216, 0.14);
  --shadow: 0 24px 80px rgba(0, 0, 0, 0.42);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 16px;
  letter-spacing: 0;
  font-feature-settings: "cv02", "cv03", "cv04", "cv11";
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

.shell {
  min-height: 100vh;
  padding: 18px;
}

.shell-inner {
  margin: 0 auto;
  max-width: 1320px;
}

.app-shell {
  min-height: 100vh;
  background: var(--bg);
}

.sidebar {
  position: fixed;
  left: 0;
  top: 0;
  z-index: 20;
  display: flex;
  width: 208px;
  height: 100vh;
  flex-direction: column;
  border-right: 1px solid var(--line);
  background: var(--bg);
}

.sidebar-logo {
  display: flex;
  height: 48px;
  align-items: center;
  border-bottom: 1px solid var(--line);
  padding: 0 12px;
}

.side-nav {
  display: grid;
  gap: 6px;
  padding: 8px 6px;
}

.nav-item {
  display: flex;
  min-height: 34px;
  align-items: center;
  gap: 10px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  padding: 0 8px;
  text-align: left;
  font-size: 12px;
  font-weight: 650;
}

.nav-item:hover,
.nav-item.active {
  background: var(--green);
  color: #000000;
}

.nav-icon {
  position: relative;
  display: inline-block;
  width: 16px;
  height: 16px;
  flex: 0 0 auto;
}

.grid-icon::before {
  position: absolute;
  inset: 2px;
  border: 2px solid currentColor;
  box-shadow: 6px 0 0 -4px currentColor, 0 6px 0 -4px currentColor, 6px 6px 0 -4px currentColor;
  content: "";
}

.audit-icon::before {
  position: absolute;
  left: 3px;
  top: 2px;
  width: 10px;
  height: 12px;
  border: 2px solid currentColor;
  border-radius: 2px;
  content: "";
}

.audit-icon::after {
  position: absolute;
  left: 6px;
  top: 6px;
  width: 5px;
  height: 2px;
  background: currentColor;
  box-shadow: 0 4px 0 currentColor;
  content: "";
}

.logs-icon::before {
  position: absolute;
  left: 2px;
  top: 3px;
  width: 12px;
  height: 2px;
  background: currentColor;
  box-shadow: 0 5px 0 currentColor, 0 10px 0 currentColor;
  content: "";
}

.alert-icon::before {
  position: absolute;
  left: 7px;
  top: 2px;
  width: 2px;
  height: 9px;
  background: currentColor;
  content: "";
}

.alert-icon::after {
  position: absolute;
  left: 6px;
  bottom: 2px;
  width: 4px;
  height: 4px;
  border-radius: 999px;
  background: currentColor;
  content: "";
}

.search-icon::before {
  position: absolute;
  left: 2px;
  top: 2px;
  width: 8px;
  height: 8px;
  border: 2px solid currentColor;
  border-radius: 999px;
  content: "";
}

.search-icon::after {
  position: absolute;
  right: 1px;
  bottom: 2px;
  width: 6px;
  height: 2px;
  background: currentColor;
  content: "";
  transform: rotate(45deg);
}

.app-header {
  position: fixed;
  top: 0;
  right: 0;
  left: 208px;
  z-index: 15;
  display: flex;
  height: 48px;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.95);
  padding: 0 12px;
  backdrop-filter: blur(12px);
}

.command-button {
  position: absolute;
  left: 50%;
  top: 50%;
  display: flex;
  width: min(220px, 40vw);
  height: 28px;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  border: 1px solid rgba(38, 38, 38, 0.6);
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.4);
  color: var(--muted);
  padding: 0 8px;
  font-size: 12px;
  transform: translate(-50%, -50%);
}

.command-button:hover {
  background: var(--panel-2);
  color: var(--text);
}

.command-button kbd {
  border: 1px solid var(--line);
  border-radius: 4px;
  background: rgba(38, 38, 38, 0.3);
  color: var(--muted);
  padding: 1px 5px;
  font-size: 10px;
  line-height: 1;
}

.content-shell {
  margin-left: 208px;
  padding: 64px 12px 18px;
}

.page-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.login-shell {
  position: relative;
  display: grid;
  min-height: 100vh;
  overflow: hidden;
  place-items: center;
  padding: 18px;
}

.login-shell::before {
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.08) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.08) 1px, transparent 1px);
  background-size: 24px 24px;
  content: "";
  opacity: 0.55;
}

.login-panel {
  position: relative;
  z-index: 1;
  width: min(100%, 440px);
  border: 0;
  border-radius: 12px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.login-header,
.login-body {
  padding: 24px;
}

.login-header {
  border-bottom: 1px solid var(--line);
}

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

.brand-mark {
  display: grid;
  width: 28px;
  height: 28px;
  place-items: center;
  overflow: hidden;
  border-radius: 6px;
}

.brand-mark img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.brand strong {
  display: block;
  font-size: 14px;
  font-weight: 700;
  line-height: 1.15;
}

.brand strong span {
  color: var(--green);
}

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

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

h1 {
  margin-bottom: 4px;
  font-size: 18px;
  line-height: 1.15;
}

.login-panel h1 {
  font-size: 24px;
}

h2 {
  margin-bottom: 6px;
  font-size: 18px;
  line-height: 1.25;
}

h3 {
  margin-bottom: 0;
  font-size: 14px;
}

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

.form {
  display: grid;
  gap: 16px;
}

.field {
  display: grid;
  gap: 7px;
}

.field label {
  color: var(--soft);
  font-size: 13px;
  font-weight: 650;
}

.input,
.select {
  min-height: 36px;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--bg);
  color: var(--text);
  outline: none;
  padding: 0 12px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.16);
}

.input:focus,
.select:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 3px var(--green-soft);
}

.button {
  display: inline-flex;
  min-height: 36px;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel-2);
  color: var(--text);
  padding: 0 12px;
  font-weight: 700;
  text-decoration: none;
}

.button:hover:not(:disabled) {
  border-color: var(--line-strong);
  background: #1f1f1f;
}

.button.primary {
  border-color: rgba(32, 215, 6, 0.48);
  background: var(--green);
  color: #000000;
}

.button.danger {
  border-color: rgba(239, 111, 97, 0.5);
  background: var(--red-soft);
  color: #ffd8d2;
}

.button.ghost {
  background: transparent;
}

.button.compact {
  min-height: 28px;
  padding: 0 9px;
  font-size: 12px;
}

.login-panel .input,
.login-panel .button {
  min-height: 48px;
  border-radius: 12px;
}

.login-panel .button {
  font-size: 16px;
}

.alert {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  font-size: 13px;
}

.alert.error {
  border-color: rgba(239, 111, 97, 0.45);
  background: var(--red-soft);
  color: #ffd8d2;
}

.alert.warn {
  border-color: rgba(232, 184, 77, 0.45);
  background: var(--amber-soft);
  color: #ffe4a3;
}

.inline-alert {
  margin: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 9px 10px;
  font-size: 12px;
}

.inline-alert.error {
  border-color: rgba(239, 68, 68, 0.45);
  background: var(--red-soft);
  color: #fecaca;
}

.inline-alert.warn {
  border-color: rgba(245, 158, 11, 0.45);
  background: rgba(245, 158, 11, 0.12);
  color: #fde68a;
}

.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 0 16px;
}

.top-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  margin-left: auto;
  gap: 8px;
}

.user-pill {
  display: inline-flex;
  min-height: 28px;
  align-items: center;
  gap: 6px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--text);
  padding: 0 6px;
  font-size: 12px;
  font-weight: 650;
}

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

.avatar {
  display: grid;
  width: 20px;
  height: 20px;
  place-items: center;
  border-radius: 999px;
  background: var(--green);
  color: #000000;
  font-size: 10px;
  font-weight: 800;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 12px;
}

.metric {
  min-height: 78px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  padding: 12px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.18);
}

.metric-label {
  margin-bottom: 10px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.metric-value {
  font-size: 22px;
  font-weight: 800;
  line-height: 1;
}

.metric-note {
  margin: 9px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.toolbar {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) 180px;
  gap: 10px;
  margin: 12px 0;
}

.alert-toolbar {
  grid-template-columns: minmax(220px, 1fr) 180px auto;
}

.log-controls {
  display: grid;
  grid-template-columns: minmax(170px, 1fr) 130px 130px 130px minmax(220px, 1.4fr);
  gap: 10px;
  border-bottom: 1px solid var(--line);
  padding: 10px 12px;
}

.log-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  padding: 8px 12px;
  font-size: 12px;
}

.log-list,
.alert-list {
  display: grid;
  gap: 0;
}

.log-entry,
.alert-card {
  border-bottom: 1px solid var(--line);
  padding: 12px;
}

.log-entry:last-child,
.alert-card:last-child {
  border-bottom: 0;
}

.log-entry.high,
.alert-card.high,
.log-entry.critical,
.alert-card.critical {
  background: rgba(239, 68, 68, 0.04);
}

.log-entry.medium,
.alert-card.medium {
  background: rgba(245, 158, 11, 0.04);
}

.log-entry-head,
.alert-card-head,
.alert-title,
.pill-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.log-message,
.alert-message {
  margin: 8px 0;
  color: var(--text);
  font-size: 13px;
  line-height: 1.45;
}

.log-raw {
  max-height: 180px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--bg);
  color: #d4d4d4;
  padding: 10px;
  white-space: pre-wrap;
  word-break: break-word;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  font-size: 11px;
  line-height: 1.5;
}

.context-pill {
  display: inline-flex;
  max-width: 100%;
  min-height: 22px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  padding: 0 8px;
  font-size: 11px;
}

.alert-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 10px;
  margin: 10px 0;
}

.mini-panel {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.35);
  padding: 10px;
  font-size: 12px;
}

.mini-panel strong {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
}

.mini-panel p {
  margin-bottom: 5px;
}

.mini-panel code {
  color: var(--soft);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  font-size: 11px;
  word-break: break-all;
}

.section {
  scroll-margin-top: 64px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.18);
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid var(--line);
  padding: 10px 12px;
}

.table-wrap {
  overflow-x: auto;
}

.process-table {
  width: 100%;
  min-width: 980px;
  border-collapse: collapse;
}

.process-table th,
.process-table td {
  border-bottom: 1px solid var(--line);
  padding: 10px 12px;
  text-align: left;
  vertical-align: middle;
}

.process-table th {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.process-table tr:last-child td {
  border-bottom: 0;
}

.process-name {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 10px;
  font-weight: 800;
}

.status-dot {
  width: 10px;
  height: 10px;
  flex: 0 0 auto;
  border-radius: 999px;
  background: var(--muted);
}

.status-dot.online {
  background: var(--green);
  box-shadow: 0 0 0 4px var(--green-soft);
}

.status-dot.stopped {
  background: var(--muted);
}

.status-dot.errored {
  background: var(--red);
  box-shadow: 0 0 0 4px var(--red-soft);
}

.status-dot.mixed {
  background: var(--amber);
  box-shadow: 0 0 0 4px var(--amber-soft);
}

.badge {
  display: inline-flex;
  min-height: 24px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0 9px;
  font-size: 12px;
  font-weight: 800;
}

.badge.online {
  border-color: rgba(32, 215, 6, 0.4);
  background: var(--green-soft);
  color: #9cff8d;
}

.badge.stopped {
  color: var(--soft);
}

.badge.errored {
  border-color: rgba(239, 111, 97, 0.45);
  background: var(--red-soft);
  color: #ffd8d2;
}

.badge.mixed {
  border-color: rgba(232, 184, 77, 0.45);
  background: var(--amber-soft);
  color: #ffe4a3;
}

.actions {
  display: flex;
  min-width: 340px;
  flex-wrap: wrap;
  gap: 6px;
}

.action-mark {
  position: relative;
  display: inline-block;
  width: 14px;
  height: 14px;
}

.action-mark.start::before {
  position: absolute;
  top: 2px;
  left: 4px;
  width: 0;
  height: 0;
  border-bottom: 5px solid transparent;
  border-left: 8px solid currentColor;
  border-top: 5px solid transparent;
  content: "";
}

.action-mark.stop::before {
  position: absolute;
  inset: 3px;
  background: currentColor;
  content: "";
}

.action-mark.restart::before,
.action-mark.reload::before {
  position: absolute;
  inset: 1px;
  border: 2px solid currentColor;
  border-left-color: transparent;
  border-radius: 999px;
  content: "";
}

.action-mark.reload::after {
  position: absolute;
  right: 1px;
  bottom: 1px;
  width: 4px;
  height: 4px;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  content: "";
  transform: rotate(-20deg);
}

.empty {
  padding: 28px 14px;
  color: var(--muted);
  text-align: center;
}

.audit-list {
  display: grid;
  gap: 0;
}

.audit-item {
  display: grid;
  grid-template-columns: 145px 1fr auto;
  gap: 12px;
  border-bottom: 1px solid var(--line);
  padding: 11px 14px;
  font-size: 13px;
}

.audit-item:last-child {
  border-bottom: 0;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  background: rgba(0, 0, 0, 0.55);
  padding: 18px;
}

.modal {
  width: min(100%, 480px);
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: var(--bg);
  box-shadow: var(--shadow);
}

.modal-header,
.modal-body,
.modal-footer {
  padding: 16px;
}

.modal-header {
  border-bottom: 1px solid var(--line);
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  border-top: 1px solid var(--line);
}

#toast-root {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 40;
  display: grid;
  width: min(420px, calc(100vw - 32px));
  gap: 8px;
}

.toast {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg);
  box-shadow: var(--shadow);
  padding: 12px 14px;
  font-size: 13px;
}

.toast.success {
  border-color: rgba(32, 215, 6, 0.45);
}

.toast.error {
  border-color: rgba(239, 111, 97, 0.5);
}

.spin {
  width: 14px;
  height: 14px;
  border: 2px solid rgba(255, 255, 255, 0.28);
  border-top-color: currentColor;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@media (max-width: 980px) {
  .sidebar {
    width: 64px;
  }

  .sidebar-logo {
    justify-content: center;
    padding: 0;
  }

  .sidebar-logo .brand > div:last-child,
  .nav-item {
    font-size: 0;
    justify-content: center;
  }

  .app-header {
    left: 64px;
  }

  .content-shell {
    margin-left: 64px;
  }

  .command-button {
    display: none;
  }

  .summary-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .log-controls,
  .alert-toolbar {
    grid-template-columns: 1fr 1fr;
  }

  .alert-grid {
    grid-template-columns: 1fr;
  }

  .topbar {
    flex-direction: column;
  }

  .top-actions {
    justify-content: flex-start;
  }
}

@media (max-width: 640px) {
  .sidebar {
    display: none;
  }

  .app-header {
    left: 0;
  }

  .content-shell {
    margin-left: 0;
    padding: 64px 10px 14px;
  }

  .summary-grid,
  .toolbar,
  .log-controls,
  .alert-toolbar {
    grid-template-columns: 1fr;
  }

  .section-header,
  .audit-item {
    grid-template-columns: 1fr;
  }

  .audit-item {
    gap: 5px;
  }
}
