:root {
  color-scheme: light;
  --page: #f4f2ec;
  --ink: #1f2523;
  --muted: #65706b;
  --line: #d7d1c4;
  --panel: #fffdf8;
  --panel-strong: #f8efe2;
  --teal: #17756a;
  --teal-dark: #0d514a;
  --amber: #b66613;
  --red: #b3342b;
  --red-dark: #7d211b;
  --shadow: 0 10px 28px rgba(49, 42, 31, 0.09);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--page);
  color: var(--ink);
  font-family: "Segoe UI", Arial, sans-serif;
  line-height: 1.45;
}

button {
  border: 0;
  font: inherit;
  cursor: pointer;
}

[hidden] {
  display: none !important;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 22px 28px;
  border-bottom: 1px solid var(--line);
  background: #fffaf1;
}

.topbar h1,
.topbar p,
.section-heading h2,
.activity-log,
.action-card h3,
.toggle-copy h3,
.toggle-copy p,
.action-card p {
  margin: 0;
}

.topbar h1 {
  font-size: 24px;
  font-weight: 700;
  letter-spacing: 0;
}

.topbar p {
  color: var(--muted);
  font-size: 13px;
}

.status-cluster {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  align-items: center;
  gap: 8px;
}

.status-strip {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  min-height: 34px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
}

.connection-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #8b918d;
}

.connection-dot.online {
  background: var(--teal);
}

.connection-dot.offline {
  background: var(--red);
}

.connection-dot.waiting {
  background: var(--amber);
}

.layout {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(300px, 0.9fr);
  gap: 18px;
  width: min(1280px, calc(100% - 36px));
  margin: 18px auto 28px;
}

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

.command-panel {
  grid-row: span 3;
}

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

.section-heading h2 {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0;
}

.small-status {
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
}

.group-stack {
  display: grid;
  gap: 16px;
  padding: 16px;
}

.action-group {
  display: grid;
  gap: 10px;
}

.action-group h3 {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.action-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  align-items: start;
  gap: 10px;
}

.action-card {
  display: grid;
  grid-template-rows: auto auto auto auto;
  align-content: start;
  gap: 10px;
  min-height: 150px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffefa;
}

.action-card h3,
.toggle-copy h3 {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0;
}

.action-card p,
.toggle-copy p {
  color: var(--muted);
  font-size: 13px;
}

.action-meta {
  display: flex;
  align-items: center;
  gap: 8px;
}

.action-controls {
  display: grid;
  gap: 8px;
}

.file-control {
  display: grid;
  gap: 6px;
}

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

.file-control input {
  width: 100%;
  min-height: 36px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
  color: var(--ink);
  font: inherit;
  font-size: 13px;
}

.file-name {
  min-height: 18px;
  color: var(--muted);
  font-size: 12px;
  overflow-wrap: anywhere;
}

.target-body {
  display: grid;
  gap: 12px;
  padding: 14px 16px 16px;
}

.target-select-label {
  display: grid;
  gap: 6px;
}

.target-select-label span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.target-select-label select {
  min-height: 38px;
  width: 100%;
  padding: 7px 9px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
  color: var(--ink);
  font: inherit;
  font-size: 13px;
}

.client-list {
  display: grid;
  gap: 8px;
}

.client-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 9px;
  min-height: 42px;
  padding: 8px 9px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fffefa;
}

.client-copy {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.client-copy strong,
.client-copy span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.client-copy strong {
  font-size: 13px;
}

.client-copy span {
  color: var(--muted);
  font-size: 12px;
}

.action-mark {
  display: inline-grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 6px;
  background: #e5f2ef;
  color: var(--teal-dark);
  font-size: 12px;
  font-weight: 800;
}

.action-mark.warn {
  background: #f7e4c6;
  color: #794207;
}

.action-mark.danger {
  background: #f5d2cc;
  color: var(--red-dark);
}

.run-button,
.secondary-button,
.danger-button,
.icon-button {
  min-height: 36px;
  border-radius: 6px;
  font-weight: 700;
}

.run-button {
  width: 100%;
  background: var(--teal);
  color: white;
}

.run-button:hover {
  background: var(--teal-dark);
}

.danger-button {
  padding: 0 13px;
  background: var(--red);
  color: white;
}

.danger-button:hover {
  background: var(--red-dark);
}

.secondary-button {
  padding: 0 13px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink);
}

.icon-button {
  display: inline-grid;
  place-items: center;
  width: 36px;
  padding: 0;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--muted);
}

.icon-button:hover,
.secondary-button:hover {
  background: var(--panel-strong);
}

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

.toggle-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 14px;
  min-height: 80px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
}

.toggle-row:last-child {
  border-bottom: 0;
}

.switch {
  position: relative;
  width: 54px;
  height: 30px;
}

.switch input {
  position: absolute;
  opacity: 0;
}

.slider {
  position: absolute;
  inset: 0;
  border: 1px solid #b7baaf;
  border-radius: 999px;
  background: #d9d7cf;
  transition: 160ms ease;
}

.slider::before {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: white;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.24);
  transition: 160ms ease;
}

.switch input:checked + .slider {
  border-color: var(--teal);
  background: var(--teal);
}

.switch input:checked + .slider::before {
  transform: translateX(24px);
}

.activity-panel {
  min-height: 290px;
}

.activity-log {
  display: grid;
  gap: 0;
  max-height: 380px;
  padding: 0;
  overflow: auto;
  list-style: none;
}

.activity-log li {
  display: grid;
  gap: 3px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
}

.activity-log li:last-child {
  border-bottom: 0;
}

.activity-time {
  color: var(--muted);
  font-size: 12px;
}

.activity-message {
  font-size: 13px;
}

.empty-state {
  padding: 18px 16px;
  color: var(--muted);
  font-size: 13px;
}

.auth-screen {
  display: grid;
  place-items: center;
  min-height: 100vh;
  padding: 24px;
}

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

.auth-panel h2,
.auth-panel p {
  margin: 0;
}

.auth-panel h2 {
  font-size: 20px;
}

.auth-panel label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.auth-panel input {
  min-height: 40px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: white;
  color: var(--ink);
  font: inherit;
}

.auth-panel p {
  min-height: 20px;
  color: var(--red);
  font-size: 13px;
}

.confirm-dialog {
  width: min(420px, calc(100% - 32px));
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--ink);
  box-shadow: 0 24px 80px rgba(32, 26, 18, 0.28);
}

.confirm-dialog::backdrop {
  background: rgba(31, 37, 35, 0.38);
}

.confirm-dialog form {
  display: grid;
  gap: 12px;
  padding: 18px;
}

.confirm-dialog h2,
.confirm-dialog p {
  margin: 0;
}

.confirm-dialog h2 {
  font-size: 18px;
}

.confirm-dialog p {
  color: var(--muted);
  font-size: 14px;
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 6px;
}

@media (max-width: 860px) {
  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .status-cluster {
    justify-content: flex-start;
  }

  .layout {
    grid-template-columns: 1fr;
    width: min(100% - 24px, 640px);
    margin-top: 12px;
  }

  .command-panel {
    grid-row: auto;
  }
}
