:root {
  --bg: #f4f6f3;
  --panel: #ffffff;
  --fg: #1e2a1c;
  --muted: #5c6b58;
  --border: #d7ddd4;
  --primary: #538234;
  --primary-soft: #eef5ea;
  --primary-fg: #ffffff;
  --bad: #c62828;
  --warn: #ef6c00;
  --radius: 8px;
  --shadow: 0 1px 2px rgba(30, 42, 28, 0.06);
  --mono: "Cascadia Code", Consolas, "Courier New", monospace;
  --sans: "Segoe UI", system-ui, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  font-family: var(--sans);
  background: var(--bg);
  color: var(--fg);
  font-size: 14px;
}

[ng-cloak] { display: none !important; }

.app {
  display: flex;
  flex-direction: column;
  height: 100%;
}

.error-banner {
  background: #ffebee;
  color: #b71c1c;
  border-bottom: 1px solid #ffcdd2;
  padding: 0.45rem 1rem;
  font-size: 0.85rem;
}

/* —— topbar —— */
.topbar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.55rem 1rem;
  background: var(--primary);
  color: var(--primary-fg);
  min-height: 48px;
  flex-wrap: wrap;
  flex-shrink: 0;
}

.topbar h1 {
  margin: 0;
  font-size: 1rem;
  font-weight: 650;
  letter-spacing: 0.01em;
}

.topbar .meta,
.topbar .status-pill {
  color: rgba(255, 255, 255, 0.9);
  font-size: 0.8rem;
}

.topbar .spacer { flex: 1; }

.top-tabs {
  display: flex;
  gap: 0.25rem;
  margin-left: 0.5rem;
}
.top-tabs .tab {
  border: 1px solid transparent;
  background: transparent;
  color: rgba(255, 255, 255, 0.85);
  border-radius: 6px;
  padding: 0.3rem 0.65rem;
  cursor: pointer;
  font-size: 0.82rem;
}
.top-tabs .tab:hover { background: rgba(255, 255, 255, 0.14); }
.top-tabs .tab.on,
.top-tabs .tab.on:hover {
  background: rgba(255, 255, 255, 0.28);
  border-color: rgba(255, 255, 255, 0.45);
  color: #fff;
  font-weight: 600;
}

.ws-dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #ffcdd2;
  margin-right: 0.3rem;
  vertical-align: middle;
}
.ws-dot.on { background: #b9f6ca; }

/* —— buttons —— */
.btn {
  border: 1px solid var(--border);
  background: #fff;
  color: var(--fg);
  border-radius: 6px;
  padding: 0.4rem 0.7rem;
  cursor: pointer;
  font-size: 0.85rem;
  line-height: 1.2;
}
.btn:hover:not(:disabled) { background: #f7faf5; }
.btn:disabled { opacity: 0.5; cursor: default; }

.topbar .btn {
  background: rgba(255, 255, 255, 0.14);
  border-color: rgba(255, 255, 255, 0.3);
  color: #fff;
}
.topbar .btn:hover:not(:disabled) { background: rgba(255, 255, 255, 0.24); }

.btn-primary {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}
.btn-primary:hover:not(:disabled) {
  background: #5f943c;
  border-color: #5f943c;
  color: #fff;
  filter: none;
}
.btn-lg { padding: 0.55rem 1rem; font-weight: 600; }
.btn-sm { padding: 0.25rem 0.5rem; font-size: 0.78rem; }
.btn-ghost {
  background: transparent;
  border-color: transparent;
  color: var(--muted);
}
.btn-ghost:hover:not(:disabled) { background: var(--primary-soft); color: var(--primary); }
.btn.danger, .icon-btn.danger { color: var(--bad); }
.btn.danger:hover:not(:disabled) { background: #ffebee; color: var(--bad); }

/* —— presets —— */
.preset-status {
  margin: 0.15rem 0 0;
  font-size: 0.78rem;
  color: var(--muted);
}
.preset-status.dirty { color: var(--warn); }
.preset-status.saved { color: var(--primary); }

.icon-btn {
  width: 28px;
  height: 28px;
  border: 1px solid var(--border);
  background: #fff;
  border-radius: 6px;
  cursor: pointer;
  color: var(--muted);
  font-size: 0.85rem;
  line-height: 1;
}
.icon-btn:hover:not(:disabled) { background: var(--primary-soft); color: var(--primary); }
.icon-btn:disabled { opacity: 0.35; cursor: default; }
.icon-btn.danger:hover:not(:disabled) { background: #ffebee; color: var(--bad); border-color: #ffcdd2; }

/* —— login —— */
.login-wrap {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem 1rem;
  background:
    radial-gradient(ellipse at top, #e8f0e3 0%, transparent 55%),
    var(--bg);
}

.login-card {
  width: 100%;
  max-width: 360px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.5rem;
  box-shadow: var(--shadow);
}

.login-card h2 {
  margin: 0 0 0.25rem;
  font-size: 1.25rem;
  color: var(--primary);
}
.login-card .hint {
  margin: 0 0 1.2rem;
  color: var(--muted);
  font-size: 0.85rem;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  margin-bottom: 0.85rem;
}
.field label { font-size: 0.78rem; color: var(--muted); }
.field input {
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.55rem 0.65rem;
  font-size: 1rem;
}
.field input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(83, 130, 52, 0.15);
}

.login-error {
  color: var(--bad);
  font-size: 0.85rem;
  margin: 0 0 0.75rem;
  min-height: 1.2em;
}
.login-actions { display: flex; justify-content: flex-end; }

/* —— shell / builder —— */
.app-shell {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}

.builder {
  flex: 1;
  min-height: 0;
  overflow: hidden;
  padding: 0.75rem;
}

.builder-layout {
  display: grid;
  grid-template-columns:
    minmax(180px, 220px)
    minmax(240px, 1fr)
    minmax(260px, 1.1fr)
    minmax(280px, 360px);
  gap: 0.75rem;
  height: 100%;
  align-items: stretch;
}

@media (max-width: 1400px) {
  .builder-layout {
    grid-template-columns: minmax(180px, 220px) minmax(0, 1fr) minmax(0, 1fr);
  }
  .builder-right {
    grid-column: 1 / -1;
  }
}

@media (max-width: 1100px) {
  .builder { overflow: auto; }
  .builder-layout {
    grid-template-columns: 1fr;
    height: auto;
  }
  .builder-presets,
  .builder-meta,
  .builder-frames,
  .builder-right {
    position: static;
    overflow: visible;
    max-height: none;
    grid-column: auto;
  }
  .result-panel { position: static; }
}

.builder-presets,
.builder-meta,
.builder-frames,
.builder-right {
  min-height: 0;
  overflow: auto;
}

.builder-presets .panel-presets,
.builder-frames .panel-frames {
  margin-bottom: 0;
  min-height: 100%;
  display: flex;
  flex-direction: column;
}

.builder-meta .panel:last-child,
.builder-frames .panel:last-child {
  margin-bottom: 0;
}

.panel-always-open > h3 {
  margin-bottom: 0.45rem;
}

.panel-hint {
  margin: 0 0 0.65rem;
  font-size: 0.78rem;
  color: var(--muted);
  line-height: 1.35;
}
.panel-hint code {
  font-family: var(--mono);
  font-size: 0.72rem;
  background: #f0f3ee;
  padding: 0.05rem 0.25rem;
  border-radius: 3px;
}

.block-title {
  margin: 0 0 0.4rem;
  font-size: 0.8rem;
  font-weight: 650;
  color: var(--fg);
}

/* presets sidebar */
.preset-save {
  display: flex;
  gap: 0.35rem;
  margin-bottom: 0.4rem;
}
.preset-save input {
  flex: 1;
  min-width: 0;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.35rem 0.5rem;
  font-size: 0.82rem;
}
.preset-list {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  margin-top: 0.55rem;
  flex: 1;
  overflow: auto;
  max-height: calc(100vh - 280px);
}
.preset-item {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  width: 100%;
  text-align: left;
  border: 1px solid var(--border);
  background: #fafbf9;
  border-radius: 6px;
  padding: 0.4rem 0.55rem;
  cursor: pointer;
  color: var(--fg);
  font-size: 0.82rem;
}
.preset-item:hover { background: var(--primary-soft); border-color: #c5d6bb; }
.preset-item.on,
.preset-item.on:hover {
  background: var(--primary-soft);
  border-color: var(--primary);
  box-shadow: inset 3px 0 0 var(--primary);
}
.preset-item-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 550;
}
.preset-item-meta {
  flex-shrink: 0;
  font-size: 0.72rem;
  color: var(--muted);
  font-family: var(--mono);
}
.preset-new {
  margin-top: 0.55rem;
  border-style: dashed;
  color: var(--muted);
}
.preset-random {
  width: 100%;
  margin-top: 0.35rem;
  margin-bottom: 0.35rem;
}
.preset-actions {
  margin-top: 0.65rem;
  padding-top: 0.55rem;
  border-top: 1px solid var(--border);
}

/* —— panels —— */
.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.85rem 1rem;
  margin-bottom: 0.65rem;
  box-shadow: var(--shadow);
}

.panel h3 {
  margin: 0;
  font-size: 0.92rem;
  color: var(--primary);
  font-weight: 650;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.panel-error {
  border-color: #ffcdd2;
  background: #fff8f7;
}

.panel-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  border: none;
  background: transparent;
  padding: 0;
  cursor: pointer;
  margin-bottom: 0;
}
.panel-toggle + div { margin-top: 0.75rem; }

.chevron {
  color: var(--muted);
  transition: transform 0.15s ease;
  display: inline-block;
}
.chevron.open { transform: rotate(180deg); }

.block {
  border-top: 1px solid var(--border);
  padding-top: 0.5rem;
  margin-top: 0.5rem;
}
.block:first-child { border-top: none; padding-top: 0; margin-top: 0; }

.block-toggle {
  display: flex;
  width: 100%;
  justify-content: space-between;
  align-items: center;
  border: none;
  background: transparent;
  padding: 0.35rem 0;
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--muted);
}
.block-title {
  margin: 0 0 0.45rem;
  font-size: 0.82rem;
  color: var(--muted);
  font-weight: 600;
}

.panel-hint {
  margin: 0 0 0.75rem;
  font-size: 0.8rem;
  color: var(--muted);
}
.panel-hint code {
  font-family: var(--mono);
  font-size: 0.78rem;
  background: #f0f3ee;
  padding: 0.1rem 0.3rem;
  border-radius: 4px;
}

.muted { color: var(--muted); }
.tiny { font-size: 0.75rem; }
.note {
  margin: 0 0 0.55rem;
  font-size: 0.78rem;
  color: var(--muted);
  line-height: 1.35;
}

.count-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.35rem;
  height: 1.35rem;
  padding: 0 0.35rem;
  margin-left: 0.35rem;
  border-radius: 999px;
  background: var(--primary-soft);
  color: var(--primary);
  font-size: 0.72rem;
  font-weight: 700;
  vertical-align: middle;
}

/* —— segments —— */
.seg-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
  margin-top: 0.65rem;
}
@media (max-width: 560px) {
  .seg-2 { grid-template-columns: 1fr; }
}

.seg {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.2rem;
  padding: 0.7rem 0.8rem;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  background: #fafcfa;
  cursor: pointer;
  text-align: left;
}
.seg b { color: var(--primary); font-size: 0.9rem; }
.seg small { color: var(--muted); font-size: 0.75rem; line-height: 1.3; }
.seg:hover { border-color: #b5c7ab; }
.seg.on,
.seg.on:hover {
  border-color: var(--primary);
  background: var(--primary-soft);
}

/* —— frames add —— */
.add-row {
  display: flex;
  gap: 0.4rem;
  margin-bottom: 0.65rem;
  align-items: center;
}

.filter-input,
.add-row select,
.toolbar-row select,
.frame-meta select,
.frame-meta input,
.fc select,
.fc input {
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.4rem 0.5rem;
  font-size: 0.85rem;
  background: #fff;
  color: var(--fg);
  width: 100%;
}
.filter-input:focus,
.add-row select:focus,
.fc select:focus,
.fc input:focus {
  outline: none;
  border-color: var(--primary);
}

.toolbar-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
  padding-bottom: 0.65rem;
  border-bottom: 1px solid var(--border);
}
.inline {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.8rem;
  color: var(--muted);
}
.inline select { width: auto; min-width: 130px; }

.empty-frames {
  padding: 1.25rem 1rem;
  text-align: center;
  color: var(--muted);
  font-size: 0.85rem;
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  background: #fafcfa;
}

/* —— frame card (collapsed by default) —— */
.frame-card {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fafbf9;
  margin-bottom: 0.45rem;
  overflow: hidden;
  padding: 0;
}
.frame-card.open {
  background: #fff;
  border-color: #c5d6bb;
}

.frame-card-head {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.5rem 0.55rem;
  cursor: pointer;
  user-select: none;
  margin-bottom: 0;
}
.frame-card-head:hover { background: rgba(83, 130, 52, 0.06); }
.frame-card-head .chevron {
  flex-shrink: 0;
  width: 1em;
  text-align: center;
  transform: rotate(0deg);
  transition: transform 0.15s ease;
  color: var(--muted);
  font-size: 0.85rem;
}
.frame-card-head .chevron.open {
  transform: rotate(90deg);
}

.frame-title {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem;
  min-width: 0;
  flex: 1;
}
.frame-title strong {
  font-size: 0.9rem;
}
.frame-summary {
  font-size: 0.75rem;
}
.frame-card-body {
  padding: 0.55rem 0.65rem 0.65rem;
  border-top: 1px solid var(--border);
}
.type-hex {
  font-family: var(--mono);
  font-size: 0.75rem;
  background: #eef1eb;
  color: var(--muted);
  padding: 0.1rem 0.35rem;
  border-radius: 4px;
}
.tag {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border: 1px solid var(--primary);
  color: var(--primary);
  border-radius: 4px;
  padding: 0.05rem 0.3rem;
  font-weight: 700;
}
.tag-warn {
  border-color: var(--warn);
  color: var(--warn);
}

.frame-actions {
  display: flex;
  gap: 0.2rem;
  flex-shrink: 0;
}

.frame-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem 0.85rem;
  align-items: flex-end;
  margin-bottom: 0.55rem;
  padding: 0.45rem 0.55rem;
  background: var(--primary-soft);
  border-radius: 6px;
}
.frame-meta label {
  display: inline-flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0.2rem;
  font-size: 0.78rem;
  color: var(--muted);
}
.frame-meta .frame-type-pick {
  flex: 1 1 240px;
  min-width: 200px;
}
.frame-meta .frame-type-pick select {
  width: 100%;
}
.frame-meta input[type="number"] { width: 64px; }
.frame-meta select { width: auto; }

/* —— field control —— */
.pb-field { margin-bottom: 0.5rem; }

.fc-label {
  display: flex;
  align-items: baseline;
  gap: 0.4rem;
  font-size: 0.78rem;
  color: var(--muted);
  margin-bottom: 0.25rem;
}
.fc-kind {
  font-family: var(--mono);
  font-size: 0.68rem;
  color: #8a9a84;
  text-transform: lowercase;
}

.fc-grid {
  display: grid;
  grid-template-columns: 96px minmax(0, 1fr);
  gap: 0.4rem;
  align-items: start;
}

.fc-mode { font-size: 0.8rem !important; }

.fc-value input,
.fc-value select { width: 100%; }

.fc-pair {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.35rem;
}

.fc-empty {
  display: inline-block;
  padding: 0.35rem 0.5rem;
  font-size: 0.78rem;
  color: var(--muted);
  font-style: italic;
}

.fc-hint {
  font-size: 0.72rem;
  color: #8a9a84;
  margin-top: 0.2rem;
  line-height: 1.3;
}

/* —— result —— */
.result-panel {
  position: sticky;
  top: 0;
  display: flex;
  flex-direction: column;
  min-height: calc(100vh - 80px);
}

.result-panel h3 { margin-bottom: 0.75rem; }

.gen-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-bottom: 0.65rem;
}
.gen-row .btn { flex: 1; min-width: 8rem; }
.gen-row .btn-primary { flex: 1.2; }

.fmt-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  margin-bottom: 0.55rem;
}
.fmt {
  border: 1px solid var(--border);
  background: #fff;
  border-radius: 999px;
  padding: 0.28rem 0.65rem;
  font-size: 0.78rem;
  cursor: pointer;
  color: var(--muted);
}
.fmt:hover { border-color: #b5c7ab; color: var(--fg); }
.fmt.on,
.fmt.on:hover {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

.result-tools {
  display: flex;
  gap: 0.35rem;
  margin-bottom: 0.55rem;
}

.gen-error {
  color: var(--bad);
  font-size: 0.82rem;
  margin: 0 0 0.5rem;
}

.result-meta {
  font-size: 0.8rem;
  color: var(--muted);
  margin-bottom: 0.45rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}
.ok, .ok-msg, .result-meta .ok { color: #2e7d32; font-weight: 600; }
.bad, .result-meta .bad { color: var(--bad); font-weight: 600; }
.ok-msg { margin: 0.35rem 0 0; font-size: 0.88rem; }

.result-topic {
  margin-bottom: 0.5rem;
}
.topic-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.25rem;
}
.result-topic code {
  display: block;
  font-family: var(--mono);
  font-size: 0.72rem;
  background: #f0f3ee;
  padding: 0.4rem 0.5rem;
  border-radius: 6px;
  word-break: break-all;
  line-height: 1.35;
}

.result-output {
  flex: 1;
  width: 100%;
  min-height: 280px;
  font-family: var(--mono);
  font-size: 0.76rem;
  line-height: 1.4;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.6rem;
  resize: vertical;
  word-break: break-all;
  background: #f8faf6;
}
.result-output:focus { outline: none; border-color: var(--primary); }
.result-output::placeholder { color: #a0aea0; }

/* —— page tabs (connections / scheduler) —— */
.page {
  flex: 1;
  overflow: auto;
  padding: 0.85rem 1rem 1.25rem;
}
.page-layout {
  display: grid;
  grid-template-columns: minmax(280px, 420px) 1fr;
  gap: 0.85rem;
  align-items: start;
}
.page-layout-3 {
  grid-template-columns: minmax(260px, 380px) minmax(280px, 1fr) minmax(280px, 1fr);
}
@media (max-width: 1100px) {
  .page-layout,
  .page-layout-3 { grid-template-columns: 1fr; }
}
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.55rem 0.7rem;
}
.form-grid label {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  font-size: 0.78rem;
  color: var(--muted);
}
.form-grid label input,
.form-grid label select {
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.4rem 0.5rem;
  font-size: 0.85rem;
  color: var(--fg);
  background: #fff;
}
.form-grid .check-row {
  flex-direction: row;
  align-items: center;
  gap: 0.45rem;
  margin-top: 0.4rem;
}
.form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 0.75rem;
}
.panel-head-row {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  margin-bottom: 0.5rem;
}
.panel-head-row h3 { margin: 0; flex: 1; }
.panel-head-row select {
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.25rem 0.4rem;
  font-size: 0.8rem;
  max-width: 180px;
}
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
}
.data-table th,
.data-table td {
  text-align: left;
  padding: 0.4rem 0.35rem;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}
.data-table th {
  color: var(--muted);
  font-weight: 600;
  font-size: 0.75rem;
}
.data-table tr.sel td { background: var(--primary-soft); }
.data-table .tiny { font-size: 0.72rem; line-height: 1.35; }
.data-table .mono { font-family: var(--mono); word-break: break-all; }
.data-table tr.click-row { cursor: pointer; }
.data-table tr.click-row:hover td { background: #f3f7f0; }

.empty-hint {
  margin: 0.55rem 0 0.35rem;
  padding: 0.55rem 0.65rem;
  font-size: 0.8rem;
  line-height: 1.4;
  color: var(--muted);
  background: #f3f6f1;
  border: 1px dashed var(--border);
  border-radius: 6px;
}

.fc-mode { min-width: 6.5rem; }

.history-table details summary {
  cursor: pointer;
  color: var(--muted);
}
.hist-preview {
  margin: 0.35rem 0 0;
  max-height: 160px;
  overflow: auto;
  font-family: var(--mono);
  font-size: 0.7rem;
  background: #f0f3ee;
  padding: 0.4rem;
  border-radius: 6px;
  white-space: pre-wrap;
  word-break: break-all;
}

/* —— scheduler redesign —— */
.scheduler-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(280px, 0.95fr);
  grid-template-areas:
    "tasks form"
    "history history";
  gap: 0.85rem;
  align-items: start;
}
.scheduler-tasks { grid-area: tasks; }
.scheduler-form { grid-area: form; }
.scheduler-history { grid-area: history; }

@media (max-width: 980px) {
  .scheduler-layout {
    grid-template-columns: 1fr;
    grid-template-areas:
      "tasks"
      "form"
      "history";
  }
}

.task-list {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  max-height: calc(100vh - 220px);
  overflow: auto;
}
.task-row {
  display: flex;
  align-items: flex-start;
  gap: 0.55rem;
  width: 100%;
  text-align: left;
  border: 1px solid var(--border);
  background: #fafbf9;
  border-radius: 8px;
  padding: 0.55rem 0.65rem;
  cursor: pointer;
  color: var(--fg);
  box-sizing: border-box;
}
.task-row:hover { background: var(--primary-soft); border-color: #c5d6bb; }
.task-row.on,
.task-row.on:hover {
  background: var(--primary-soft);
  border-color: var(--primary);
  box-shadow: inset 3px 0 0 var(--primary);
}
.task-row.off { opacity: 0.72; }
.task-row-main { flex: 1; min-width: 0; }
.task-row-title {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-wrap: wrap;
  margin-bottom: 0.15rem;
}
.task-row-title strong { font-size: 0.9rem; }
.task-row-meta {
  margin-top: 0.25rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 0.55rem;
}
.task-row-actions {
  flex-shrink: 0;
  display: flex;
  gap: 0.25rem;
}
.task-badge {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-weight: 700;
  border-radius: 4px;
  padding: 0.05rem 0.35rem;
  border: 1px solid var(--border);
  color: var(--muted);
}
.task-badge.on {
  border-color: var(--primary);
  color: var(--primary);
  background: #fff;
}
.task-badge.off {
  border-color: #ccc;
  color: #888;
}
.form-grid .span-2 { grid-column: 1 / -1; }

.label-with-help {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}
.help-i {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.15rem;
  height: 1.15rem;
  padding: 0;
  border-radius: 50%;
  border: 1px solid var(--primary);
  background: var(--primary-soft);
  color: var(--primary);
  font-size: 0.72rem;
  font-weight: 700;
  font-style: italic;
  font-family: Georgia, "Times New Roman", serif;
  cursor: pointer;
  line-height: 1;
  flex-shrink: 0;
}
.help-i:hover { background: var(--primary); color: #fff; }

.topic-custom-field .topic-chips {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.3rem;
  margin-top: 0.4rem;
}
.topic-chips-label {
  font-size: 0.75rem;
  color: var(--muted);
  margin-right: 0.15rem;
}
.topic-chip {
  font-family: var(--mono);
  font-size: 0.72rem;
  padding: 0.15rem 0.4rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--primary-soft);
  color: var(--fg);
  cursor: pointer;
}
.topic-chip:hover {
  border-color: var(--primary);
  background: #e2efda;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(20, 30, 18, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}
.modal-card {
  background: var(--panel);
  border-radius: var(--radius);
  box-shadow: 0 8px 28px rgba(30, 42, 28, 0.18);
  max-width: 640px;
  width: 100%;
  max-height: min(88vh, 720px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.modal-head h3 {
  margin: 0;
  font-size: 1rem;
  font-weight: 650;
}
.modal-body {
  padding: 0.85rem 1rem 1.1rem;
  overflow: auto;
  font-size: 0.88rem;
  line-height: 1.45;
}
.modal-body h4 {
  margin: 1rem 0 0.4rem;
  font-size: 0.92rem;
}
.modal-body h4:first-child { margin-top: 0; }
.modal-body p { margin: 0.35rem 0; }
.help-examples {
  margin: 0.35rem 0 0.5rem;
  padding-left: 1.2rem;
}
.help-examples li { margin: 0.25rem 0; }
.help-examples code,
.modal-body code {
  font-family: var(--mono);
  font-size: 0.82em;
  background: var(--primary-soft);
  padding: 0.05rem 0.3rem;
  border-radius: 3px;
}
.help-keys-table {
  font-size: 0.8rem;
  margin-top: 0.35rem;
}
.help-keys-table th,
.help-keys-table td {
  padding: 0.3rem 0.45rem;
  vertical-align: top;
}

.scheduler-history .data-table {
  max-height: 320px;
  display: block;
  overflow: auto;
}
.scheduler-history .data-table thead,
.scheduler-history .data-table tbody { display: table; width: 100%; table-layout: fixed; }
