:root {
  color-scheme: light;
  --bg: #f7f8fa;
  --panel: #ffffff;
  --line: #dfe3ea;
  --line-strong: #c8ced8;
  --text: #18202c;
  --muted: #657182;
  --accent: #2367e8;
  --accent-dark: #174db4;
  --success: #138a5b;
  --danger: #b42318;
  --shadow: 0 18px 48px rgba(22, 34, 51, 0.12);
}

* {
  box-sizing: border-box;
}

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

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

.cot-shell {
  min-height: 100vh;
  padding: 28px;
}

.cot-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  max-width: 1280px;
  margin: 0 auto 20px;
}

.cot-kicker {
  margin: 0 0 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
}

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

h1 {
  margin-bottom: 0;
  font-size: 32px;
  line-height: 1.04;
}

h2 {
  margin-bottom: 6px;
  font-size: 18px;
}

h3 {
  margin-bottom: 0;
  font-size: 14px;
}

.cot-status {
  min-width: 170px;
  color: var(--muted);
  text-align: right;
  font-size: 14px;
}

.cot-workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 18px;
  max-width: 1280px;
  margin: 0 auto;
}

.cot-main,
.cot-preview {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.cot-main {
  min-width: 0;
}

.cot-toolbar,
.cot-settings,
.cot-actions,
.cot-preview {
  padding: 20px;
}

.cot-toolbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  border-bottom: 1px solid var(--line);
}

.cot-toolbar p,
.cot-preview p {
  color: var(--muted);
  margin-bottom: 0;
}

.cot-settings {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 14px;
  border-bottom: 1px solid var(--line);
}

.cot-widget-description {
  grid-column: 1 / -1;
}

.cot-widget-description textarea {
  min-height: 64px;
}

.cot-access-rule {
  display: grid;
  grid-column: 1 / -1;
  grid-template-columns: minmax(190px, 1fr) auto minmax(220px, 1fr);
  align-items: center;
  gap: 18px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.cot-access-rule p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.cot-switch {
  position: relative;
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 9px;
  cursor: pointer;
  white-space: nowrap;
}

.cot-switch input {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  opacity: 0;
}

.cot-switch-track {
  width: 40px;
  height: 22px;
  flex: 0 0 40px;
  padding: 2px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: #e8ebf0;
  transition: background 140ms ease, border-color 140ms ease;
}

.cot-switch-track i {
  display: block;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #ffffff;
  box-shadow: 0 1px 3px rgba(24, 32, 44, 0.24);
  transition: transform 140ms ease;
}

.cot-switch input:checked + .cot-switch-track {
  border-color: var(--accent);
  background: var(--accent);
}

.cot-switch input:checked + .cot-switch-track i {
  transform: translateX(18px);
}

.cot-switch input:focus-visible + .cot-switch-track {
  box-shadow: 0 0 0 3px rgba(35, 103, 232, 0.16);
}

.cot-access-threshold {
  transition: opacity 140ms ease;
}

.cot-access-rule.is-disabled .cot-access-threshold {
  opacity: 0.44;
}

.cot-branding {
  display: grid;
  grid-column: 1 / -1;
  gap: 14px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

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

.cot-text-button {
  padding: 5px 0;
  border: 0;
  background: transparent;
  color: var(--accent-dark);
  font-size: 12px;
  font-weight: 750;
  cursor: pointer;
}

.cot-theme-presets {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.cot-theme-preset {
  display: flex;
  min-width: 0;
  min-height: 42px;
  align-items: center;
  gap: 8px;
  padding: 7px 9px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #ffffff;
  color: #384253;
  font-size: 12px;
  font-weight: 750;
  cursor: pointer;
}

.cot-theme-preset:hover {
  border-color: var(--line-strong);
  background: #f8fafc;
}

.cot-theme-preset[aria-pressed="true"] {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(35, 103, 232, 0.11);
}

.cot-theme-swatches {
  display: flex;
  flex: 0 0 auto;
}

.cot-theme-swatches i {
  width: 15px;
  height: 15px;
  border: 1px solid rgba(24, 32, 44, 0.16);
  border-radius: 50%;
}

.cot-theme-swatches i + i {
  margin-left: -4px;
}

.cot-color-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.cot-color-control {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr);
  gap: 7px;
}

.cot-color-control input[type="color"] {
  width: 42px;
  min-height: 40px;
  padding: 4px;
  border-radius: 7px;
  cursor: pointer;
}

.cot-color-control input[type="color"]::-webkit-color-swatch-wrapper {
  padding: 0;
}

.cot-color-control input[type="color"]::-webkit-color-swatch {
  border: 0;
  border-radius: 4px;
}

.cot-color-control input[type="text"] {
  min-width: 0;
  text-transform: uppercase;
}

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

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  background: #fff;
  color: var(--text);
  padding: 10px 11px;
  outline: none;
}

textarea {
  min-height: 72px;
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(35, 103, 232, 0.13);
}

.cot-button {
  border: 0;
  border-radius: 7px;
  background: var(--accent);
  color: #fff;
  padding: 10px 14px;
  font-weight: 750;
  cursor: pointer;
  transition: background 140ms ease, transform 140ms ease;
}

.cot-button:hover {
  background: var(--accent-dark);
  transform: translateY(-1px);
}

.cot-secondary {
  background: #eef2f7;
  color: #263244;
}

.cot-secondary:hover {
  background: #e1e7ef;
}

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

.cot-item {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr) 40px;
  gap: 12px;
  padding: 18px 20px;
  border-bottom: 1px solid var(--line);
}

.cot-item-index {
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  background: #edf3ff;
  color: var(--accent);
  font-weight: 800;
  font-size: 13px;
}

.cot-item-fields {
  display: grid;
  gap: 12px;
}

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

.cot-target-editor,
.cot-target-label {
  min-width: 0;
}

.cot-combobox {
  position: relative;
}

.cot-combobox input[type="search"] {
  padding-right: 34px;
}

.cot-combobox-list {
  position: absolute;
  z-index: 20;
  top: calc(100% + 5px);
  right: 0;
  left: 0;
  max-height: 260px;
  overflow-y: auto;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  background: #ffffff;
  box-shadow: 0 12px 28px rgba(22, 34, 51, 0.14);
}

.cot-combobox-option {
  display: block;
  width: 100%;
  min-height: 40px;
  padding: 10px 12px;
  border: 0;
  border-bottom: 1px solid #edf0f4;
  background: #ffffff;
  color: var(--text);
  text-align: left;
  cursor: pointer;
}

.cot-combobox-option:last-child {
  border-bottom: 0;
}

.cot-combobox-option:hover,
.cot-combobox-option[aria-selected="true"] {
  background: #edf3ff;
  color: var(--accent-dark);
}

.cot-combobox-empty {
  padding: 14px 12px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
}

.cot-field-notice {
  color: var(--danger);
  font-weight: 600;
  line-height: 1.4;
}

.cot-flags {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
}

.cot-flags label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 650;
}

.cot-flags input {
  width: auto;
}

.cot-item-actions {
  display: grid;
  gap: 8px;
  align-self: start;
}

.cot-item-actions button {
  width: 32px;
  height: 32px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  cursor: pointer;
}

.cot-empty {
  margin: 20px;
  padding: 24px;
  border: 1px dashed var(--line-strong);
  border-radius: 8px;
  color: var(--muted);
  text-align: center;
}

.cot-preview {
  align-self: start;
  position: sticky;
  top: 16px;
}

.cot-widget-preview {
  --preview-primary: #2367e8;
  --preview-on-primary: #ffffff;
  --preview-accent: #138a5b;
  --preview-on-accent: #ffffff;
  --preview-surface: #ffffff;
  --preview-text: #17202d;
  --preview-muted: #657182;
  --preview-line: #dfe3ea;
  --preview-soft: #edf0f4;
  margin-top: 18px;
  border: 1px solid var(--preview-line);
  border-radius: 8px;
  background: var(--preview-surface);
  color: var(--preview-text);
  overflow: hidden;
  transition: background 140ms ease, border-color 140ms ease, color 140ms ease;
}

.cot-preview-head {
  padding: 14px;
  border-bottom: 1px solid var(--preview-line);
}

.cot-preview-head strong {
  display: block;
  margin-bottom: 8px;
}

.cot-preview-description {
  margin: -2px 0 10px;
  color: var(--preview-muted);
  font-size: 11px;
  font-weight: 500;
  line-height: 1.4;
}

.cot-preview-access {
  margin: 10px 0 0;
  color: var(--preview-muted);
  font-size: 11px;
  font-weight: 750;
}

.cot-meter {
  height: 8px;
  border-radius: 999px;
  background: var(--preview-soft);
  overflow: hidden;
}

.cot-meter span {
  display: block;
  height: 100%;
  width: 0;
  background: var(--preview-accent);
  transition: width 180ms ease;
}

.cot-preview-list {
  display: grid;
}

.cot-preview-row {
  display: grid;
  grid-template-columns: 22px 1fr;
  gap: 8px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--preview-line);
  font-size: 13px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

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

.cot-tabs {
  display: flex;
  max-width: 1280px;
  margin: 0 auto 18px;
  border-bottom: 1px solid var(--line);
}

.cot-tab {
  min-height: 42px;
  padding: 0 18px;
  border: 0;
  border-bottom: 2px solid transparent;
  background: transparent;
  color: var(--muted);
  font-weight: 750;
  cursor: pointer;
}

.cot-tab:hover {
  color: var(--text);
}

.cot-tab.is-active {
  border-bottom-color: var(--accent);
  color: var(--accent-dark);
}

.cot-page {
  max-width: 1280px;
  margin: 0 auto;
}

.cot-page[hidden] {
  display: none;
}

.cot-page-head,
.cot-template-band {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  padding: 20px 0;
}

.cot-page-head p,
.cot-template-band p {
  margin-bottom: 0;
  color: var(--muted);
}

.cot-summary {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  background: #ffffff;
}

.cot-summary > div {
  display: grid;
  gap: 3px;
  min-width: 0;
  padding: 16px 18px;
  border-right: 1px solid var(--line);
}

.cot-summary > div:last-child {
  border-right: 0;
}

.cot-summary strong {
  font-size: 23px;
  line-height: 1;
}

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

.cot-filters {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 16px 0;
}

.cot-search-field {
  width: min(300px, 100%);
}

.cot-filter-buttons {
  display: flex;
  align-items: center;
  overflow-x: auto;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  background: #ffffff;
}

.cot-filter-buttons button {
  min-height: 38px;
  padding: 0 12px;
  border: 0;
  border-right: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
  white-space: nowrap;
  cursor: pointer;
}

.cot-filter-buttons button:last-child {
  border-right: 0;
}

.cot-filter-buttons button.is-active {
  background: #edf3ff;
  color: var(--accent-dark);
}

.cot-table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.cot-client-table {
  width: 100%;
  min-width: 1060px;
  border-collapse: collapse;
}

.cot-client-table th,
.cot-client-table td {
  padding: 13px 14px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
}

.cot-client-table th {
  background: #f8fafc;
  color: #526071;
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.cot-client-table tbody tr:last-child td {
  border-bottom: 0;
}

.cot-client-table td:first-child {
  max-width: 230px;
}

.cot-client-table td:first-child strong,
.cot-client-table td:first-child small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cot-client-table td:first-child small {
  margin-top: 3px;
  color: var(--muted);
}

.cot-status-badge,
.cot-tag-state {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 3px 8px;
  border-radius: 6px;
  background: #eef2f7;
  color: #465365;
  font-size: 11px;
  font-weight: 800;
  white-space: nowrap;
}

.cot-status-badge.is-in_progress {
  background: #e7f0ff;
  color: #1854a8;
}

.cot-status-badge.is-overdue,
.cot-tag-state.is-error {
  background: #feebea;
  color: #9f241b;
}

.cot-status-badge.is-completed,
.cot-tag-state.is-ready {
  background: #e5f5ed;
  color: #08734a;
}

.cot-status-badge.is-paused {
  background: #fff4d9;
  color: #835500;
}

.cot-table-progress {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 126px;
}

.cot-table-progress > span {
  width: 76px;
  height: 6px;
  overflow: hidden;
  border-radius: 999px;
  background: #e7ebf0;
}

.cot-table-progress i {
  display: block;
  height: 100%;
  background: var(--success);
}

.cot-table-progress strong {
  min-width: 34px;
  font-size: 12px;
}

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

.cot-row-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
}

.cot-row-actions button,
.cot-action-menu {
  width: auto;
  min-height: 32px;
  padding: 5px 8px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: #ffffff;
  color: #334155;
  font-size: 11px;
  font-weight: 750;
  cursor: pointer;
}

.cot-action-menu {
  max-width: 76px;
}

.cot-template-band {
  align-items: center;
  margin-bottom: 18px;
  padding: 18px 20px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.cot-template-picker {
  display: grid;
  grid-template-columns: minmax(240px, 340px) auto;
  align-items: end;
  gap: 6px 10px;
}

.cot-template-picker p {
  grid-column: 1 / -1;
  grid-row: 2;
  font-size: 12px;
}

.cot-rule-row {
  align-items: end;
}

.cot-preview-row > span:last-child {
  min-width: 0;
}

.cot-preview-row strong,
.cot-preview-row small {
  display: block;
}

.cot-preview-row small {
  margin-top: 3px;
  color: var(--preview-muted);
  font-size: 10px;
}

.cot-preview-row.is-locked {
  opacity: 0.56;
}

.cot-automation-layout {
  display: grid;
  grid-template-columns: minmax(0, 560px) minmax(280px, 1fr);
  gap: 36px;
  padding: 28px 0;
  border-top: 1px solid var(--line);
}

.cot-automation-form {
  display: grid;
  gap: 18px;
  align-content: start;
}

.cot-automation-form .cot-button {
  justify-self: start;
}

.cot-permission-state {
  align-self: start;
  padding: 18px;
  border-left: 4px solid #d18a00;
  background: #fff9e8;
}

.cot-permission-state.is-ready {
  border-left-color: var(--success);
  background: #edf9f3;
}

.cot-permission-state strong {
  display: block;
  margin-bottom: 5px;
}

.cot-permission-state p {
  margin: 0;
  color: #536071;
  line-height: 1.5;
}

.cot-dialog {
  width: min(520px, calc(100vw - 28px));
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  color: var(--text);
  box-shadow: var(--shadow);
}

.cot-dialog::backdrop {
  background: rgba(20, 28, 39, 0.38);
}

.cot-dialog form,
.cot-dialog > div {
  display: grid;
  gap: 18px;
  padding: 22px;
}

.cot-dialog header,
.cot-dialog footer {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.cot-dialog footer {
  justify-content: flex-end;
}

.cot-dialog-close {
  width: 34px;
  height: 34px;
  flex: 0 0 auto;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #ffffff;
  color: #526071;
  font-size: 22px;
  cursor: pointer;
}

.cot-help {
  margin: -5px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.cot-contact-source {
  display: grid;
  gap: 4px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--bg);
}

.cot-contact-source span,
.cot-contact-source small {
  color: var(--muted);
}

.cot-contact-source strong,
.cot-contact-source small {
  overflow-wrap: anywhere;
}

.cot-preview-dialog {
  width: min(620px, calc(100vw - 28px));
}

.cot-live-preview-meta {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

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

.cot-preview-dot {
  width: 18px;
  height: 18px;
  border: 1px solid var(--preview-line);
  border-radius: 999px;
  background: var(--preview-surface);
}

.cot-preview-dot.is-complete {
  border-color: var(--preview-accent);
  background: var(--preview-accent);
}

.cot-preview-complete {
  margin: 14px;
  width: calc(100% - 28px);
  background: var(--preview-primary);
  color: var(--preview-on-primary);
}

.cot-preview-complete:hover {
  background: var(--preview-primary);
}

.cot-preview-complete[disabled] {
  filter: blur(0.6px);
  opacity: 0.48;
  cursor: not-allowed;
  transform: none;
}

.cot-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  padding-left: 0;
  padding-right: 0;
  padding-bottom: 0;
}

@media (max-width: 920px) {
  .cot-shell {
    padding: 16px;
  }

  .cot-header,
  .cot-workspace {
    display: grid;
    grid-template-columns: 1fr;
  }

  .cot-page-head,
  .cot-template-band,
  .cot-filters {
    align-items: stretch;
    flex-direction: column;
  }

  .cot-summary {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .cot-summary > div {
    border-bottom: 1px solid var(--line);
  }

  .cot-template-picker,
  .cot-automation-layout {
    grid-template-columns: 1fr;
  }

  .cot-filter-buttons {
    width: 100%;
  }

  .cot-status {
    text-align: left;
  }

  .cot-settings,
  .cot-access-rule,
  .cot-row,
  .cot-color-grid {
    grid-template-columns: 1fr;
  }

  .cot-theme-presets {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .cot-preview {
    position: static;
  }

  h1 {
    font-size: 28px;
  }
}

@media (max-width: 560px) {
  .cot-shell {
    padding: 12px;
  }

  .cot-header {
    gap: 12px;
  }

  .cot-tabs {
    overflow-x: auto;
  }

  .cot-tab {
    padding: 0 12px;
    white-space: nowrap;
  }

  .cot-summary {
    grid-template-columns: 1fr 1fr;
  }

  .cot-template-picker {
    display: grid;
  }

  .cot-template-picker p {
    grid-column: 1;
    grid-row: auto;
  }
}
