* { box-sizing: border-box; }
body { font-family: -apple-system, Segoe UI, Roboto, sans-serif; margin: 0; background: #f4f5f7; color: #1f2330; }

header { background: #1f2330; color: #fff; padding: 14px 22px; display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
header h1 { font-size: 18px; margin: 0; }
.tag { background: #3a78ff; font-size: 12px; padding: 3px 8px; border-radius: 10px; }
.hdr-note { color: #aeb4c2; font-size: 12px; }
.hdr-live { width: 9px; height: 9px; border-radius: 50%; background: #6b7280; margin-left: auto; }
.hdr-live.on { background: #35d07f; box-shadow: 0 0 0 3px rgba(53,208,127,.2); }

.wrap { max-width: 1180px; margin: 22px auto; padding: 0 18px; }
.card { background: #fff; border: 1px solid #e3e6ec; border-radius: 10px; padding: 18px; margin-bottom: 20px; }
.card-head-only { padding-bottom: 14px; }
.card h2 { margin: 0; font-size: 16px; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 8px; }
h4 { margin: 20px 0 4px; font-size: 13px; color: #5a6071; border-top: 1px solid #eef0f4; padding-top: 14px; }

label { display: block; font-size: 12px; color: #5a6071; margin: 10px 0 4px; font-weight: 600; }
input, select, textarea { width: 100%; padding: 8px 10px; border: 1px solid #ccd2de; border-radius: 6px; font-size: 13px; font-family: inherit; background: #fff; color: inherit; }
textarea { min-height: 90px; resize: vertical; font-family: ui-monospace, Consolas, monospace; }
.row { display: flex; gap: 12px; flex-wrap: wrap; }
.row > div { flex: 1; min-width: 160px; }
.inline-form { margin-top: 8px; display: flex; gap: 6px; }
.inline-form input { max-width: 210px; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-top: 10px; }
.filters input, .filters select { max-width: 260px; }
.chk { display: flex; align-items: center; gap: 5px; font-size: 12px; color: #5a6071; margin: 0; font-weight: 600; white-space: nowrap; }
.chk input { width: auto; }

button { cursor: pointer; border: none; border-radius: 6px; padding: 8px 14px; font-size: 13px; font-weight: 600; font-family: inherit; }
.btn-primary { background: #3a78ff; color: #fff; }
.btn-danger { background: #ffe5e5; color: #c0263a; }
.btn-ghost { background: #eef0f4; color: #1f2330; }
.btn-on { background: #1a7f37; color: #fff; }
.btn-off { background: #c0263a; color: #fff; }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-link { display: inline-block; text-decoration: none; line-height: 1.5; }
.btn-icon { background: #eef0f4; color: #5a6071; padding: 4px 8px; font-size: 12px; line-height: 1; }
button:disabled { opacity: .55; cursor: default; }

.tbl-scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid #eef0f4; vertical-align: top; }
th { color: #5a6071; font-size: 11px; text-transform: uppercase; white-space: nowrap; }
tr.shadowed td { background: #fffaf0; }

.pill { font-size: 11px; padding: 2px 7px; border-radius: 8px; white-space: nowrap; }
.on { background: #def7e5; color: #1a7f37; }
.off { background: #f0f1f4; color: #8b909c; }
.warn { background: #fff3d6; color: #9a6700; }
.mono { font-family: ui-monospace, Consolas, monospace; font-size: 12px; word-break: break-all; }
.muted { color: #8b909c; font-size: 12px; font-weight: 400; }
.err-text { color: #c0263a; font-size: 12px; }
.actions { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.hint { font-size: 11px; color: #8b909c; margin-top: 3px; }
.preview { background: #f4f5f7; padding: 8px; border-radius: 6px; white-space: pre-wrap; min-height: 20px; }

.tabs { display: flex; gap: 8px; margin-bottom: 16px; flex-wrap: wrap; }
.tabs button.active { background: #1f2330; color: #fff; }
.tabs button { background: #eef0f4; color: #1f2330; }

.status-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 14px; }
.st-line { display: flex; align-items: center; gap: 8px; padding: 6px 0; font-size: 13px; }
.dot { width: 11px; height: 11px; border-radius: 50%; flex: 0 0 auto; }
.dot.green { background: #1a7f37; }
.dot.red { background: #c0263a; }
.dot.gray { background: #b6bcc8; }
.st-box { border: 1px solid #e3e6ec; border-radius: 8px; padding: 12px 14px; }
.st-box h3 { margin: 0 0 6px; font-size: 13px; }

/* карточки клиентов со сценариями */
.client-card { background: #fff; border: 1px solid #e3e6ec; border-radius: 10px; padding: 16px 18px; margin-bottom: 14px; }
.client-head { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.client-head b { font-size: 15px; }
.scenarios { display: flex; gap: 8px; flex-wrap: wrap; }
.scenario { border: 1px solid #ccd2de; background: #fff; border-radius: 8px; padding: 9px 13px; text-align: left; min-width: 150px; }
.scenario:hover { border-color: #3a78ff; }
.scenario.active { background: #1a7f37; border-color: #1a7f37; color: #fff; }
.scenario .s-sub { display: block; font-weight: 400; font-size: 11px; opacity: .75; margin-top: 2px; }
.client-meta { font-size: 12px; color: #8b909c; margin-top: 10px; display: flex; gap: 14px; flex-wrap: wrap; }

dialog { border: none; border-radius: 12px; padding: 0; width: min(820px, 94vw); color: inherit; }
dialog::backdrop { background: rgba(20,24,35,.45); }
.dlg-head { padding: 16px 20px; border-bottom: 1px solid #eef0f4; font-weight: 700; }
.dlg-body { padding: 16px 20px; max-height: 72vh; overflow: auto; }
.dlg-foot { padding: 14px 20px; border-top: 1px solid #eef0f4; display: flex; justify-content: flex-end; gap: 10px; }

.extra-row { display: flex; gap: 6px; margin-bottom: 6px; }
.extra-row input { flex: 1; }
.extra-row select { max-width: 120px; }

#toast-wrap { position: fixed; top: 16px; right: 16px; z-index: 9999; display: flex; flex-direction: column; gap: 8px; }
.toast { background: #1f2330; color: #fff; padding: 11px 15px; border-radius: 8px; font-size: 13px; max-width: 360px; box-shadow: 0 6px 20px rgba(20,24,35,.28); transition: opacity .35s, transform .35s; }
.toast.error { background: #c0263a; }
.toast.ok { background: #1a7f37; }

.detail { background: #f9fafb; font-size: 11px; line-height: 1.7; }
.sys-row td { background: #fbfbfd; color: #5a6071; font-style: italic; }
.sys-row.warn-row td { background: #fff8e8; }
.sys-row.error-row td { background: #fff0f0; color: #c0263a; }

@media (max-width: 760px) {
  .wrap { padding: 0 10px; margin: 14px auto; }
  .card { padding: 14px; }
  th, td { padding: 6px; }
  .scenario { flex: 1 1 100%; }
}
