:root {
  color-scheme: light;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  background: #f7f8f5;
  color: #17211f;
  letter-spacing: 0;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  background: #f7f8f5;
}

body:has(.auth-screen:not([hidden])) {
  background: #17211f;
}

button {
  font: inherit;
}

a {
  color: inherit;
  text-decoration: none;
}

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

.auth-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    linear-gradient(135deg, rgba(23, 33, 31, 0.94), rgba(31, 54, 58, 0.94)),
    #17211f;
}

.login-panel {
  width: min(100%, 420px);
  border: 1px solid #dbe2dd;
  border-radius: 8px;
  background: #ffffff;
  padding: 24px;
  display: grid;
  gap: 22px;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.22);
}

.login-fields {
  display: grid;
  gap: 14px;
}

.login-fields label {
  display: grid;
  gap: 7px;
  color: #455551;
  font-size: 13px;
  font-weight: 700;
}

.login-fields input {
  width: 100%;
  min-height: 42px;
  border: 1px solid #cad4cf;
  border-radius: 8px;
  padding: 0 12px;
  color: #17211f;
  font: inherit;
}

.login-fields input:focus {
  border-color: #0d9488;
  outline: 3px solid #d8f3ee;
}

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

.form-error {
  color: #9f341f;
  font-size: 13px;
  font-weight: 700;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 248px minmax(0, 1fr);
}

.sidebar {
  background: #17211f;
  color: #f7f8f5;
  padding: 24px 16px;
  display: flex;
  flex-direction: column;
  gap: 32px;
}

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

.brand-mark {
  width: 40px;
  height: 40px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: #f2c14e;
  color: #17211f;
  font-weight: 800;
}

.brand-name {
  font-size: 18px;
  font-weight: 800;
}

.brand-meta,
.page-kicker,
.summary-label,
dt {
  color: #71807c;
  font-size: 13px;
}

.brand-meta {
  color: #b8c4c0;
}

.brand-meta.dark {
  color: #71807c;
}

.nav-list {
  display: grid;
  gap: 6px;
}

.nav-item {
  border: 0;
  border-radius: 8px;
  min-height: 40px;
  padding: 0 12px;
  display: flex;
  align-items: center;
  color: #dce6e2;
  background: transparent;
  text-align: left;
  cursor: pointer;
}

.nav-item.active,
.nav-item:hover {
  background: #263532;
  color: #ffffff;
}

.main {
  padding: 28px;
  display: grid;
  gap: 20px;
}

.topbar {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 16px;
}

.topbar-controls {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 10px;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 28px;
  line-height: 1.15;
}

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

.env-switcher {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.session-bar {
  display: flex;
  align-items: center;
  gap: 8px;
}

.user-chip {
  min-height: 32px;
  display: inline-flex;
  align-items: center;
  border: 1px solid #d7ded9;
  border-radius: 8px;
  background: #ffffff;
  padding: 0 10px;
  color: #31413d;
  font-size: 13px;
  font-weight: 700;
  max-width: 280px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.env-tab,
.theme-switch,
.primary-action,
.secondary-action {
  border-radius: 8px;
  min-height: 36px;
  padding: 0 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.env-tab {
  border: 1px solid #d7ded9;
  background: #ffffff;
  color: #31413d;
}

.env-tab.active {
  border-color: #0d9488;
  background: #d8f3ee;
  color: #0f514b;
}

.theme-form {
  display: inline-flex;
}

.theme-switch {
  gap: 8px;
  border: 1px solid #d7ded9;
  background: #ffffff;
  color: #31413d;
}

.theme-switch-track {
  width: 34px;
  height: 20px;
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  background: #d7ded9;
  padding: 2px;
}

.theme-switch-thumb {
  width: 16px;
  height: 16px;
  border-radius: 999px;
  background: #ffffff;
  box-shadow: 0 1px 3px rgba(23, 33, 31, 0.25);
  transform: translateX(0);
  transition: transform 160ms ease;
}

.theme-switch-label {
  font-size: 13px;
  font-weight: 800;
}

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

.summary-panel,
.service-group,
.detail-pane,
.activity-section {
  background: #ffffff;
  border: 1px solid #dbe2dd;
  border-radius: 8px;
}

.summary-panel {
  min-height: 78px;
  padding: 14px;
  display: grid;
  gap: 8px;
}

.summary-panel strong {
  font-size: 22px;
}

.flash-message,
.empty-state {
  margin: 0;
  padding: 12px 14px;
  border: 1px solid #cad4cf;
  border-radius: 8px;
  background: #ffffff;
  color: #31413d;
  font-size: 14px;
  font-weight: 700;
}

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

.service-group,
.detail-pane,
.activity-section {
  overflow: hidden;
}

.service-groups,
.compare-groups {
  display: grid;
  gap: 10px;
  min-width: 0;
}

.section-heading {
  min-height: 58px;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid #e5ebe7;
}

.section-heading.compact {
  min-height: 50px;
}

.section-heading.inline {
  min-height: 34px;
  padding: 0 0 6px;
  border-bottom: 0;
}

.group-heading {
  min-height: 54px;
  padding: 0 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  cursor: pointer;
  list-style: none;
}

.group-heading::-webkit-details-marker {
  display: none;
}

.group-title {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.group-caret {
  width: 16px;
  height: 16px;
  display: inline-grid;
  place-items: center;
  color: #71807c;
  transition: transform 160ms ease;
}

.group-caret::before {
  content: ">";
  font-size: 12px;
  font-weight: 800;
}

.service-group[open] .group-caret {
  transform: rotate(90deg);
}

.group-name {
  overflow: hidden;
  color: #17211f;
  font-size: 15px;
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.deployment-table-wrap,
.compare-table-wrap {
  overflow-x: auto;
  border-top: 1px solid #e5ebe7;
}

.toolbar,
.detail-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.primary-action {
  border: 1px solid #0f766e;
  background: #0f766e;
  color: #ffffff;
}

.secondary-action {
  border: 1px solid #cad4cf;
  background: #ffffff;
  color: #263532;
}

.deployment-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
  font-size: 14px;
}

.compare-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
  font-size: 13px;
}

th,
td {
  padding: 12px 14px;
  border-bottom: 1px solid #edf1ee;
  text-align: left;
  vertical-align: middle;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

th {
  color: #71807c;
  font-weight: 700;
  font-size: 12px;
  text-transform: uppercase;
}

tbody tr {
  cursor: default;
}

tbody tr:hover,
tbody tr.selected {
  background: #f2f7f4;
}

.pill,
.status-chip {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: 999px;
  padding: 0 9px;
  font-size: 12px;
  font-weight: 700;
  max-width: 100%;
}

.pill.neutral,
.status-chip.neutral {
  background: #edf1ee;
  color: #455551;
}

.status-chip.good {
  background: #dcf5df;
  color: #1d6a2f;
}

.status-chip.running {
  background: #e5efff;
  color: #245a9d;
}

.status-chip.bad {
  background: #ffe0d6;
  color: #9f341f;
}

.compare-table th:first-child {
  width: 180px;
}

.compare-table th,
.compare-table td {
  white-space: normal;
  vertical-align: top;
}

.compare-table tbody th {
  color: #17211f;
  font-size: 14px;
  text-transform: none;
}

.compare-cell {
  min-height: 154px;
  display: grid;
  align-content: start;
  gap: 8px;
}

.compare-cell.missing {
  min-height: 154px;
  align-content: center;
  color: #71807c;
  font-weight: 700;
}

.compare-cell-head {
  display: grid;
  gap: 6px;
}

.compare-cell strong,
.compare-meta {
  overflow-wrap: anywhere;
}

.compare-marker {
  width: max-content;
  max-width: 100%;
  min-height: 22px;
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 0 8px;
  font-size: 11px;
  font-weight: 800;
}

.compare-marker.base,
.compare-marker.same {
  background: #dcf5df;
  color: #1d6a2f;
}

.compare-marker.warn {
  background: #fff2bf;
  color: #76590d;
}

.compare-marker.bad {
  background: #ffe0d6;
  color: #9f341f;
}

.compare-meta {
  color: #455551;
  font-size: 12px;
  line-height: 1.35;
}

.compare-statuses {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.detail-list {
  margin: 0;
  padding: 6px 16px 16px;
  display: grid;
  gap: 14px;
}

.detail-list div {
  display: grid;
  gap: 4px;
}

dt,
dd {
  margin: 0;
}

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

.detail-actions {
  padding: 0 16px 16px;
}

.activity-list {
  margin: 0;
  padding: 12px 18px 16px 36px;
  display: grid;
  gap: 8px;
}

.activity-list li {
  line-height: 1.4;
}

.action-cell {
  white-space: normal;
}

.inline-form {
  display: inline-flex;
  margin: 2px 4px 2px 0;
}

html[data-theme="dark"] {
  color-scheme: dark;
  background: #101514;
  color: #eef4f0;
}

html[data-theme="dark"] body {
  background: #101514;
}

html[data-theme="dark"] body:has(.auth-screen:not([hidden])),
html[data-theme="dark"] .auth-screen {
  background:
    linear-gradient(135deg, rgba(16, 21, 20, 0.96), rgba(30, 46, 43, 0.96)),
    #101514;
}

html[data-theme="dark"] .sidebar {
  background: #0c1110;
}

html[data-theme="dark"] .nav-item.active,
html[data-theme="dark"] .nav-item:hover {
  background: #1d2a27;
}

html[data-theme="dark"] .login-panel,
html[data-theme="dark"] .summary-panel,
html[data-theme="dark"] .service-group,
html[data-theme="dark"] .detail-pane,
html[data-theme="dark"] .activity-section,
html[data-theme="dark"] .flash-message,
html[data-theme="dark"] .empty-state {
  background: #151d1b;
  border-color: #2e3c38;
  color: #eef4f0;
}

html[data-theme="dark"] .brand-meta.dark,
html[data-theme="dark"] .page-kicker,
html[data-theme="dark"] .summary-label,
html[data-theme="dark"] dt,
html[data-theme="dark"] th,
html[data-theme="dark"] .compare-cell.missing {
  color: #95a7a1;
}

html[data-theme="dark"] .login-fields label,
html[data-theme="dark"] .compare-meta {
  color: #b8c8c2;
}

html[data-theme="dark"] .login-fields input,
html[data-theme="dark"] .env-tab,
html[data-theme="dark"] .theme-switch,
html[data-theme="dark"] .user-chip,
html[data-theme="dark"] .secondary-action {
  border-color: #34433f;
  background: #101514;
  color: #eef4f0;
}

html[data-theme="dark"] .login-fields input:focus {
  border-color: #2dd4bf;
  outline-color: #164e47;
}

html[data-theme="dark"] .env-tab.active {
  border-color: #2dd4bf;
  background: #123a36;
  color: #c7fff5;
}

html[data-theme="dark"] .theme-switch-track {
  background: #0f766e;
}

html[data-theme="dark"] .theme-switch-thumb {
  transform: translateX(14px);
}

html[data-theme="dark"] .group-name,
html[data-theme="dark"] .compare-table tbody th {
  color: #eef4f0;
}

html[data-theme="dark"] .section-heading,
html[data-theme="dark"] .deployment-table-wrap,
html[data-theme="dark"] .compare-table-wrap {
  border-color: #273531;
}

html[data-theme="dark"] th,
html[data-theme="dark"] td {
  border-color: #22302c;
}

html[data-theme="dark"] tbody tr:hover,
html[data-theme="dark"] tbody tr.selected {
  background: #1b2824;
}

html[data-theme="dark"] .pill.neutral,
html[data-theme="dark"] .status-chip.neutral {
  background: #23302d;
  color: #c6d5cf;
}

html[data-theme="dark"] .status-chip.good,
html[data-theme="dark"] .compare-marker.base,
html[data-theme="dark"] .compare-marker.same {
  background: #123b25;
  color: #9af1b2;
}

html[data-theme="dark"] .status-chip.running {
  background: #132f52;
  color: #a8cfff;
}

html[data-theme="dark"] .status-chip.bad,
html[data-theme="dark"] .compare-marker.bad {
  background: #4a1f18;
  color: #ffb8a7;
}

html[data-theme="dark"] .compare-marker.warn {
  background: #3d3210;
  color: #ffe28a;
}

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

  .sidebar {
    position: static;
    padding: 16px;
  }

  .nav-list {
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  }

  .nav-item {
    text-align: center;
  }

  .topbar,
  .workspace {
    align-items: stretch;
    grid-template-columns: 1fr;
  }

  .topbar {
    flex-direction: column;
  }

  .topbar-controls,
  .session-bar {
    justify-content: flex-start;
    width: 100%;
  }

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

@media (max-width: 640px) {
  .main {
    padding: 16px;
  }

  .nav-list,
  .summary-grid {
    grid-template-columns: 1fr;
  }

  .deployment-table,
  .compare-table {
    min-width: 760px;
  }

  .deployment-table-wrap,
  .compare-table-wrap {
    overflow-x: auto;
  }
}
