:root {
  color-scheme: light;
  --bg: #ffffff;
  --sidebar: #fffc00;
  --panel: #ffffff;
  --panel-2: #f6f6f6;
  --text: #0a0a0a;
  --muted: #5c5c5c;
  --accent: #fffc00;
  --danger: #e10600;
  --border: #e6e6e6;
  --ok: #0a7a32;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 12.5px/1.4 "Segoe UI", -apple-system, BlinkMacSystemFont, sans-serif;
}

.shell {
  display: grid;
  grid-template-columns: 220px 1fr;
  min-height: 100vh;
}

.sidebar {
  display: flex;
  flex-direction: column;
  background: var(--sidebar);
  border-right: 1px solid #111;
  padding: 16px 12px;
}

.brand {
  display: grid;
  grid-template-columns: 36px 1fr;
  grid-template-rows: auto auto;
  column-gap: 10px;
  padding: 4px 8px 18px;
}

.brand-mark {
  grid-row: 1 / span 2;
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  background: #111;
  color: var(--accent);
  font-weight: 800;
  border-radius: 8px;
  letter-spacing: -0.04em;
}

.brand-name {
  font-size: 15px;
  font-weight: 750;
}

.brand-sub {
  color: var(--muted);
  font-size: 11px;
}

.nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.nav-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  border: 0;
  background: transparent;
  color: #111;
  text-align: left;
  padding: 9px 12px;
  border-radius: 8px;
  font: inherit;
  font-weight: 650;
  cursor: pointer;
}

.nav-ico {
  width: 16px;
  text-align: center;
  opacity: 0.7;
}

.nav-label {
  margin: 14px 12px 4px;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #111;
  opacity: 0.45;
}

.nav-label:first-child {
  margin-top: 0;
}

.nav-btn:hover {
  background: rgba(0, 0, 0, 0.08);
  color: #111;
}

.nav-btn.active {
  background: #111;
  color: #fff;
}

.nav-badge {
  min-width: 18px;
  height: 18px;
  margin-left: auto;
  padding: 0 5px;
  border-radius: 999px;
  background: #111;
  color: var(--accent);
  font-size: 10px;
  font-weight: 800;
  display: grid;
  place-items: center;
}

.sidebar-foot {
  margin-top: auto;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 12px 8px 4px;
}

.lock-chip {
  background: #111;
  color: #fff;
  border: 1px solid #111;
  border-radius: 999px;
  padding: 3px 8px;
  font-size: 10px;
  font-weight: 650;
}

.workspace {
  display: flex;
  flex-direction: column;
  min-width: 0;
  height: 100vh;
  min-height: 100vh;
  background: #fff;
}

.top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  background: #fff;
}

.top h1 {
  margin: 0;
  font-size: 16px;
  font-weight: 750;
}

.top-sub {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.top-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.status-pill {
  padding: 5px 10px;
  border-radius: 999px;
  background: #fff;
  border: 1px solid var(--border);
  color: var(--muted);
  font-size: 12px;
}

.status-pill.status-ok {
  color: var(--ok);
  border-color: #b7e0c3;
  background: #eef8f1;
}

.status-pill.status-error {
  color: var(--danger);
  border-color: #ffc9c9;
  background: #fff1f1;
}

.top-meta {
  color: var(--muted);
  font-size: 12px;
}

.workspace-body {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 16px 20px 16px;
  background: #f4f4f4;
}

.page:not(.hidden) {
  flex: 1;
  min-height: 0;
}

#page-launch {
  display: flex;
  flex-direction: column;
}

#page-launch:has(#oauthSetup:not(.hidden)) {
  justify-content: center;
  align-items: center;
}

.page.hidden {
  display: none !important;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px 16px;
  margin-bottom: 12px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}

.panel h2,
.panel summary {
  margin: 0;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  list-style: none;
}

.panel summary::-webkit-details-marker {
  display: none;
}

.panel-head {
  margin-bottom: 10px;
}

.panel-head h2 {
  margin-bottom: 4px;
}

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

.connect-panel {
  width: min(520px, 100%);
  padding: 28px 28px 24px;
}

.launch-flow {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  gap: 16px;
}

.stepper {
  list-style: none;
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 8px;
  margin: 0;
  padding: 0;
}

.stepper-btn {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--border);
  background: #fff;
  color: #111;
  border-radius: 12px;
  padding: 10px 12px;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.stepper-btn span {
  flex: none;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: #111;
  color: var(--accent);
  display: grid;
  place-items: center;
  font-size: 11px;
}

.stepper-btn.is-on {
  border-color: #111;
  background: var(--accent);
}

.stepper-btn.is-done {
  border-color: #111;
}

.launch-stage {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding-bottom: 8px;
}

.launch-step {
  display: none;
}

.launch-step.is-on {
  display: block;
}

.step-hero {
  margin-bottom: 8px;
}

.step-kicker {
  margin: 0 0 6px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
}

.step-hero h2 {
  margin: 0 0 6px;
  font-size: 28px;
  font-weight: 800;
  letter-spacing: -0.03em;
}

.step-hero p {
  margin: 0 0 16px;
  color: var(--muted);
  max-width: 56ch;
  font-size: 14px;
}

.step-card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 22px 24px 24px;
  box-shadow: 0 10px 32px rgba(0, 0, 0, 0.05);
}

.step-card-split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 28px;
}

.dropzone-lg {
  min-height: 168px;
  padding: 48px 16px;
  font-size: 14px;
}

.dock-left {
  display: flex;
  align-items: center;
  gap: 8px;
}

.dock-step {
  font-size: 12px;
  font-weight: 700;
  min-width: 118px;
}

.toolbar {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  gap: 8px;
  align-items: end;
}

.toolbar-field {
  min-width: 0;
}

.label {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
}

.dropzone {
  position: relative;
  border: 1px dashed #c8c8c8;
  border-radius: 10px;
  padding: 16px;
  text-align: center;
  background: var(--panel-2);
  cursor: pointer;
}

.dropzone.dragover {
  border-color: #111;
  background: var(--accent);
}

.dropzone input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.table-wrap {
  margin-top: 10px;
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  background: var(--panel-2);
}

.table-head {
  display: grid;
  grid-template-columns: 1fr 90px 170px;
  gap: 8px;
  padding: 8px 10px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  border-bottom: 1px solid var(--border);
}

.file-list {
  list-style: none;
  margin: 0;
  padding: 0;
  max-height: 360px;
  overflow: auto;
}

.file-list li {
  display: block;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  font-size: 12px;
}

.file-list li:last-child {
  border-bottom: 0;
}

.file-row {
  display: grid;
  grid-template-columns: 1fr 90px 170px;
  gap: 8px;
  align-items: center;
}

.file-row .file-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-row .file-meta {
  color: var(--muted);
  font-size: 11px;
}

.file-actions {
  display: flex;
  justify-content: flex-end;
  gap: 6px;
}

.pour-scheme {
  margin-top: 12px;
}

.scheme-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.scheme-card {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--panel-2);
  cursor: pointer;
  color: var(--text);
}

.scheme-card input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.scheme-card:has(input:checked) {
  border-color: #111;
  background: var(--accent);
}

.scheme-code {
  font-size: 15px;
  font-weight: 800;
  color: #111;
}

.scheme-title {
  font-size: 12px;
  font-weight: 650;
}

.scheme-note {
  font-size: 11px;
  color: var(--muted);
}

#squadCopiesWrap {
  margin-top: 10px;
}

.btn-mini {
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text);
  border-radius: 8px;
  padding: 6px 8px;
  font-size: 11px;
  font-weight: 650;
  cursor: pointer;
}

.btn-mini.active {
  border-color: #111;
  background: var(--accent);
  color: #111;
}

.btn-mini.danger {
  color: var(--danger);
}

.file-override {
  margin-top: 8px;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg);
}

.file-override .span-2 {
  grid-column: 1 / -1;
}

.file-override-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 8px;
}

.entity-add-toggle {
  margin-top: 8px;
}

.add-entity {
  margin-top: 10px;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--panel-2);
}

.add-entity .btn {
  margin-top: 8px;
  width: 100%;
}

.grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 11px;
  color: var(--muted);
}

input[type="text"],
input[type="number"],
input[type="datetime-local"],
select,
textarea {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  padding: 8px;
  font-size: 12px;
}

input[type="datetime-local"] {
  width: 100%;
  color-scheme: light;
  min-height: 34px;
}

select {
  width: 100%;
}

.macro-select {
  font-size: 11px;
  padding: 6px 8px;
  color: var(--muted);
}

.status-error {
  color: var(--danger);
}

.status-ok {
  color: var(--ok);
}

input:disabled,
input[readonly] {
  opacity: 0.72;
  cursor: not-allowed;
  color: var(--muted);
}

.field-hint {
  margin: 4px 0 8px;
  font-size: 11px;
  color: var(--muted);
}

.url-mask {
  display: flex;
  align-items: stretch;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}

.url-mask:focus-within {
  border-color: #555;
}

.url-mask-prefix {
  flex: none;
  display: flex;
  align-items: center;
  padding: 8px 0 8px 8px;
  color: var(--muted);
  font-size: 12px;
  user-select: none;
}

.url-mask input {
  flex: 1;
  min-width: 0;
  border: 0;
  border-radius: 0;
  padding-left: 0;
  background: transparent;
}

.url-mask input:focus {
  outline: none;
}

.url-preview {
  margin-top: 10px;
  font-size: 11px;
  color: var(--muted);
  word-break: break-word;
  overflow-wrap: anywhere;
  background: var(--panel-2);
  border-radius: 8px;
  padding: 8px;
}

.checkbox {
  flex-direction: row;
  align-items: center;
  margin-top: 10px;
  gap: 8px;
}

.checkbox.tight {
  margin: 0;
}

.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 6px 0 10px;
}

.chip {
  flex-direction: row;
  align-items: center;
  gap: 6px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 5px 8px;
  color: var(--text);
  font-size: 11px;
}

.schedule-card {
  margin-top: 10px;
  padding: 12px;
  border: 1px solid #111;
  border-radius: 12px;
  background: var(--accent);
}

.schedule-fields {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.schedule-fields:has(#startAtWrap.hidden) #startModeWrap,
.schedule-fields:has(#startAtWrap[hidden]) #startModeWrap {
  grid-column: 1 / -1;
}

.schedule-fields #startTzWrap {
  grid-column: 1 / -1;
}

.schedule-card > .field-hint[hidden],
.schedule-card > .field-hint.hidden {
  display: none;
}

.status-switch {
  position: relative;
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 12px;
  padding: 10px 0 0;
  border-top: 1px solid #111;
  color: var(--text);
  cursor: pointer;
}

.status-switch-title {
  font-size: 12px;
  font-weight: 650;
  color: var(--text);
}

.status-switch-value {
  font-size: 11px;
  font-weight: 700;
  color: #111;
}

.schedule-card:has(#startPaused:checked) {
  border-color: #111;
  background: #fff4b0;
}

.status-switch:has(#startPaused:checked) .status-switch-value {
  color: #111;
}

.status-switch input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.switch-track {
  position: relative;
  flex: none;
  width: 48px;
  height: 28px;
  border-radius: 999px;
  background: #111;
}

.switch-track::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--accent);
  transition: transform 0.18s ease;
}

.status-switch:has(#startPaused:checked) .switch-track {
  background: #111;
}

.status-switch:has(#startPaused:checked) .switch-track::after {
  transform: translateX(20px);
}

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

.progress-wrap {
  margin-top: 10px;
}

.progress-bar {
  height: 8px;
  background: #ececec;
  border-radius: 999px;
  overflow: hidden;
}

#progressFill {
  height: 100%;
  width: 0;
  background: #111;
}

.progress-text {
  margin-top: 6px;
  font-size: 11px;
  color: var(--muted);
}

.queue-panel .log {
  max-height: calc(100vh - 280px);
}

.log {
  margin-top: 10px;
  max-height: 240px;
  overflow: auto;
  background: #f6f6f6;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px;
  font-size: 11px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

.log .line-error {
  color: var(--danger);
}

.log .line-ok {
  color: var(--ok);
}

.queue-grid,
.rules-layout {
  display: grid;
  grid-template-columns: minmax(320px, 1.2fr) minmax(280px, 0.9fr);
  gap: 16px;
  align-items: start;
}

.job-history {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.job-card {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px;
  background: var(--panel-2);
}

.job-card strong {
  display: block;
  margin-bottom: 2px;
}

.preset-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 0 0 12px;
}

.mode-row {
  display: flex;
  gap: 6px;
  margin: 0 0 12px;
}

.mode-btn {
  border: 1px solid #111;
  background: #fff;
  color: #111;
  border-radius: 999px;
  padding: 6px 12px;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.mode-btn.active {
  background: #111;
  color: #fff;
}

.cond-head {
  margin: 12px 0 8px;
}

.join-field {
  min-width: 180px;
}

.conditions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 8px;
}

.preset-btn {
  border: 1px solid #111;
  background: var(--accent);
  color: #111;
  border-radius: 999px;
  padding: 6px 10px;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.rules-form {
  margin-bottom: 10px;
}

.condition-row {
  display: grid;
  grid-template-columns: 1.4fr 90px 1fr auto;
  gap: 8px;
  align-items: center;
}

.rules-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.rules-meta {
  margin: 0 0 12px;
  color: var(--muted);
  font-size: 12px;
}

.rules-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.rule-card {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px;
  background: var(--panel-2);
}

.rule-card.is-off {
  opacity: 0.55;
}

.rule-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 4px;
}

.rule-card p {
  margin: 0 0 6px;
  font-size: 12px;
}

.rules-log {
  max-height: 280px;
}

.empty-hint {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
}

.dock {
  position: sticky;
  bottom: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 20px;
  border-top: 1px solid var(--border);
  background: #fff;
  z-index: 5;
}

.dock-status {
  color: var(--muted);
  font-size: 12px;
  min-width: 0;
}

.actions {
  display: flex;
  gap: 8px;
}

.btn {
  border: none;
  border-radius: 10px;
  padding: 10px 14px;
  font-weight: 700;
  cursor: pointer;
}

.btn.primary {
  background: var(--accent);
  color: #111;
}

.btn.secondary {
  background: #111;
  color: #fff;
}

.btn.danger {
  background: var(--danger);
  color: #fff;
}

.hidden {
  display: none !important;
}

@media (max-width: 1100px) {
  .launch-grid,
  .toolbar,
  .table-head,
  .file-row,
  .queue-grid,
  .rules-layout,
  .condition-row,
  .stepper,
  .step-card-split {
    grid-template-columns: 1fr;
  }

  .file-actions {
    justify-content: flex-start;
  }
}

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

  .sidebar {
    flex-direction: row;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
  }

  .brand {
    padding: 0;
  }

  .nav {
    flex-direction: row;
    flex: 1;
  }

  .sidebar-foot,
  .brand-sub,
  .nav-label {
    display: none;
  }

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

  .dock-left {
    justify-content: space-between;
  }
}
