/* Keep horizontal scrolling inside data tables, with room to read ranks. */
.service-ui .history-table td.history-frequency{position:static}
.service-ui .history-table th.history-frequency{left:auto;top:0;z-index:2}
.service-ui .heading h1{overflow-wrap:anywhere}
@media(max-width:1100px){
 .service-ui aside nav{flex-wrap:wrap}
 .service-ui button,.service-ui aside nav a{min-height:44px}
 .service-ui input:not([type=checkbox]):not([type=radio]),.service-ui select,.service-ui textarea{font-size:16px}
 .service-ui .context-controls .device-switch button{min-height:44px}
 .service-ui .project-sites button{flex-shrink:0;min-height:44px}
 .service-ui .pager{flex-wrap:wrap;gap:8px}
 .service-ui .pager button{min-height:44px}
 .service-ui dialog .dialog-actions{flex-wrap:wrap}
 .service-ui #toast{left:12px;right:12px;max-width:400px;margin-left:auto;bottom:12px}
}
@media(max-width:740px){
 .service-ui .context-controls .device-switch{grid-column:1/-1;justify-self:start;max-width:100%}
 .service-ui .context-controls>span{min-width:0;overflow-wrap:anywhere}
 .service-ui .history-table .history-query{width:144px;min-width:144px;max-width:144px;font-size:12px}
 .service-ui .history-table th.history-frequency,.service-ui .history-table td.history-frequency{width:112px;min-width:112px;max-width:112px}
 .service-ui .history-frequency button{min-height:44px}
 .service-ui .project-heading>.actions{width:100%}
 .service-ui .project-title-row{min-width:0}
 .service-ui dialog{padding:18px}
}
@media(max-width:420px){
 .service-ui aside nav{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));width:100%;gap:4px}
 .service-ui aside nav a{justify-content:center}
 .service-ui .padded{padding:16px}
}
.service-ui main{overflow-anchor:none}

/* The same navigation is available at both edges of every position history. */
.history-scroll-top{overflow-x:scroll;overflow-y:hidden;height:22px;overscroll-behavior-x:contain;background:var(--surface);scrollbar-color:var(--muted) var(--surface)}
.history-scroll-top svg{display:block;max-width:none;height:1px}
.service-ui .history-pager{gap:10px;flex-wrap:wrap}
.service-ui .history-pager>span{line-height:1.7;flex:1 1 300px}
.service-ui .history-pager .actions{width:auto;gap:6px}
.service-ui .history-pager button{min-width:44px;min-height:36px}
.service-ui .history-pager [aria-current=page]{background:var(--soft);color:var(--ink);opacity:1;cursor:default;font-weight:700}
@media(max-width:1100px){.service-ui .history-pager button{min-height:44px}}
@media print{#historyScrollControls,.history-pager{display:none!important}}

/* Query actions stay in the sticky query cell; touch users do not need hover. */
.service-ui .history-table td.history-query.keyword-manage{padding-left:42px;padding-right:42px;height:56px}
.keyword-check{position:absolute;left:2px;top:5px;width:36px;height:36px;display:flex;align-items:center;justify-content:center;margin:0}
.keyword-check input{width:18px;height:18px;margin:0}
.keyword-row-actions{position:absolute;right:4px;top:5px;display:flex;flex-direction:column;gap:2px;opacity:0;pointer-events:none}
.keyword-row-actions button{display:flex;align-items:center;justify-content:center;min-width:24px!important;min-height:24px!important;width:24px;height:24px;padding:2px;border:0;background:transparent}
.service-ui .keyword-remove{color:var(--bad,#c94343)}
.service-ui .keyword-recheck{color:var(--good,#238b58)}
.keyword-manage:hover .keyword-row-actions,.keyword-manage:focus-within .keyword-row-actions{opacity:1;pointer-events:auto}
.keyword-selection{gap:8px;flex-wrap:wrap}
.keyword-confirm-list{max-height:220px;overflow:auto;padding-left:24px;overflow-wrap:anywhere}
@media(hover:none),(pointer:coarse),(max-width:700px){.keyword-row-actions{opacity:1;pointer-events:auto;flex-direction:row;right:2px;top:auto;bottom:2px}.keyword-row-actions button{min-width:44px!important;min-height:44px!important;width:44px;height:44px}.service-ui .history-table td.history-query.keyword-manage{padding:8px 8px 52px 42px;min-width:144px;max-width:144px;width:144px;height:96px}.keyword-check{width:40px;height:44px}.keyword-selection button{min-height:44px}}
@media print{.keyword-row-actions,.keyword-check,.keyword-selection{display:none!important}.service-ui .history-table td.history-query.keyword-manage{padding-left:12px;padding-right:12px}}
/* A compact persistent action shares the date's vertical centre. */
.history-date-heading{display:flex;align-items:center;justify-content:center;gap:3px;min-width:0}
.service-ui .history-date-heading .history-date-sort{min-width:0;min-height:20px;font-size:10px;white-space:nowrap;line-height:1.25}
.service-ui .history-delete-run{display:inline-flex;flex:0 0 18px;align-items:center;justify-content:center;width:18px;min-width:18px;height:20px;min-height:20px;padding:0;margin:0;border:0;background:transparent;box-shadow:none;opacity:1;pointer-events:auto;vertical-align:middle}
.service-ui .history-delete-run svg{display:block;flex:0 0 14px;width:14px;height:14px;fill:none;stroke:currentColor;stroke-width:1.8;stroke-linecap:round;stroke-linejoin:round}
.service-ui .history-delete-run:hover{background:transparent;color:var(--bad);opacity:.8}
@media(hover:none),(pointer:coarse),(max-width:700px){.service-ui .history-delete-run{flex-basis:44px;width:44px;min-width:44px;height:44px;min-height:44px}.history-date-heading{gap:0}.service-ui .history-date-heading .history-date-sort{white-space:normal}}
@media print{.service-ui .history-delete-run{display:none}}

/* Saved collection devices are separate from the result-view switch. */
.service-ui .collection-devices{display:flex;align-items:center;gap:6px;flex-wrap:wrap;margin:2px 0;font-size:9px;line-height:1.3;color:var(--muted)}
.service-ui .collection-devices label{display:inline-flex;flex-direction:row;align-items:center;gap:3px;min-height:18px;margin:0;cursor:pointer;white-space:nowrap;font-size:inherit}
.service-ui .collection-devices input{flex:0 0 11px;width:11px;min-width:11px;max-width:11px;height:11px;min-height:11px;max-height:11px;margin:0;padding:0;accent-color:var(--accent)}
.service-ui .collection-devices[aria-busy=true]{opacity:.6}
@media(max-width:1100px),(pointer:coarse){.service-ui .collection-devices label{min-height:44px}.service-ui .collection-devices{font-size:12px}}

.service-ui .service-projects-table .project-context-label{max-width:none}
.service-ui .service-projects-table td:nth-child(2){min-width:240px}

.service-ui .keyword-selection[hidden]{display:none!important}

.service-ui .history-tools-row{display:flex;align-items:flex-start;gap:8px;margin:8px 0}
.service-ui .history-tools{flex:1;min-width:0}
.service-ui .history-tools>summary{display:list-item;cursor:pointer;width:fit-content;padding:8px 10px;border:1px solid var(--line);border-radius:8px;background:var(--surface);font-size:.85rem;font-weight:600}
.service-ui .history-tools[open]{border:1px solid var(--line);border-radius:8px;background:var(--surface)}
.service-ui .history-tools[open]>summary{border:0}
.service-ui .history-tools .toolbar{flex-wrap:wrap;gap:8px}
.service-ui .history-tools .run-state{padding:0 12px}
.service-ui .history-scroll-top{height:15px}
.service-ui #historyFocusControl .focus-toggle{white-space:nowrap;margin:0}
.service-ui #frequencyStatus:empty{display:none}
@media print{.history-tools-row{display:none!important}}

/* Keep the finance table readable and leave enough room for admin navigation. */
.service-ui #adminAnalytics table[aria-label="Расходы по аккаунтам"]{width:100%;min-width:0}
.service-ui #adminAnalytics table[aria-label="Расходы по аккаунтам"] th[scope=row]{white-space:normal;overflow-wrap:anywhere}
.service-ui #adminAnalytics table[aria-label="Расходы по аккаунтам"] td{white-space:nowrap}
@media(min-width:1000px) and (max-width:1440px){
 .service-ui #app:has(#adminAnalytics)>aside{flex-wrap:wrap;height:auto;min-height:54px}
}

.admin-wallet-note{margin:.7rem 1rem 1rem;color:var(--muted);line-height:1.5}
.admin-users-table .admin-wallet-figures{display:grid;grid-template-columns:max-content max-content;gap:.25rem .8rem;align-items:baseline;margin:0}
.admin-wallet-figures dt{color:var(--muted);font-weight:400}
.admin-wallet-figures dd{margin:0;text-align:end;white-space:nowrap;font-variant-numeric:tabular-nums}
.admin-users-table th[scope=row]{text-align:start;font-weight:600}

.service-ui .history-table .history-row-gap td{padding:0;border:0}
.service-ui .history-table .history-row-gap svg{display:block}

.service-ui .history-matrix:has(.history-row-gap){overflow-anchor:none}

/* Clip rounded corners without making the card the toolbar's scroll container. */
.service-ui .card:has(> .project-toolbar){overflow:clip}
.service-ui .card > .project-toolbar{position:sticky;top:0;z-index:13;background:var(--surface,white)}

.admin-summary-grid{display:grid;gap:16px;grid-template-columns:repeat(auto-fit,minmax(min(100%,270px),1fr))}
.admin-summary{display:flex;flex-direction:column;gap:12px}
.admin-summary h2,.admin-summary p{margin:0}
.admin-summary [data-summary]{display:grid;gap:6px}
.admin-summary a{align-self:flex-start;margin-top:auto;padding-block:6px}

/* Long account names must not push the desktop navigation outside the page. */
@media(min-width:1101px){
 .service-ui #app>aside{height:auto;min-height:54px;flex-wrap:wrap;row-gap:8px}
 .service-ui aside nav{max-width:100%;flex-wrap:wrap}
 .service-ui .aside-bottom{min-width:0}
}
