:root {
  color-scheme: light;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #f7f6f3;
  color: #202124;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: #f7f6f3;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

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

.login-panel {
  width: min(420px, 100%);
  background: #ffffff;
  border: 1px solid #e6e1da;
  border-radius: 8px;
  padding: 28px;
  box-shadow: 0 16px 42px rgba(32, 33, 36, 0.08);
  display: grid;
  gap: 18px;
}

.eyebrow {
  margin: 0 0 6px;
  color: #7b756b;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

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

h1 {
  font-size: 28px;
  letter-spacing: 0;
}

h2 {
  font-size: 24px;
  letter-spacing: 0;
}

h3 {
  font-size: 16px;
  letter-spacing: 0;
}

label {
  display: grid;
  gap: 8px;
  color: #5f5a52;
  font-size: 13px;
  font-weight: 650;
}

.field-block {
  display: grid;
  gap: 8px;
}

.field-label {
  color: #5f5a52;
  font-size: 13px;
  font-weight: 650;
}

input,
textarea {
  width: 100%;
  border: 1px solid #d8d2c9;
  border-radius: 6px;
  background: #ffffff;
  color: #202124;
  outline: none;
}

input,
select {
  height: 42px;
  padding: 0 12px;
}

textarea {
  min-height: 132px;
  resize: vertical;
  padding: 12px;
  line-height: 1.6;
}

input:focus,
textarea:focus {
  border-color: #5f6f52;
  box-shadow: 0 0 0 3px rgba(95, 111, 82, 0.12);
}

.custom-select {
  position: relative;
  width: 100%;
}

.custom-select-trigger {
  width: 100%;
  min-height: 42px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border: 1px solid #d8d2c9;
  border-radius: 6px;
  background: #ffffff;
  color: #202124;
  padding: 0 14px 0 12px;
  text-align: left;
  font-weight: 700;
}

.custom-select-trigger span:first-child {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.custom-select[data-open="true"] .custom-select-trigger,
.custom-select-trigger:focus {
  border-color: #5f6f52;
  box-shadow: 0 0 0 3px rgba(95, 111, 82, 0.12);
}

.select-arrow {
  width: 8px;
  height: 8px;
  flex: 0 0 auto;
  border-right: 2px solid #5f5a52;
  border-bottom: 2px solid #5f5a52;
  transform: rotate(45deg) translateY(-2px);
}

.custom-select[data-open="true"] .select-arrow {
  transform: rotate(225deg) translateY(-2px);
}

.custom-select-menu {
  position: absolute;
  z-index: 30;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  display: none;
  max-height: 260px;
  overflow: auto;
  border: 1px solid #ded8ce;
  border-radius: 8px;
  background: #ffffff;
  box-shadow: 0 18px 44px rgba(32, 33, 36, 0.16);
  padding: 6px;
}

.custom-select[data-open="true"] .custom-select-menu {
  display: grid;
  gap: 2px;
}

.custom-select-option {
  width: 100%;
  min-height: 36px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: #202124;
  padding: 0 10px;
  text-align: left;
  font-weight: 650;
}

.custom-select-option:hover,
.custom-select-option.selected {
  background: #ece7dd;
}

.primary,
.ghost,
.icon-button,
.small-button {
  border: 1px solid transparent;
  border-radius: 6px;
  height: 40px;
  padding: 0 14px;
}

.primary {
  background: #202124;
  color: #ffffff;
  font-weight: 700;
}

.ghost {
  background: #ffffff;
  border-color: #ded8ce;
  color: #2f302f;
}

.layout {
  min-height: 100vh;
  display: block;
}

.login-shell footer,
.app-footer {
  color: #8b857b;
  font-size: 12px;
}

.workspace {
  min-height: 100vh;
  padding: 28px;
  display: grid;
  gap: 18px;
  grid-template-rows: auto 1fr auto;
}

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

.page-title {
  display: flex;
  align-items: end;
  gap: 28px;
  min-width: 0;
}

.brand-mark {
  min-width: 180px;
}

.brand-mark h1 {
  white-space: nowrap;
}

.title-copy {
  min-width: 0;
}

.topbar p {
  color: #7b756b;
  margin-top: 4px;
}

.account-menu {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.account-menu span {
  color: #5f5a52;
  font-weight: 700;
}

.logout-button {
  height: 36px;
  border: 1px solid #ded8ce;
  border-radius: 999px;
  background: #ffffff;
  color: #202124;
  padding: 0 14px;
  font-weight: 700;
}

.logout-button:hover {
  background: #202124;
  color: #ffffff;
}

.app-footer {
  align-self: end;
}

.panel,
.table-panel {
  background: #ffffff;
  border: 1px solid #e1dcd3;
  border-radius: 8px;
  padding: 18px;
}

.panel {
  display: grid;
  gap: 16px;
}

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

.panel-head span {
  color: #7b756b;
  font-size: 13px;
}

.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.switch {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: #5f5a52;
  font-size: 13px;
  font-weight: 700;
}

.switch input {
  display: none;
}

.switch span {
  width: 42px;
  height: 24px;
  border-radius: 999px;
  background: #d8d2c9;
  position: relative;
}

.switch span::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #ffffff;
  transition: transform 0.16s ease;
}

.switch input:checked + span {
  background: #5f6f52;
}

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

.preview-frame {
  min-height: 420px;
  display: grid;
  place-items: center;
  overflow: hidden;
  border: 1px solid #ebe6de;
  border-radius: 8px;
  background: #0d0d0f;
}

.preview-frame img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.empty,
.empty-cell {
  color: #8b857b;
  text-align: center;
}

.selected-line {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  color: #6b665d;
  font-size: 13px;
}

table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 12px;
}

th,
td {
  text-align: left;
  padding: 12px 10px;
  border-bottom: 1px solid #ece7dd;
  font-size: 14px;
}

th {
  color: #6b665d;
  font-size: 12px;
  text-transform: uppercase;
}

.task-table-shell {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  margin-top: 12px;
  border-bottom: 1px solid #ece7dd;
}

.task-fixed-column {
  position: relative;
  z-index: 1;
  background: #ffffff;
  border-right: 1px solid #ece7dd;
}

.task-grid-head,
.task-grid-cell {
  height: 58px;
  display: flex;
  align-items: center;
  border-bottom: 1px solid #ece7dd;
  padding: 12px 12px;
}

.task-grid-head {
  color: #6b665d;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

.task-grid-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: #202124;
  font-size: 14px;
  font-weight: 700;
}

.task-scroll-column {
  overflow-x: auto;
  overflow-y: hidden;
}

.task-detail-table {
  min-width: 1220px;
  margin-top: 0;
}

.task-detail-table th,
.task-detail-table td {
  height: 58px;
  white-space: nowrap;
  vertical-align: middle;
}

.task-detail-table th:nth-child(1),
.task-detail-table td:nth-child(1) {
  min-width: 320px;
}

.task-detail-table th:nth-child(2),
.task-detail-table td:nth-child(2) {
  min-width: 130px;
}

.task-detail-table th:nth-child(3),
.task-detail-table td:nth-child(3) {
  min-width: 210px;
}

.task-detail-table th:nth-child(4),
.task-detail-table td:nth-child(4) {
  min-width: 220px;
}

.task-detail-table th:nth-child(5),
.task-detail-table td:nth-child(5) {
  min-width: 90px;
}

.task-detail-table th:nth-child(6),
.task-detail-table td:nth-child(6) {
  min-width: 210px;
}

.task-detail-table th:nth-child(7),
.task-detail-table td:nth-child(7) {
  min-width: 320px;
}

.status {
  display: inline-flex;
  height: 24px;
  align-items: center;
  border-radius: 999px;
  background: #ece7dd;
  padding: 0 10px;
  color: #6b665d;
  font-size: 12px;
  font-weight: 700;
}

.status.ok {
  background: #e2ead9;
  color: #405235;
}

.icon-button {
  width: 32px;
  padding: 0;
  background: #ffffff;
  border-color: #ded8ce;
  color: #7b756b;
  font-size: 20px;
}

.row-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  flex-wrap: nowrap;
}

.small-button {
  height: 32px;
  background: #ffffff;
  border-color: #ded8ce;
  color: #202124;
  font-weight: 700;
  flex: 0 0 auto;
}

.small-button.danger {
  color: #a33a2b;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 20;
  background: rgba(32, 33, 36, 0.38);
  display: grid;
  place-items: center;
  padding: 24px;
}

.task-modal {
  width: min(1180px, 100%);
  max-height: min(860px, calc(100vh - 48px));
  overflow: auto;
  background: #ffffff;
  border: 1px solid #e1dcd3;
  border-radius: 8px;
  box-shadow: 0 28px 80px rgba(32, 33, 36, 0.24);
}

.modal-head {
  position: sticky;
  top: 0;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 20px 22px;
  border-bottom: 1px solid #ece7dd;
  background: #ffffff;
}

.modal-head-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.modal-grid {
  display: grid;
  grid-template-columns: minmax(320px, 380px) minmax(0, 1fr);
  gap: 18px;
  padding: 22px;
}

.modal-form,
.modal-preview,
.content-builder {
  display: grid;
  gap: 16px;
  align-content: start;
}

.content-list {
  display: grid;
  gap: 14px;
}

.content-builder-actions {
  display: flex;
  justify-content: flex-end;
}

.content-item {
  display: grid;
  gap: 14px;
  border: 1px solid #e1dcd3;
  border-radius: 8px;
  padding: 16px;
  background: #fbfaf8;
}

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

.preview-frame.compact {
  min-height: 280px;
}

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

.check-option {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 38px;
  border: 1px solid #ded8ce;
  border-radius: 6px;
  padding: 0 10px;
  background: #ffffff;
}

.check-option input {
  width: 16px;
  height: 16px;
}

.check-option span {
  color: #202124;
  font-weight: 700;
}

.ai-toggle {
  width: fit-content;
  min-height: 40px;
  padding-right: 14px;
}

.ai-config {
  display: grid;
  gap: 14px;
  border-top: 1px solid #e1dcd3;
  padding-top: 14px;
}

.content-type-backdrop {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: rgba(32, 33, 36, 0.18);
  display: grid;
  place-items: center;
  padding: 24px;
}

.content-type-dialog {
  width: min(420px, 100%);
  border: 1px solid #e1dcd3;
  border-radius: 8px;
  background: #ffffff;
  box-shadow: 0 22px 64px rgba(32, 33, 36, 0.22);
  padding: 18px;
  display: grid;
  gap: 16px;
}

.content-type-dialog header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.content-type-options {
  display: grid;
  gap: 10px;
}

.content-type-option {
  display: grid;
  gap: 6px;
  width: 100%;
  text-align: left;
  border: 1px solid #ded8ce;
  border-radius: 8px;
  background: #fbfaf8;
  color: #202124;
  padding: 14px;
}

.content-type-option:hover {
  border-color: #5f6f52;
  background: #ffffff;
}

.content-type-option span {
  color: #7b756b;
  font-size: 13px;
}

.preview-backdrop {
  position: fixed;
  inset: 0;
  z-index: 45;
  background: rgba(32, 33, 36, 0.38);
  display: grid;
  place-items: center;
  padding: 24px;
}

.preview-dialog {
  width: min(980px, 100%);
  max-height: min(860px, calc(100vh - 48px));
  overflow: auto;
  border: 1px solid #e1dcd3;
  border-radius: 8px;
  background: #ffffff;
  box-shadow: 0 28px 80px rgba(32, 33, 36, 0.24);
}

.preview-head {
  position: sticky;
  top: 0;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 20px;
  border-bottom: 1px solid #ece7dd;
  background: #ffffff;
}

.preview-body {
  display: grid;
  gap: 16px;
  padding: 20px;
}

.preview-image {
  width: 100%;
  display: block;
  border-radius: 8px;
  background: #0d0d0f;
}

.telegram-preview-text {
  white-space: pre-wrap;
  line-height: 1.65;
  border: 1px solid #e1dcd3;
  border-radius: 8px;
  background: #fbfaf8;
  padding: 14px;
  color: #202124;
  font-size: 14px;
}

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

@media (max-width: 640px) {
  .workspace {
    padding: 16px;
  }

  .topbar,
  .field-row {
    display: grid;
    grid-template-columns: 1fr;
  }

  .page-title {
    display: grid;
    gap: 12px;
  }

  .brand-mark {
    min-width: 0;
  }

  .account-menu,
  .topbar-actions {
    width: 100%;
    justify-content: space-between;
  }

  .logout-button {
    min-width: 82px;
  }
}
