/* Overlays (FW-UI-183, M06 of docs/design/apple-system/MIGRATION-PLAN.md):
   menus, popovers, sheets and alerts as the accepted Apple mockup draws them
   (docs/design/reference/ref.css «Popover, menu, sheet»; the design system's
   Menu, Popover and Sheet), with the photo dialog, notifications and the toast.
   Loaded after controls.css (the order is in base.css); the files after it
   only place a menu or size a sheet. */
/* Photo dialog: the 72px avatar over Upload and Remove, centred. */
.photo-dialog-body{display:grid;justify-items:center;gap:12px;text-align:center}
.photo-dialog-actions{display:flex;flex-wrap:wrap;justify-content:center;gap:8px}
.header-count{position:absolute;right:-3px;top:0;box-shadow:0 0 0 2px var(--window)}

/* ---------- Menu (P57, P66) ----------
   The menu material with its shadow, 10px corners, 5px padding; items 24px
   high with 5px corners, filled with the accent under the pointer; a small
   heading, a separator line, a note in label-2. A long item stops at «…» on
   the Mac and wraps on iPhone. It opens at its button (shell.js placeMenu):
   flipped above where there is no room below, slid inward at the window's
   edge, and a menu taller than the window scrolls with macOS's arrows. */
.menu-popover{position:absolute;top:calc(100% + 6px);left:0;z-index:40;min-width:220px;width:max-content;max-width:min(360px,calc(100vw - 24px));padding:5px;border:0;border-radius:var(--r-lg);background:var(--menu);-webkit-backdrop-filter:blur(30px) saturate(180%);backdrop-filter:blur(30px) saturate(180%);box-shadow:var(--popover-shadow);color:var(--label);font:var(--type-mac-body);text-align:left;overflow-x:hidden}
/* A menu's items: its links and buttons, but not a form's own buttons, an icon, a checked item, a notification or the popover's footer. */
.menu-popover :is(a,button):not(.primary-button,.quiet-button,.danger-button,.icon-button,.menu-item,.popover-footer,.notification-item button,.date-calendar,.field-clear,.field-action){display:block;width:100%;min-height:var(--ctl-mac);margin:0;padding:3px 10px;border:0;border-radius:var(--r-xs);background:none;box-shadow:none;font:inherit;color:var(--label);text-align:left;text-decoration:none;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;cursor:default}
.menu-popover :is(a,button):not(.primary-button,.quiet-button,.danger-button,.icon-button,.menu-item,.popover-footer,.notification-item button,.date-calendar,.field-clear,.field-action):hover:not(:disabled,[aria-disabled="true"]),.menu-popover :is(a,button):not(.primary-button,.quiet-button,.danger-button,.icon-button,.menu-item,.popover-footer,.notification-item button,.date-calendar,.field-clear,.field-action):focus-visible{background:var(--accent);color:var(--on-accent);text-decoration:none;outline:none}
.menu-popover :is(a,button):not(.primary-button,.quiet-button,.danger-button,.icon-button,.menu-item,.popover-footer,.notification-item button,.date-calendar,.field-clear,.field-action):is(:disabled,[aria-disabled="true"]){color:var(--label-3);background:none;cursor:default}
.menu-popover :is(a,button):not(.primary-button,.quiet-button,.danger-button,.icon-button,.menu-item,.popover-footer,.notification-item button,.date-calendar,.field-clear,.field-action) small{display:block;color:var(--label-2);font:var(--type-mac-caption);white-space:normal}
.menu-popover :is(a,button):not(.primary-button,.quiet-button,.danger-button,.icon-button,.menu-item,.popover-footer,.notification-item button,.date-calendar,.field-clear,.field-action):hover:not(:disabled) small,.menu-popover :is(a,button):not(.primary-button,.quiet-button,.danger-button,.icon-button,.menu-item,.popover-footer,.notification-item button,.date-calendar,.field-clear,.field-action):focus-visible small{color:var(--on-accent)}
.menu-popover h2,.menu-popover .eyebrow{margin:0;padding:6px 10px 2px;font:var(--type-mac-caption);font-weight:600;letter-spacing:0;text-transform:none;color:var(--label-2)}
.menu-popover strong{display:block;padding:3px 10px;font:var(--type-mac-emphasis)}
.menu-popover>.muted{margin:0;padding:3px 10px;color:var(--label-2)}
.menu-popover hr{height:0;margin:5px 8px;border:0;border-top:var(--hairline-w) solid var(--separator)}
.profile .menu-popover{left:auto;right:0}
.profile form{margin:5px 0 0;padding-top:5px;border-top:var(--hairline-w) solid var(--separator)}
.bar-end .menu-popover{right:0;left:auto;max-height:70vh;overflow:auto}
/* Checked menu item: a 12px check column; the current item shows the check. */
.menu-popover .menu-item{box-shadow:none;display:grid;grid-template-columns:12px minmax(0,1fr);column-gap:8px;align-items:center;width:100%;min-height:var(--ctl-mac);margin:0;padding:3px 10px 3px 8px;border:0;border-radius:var(--r-xs);background:none;font:inherit;text-align:left;color:var(--label);cursor:default}
.menu-item .check{visibility:hidden;font-weight:600}
/* A menu item's symbol, the mockup's (.mi .mk): 16 px in the item's first column. */
.menu-popover .menu-item>.mk{display:grid;place-items:center;width:12px;color:var(--label)}
.menu-popover .menu-item>.mk svg{width:16px;height:16px;flex:none;fill:none;stroke:currentColor;stroke-width:1.6;stroke-linecap:round;stroke-linejoin:round}
.menu-popover .menu-item:is(:hover,:focus-visible):not(:disabled,[aria-disabled="true"])>.mk{color:inherit}
.menu-popover .menu-item:is(:disabled,[aria-disabled="true"])>.mk{color:var(--label-3)}
.menu-item[aria-checked="true"] .check{visibility:visible}
.menu-item small{grid-column:2;color:var(--label-2);font:var(--type-mac-caption)}
.menu-popover .menu-item:is(:hover,:focus-visible):not(:disabled,[aria-disabled="true"]){background:var(--accent);color:var(--on-accent);outline:none}
.menu-popover .menu-item:is(:disabled,[aria-disabled="true"]){color:var(--label-3)}
.menu-popover a.menu-item{text-decoration:none}
/* A destructive item (Delete, Cancel Operation): its label and symbol in red, as Apple's destructive menu item; the highlight and a locked item stay as every item's. */
.menu-popover :is(.text-button,.menu-item)[data-destructive]:not(:disabled,[aria-disabled="true"],:hover,:focus-visible),.menu-popover .menu-item[data-destructive]:not(:disabled,[aria-disabled="true"],:hover,:focus-visible)>.mk{color:var(--red-text)}
.menu-item:hover small,.menu-item:focus-visible small{color:var(--on-accent)}
/* A value with its count at the trailing edge (a header's Filter, FW-UI-184),
   and a search field over a long list of values. */
.menu-popover .menu-item:has(>.menu-count){grid-template-columns:12px minmax(0,1fr) auto}
.menu-count{padding-left:16px;color:var(--label-2);font-variant-numeric:tabular-nums}
.menu-item:hover .menu-count,.menu-item:focus-visible .menu-count{color:var(--on-accent)}
.menu-popover .menu-search{display:block;width:calc(100% - 16px);margin:2px 8px 6px}
/* A header's Filter (FW-UI-184) is the mockup's popover of a column's values: a value a 36 px row with its count, Show All the last row. */
/* The mockup's facet popover (.pop-list): 360 px, 6 px in, the counts in the third label colour. */
.menu-popover.head-filter{width:360px;max-width:calc(100vw - 24px);padding:6px;border-radius:var(--r-xl)}
.menu-popover.head-filter .menu-title{font:var(--type-mac-callout);font-weight:600}
.menu-popover.head-filter :is(.menu-item,.text-button){min-height:36px}
.menu-popover.head-filter .menu-count{font:var(--type-mac-callout)}
.menu-popover.head-filter .menu-item:not(:hover,:focus-visible) .menu-count{color:var(--label-3)}
.menu-popover.head-filter .filter-values{margin:0 0 4px;border-radius:var(--r-xl);background:var(--group);overflow:hidden;box-shadow:0 0 0 var(--hairline-w) var(--separator)}
.menu-popover.head-filter .filter-values>:is(.menu-item,.text-button){border-radius:0}
/* A menu taller than the window scrolls inside itself, with macOS's arrows at
   its top and bottom while there is more that way (shell.js menuArrows). */
/* Inside a glass part the blur cannot reach the page: the window's ground (shell.js menuGround). */
.menu-popover[data-solid]{background:var(--window);-webkit-backdrop-filter:none;backdrop-filter:none}
.menu-popover[data-scrolls]{overflow-y:auto;overscroll-behavior:contain;padding-top:0;padding-bottom:0}
.menu-arrow{position:sticky;z-index:1;display:grid;place-items:center;height:18px;background:var(--menu);color:var(--label-2)}
.menu-arrow.up{top:0}
.menu-arrow.down{bottom:0}
.menu-arrow svg{width:10px;height:10px;fill:none;stroke:currentColor;stroke-width:2;stroke-linecap:round;stroke-linejoin:round}
.menu-arrow.up svg{transform:rotate(180deg)}
/* A disabled menu item with a reason (PO 2026-10-30, a trial: «давай
   попробуем, посмотрим»): the lock at the item's trailing edge, as muted as
   the item; a click opens the reason in the (i)'s card. */
.menu-item-locked{display:flex;align-items:center}
.menu-item-locked>:is(.text-button,.menu-item){flex:1;min-width:0}
.menu-item-locked>.field-lock{margin-right:4px;opacity:.45}

/* ---------- Notifications ---------- */
.notification-item{margin:0}
.notification-item button{display:flex;gap:10px;align-items:flex-start;width:100%;text-align:left;background:none;border:0;border-radius:var(--r-xs);padding:6px 10px;margin:0;color:var(--label);font:inherit;cursor:default}
.notification-item button:hover,.notification-item button:focus-visible{background:var(--fill-2)}
.notification-dot{flex:none;width:8px;height:8px;margin-top:6px;border-radius:50%;background:transparent}
.notification-item.unread .notification-dot{background:var(--accent)}
.notification-text{display:grid;gap:1px;min-width:0}
.notification-text strong{padding:0;font-weight:500;overflow-wrap:anywhere}
.notification-item.unread .notification-text strong{font-weight:600}
.notification-text small{color:var(--label-2);font:var(--type-mac-caption)}
.popover-footer{display:block;border-top:var(--hairline-w) solid var(--separator);margin-top:4px;padding:6px 10px 4px}
.menu-popover a.popover-footer{border-radius:0 0 var(--r-xs) var(--r-xs);color:var(--accent-text)}
.menu-popover a.popover-footer:hover,.menu-popover a.popover-footer:focus-visible{color:var(--on-accent)}
.notification-rows{display:grid}
.notification-row{display:grid;grid-template-columns:auto minmax(0,1fr);gap:0 8px;align-items:start;padding:8px 6px}
.notification-row+.notification-row{border-top:var(--hairline-w) solid var(--field-line)}
.notification-row>input{margin:9px 0 0 4px}
.notification-row .notification-body{grid-column:2;margin:0 0 2px 28px;color:var(--label-2)}
.notification-actions{display:flex;flex-wrap:wrap;justify-content:flex-end;align-items:center;gap:8px;margin-top:12px}
.notification-confirm{flex:1 1 100%;margin:0;font:var(--type-mac-callout);color:var(--red-text)}

/* ---------- Sheets (P16, P26) ----------
   A dialog is a sheet attached to the window under its toolbar: the sheet
   ground, 18px corners, the sheet shadow over the scrim. Its head is the
   title (15px semibold) and a line in label-2; its body scrolls; its foot
   holds Cancel and the default button at the bottom right, the default last.
   No close cross: Cancel and Esc close it. */
.notification-dialog,.table-dialog,.confirm-dialog{width:calc(100vw - 32px);max-width:640px;max-height:calc(100vh - var(--toolbar-h) - 48px);margin:calc(var(--toolbar-h) + var(--gap-window)) auto auto;padding:0;border:0;border-radius:18px;background:var(--sheet);color:var(--label);box-shadow:var(--sheet-shadow);font:var(--type-mac-body);overflow:hidden}
.notification-dialog::backdrop,.table-dialog::backdrop,.confirm-dialog::backdrop{background:var(--scrim)}
:is(.personal-settings,.notification-dialog,.table-dialog,.confirm-dialog)[open]{display:flex;flex-direction:column}
:is(.personal-settings,.notification-dialog,.table-dialog,.confirm-dialog)[open]>form{display:flex;flex-direction:column;flex:1 1 auto;min-height:0}
/* The sheet itself is no control: no focus ring around it (PO 2026-10-30 «Окно не нужно обводить»). */
dialog:focus-visible{outline:none}
.notification-dialog{max-width:540px}
dialog>.settings-titlebar,dialog>form>.settings-titlebar{flex:none;display:block;min-height:0;padding:16px 20px 8px;border:0;background:none;text-align:left}
dialog>.settings-titlebar h2,dialog>form>.settings-titlebar h2{margin:0;font:var(--type-mac-title)}
dialog>.settings-titlebar small,dialog>form>.settings-titlebar small{display:block;margin-top:2px;font:var(--type-mac-callout);color:var(--label-2)}
.notification-dialog-body{flex:1 1 auto;min-height:0;max-height:min(60vh,520px);overflow:auto;padding:4px 20px 16px}
.table-dialog-body{flex:1 1 auto;min-height:0;overflow:auto;padding:4px 20px 16px}
.table-dialog-body ul{margin:0;padding-left:18px}
.table-dialog-body li+li{margin-top:4px}
dialog>.settings-footer,dialog>form>.settings-footer{flex:none;display:flex;justify-content:flex-end;align-items:center;flex-wrap:wrap;gap:8px;padding:12px 20px 16px;border:0;background:none}
/* A destructive action standing first in a sheet's foot keeps to the left of the same bar (P26). */
dialog:not(:has(.alert-head))>.settings-footer>.danger-button:first-child,dialog:not(:has(.alert-head))>form>.settings-footer>.danger-button:first-child{margin-right:auto}
.table-error{color:var(--red-text);margin:10px 0 0}
.table-usage{margin:10px 0 0}
.table-usage p{margin:0 0 4px}
.table-usage ul{margin:0 0 8px;padding-left:18px}
.table-usage-hint{color:var(--label-2);font:var(--type-mac-callout)}
.table-frame{max-width:980px;height:min(86vh,860px)}
/* Settings forms (roles) hold wide permission matrices: give them room. */
.table-frame.own-footer{max-width:1280px;height:min(90vh,920px)}
.table-frame iframe{flex:1;width:100%;border:0;background:var(--page)}

/* ---------- Alerts (P16, P26; FW-UI-164) ----------
   A question before an action (Discard the changes?, Delete, Leave, a session
   about to end) is Apple's alert: the warning symbol on its grey tile, the
   title and its text under it, all centred alike; the buttons centred under
   them, the destructive one red. Its head is the alert-head of window.html. */
dialog:has(>.alert-head,>form>.alert-head){width:calc(100vw - 32px);max-width:300px}
.alert-head{flex:none;padding:20px 20px 2px;text-align:center}
.alert-head::before{content:"";display:block;width:44px;height:44px;margin:0 auto 10px;border-radius:11px;background:var(--tile-gray) url("/assets/alert-warn.a05fa245e67a.svg") center/26px no-repeat}
.alert-head h2{margin:0;font:var(--type-mac-title);overflow-wrap:anywhere}
.alert-head small{display:block;margin-top:2px;font:var(--type-mac-callout);color:var(--label-2)}
dialog:has(>.alert-head,>form>.alert-head) .table-dialog-body{padding:0 20px 8px;text-align:center;font:var(--type-mac-callout);color:var(--label-2);overflow-wrap:anywhere}
dialog:has(>.alert-head,>form>.alert-head) .table-dialog-body p{margin:0}
dialog:has(>.alert-head,>form>.alert-head) .table-dialog-body p+p{margin-top:6px}
dialog:has(>.alert-head,>form>.alert-head) .table-dialog-body :is(ul,ol){text-align:left}
dialog:has(>.alert-head)>.settings-footer,dialog>form:has(>.alert-head)>.settings-footer{justify-content:center;padding:12px 20px 16px}

/* ---------- Popover (P25, P73, P75) ----------
   Details behind a button - a field's help, the audit stamps, a reason - in
   the menu material, 12px corners, pointing at its button (shell.js
   placeFieldCard): on its own side when it fits, else on the side with more
   room, within the window; taller than the room, it scrolls inside. */
.audit-card,.field-why-card{position:fixed;inset:auto;margin:0;min-width:220px;width:max-content;max-width:min(340px,calc(100vw - 24px));padding:12px 14px;border:0;border-radius:var(--r-group);background:var(--menu);-webkit-backdrop-filter:blur(30px) saturate(180%);backdrop-filter:blur(30px) saturate(180%);color:var(--label);box-shadow:var(--popover-shadow);font:var(--type-mac-body);text-align:left;overflow-y:auto;overscroll-behavior:contain}
.audit-card[data-placing],.field-why-card[data-placing]{visibility:hidden}
.audit-card dl{margin:0;display:grid;gap:10px}
.audit-card dt{color:var(--label-2);font:var(--type-mac-caption);font-weight:600}
.audit-card dd{margin:2px 0 0}
.audit-card dd small{display:block;color:var(--label-2);font:var(--type-mac-caption);font-variant-numeric:tabular-nums}

/* A notice carried to a page after a save (web.Notice): the information of Business Rules. */
/* Toast: a dark note at the bottom centre. */
.tp-notice{position:fixed;left:50%;bottom:18px;transform:translateX(-50%);z-index:3000;max-width:min(560px,calc(100vw - 32px));padding:8px 14px;border-radius:var(--r-group);background:var(--label);color:var(--window);box-shadow:var(--popover-shadow);font:var(--type-mac-body);cursor:pointer}
.tp-notice p{margin:0}.tp-notice p+p{margin-top:4px}

/* ---------- iPhone (700px and less) ----------
   Menus and popovers stand 12px from the screen's edges with larger corners
   and iOS text, menu items 44px high and wrapping. A sheet rises from the
   bottom, full width, with Cancel at the top left and Done at the top right;
   an alert stays in the middle with its buttons under its text. */
@media(max-width:700px){
 .menu-popover{min-width:0;max-width:none;border-radius:var(--r-sidebar);font:var(--type-ios-body)}
 .menu-popover :is(a,button):not(.primary-button,.quiet-button,.danger-button,.icon-button,.menu-item,.popover-footer,.notification-item button,.date-calendar,.field-clear,.field-action),.menu-popover .menu-item{min-height:44px;padding-top:10px;padding-bottom:10px;white-space:normal;overflow:visible;overflow-wrap:anywhere}
 .menu-popover :is(a,button):not(.primary-button,.quiet-button,.danger-button,.icon-button,.menu-item,.popover-footer,.notification-item button,.date-calendar,.field-clear,.field-action) small,.menu-item small{font:var(--type-ios-footnote)}
 .menu-popover h2,.menu-popover .eyebrow{font:var(--type-ios-footnote);font-weight:600}
 .audit-card,.field-why-card{min-width:0;width:calc(100vw - 24px);max-width:none;border-radius:18px;font:var(--type-ios-subhead)}
 .notification-dialog,.table-dialog,.confirm-dialog{width:100%;max-width:none;max-height:94vh;margin:auto 0 0;border-radius:26px 26px 0 0}
 dialog>.settings-titlebar,dialog>form>.settings-titlebar{padding:14px 16px 6px;text-align:center}
 dialog>.settings-titlebar h2,dialog>form>.settings-titlebar h2{font:var(--type-ios-headline)}
 .table-dialog-body,.notification-dialog-body{padding:4px 16px 16px}
 dialog:not(:has(.alert-head))>.settings-footer,dialog:not(:has(.alert-head))>form>.settings-footer{order:-1;position:sticky;top:0;z-index:2;padding:10px 16px;border-bottom:var(--hairline-w) solid var(--separator);background:inherit}
 dialog>.settings-footer,dialog>form>.settings-footer{align-items:stretch}
 dialog>.settings-footer>:is(button,.button),dialog>form>.settings-footer>:is(button,.button){flex:1 1 0;min-width:0;min-height:50px;padding:0 16px;border-radius:25px;font:var(--type-ios-body)}
 dialog>.settings-footer>.settings-count,dialog>form>.settings-footer>.settings-count{flex:1 1 100%}
 /* An alert on iPhone sits at the bottom edge, as the mockup draws it (the
    mockup's alertSheet at 390 px takes the sheet's phone rule: only the top
    corners round, it rises from the bottom; PO 2026-11-17, Rc8b963: the
    mockup comes first). It keeps the alert's width and its buttons under
    the text. */
 dialog:has(>.alert-head,>form>.alert-head){width:calc(100vw - 32px);max-width:300px;max-height:94vh;margin:auto auto 0;border-radius:26px 26px 0 0}
 .alert-head{padding:20px 16px 2px}
 dialog:has(>.alert-head,>form>.alert-head) .table-dialog-body{padding:0 16px 6px}
 dialog:has(>.alert-head)>.settings-footer,dialog>form:has(>.alert-head)>.settings-footer{padding:10px 16px calc(16px + env(safe-area-inset-bottom))}
 .alert-head h2{font:var(--type-ios-headline)}
}

/* ---------- Motion ----------
   A sheet drops from the toolbar (rises from the bottom on iPhone), a menu
   and a popover fade in; nothing moves when the reader asks for less motion. */
@media(prefers-reduced-motion:no-preference){
 dialog[open]{animation:sheet-drop .22s cubic-bezier(.2,.9,.3,1)}
 dialog[open]::backdrop{animation:scrim-in .15s}
 .menu-popover{animation:pop-in .1s ease-out}
}
@media(prefers-reduced-motion:no-preference) and (max-width:700px){
 dialog[open]{animation:sheet-rise .25s cubic-bezier(.2,.9,.3,1)}
}
@keyframes sheet-drop{from{opacity:0;transform:translateY(-16px)}}
@keyframes sheet-rise{from{opacity:0;transform:translateY(40px)}}
@keyframes scrim-in{from{opacity:0}}
@keyframes pop-in{from{opacity:0;transform:translateY(-3px)}to{opacity:1;transform:none}}
