/* Settings → «WhatsApp» (static/whatsapp.js): the numbers list, its row menus (top-layer popovers), the auto-send
   panel under a row and the connect dialog's contents inside the shared #dialog. Colors from palette.css only. */
.wa-section .wa-heading{display:flex;align-items:center;justify-content:space-between;gap:12px 24px;flex-wrap:wrap}
.wa-body:not(:empty){margin-top:18px}
.wa-section .wa-heading h2{margin:0}
.wa-section .wa-heading .btn{min-height:40px}
.wa-section ::selection,.wa-flow ::selection{background:var(--plum-200);color:var(--plum-900)}
.wa-section .num,.wa-flow .num{font-variant-numeric:tabular-nums}

/* ---------------------------------------------------------------- rows */
.wa-list{list-style:none;margin:0;padding:0;border-top:1px solid var(--line)}
.wa-row{border-bottom:1px solid var(--line)}
.wa-row:last-child{border-bottom:0}
.wa-row.wa-fresh{animation:wa-fresh 1400ms var(--ease)}
@keyframes wa-fresh{0%,35%{background:var(--mint-50)}}
.wa-head{display:grid;grid-template-columns:minmax(0,1fr) auto;align-items:center;gap:10px 20px;padding:15px 0}
.wa-info{min-width:0}
.settings-section .wa-info p{margin:0;line-height:1.5}
.settings-section .wa-info p+p{margin-top:3px}
.settings-section p.wa-name{font-size:14px;font-weight:500;color:var(--ink);overflow-wrap:anywhere}
.settings-section p.wa-meta{display:flex;flex-wrap:wrap;align-items:center;gap:2px 8px;font-size:12px;color:var(--muted)}
.settings-section p.wa-when{font-size:12px;color:var(--muted)}
.wa-sep{color:var(--plum-300)}
.wa-state{display:inline-flex;align-items:center;gap:6px;font-weight:500}
.wa-state i{width:7px;height:7px;border-radius:50%;background:currentColor}
.wa-ok{color:var(--success-600)}
.wa-wait{color:var(--warning-600)}
.wa-bad{color:var(--danger-600)}
.wa-off,.wa-idle{color:var(--muted)}
.wa-state.wa-off i,.wa-state.wa-idle i{background:var(--plum-400)}
.settings-section p.wa-error,.wa-flow .wa-error{font-size:12px;line-height:1.55;color:var(--danger-600)}
.settings-section p.wa-auto-on{display:inline-flex;align-items:center;gap:6px;font-size:12px;font-weight:500;color:var(--plum-700)}
.wa-auto-on svg{color:var(--plum-500)}
.wa-import{margin-top:6px}
.settings-section .wa-import p,.wa-flow .wa-import p{font-size:12px;color:var(--muted);font-variant-numeric:tabular-nums}
.wa-bar{max-width:320px;height:4px;margin-top:7px;border-radius:2px;background:var(--plum-150);overflow:hidden}
.wa-bar i{display:block;height:100%;background:var(--plum-700);transform-origin:left center;transition:transform 300ms var(--ease)}
.wa-actions{display:flex;align-items:center;justify-content:flex-end;gap:6px}
.wa-actions .btn{min-height:36px;font-size:12px}
.wa-more{color:var(--plum-600)}
.wa-more svg{stroke-width:2.8}
.wa-more:is(:hover,[aria-expanded="true"]){color:var(--plum);background:var(--plum-150)}
.wa-link{min-height:32px;padding:4px 2px;color:var(--plum-700);font-weight:500;text-decoration:underline;text-underline-offset:3px;text-decoration-thickness:1px;cursor:pointer}
.wa-link:hover{color:var(--plum)}
.wa-skeleton{display:grid;gap:10px;border-top:1px solid var(--line);padding-top:15px}
.wa-skeleton i{display:block;height:44px;border-radius:10px;background:var(--plum-100)}
.wa-skeleton i+i{width:62%}
.wa-skeleton-log{border:0;padding:0}
.wa-skeleton-log i{height:28px}

/* Row menu: a top-layer popover placed next to its trigger. */
.wa-menu{position:fixed;inset:auto;margin:0;min-width:220px;max-width:min(300px,calc(100vw - 24px));padding:6px;border:1px solid var(--line);border-radius:12px;background:var(--white);color:var(--ink);box-shadow:0 14px 40px oklch(from var(--plum-950) l c h / .16),0 2px 6px oklch(from var(--plum-950) l c h / .06)}
.wa-menu:popover-open{animation:wa-menu-in 160ms var(--ease)}
.wa-menu button{display:flex;align-items:center;gap:10px;width:100%;min-height:42px;padding:9px 12px;border:0;border-radius:8px;background:none;font-size:13px;line-height:1.35;text-align:left;color:var(--ink);cursor:pointer}
.wa-menu button svg{flex-shrink:0;color:var(--plum-500)}
.wa-menu button:hover{background:var(--plum-100)}
.wa-menu button:focus-visible{outline:2px solid var(--focus);outline-offset:-2px}
.wa-menu .wa-danger,.wa-menu .wa-danger svg{color:var(--danger-600)}
.wa-menu .wa-danger:hover{background:var(--danger-100)}
@keyframes wa-menu-in{from{opacity:0;transform:translateY(-4px)}}

/* ---------------------------------------------------------------- «Автоотправка» */
.wa-auto{margin:0 0 16px;padding:18px 20px 20px;border:1px solid var(--line);border-radius:12px;background:var(--plum-50);animation:wa-in 220ms var(--ease)}
.wa-auto-head{display:flex;align-items:center;justify-content:space-between;gap:12px;margin:-6px -8px 4px 0}
.wa-auto-head h3{font-size:15px;font-weight:600;letter-spacing:-.01em}
.wa-auto-close{width:40px;height:40px;min-width:40px}
.settings-section .wa-auto p.wa-quiet{margin:0 0 6px;font-size:12px;line-height:1.55}
.wa-switch-row{flex-wrap:wrap}
.wa-switch{position:relative;display:inline-flex;align-items:center;gap:12px;min-height:44px;font-size:14px;font-weight:500;color:var(--ink);cursor:pointer}
.wa-switch input{position:absolute;z-index:1;left:0;top:50%;width:36px;height:20px;margin:-10px 0 0;opacity:0;cursor:inherit}
.wa-track{position:relative;flex:none;width:36px;height:20px;border-radius:10px;background:var(--plum-400);transition:background-color var(--fast)}
.wa-track::after{content:'';position:absolute;left:3px;top:3px;width:14px;height:14px;border-radius:50%;background:var(--white);box-shadow:0 1px 2px oklch(from var(--plum-950) l c h / .2);transition:transform 200ms var(--ease)}
.wa-switch input:checked+.wa-track{background:var(--plum-800)}
.wa-switch input:checked+.wa-track::after{transform:translateX(16px)}
.wa-switch input:focus-visible+.wa-track{outline:2px solid var(--plum-500);outline-offset:3px}
.wa-switch:has(input:disabled){cursor:default;color:var(--plum-700)}
.wa-switch input:disabled+.wa-track{background:var(--plum-300)}
.wa-switch input:disabled:checked+.wa-track{background:var(--plum-500)}
.wa-auto-grid{display:flex;flex-wrap:wrap;align-items:flex-start;gap:14px 32px;margin:8px 0 10px}
.wa-auto fieldset,.wa-choice{min-width:0;margin:0;padding:0;border:0}
.wa-auto legend{margin-bottom:8px;padding:0;font-size:12px;font-weight:500;color:var(--ink)}
.wa-tz{margin-left:4px;font-weight:400;color:var(--muted);font-variant-numeric:tabular-nums}
.wa-range{display:flex;align-items:center;flex-wrap:wrap;gap:8px 12px}
.wa-range label{display:inline-flex;align-items:center;gap:8px;font-size:13px;color:var(--muted)}
.wa-auto :is(.wa-time,input[type=number]){box-sizing:border-box;width:76px;min-height:40px;padding:8px 10px;border:1px solid var(--control-line);border-radius:10px;background:var(--white);color:var(--ink);font:inherit;font-size:14px;font-variant-numeric:tabular-nums}
.wa-auto :is(.wa-time,input[type=number]):focus-visible{outline:2px solid var(--plum-500);outline-offset:2px}
.wa-auto :is(.wa-time,input[type=number]):disabled{border-color:var(--plum-200);background:var(--plum-50);color:var(--plum-700)}
.wa-auto input[aria-invalid=true]{border-color:var(--danger-600)}
.settings-section .wa-auto p.inline-error{margin:8px 0 0;font-size:13px;line-height:1.6;color:var(--danger-600)}
/* The hours error sits right under «с … до …» (a full row of the fieldset). */
.settings-section .wa-auto p.wa-field-error{flex-basis:100%;margin:0;contain:inline-size}
.wa-auto input[type=number]{appearance:textfield;-moz-appearance:textfield}
.wa-auto input[type=number]::-webkit-inner-spin-button,.wa-auto input[type=number]::-webkit-outer-spin-button{margin:0;-webkit-appearance:none}
.wa-auto-actions{margin-top:12px}
.wa-auto-actions .btn{min-height:40px}
.wa-log{margin-top:20px;padding-top:16px;border-top:1px solid var(--line)}
.wa-log h4{margin:0 0 8px;font-size:13px;font-weight:600;color:var(--ink)}
.settings-section .wa-log p.wa-quiet{margin:0;font-size:12px}
.wa-log-list{list-style:none;margin:0;padding:0}
.wa-entry{display:grid;grid-template-columns:116px minmax(150px,210px) minmax(0,1fr);align-items:baseline;gap:2px 14px;padding:8px 0;border-top:1px solid var(--plum-150);font-size:12px;line-height:1.5}
.wa-entry:first-child{border-top:0}
.wa-entry time{color:var(--muted)}
.wa-decision{font-weight:500}
.wa-entry-chat{display:flex;align-items:baseline;gap:8px;min-width:0}
.wa-chat-link{flex:none;max-width:45%;min-height:28px;padding:0;border:0;background:none;font:inherit;font-weight:500;color:var(--ink);text-decoration:underline;text-decoration-color:var(--plum-300);text-underline-offset:3px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;cursor:pointer}
.wa-chat-link:hover{text-decoration-color:currentColor}
.wa-client-text{min-width:0;color:var(--muted);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}

/* ---------------------------------------------------------------- connect dialog (#dialog-body) */
.wa-connect-form .field{margin-bottom:18px}
.wa-choice{display:flex;flex-wrap:wrap;gap:0 24px;margin:0 0 14px}
.wa-choice legend{width:100%;margin-bottom:2px;padding:0;font-size:13px;font-weight:500;color:var(--ink)}
.wa-choice .check-label input,.wa-consent .check-label input{flex:none}
.wa-consent{align-items:flex-start;gap:10px;margin-top:4px}
.wa-consent .check-label{align-self:auto;font-size:14px;line-height:1.45}
.wa-consent .check-label input[aria-invalid=true]{outline:2px solid var(--danger-600);outline-offset:2px}
.wa-consent .hint{margin-top:12px}
/* The consent tip opens above its line, never over the dialog's actions. */
.wa-consent .hint-tip{top:auto;bottom:calc(100% + 8px);transform:translateY(3px)}
.wa-consent .hint-tip::before{inset:auto 0 -10px}
.wa-phase:focus{outline:none}
.wa-phase.wa-enter>*{animation:wa-in 220ms var(--ease) both}
@keyframes wa-in{from{opacity:0;transform:translateY(6px)}}
.wa-qr-frame{position:relative;display:grid;place-items:center;width:264px;height:264px;margin:2px auto 14px;border:1px solid var(--line);border-radius:16px;background:var(--white)}
.wa-qr-frame img{width:240px;height:240px;border-radius:4px}
.wa-qr-frame.is-ready img{animation:wa-qr-in 220ms var(--ease)}
@keyframes wa-qr-in{from{opacity:0}}
.wa-qr-wait{position:absolute;inset:12px;display:grid;place-items:center;border-radius:8px;background:var(--plum-100)}
.wa-qr-frame.is-ready .wa-qr-wait{display:none}
.wa-spin{width:22px;height:22px;border:2px solid var(--plum-400);border-right-color:transparent;border-radius:50%;animation:btn-busy .9s linear infinite}
.dialog-body p.wa-qr-note{margin:0 0 6px;text-align:center;font-size:13px;color:var(--muted)}
.dialog-body p.wa-path{display:flex;flex-wrap:wrap;justify-content:center;align-items:center;gap:2px 6px;margin:0;font-size:14px;font-weight:500;line-height:1.5;color:var(--ink);text-align:center}
.wa-path svg{flex:none;color:var(--plum-400)}
.dialog-body p.wa-state-line{display:flex;align-items:flex-start;gap:10px;margin:0 0 12px;font-size:15px;font-weight:500;line-height:1.45}
.wa-state-line>span{min-width:0}
.dialog-body p.wa-state-line.wa-ok{color:var(--success-600)}
.dialog-body p.wa-state-line.wa-wait{color:var(--warning-600)}
.dialog-body p.wa-state-line.wa-bad{color:var(--danger-600)}
.wa-state-line svg{flex:none;margin-top:1px}
.wa-state-line.wa-wait span,.wa-state-line.wa-ok span{color:var(--ink)}
.wa-state-line.wa-ok .num{margin-left:6px;font-weight:400;color:var(--muted);white-space:nowrap}
.dialog-body p.wa-ext{position:relative;display:flex;align-items:center;gap:10px;margin:0 0 10px 30px;font-size:13px}
.wa-ext a{display:inline-flex;align-items:center;gap:5px;color:var(--plum-700);font-weight:500;text-decoration:underline;text-underline-offset:3px;text-decoration-thickness:1px}
.wa-ext a:hover{color:var(--plum)}
.dialog-body p.wa-code{margin:4px 0 0 30px;font-size:13px;color:var(--muted)}
.wa-code strong{margin-left:8px;font-size:22px;font-weight:600;letter-spacing:.18em;color:var(--ink)}
/* «Войти по коду»: the quiet alternative under the QR path, styled like the dialog's other text links. */
.dialog-body p.wa-alt{margin:6px 0 0;text-align:center}
.wa-alt button{display:inline-flex;align-items:center;min-height:32px;padding:0 6px;border:0;border-radius:6px;background:none;color:var(--plum-700);font:500 13px/1.4 'Golos Text',sans-serif;text-decoration:underline;text-underline-offset:3px;text-decoration-thickness:1px;cursor:pointer}
.wa-alt button:hover{color:var(--plum)}
.wa-alt button:focus-visible{outline:2px solid var(--focus);outline-offset:2px}
.wa-pair-form .field{margin-bottom:0}
.wa-pair-form input{font-variant-numeric:tabular-nums}
/* The pairing code: one 8-character line in the QR's white frame, easy to read off and select whole. */
.dialog-body p.wa-pair-code{display:grid;place-items:center;width:min(264px,100%);margin:2px auto 14px;padding:22px 12px;border:1px solid var(--line);border-radius:16px;background:var(--white);font-size:30px;font-weight:600;line-height:1.2;letter-spacing:.14em;color:var(--plum-900);user-select:all}
.wa-pair-code:focus{outline:none}
.wa-pair-code:focus-visible{outline:2px solid var(--focus);outline-offset:2px}
.wa-flow [data-wa-import]{margin-left:30px}
.wa-flow [data-wa-import] .btn{margin-top:10px}
.wa-flow .wa-error{margin:0}
.wa-flow .inline-error{margin:10px 0 0}

@media(max-width:850px){
 .wa-entry{grid-template-columns:104px minmax(0,1fr)}
 .wa-entry-chat{grid-column:2}
}
@media(max-width:1024px){.wa-actions .btn{min-height:44px}.wa-more{width:44px;height:44px;min-width:44px}}
/* Touch: every control here reaches 44px. */
@media(pointer:coarse){.wa-menu button{min-height:44px}.wa-auto-close{width:44px;height:44px;min-width:44px}.wa-ext a,.wa-alt button{min-height:44px}}
/* Short windows (a phone sideways, a small laptop window): the QR shrinks to fit the dialog, and with room beside it the
   path and «Закрыть» move to its right. */
@media(max-height:560px){
 .wa-qr-frame{width:min(264px,calc(100dvh - 190px));height:min(264px,calc(100dvh - 190px))}
 .wa-qr-frame img{width:calc(100% - 24px);height:auto;aspect-ratio:1}
}
@media(max-height:560px) and (min-width:600px){
 .wa-phase:has(>.wa-qr-frame){display:grid;grid-template-columns:auto minmax(0,1fr);column-gap:22px;align-items:center}
 .wa-phase:has(>.wa-qr-frame)>*{grid-column:2}
 .wa-phase>.wa-qr-frame{grid-column:1;grid-row:1/span 5;margin:0}
 .dialog-body .wa-phase p.wa-alt{text-align:left}
 .dialog-body .wa-phase p.wa-path{justify-content:flex-start;text-align:left}
 .wa-phase:has(>.wa-qr-frame) .row{justify-content:flex-start}
}
@media(max-width:650px){
 .wa-section .wa-heading .btn{min-height:44px}
 .wa-head{grid-template-columns:minmax(0,1fr) 44px;align-items:start;gap:8px 12px}
 /* Stacked meta: no «·» can be left hanging at a line end. */
 .settings-section p.wa-meta{flex-direction:column;align-items:flex-start;gap:2px}
 .wa-meta .wa-sep{display:none}
 .wa-actions{display:contents}
 .wa-actions .btn{grid-column:1;grid-row:2;justify-self:start}
 .wa-more{grid-column:2;grid-row:1}
 .wa-auto{margin:0 -8px 14px;padding:16px 14px 18px}
 .wa-auto-grid{flex-direction:column;gap:14px}
 .wa-auto :is(.wa-time,input[type=number]){min-height:44px;font-size:16px}
 .wa-auto-actions .btn{width:100%;min-height:44px}
 .wa-switch{font-size:15px}
 .wa-entry{grid-template-columns:minmax(0,1fr);gap:0}
 .wa-entry-chat{grid-column:auto;flex-wrap:wrap}
 .wa-chat-link{max-width:100%}
 .wa-client-text{flex-basis:100%}
 .wa-qr-frame{width:244px;height:244px}
 .wa-qr-frame img{width:220px;height:220px}
 .dialog-body p.wa-ext,.dialog-body p.wa-code,.wa-flow [data-wa-import]{margin-left:0}
}
@media(prefers-reduced-motion:reduce){
 .wa-row.wa-fresh,.wa-menu:popover-open,.wa-auto,.wa-phase.wa-enter>*,.wa-qr-frame.is-ready img{animation:none}
 .wa-spin{animation:none}
 .wa-track,.wa-track::after,.wa-bar i{transition:none}
}
