:root {
  --bg: #f3f5f7;
  --panel: #ffffff;
  --line: #d8dee6;
  --text: #17202a;
  --muted: #667085;
  --accent: #1f7a5a;
  --accent-dark: #155c43;
  --danger: #b42318;
  --warn: #b54708;
  --soft: #eef7f3;
  --shadow: 0 16px 40px rgba(15, 23, 42, .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;
}

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

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

.sidebar {
  background: #18212b;
  color: #fff;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.brand-block {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 58px;
}

.brand-mark {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: #26a06f;
  font-weight: 800;
}

.brand-block h1,
.topbar h2,
.drawer-head h3,
.empty-state h3 {
  margin: 0;
  letter-spacing: 0;
}

.brand-block h1 {
  font-size: 18px;
}

.brand-block p,
.topbar p,
.drawer-head p,
.empty-state p,
.session-meta {
  margin: 4px 0 0;
  color: var(--muted);
}

.brand-block p,
.session-meta {
  color: #aeb8c4;
}

.login-panel,
.session-panel {
  padding: 14px;
  border: 1px solid rgba(255,255,255,.12);
  border-radius: 8px;
  background: rgba(255,255,255,.06);
}

label {
  display: grid;
  gap: 6px;
  margin-bottom: 10px;
  color: inherit;
  font-size: 13px;
}

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

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

.login-panel input {
  border-color: rgba(255,255,255,.18);
  background: rgba(255,255,255,.95);
}

button {
  border: 0;
  border-radius: 6px;
  min-height: 38px;
  padding: 0 14px;
  cursor: pointer;
}

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

.primary:hover {
  background: var(--accent-dark);
}

.ghost {
  color: var(--text);
  background: #fff;
  border: 1px solid var(--line);
}

.secondary {
  color: var(--accent-dark);
  background: #eef6ff;
  border: 1px solid #bfdcff;
}

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

.danger-light {
  color: var(--danger);
  background: #fff;
  border: 1px solid #fecdca;
}

.danger-light:hover {
  background: #fff5f5;
}

.mini-btn {
  min-height: 30px;
  padding: 0 10px;
  font-size: 12px;
}

.sidebar .ghost {
  color: #fff;
  background: rgba(255,255,255,.08);
  border-color: rgba(255,255,255,.18);
}

.message {
  margin-top: 10px;
  font-size: 12px;
  color: #fecdca;
  min-height: 16px;
}

.hidden {
  display: none !important;
}

.session-name {
  font-weight: 700;
}

.nav-list {
  display: grid;
  gap: 5px;
  overflow: auto;
}

.nav-item {
  width: 100%;
  text-align: left;
  color: #d8dee6;
  background: transparent;
  border: 1px solid transparent;
}

.nav-item.active,
.nav-item:hover {
  background: rgba(255,255,255,.1);
  border-color: rgba(255,255,255,.14);
  color: #fff;
}

.main {
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.topbar {
  min-height: 84px;
  padding: 20px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
}

.topbar h2 {
  font-size: 24px;
}

.api-status {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 0 10px;
  border-radius: 999px;
  background: var(--soft);
  color: var(--accent-dark);
  font-size: 13px;
}

.toolbar {
  padding: 12px 24px;
  display: grid;
  grid-template-columns: minmax(260px, 1fr) auto auto auto;
  gap: 10px;
  align-items: end;
  border-bottom: 1px solid var(--line);
  background: #fbfcfd;
}

.search-wrap {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 12px;
}

.content {
  padding: 20px 24px 32px;
  overflow: auto;
}

.empty-state {
  max-width: 680px;
  padding: 26px 0;
}

.table-filters {
  display: flex;
  align-items: end;
  gap: 12px;
  margin-bottom: 10px;
}

.table-filters label {
  margin: 0;
  min-width: 220px;
}

.table-filters .filter-check {
  display: inline-flex;
  min-width: auto;
  align-items: center;
  gap: 8px;
  min-height: 38px;
}

.table-filters .filter-check input {
  width: 18px;
  min-height: 18px;
}

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

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 860px;
}

th,
td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
  font-size: 13px;
}

th {
  position: sticky;
  top: 0;
  background: #f8fafc;
  z-index: 1;
  color: #475467;
  font-weight: 700;
}

tr:hover td {
  background: #fbfdfc;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 8px;
  border-radius: 999px;
  background: #eef2f6;
  color: #344054;
  white-space: nowrap;
}

.pill.ok {
  background: #dcfae6;
  color: #067647;
}

.pill.off {
  background: #fee4e2;
  color: var(--danger);
}

.row-action {
  min-height: 30px;
  padding: 0 10px;
}

.drawer {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: 1fr minmax(360px, 620px);
  height: 100vh;
  height: 100dvh;
  min-height: 0;
  overflow: hidden;
}

.drawer-backdrop {
  background: rgba(15, 23, 42, .36);
}

.drawer-panel {
  background: #fff;
  box-shadow: var(--shadow);
  display: grid;
  grid-template-rows: auto 1fr auto;
  min-width: 0;
  min-height: 0;
  max-height: 100vh;
  max-height: 100dvh;
}

.drawer-head {
  min-height: 78px;
  padding: 18px 20px;
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  gap: 16px;
  flex-shrink: 0;
}

.icon-btn {
  width: 38px;
  padding: 0;
  font-size: 24px;
  background: #f2f4f7;
}

.detail-form {
  padding: 18px 20px;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  align-content: start;
  overscroll-behavior: contain;
}

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

.checkbox-field {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 38px;
  margin: 22px 0 0;
}

.checkbox-field input {
  width: 18px;
  min-height: 18px;
}

.opening-hours-field {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fbfcfe;
}

.opening-hours-title {
  margin-bottom: 10px;
  font-size: 13px;
  font-weight: 700;
}

.opening-hours-grid {
  display: grid;
  gap: 8px;
}

.opening-hours-row {
  display: grid;
  grid-template-columns: 82px 74px repeat(4, minmax(0, 1fr));
  gap: 8px;
  align-items: center;
}

.opening-day-name {
  font-size: 13px;
  font-weight: 700;
}

.opening-closed {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin: 0;
  color: var(--muted);
}

.opening-closed input {
  width: 16px;
  min-height: 16px;
}

.opening-hours-row input[type="time"] {
  min-height: 34px;
  padding: 6px;
}

.checkbox-group {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfe;
  padding: 12px;
}

.checkbox-group-title {
  font-size: 13px;
  font-weight: 700;
  margin-bottom: 10px;
}

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

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

.checkbox-card {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
}

.checkbox-card input {
  width: 18px;
  min-height: 18px;
}

.workflow-steps-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
}

.workflow-head-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: flex-end;
}

.workflow-steps-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  max-height: 52vh;
  overflow: auto;
  padding-right: 4px;
}

.workflow-blocks-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 10px;
  margin: 12px 0;
}

.workflow-summary {
  margin-top: 10px;
}

.workflow-summary-card {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 10px;
  padding: 10px;
  border: 1px solid #b7d8cf;
  border-radius: 8px;
  background: #f1fbf8;
}

.workflow-summary-card div {
  display: grid;
  gap: 4px;
}

.workflow-summary-card strong {
  color: var(--accent-dark);
  font-size: 12px;
  text-transform: uppercase;
}

.workflow-summary-card span {
  color: var(--text);
  font-size: 12px;
  line-height: 1.35;
}

.workflow-summary-empty {
  padding: 10px;
  border: 1px dashed #e5b7b7;
  border-radius: 8px;
  background: #fff6f6;
  color: #8a3030;
  font-size: 12px;
  font-weight: 700;
}

.workflow-empty-warning {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  justify-content: space-between;
  margin-top: 10px;
  padding: 10px;
  border: 1px solid #f0c36d;
  border-radius: 8px;
  background: #fff8e8;
  color: #704600;
  font-size: 12px;
  font-weight: 700;
}

.workflow-debug-details {
  margin-top: 8px;
  color: var(--muted);
  font-size: 11px;
}

.workflow-debug-details summary {
  cursor: pointer;
}

.workflow-debug-details code {
  display: block;
  margin-top: 4px;
  white-space: pre-wrap;
}

.workflow-block-card {
  display: grid;
  grid-template-columns: 22px 1fr;
  gap: 10px;
  margin: 0;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.workflow-block-card.is-active {
  border-color: var(--accent);
  background: #eef8f5;
}

.workflow-block-card.is-partial {
  border-style: dashed;
}

.workflow-hide-inactive .workflow-block-card:not(.is-active) {
  display: none;
}

.workflow-block-card input {
  width: 18px;
  min-height: 18px;
  margin-top: 2px;
}

.workflow-block-card strong,
.workflow-block-card small,
.workflow-block-card em,
.workflow-block-card code {
  display: block;
}

.workflow-block-card strong {
  color: var(--accent-dark);
  font-size: 14px;
}

.workflow-block-card small {
  margin-top: 3px;
  color: var(--text);
  line-height: 1.35;
}

.workflow-block-card em {
  margin-top: 5px;
  color: var(--muted);
  font-size: 11px;
  font-style: normal;
}

.workflow-notification-line {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 6px;
  align-items: center;
  margin-top: 7px;
  padding: 6px 7px;
  border-radius: 6px;
  background: #fff7db;
  color: #6f4d00;
  font-size: 11px;
  font-weight: 700;
  line-height: 1.3;
}

.workflow-notification-line i {
  padding: 2px 5px;
  border-radius: 999px;
  background: #f1c84b;
  color: #3f2c00;
  font-style: normal;
  text-transform: uppercase;
}

.workflow-block-card code {
  margin-top: 7px;
  color: var(--muted);
  font-size: 11px;
  white-space: normal;
}

.workflow-technical-details {
  margin-top: 10px;
}

.workflow-technical-details summary {
  cursor: pointer;
  color: var(--accent-dark);
  font-size: 13px;
  font-weight: 700;
}

.workflow-step-card {
  display: grid;
  grid-template-columns: 22px 1fr;
  gap: 8px;
  margin: 0;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
}

.workflow-step-card input {
  width: 18px;
  min-height: 18px;
  margin-top: 2px;
}

.workflow-step-card strong {
  display: block;
  color: var(--accent-dark);
  font-size: 13px;
}

.workflow-step-card small {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  line-height: 1.35;
}

.products-checklist {
  grid-template-columns: 1fr;
  max-height: 52vh;
  overflow: auto;
  padding-right: 4px;
}

.products-checklist .checkbox-card {
  align-items: flex-start;
  padding: 7px 9px;
}

.products-checklist strong {
  color: var(--accent-dark);
}

.tiers-editor {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfe;
  padding: 12px;
}

.tiers-editor-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
  margin-bottom: 10px;
}

.tiers-editor-head h4 {
  margin: 0;
  font-size: 14px;
}

.tiers-editor-head p {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.tiers-table-wrap {
  overflow-x: auto;
}

.tiers-table {
  min-width: 860px;
  font-size: 12px;
}

.tiers-table th,
.tiers-table td {
  padding: 6px;
  vertical-align: middle;
}

.tiers-table th:first-child,
.tiers-table td:first-child {
  width: 34px;
  text-align: center;
}

.tiers-table input,
.tiers-table select {
  min-height: 32px;
  padding: 5px 7px;
  font-size: 12px;
}

.tiers-table .tier-active {
  text-align: center;
}

.tiers-table .tier-active input {
  width: 18px;
  min-height: 18px;
}

.campaign-sales-table th:first-child,
.campaign-sales-table td:first-child {
  width: 58px;
}

.campaign-sales-table th:nth-child(4),
.campaign-sales-table td:nth-child(4) {
  width: 150px;
}

.visual-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 12px;
}

.visual-card {
  display: grid;
  grid-template-columns: 120px 1fr;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 10px;
}

.visual-preview {
  width: 120px;
  aspect-ratio: 1 / 1;
  border: 1px dashed var(--line);
  border-radius: 6px;
  background: #f6f8fb;
  display: grid;
  place-items: center;
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  text-align: center;
}

.visual-preview img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #fff;
}

.visual-fields {
  display: grid;
  gap: 8px;
  min-width: 0;
}

.visual-fields strong {
  color: var(--accent-dark);
}

.visual-fields label {
  display: grid;
  gap: 4px;
  font-size: 12px;
  color: var(--muted);
}

.drawer-actions {
  padding: 14px 20px;
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  border-top: 1px solid var(--line);
  flex-shrink: 0;
}

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

  .sidebar {
    position: static;
  }

  .toolbar {
    grid-template-columns: 1fr;
  }

  .drawer {
    grid-template-columns: 1fr;
  }

  .drawer-backdrop {
    display: none;
  }

  .visual-card {
    grid-template-columns: 1fr;
  }

  .visual-preview {
    width: 100%;
  }

  .detail-form {
    grid-template-columns: 1fr;
  }
}
