:root {
  color-scheme: light;
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #eef2f5;
  color: #18202a;
}

* {
  box-sizing: border-box;
}

body {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  min-height: 100vh;
  margin: 0;
}

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

button {
  min-height: 36px;
  border: 1px solid #176f62;
  border-radius: 6px;
  padding: 0 14px;
  background: #176f62;
  color: #fff;
  cursor: pointer;
}

button:hover {
  filter: brightness(0.96);
}

button.secondary {
  border-color: #c8d1da;
  background: #fff;
  color: #25313f;
}

button.danger {
  color: #9b1c1c;
}

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

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

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 22px;
  padding: 22px;
  border-right: 1px solid #d5dde5;
  background: #111827;
  color: #fff;
}

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

.brand-mark {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 8px;
  background: #2f8f78;
  font-weight: 800;
  letter-spacing: 0;
}

.brand h1 {
  font-size: 17px;
  font-weight: 700;
}

.brand p,
.panel p,
.topbar p {
  margin-top: 4px;
  color: #6b7785;
  font-size: 13px;
}

.brand p {
  color: #aab4c0;
}

.nav {
  display: grid;
  gap: 8px;
}

.nav-item {
  justify-content: flex-start;
  border-color: transparent;
  background: transparent;
  color: #cbd5df;
  text-align: left;
}

.nav-link {
  display: flex;
  align-items: center;
  min-height: 36px;
  border-radius: 6px;
  padding: 0 14px;
  color: #cbd5df;
  text-decoration: none;
}

.nav-item.active,
.nav-item:hover,
.nav-link:hover {
  background: #25313f;
  color: #fff;
}

.token-box {
  display: grid;
  gap: 10px;
  margin-top: auto;
  padding-top: 18px;
  border-top: 1px solid #2d3745;
}

label {
  display: grid;
  gap: 7px;
  color: #354152;
  font-size: 13px;
  font-weight: 650;
}

.token-box label {
  color: #d7dde5;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid #c8d1da;
  border-radius: 6px;
  padding: 9px 10px;
  background: #fff;
  color: #111827;
}

.token-box input {
  border-color: #384657;
  background: #172131;
  color: #fff;
}

.workspace {
  min-width: 0;
  padding: 22px;
}

.topbar,
.panel-head,
.actions,
.top-actions,
.deploy-row {
  display: flex;
  gap: 10px;
  align-items: center;
}

.topbar {
  justify-content: space-between;
  margin-bottom: 16px;
}

.topbar h2 {
  font-size: 24px;
  font-weight: 750;
}

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

.stat {
  display: grid;
  gap: 6px;
  padding: 14px;
  border: 1px solid #d8e0e7;
  border-radius: 8px;
  background: #fff;
}

.stat-label {
  color: #687586;
  font-size: 12px;
}

.stat strong {
  min-height: 26px;
  font-size: 22px;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

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

.clients-grid,
.template-grid {
  grid-template-columns: 360px minmax(0, 1fr);
}

.panel {
  min-width: 0;
  border: 1px solid #d8e0e7;
  border-radius: 8px;
  background: #fff;
  overflow: hidden;
}

.panel-head {
  justify-content: space-between;
  min-height: 64px;
  padding: 14px 16px;
  border-bottom: 1px solid #e7ebef;
}

.panel h3 {
  font-size: 16px;
}

.list {
  display: grid;
  max-height: calc(100vh - 245px);
  overflow: auto;
}

.list-row {
  display: grid;
  gap: 8px;
  width: 100%;
  padding: 14px 16px;
  border: 0;
  border-bottom: 1px solid #edf1f4;
  background: #fff;
  color: inherit;
  text-align: left;
}

.list-row:hover,
.list-row.active {
  background: #eff8f5;
}

.row-main {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.row-title {
  min-width: 0;
  overflow: hidden;
  font-weight: 750;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.row-meta {
  color: #697789;
  font-size: 12px;
  line-height: 1.5;
}

.badge {
  flex: 0 0 auto;
  border-radius: 999px;
  padding: 3px 8px;
  background: #e7edf3;
  color: #475569;
  font-size: 12px;
  font-weight: 700;
}

.badge.online {
  background: #dff7ea;
  color: #136c44;
}

.badge.offline {
  background: #f1f4f7;
  color: #667085;
}

.detail-panel {
  min-height: calc(100vh - 245px);
}

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

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

#templateForm .form-row {
  grid-template-columns: 180px minmax(0, 1fr) 220px;
}

.deploy-row {
  align-items: end;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto auto;
}

.checkline {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 36px;
}

.checkline input {
  width: auto;
}

textarea {
  min-height: calc(100vh - 470px);
  resize: vertical;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13px;
  line-height: 1.48;
}

textarea.log-output {
  min-height: 180px;
  background: #111827;
  color: #d7e0ea;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  max-width: min(420px, calc(100vw - 36px));
  padding: 11px 13px;
  border-radius: 7px;
  background: #172131;
  color: #fff;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 160ms ease, transform 160ms ease;
  pointer-events: none;
}

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

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

  .sidebar {
    position: static;
  }

  .stats,
  .clients-grid,
  .template-grid,
  .form-row,
  #templateForm .form-row,
  .deploy-row {
    grid-template-columns: 1fr;
  }

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

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

  .list {
    max-height: 320px;
  }

  textarea {
    min-height: 360px;
  }
}
