:root {
  color-scheme: dark;
  --bg: #101113;
  --surface: #181a1d;
  --surface-2: #202329;
  --line: #323741;
  --text: #f3f5f7;
  --muted: #a9b0bb;
  --accent: #2f8f7a;
  --accent-2: #d4a93d;
  --danger: #c94f4f;
  --focus: #78c8b6;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
select {
  font: inherit;
}

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

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 28px;
  padding: 24px;
  background: #15171a;
  border-right: 1px solid var(--line);
}

.brand {
  display: grid;
  grid-template-columns: 48px 1fr;
  gap: 14px;
  align-items: center;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--accent-2);
  font-weight: 800;
}

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

h1 {
  font-size: 18px;
  line-height: 1.1;
}

h2 {
  font-size: 28px;
  line-height: 1.1;
}

h3 {
  font-size: 15px;
}

p {
  color: var(--muted);
  line-height: 1.5;
}

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

.tab-button,
.command,
.icon-button {
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--text);
  min-height: 38px;
  border-radius: 6px;
  cursor: pointer;
}

.tab-button {
  text-align: left;
  padding: 10px 12px;
}

.tab-button.active,
.command.primary {
  border-color: transparent;
  background: var(--accent);
  color: #041b16;
  font-weight: 700;
}

.command.danger {
  border-color: transparent;
  background: var(--danger);
  color: #fff;
}

.command.compact,
.icon-button {
  min-height: 32px;
  padding: 0 10px;
}

.icon-button {
  width: 34px;
  font-weight: 800;
}

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

button:focus-visible,
input:focus-visible,
select:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

.status-strip {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: auto;
  padding: 12px;
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 6px;
  color: var(--muted);
}

.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #6b7280;
}

.status-dot.online {
  background: #35c486;
  box-shadow: 0 0 0 4px rgba(53, 196, 134, 0.14);
}

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

.view {
  display: none;
}

.view.active {
  display: grid;
  gap: 22px;
}

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

.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.command {
  padding: 0 16px;
}

.control-grid,
.settings-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}

.panel {
  display: grid;
  gap: 16px;
  padding: 18px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
}

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

.panel header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
}

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

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

.field span {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0;
}

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

input[type="checkbox"] {
  width: auto;
  min-height: 0;
}

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

.switch span {
  display: block;
  width: 46px;
  height: 26px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #111317;
  position: relative;
}

.switch span::after {
  content: "";
  position: absolute;
  width: 18px;
  height: 18px;
  top: 3px;
  left: 4px;
  border-radius: 50%;
  background: var(--muted);
  transition: transform 150ms ease, background 150ms ease;
}

.switch input:checked + span::after {
  transform: translateX(18px);
  background: var(--accent);
}

.rows {
  display: grid;
  gap: 10px;
}

.row {
  display: grid;
  grid-template-columns: 28px minmax(110px, 1fr) minmax(180px, 2fr) 84px;
  gap: 10px;
  align-items: end;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #13161a;
}

.row.destination {
  grid-template-columns: 28px minmax(120px, 1fr) minmax(90px, 0.7fr) minmax(180px, 1.4fr) minmax(130px, 0.9fr) minmax(130px, 0.9fr) 84px;
}

.row.schedule {
  grid-template-columns: minmax(150px, 1.4fr) minmax(120px, 1fr) minmax(110px, 0.8fr) minmax(110px, 0.8fr) 84px;
}

.remove {
  border-color: rgba(201, 79, 79, 0.45);
  color: #ffd2d2;
}

.destination-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 10px;
}

.destination-chip {
  display: grid;
  gap: 4px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #13161a;
}

.destination-chip strong {
  font-size: 14px;
}

.destination-chip span {
  color: var(--muted);
  font-size: 13px;
  overflow-wrap: anywhere;
}

.log-view {
  min-height: 620px;
  margin: 0;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #090a0c;
  color: #d8dee9;
  overflow: auto;
  white-space: pre-wrap;
}

.toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  max-width: min(420px, calc(100vw - 44px));
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #22262c;
  color: var(--text);
  box-shadow: 0 12px 38px rgba(0, 0, 0, 0.32);
}

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

  .sidebar {
    position: sticky;
    top: 0;
    z-index: 10;
    padding: 14px;
    gap: 14px;
  }

  .nav-tabs {
    grid-template-columns: repeat(4, 1fr);
  }

  .tab-button {
    text-align: center;
  }

  .status-strip {
    display: none;
  }

  .workspace {
    padding: 18px;
  }

  .topbar,
  .control-grid,
  .settings-grid,
  .field-grid,
  .effect-grid {
    grid-template-columns: 1fr;
    display: grid;
  }

  .row,
  .row.destination,
  .row.schedule {
    grid-template-columns: 1fr;
  }
}

.login-body {
  display: grid;
  place-items: center;
  min-height: 100vh;
  padding: 18px;
}

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

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

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

.login-message {
  min-height: 24px;
  color: #ffd2d2;
}
