:root {
  --bg: #f6f7f9;
  --panel: #ffffff;
  --text: #111111;
  --muted: #68707d;
  --line: #e2e5ea;
  --soft-line: #eef0f4;
  --accent: #ec008c;
  --accent-strong: #bd006f;
  --accent-soft: #fff0f8;
  --success: #16845f;
  --warning: #b76b00;
  --danger: #b42318;
  --blue: #3157d5;
  --shadow: 0 10px 24px rgba(17, 17, 17, 0.06);
}

* {
  box-sizing: border-box;
}

.hidden {
  display: none !important;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  background:
    linear-gradient(180deg, #ffffff 0, var(--bg) 220px),
    var(--bg);
  font-family: Inter, "Segoe UI", Arial, sans-serif;
}

.login-screen {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: none;
  place-items: center;
  padding: 20px;
  background: rgba(245, 247, 251, 0.96);
}

.login-screen.visible {
  display: grid;
}

.login-card {
  display: grid;
  gap: 14px;
  width: min(420px, 100%);
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.login-card label {
  display: grid;
  gap: 6px;
}

.login-card span,
.login-card small {
  color: var(--muted);
}

.login-error {
  display: none;
  margin: 0;
  color: #b42318;
  font-size: 13px;
  font-weight: 700;
}

.login-error.visible {
  display: block;
}

.shell {
  width: min(1280px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 40px;
}

.topbar {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) auto auto auto;
  align-items: center;
  gap: 16px;
  padding: 10px 0 24px;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--accent-strong);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

.eyebrow::before {
  content: "";
  display: inline-block;
  width: 7px;
  height: 7px;
  margin-right: 7px;
  border-radius: 2px;
  background: var(--accent);
  vertical-align: 1px;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: 34px;
  line-height: 1.05;
}

h2 {
  font-size: 18px;
  line-height: 1.2;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 36px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--muted);
  font-size: 14px;
}

.language-switch {
  display: grid;
  gap: 4px;
  min-width: 132px;
}

.language-switch span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.language-switch select {
  min-height: 36px;
}

.console-layout {
  display: grid;
  grid-template-columns: 210px minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}

.workspace {
  display: grid;
  gap: 14px;
  min-width: 0;
}

.tabs {
  position: sticky;
  top: 12px;
  display: grid;
  gap: 4px;
  margin-bottom: 0;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.nav-label {
  padding: 6px 10px 8px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.tab {
  min-height: 38px;
  padding: 0 10px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-weight: 700;
  text-align: left;
}

.tab.active {
  background: var(--accent-soft);
  color: var(--text);
  box-shadow: inset 3px 0 0 var(--accent);
}

.tab:hover {
  background: #f7f7f8;
  color: var(--text);
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
.tab:focus-visible,
.text-button:focus-visible {
  outline: 3px solid rgba(236, 0, 140, 0.16);
  outline-offset: 2px;
}

.dot,
.service-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--success);
  box-shadow: 0 0 0 4px rgba(22, 132, 95, 0.12);
}

.summary-strip {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.summary-strip div {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 34px;
  padding: 0 10px;
  border-radius: 6px;
  background: #f7f8fa;
}

.summary-strip span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.summary-strip strong {
  font-size: 16px;
}

body[data-active-tab="overview"] .summary-strip {
  display: none;
}

body:not([data-active-tab="overview"]) .overview-metrics {
  display: none;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
  margin-bottom: 14px;
}

.metric,
.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.metric {
  display: grid;
  gap: 7px;
  min-height: 104px;
  padding: 16px;
}

.metric span,
.metric small,
dt,
.split-list span,
td,
th,
.service-list small {
  color: var(--muted);
}

.metric strong {
  font-size: 24px;
  line-height: 1;
}

.grid {
  display: grid;
  grid-template-columns: 1.25fr 0.85fr;
  gap: 14px;
}

.tab-panel {
  display: none;
}

.tab-panel.active {
  display: grid;
}

.tab-panel:not(.grid) {
  gap: 14px;
}

.panel {
  padding: 18px;
}

.primary-panel {
  grid-row: span 2;
}

.wide {
  grid-column: 1 / -1;
}

.panel-head {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
}

.icon-button {
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--accent-soft);
  color: var(--accent-strong);
  cursor: pointer;
  font-weight: 700;
}

.icon-button:hover {
  border-color: rgba(236, 0, 140, 0.35);
  background: #ffe4f3;
}

.actions {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.file-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.file-button input {
  display: none;
}

.config-list {
  display: grid;
  gap: 10px;
  margin: 0;
}

.config-list div,
.split-list {
  display: grid;
  grid-template-columns: 150px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  min-height: 44px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfbfc;
}

dt {
  font-size: 13px;
}

dd {
  margin: 0;
  overflow-wrap: anywhere;
  font-weight: 700;
}

.mono,
td:first-child,
td:nth-child(2) {
  font-family: "Cascadia Mono", Consolas, monospace;
}

.service-list {
  display: grid;
  gap: 12px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.service-list li {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 58px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfbfc;
}

.service-list strong,
.service-list small {
  display: block;
}

.split-list {
  grid-template-columns: minmax(0, 1fr) auto;
}

.split-list strong {
  color: var(--accent-strong);
}

table {
  width: 100%;
  border-collapse: collapse;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
}

th,
td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  font-size: 14px;
}

th {
  background: #f4f5f7;
  color: var(--text);
  font-size: 12px;
  text-transform: uppercase;
}

tbody tr:hover td {
  background: #fff8fc;
}

tbody tr:last-child td {
  border-bottom: 0;
}

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

.manager-form label,
.list-toolbar {
  display: grid;
  gap: 6px;
}

.manager-form span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

input,
select {
  width: 100%;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfbfc;
  color: var(--text);
  font: inherit;
  padding: 0 10px;
}

select[multiple] {
  min-height: 116px;
  padding: 8px 10px;
}

input:focus,
select:focus {
  border-color: rgba(236, 0, 140, 0.55);
  outline: 3px solid rgba(236, 0, 140, 0.12);
}

.form-wide {
  grid-column: span 2;
}

.form-actions {
  display: flex;
  align-items: end;
  gap: 8px;
}

.primary-button,
.ghost-button {
  min-height: 38px;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 700;
  padding: 0 12px;
}

.primary-button {
  border: 1px solid var(--accent-strong);
  background: var(--accent);
  color: #fff;
}

.primary-button:hover {
  background: var(--accent-strong);
}

.ghost-button {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--muted);
}

.list-toolbar {
  grid-template-columns: minmax(0, 1fr) 180px;
  margin-bottom: 12px;
}

.log-toolbar {
  grid-template-columns: 160px 140px minmax(0, 1fr);
}

.session-toolbar {
  grid-template-columns: repeat(5, minmax(120px, 1fr));
}

.session-toolbar [data-session-search] {
  grid-column: span 2;
}

.log-view {
  min-height: 360px;
  max-height: 520px;
  overflow: auto;
  margin: 0;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #111111;
  color: #f3f3f3;
  font-family: "Cascadia Mono", Consolas, monospace;
  font-size: 12px;
  line-height: 1.55;
  white-space: pre-wrap;
}

.compact-log {
  min-height: 180px;
  max-height: 260px;
  margin-top: 14px;
}

.monitor-grid {
  grid-template-columns: minmax(0, 1fr) auto;
}

.stacked-table {
  margin-top: 14px;
}

.connection-result {
  display: none;
  margin-top: 14px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfbfc;
}

.connection-result.visible {
  display: grid;
  gap: 10px;
}

.connection-result a {
  color: var(--accent-strong);
  font-weight: 700;
}

.connection-result code {
  overflow-wrap: anywhere;
  font-family: "Cascadia Mono", Consolas, monospace;
}

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

.row-actions {
  display: flex;
  gap: 6px;
  align-items: center;
}

.text-button {
  min-height: 30px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--accent-strong);
  cursor: pointer;
  font-weight: 700;
  padding: 0 8px;
}

.text-button.danger {
  color: var(--danger);
}

.status-badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 8px;
  border-radius: 999px;
  background: #eef2ff;
  color: var(--blue);
  font-size: 12px;
  font-weight: 700;
}

.status-badge.ready,
.status-badge.active {
  background: #eaf7f2;
  color: var(--success);
}

.status-badge.blocked,
.status-badge.paused,
.status-badge.limit-exceeded {
  background: #fff1f0;
  color: var(--danger);
}

.status-badge.no-data,
.status-badge.unknown {
  background: #f4f5f7;
  color: var(--muted);
}

.status-badge.warning,
.status-badge.needs-setup,
.status-badge.stale {
  background: #fff7e8;
  color: var(--warning);
}

.empty-state {
  display: none;
  margin: 12px 0 0;
  padding: 16px;
  border: 1px dashed #d8dce3;
  border-radius: 8px;
  background: #fbfbfc;
  color: var(--muted);
}

.empty-state.visible {
  display: grid;
  gap: 4px;
}

.empty-state strong {
  color: var(--text);
}

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  transform: translateY(20px);
  opacity: 0;
  pointer-events: none;
  border-radius: 8px;
  background: var(--text);
  color: #fff;
  padding: 10px 14px;
  transition: opacity 160ms ease, transform 160ms ease;
}

.toast.visible {
  transform: translateY(0);
  opacity: 1;
}

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

  .console-layout {
    grid-template-columns: 1fr;
  }

  .tabs {
    position: static;
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .nav-label {
    grid-column: 1 / -1;
  }

  .tab {
    text-align: center;
  }

  .tab.active {
    box-shadow: inset 0 -3px 0 var(--accent);
  }

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

  .metrics,
  .grid {
    grid-template-columns: 1fr;
  }

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

  .primary-panel,
  .wide {
    grid-column: auto;
    grid-row: auto;
  }
}

@media (max-width: 560px) {
  .shell {
    width: min(100% - 20px, 1180px);
    padding-top: 16px;
  }

  .topbar,
  .panel-head {
    align-items: stretch;
  }

  .panel-head {
    flex-direction: column;
  }

  h1 {
    font-size: 28px;
  }

  .config-list div,
  .split-list {
    grid-template-columns: 1fr;
  }

  .manager-form,
  .list-toolbar,
  .session-toolbar {
    grid-template-columns: 1fr;
  }

  .form-wide {
    grid-column: auto;
  }

  .tabs {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    width: 100%;
  }

  .summary-strip {
    grid-template-columns: 1fr;
  }

  table {
    display: block;
    overflow-x: auto;
    white-space: nowrap;
  }
}
