/* Phone layout for the manage pages (2026-10-06). See app.css for the meeting room's own phone rules. */

/* The Manage section, Client Setup, Users, Projects, Layouts and the section
   nav that Manage and Settings share. Everything sits behind the 600px query,
   so desktop reads only app.css. Pages without a class of their own are named
   by what they contain (:has), so a rule cannot leak onto a page another
   phone stylesheet owns. "The Manage shell" below is
   .manage-shell:has(a[href="/manage/overview"]) — the one with Manage's links. */
@media (max-width: 600px) {

    /* --- Section shell (ManageLayout) ------------------------------------
       The shell turns into a column below 960px but kept align-items:
       flex-start from its desktop row, so the body shrank-to-fit its widest
       content instead of the screen — every page under it ran off the right
       edge of a scroll box that hid the overflow (the Users email column,
       the Secrets values, the Agents chips). Stretch gives the body the
       phone's width; pages then wrap inside it. (Settings has the same fix
       in mobile-client.css.) */
    .manage-shell:has(a[href="/manage/overview"]) { align-items: stretch; min-height: 0; }
    .manage-shell:has(a[href="/manage/overview"]) > .manage-body { width: 100%; min-width: 0; }

    /* --- Section nav (Manage and Settings) -------------------------------
       MudBlazor gives each nav item width:100%, so the sideways strip held
       one full-width link per screen and the rest were out of sight. Compact
       pills that wrap instead: the whole section on view, the current page
       marked. Icons go — the words are the nav at this size. */
    /* One row you swipe sideways, rather than five rows of pills pushing every
       page down a screen. */
    .manage-nav { padding: 8px 10px; overflow-x: auto; overflow-y: hidden; scrollbar-width: none; }
    .manage-nav::-webkit-scrollbar { display: none; }
    .manage-nav .mud-navmenu { flex-wrap: nowrap; gap: 6px; }
    .manage-nav .mud-nav-item { width: auto; }
    .manage-nav .mud-navmenu .mud-nav-item .mud-nav-link {
        width: auto;
        min-height: 36px;   /* a comfortable thumb, not a 28px sliver */
        padding: 6px 12px;
        border: 1px solid var(--card-border);
        border-radius: 999px;
    }
    .manage-nav .mud-nav-link .mud-nav-link-icon { display: none; }
    .manage-nav .mud-nav-link .mud-nav-link-text {
        margin-left: 0;
        margin-inline-start: 0;
        font-size: 0.8rem;
        white-space: nowrap;
    }
    .manage-nav .mud-nav-link.active { border-color: currentColor; }

    /* --- Page furniture inside the Manage shell --------------------------
       32px a side is a sixth of a phone; 16px matches the rest of the app's
       phone gutters. Comparisons and Usage have no page shell of their own
       (title straight in the body), so the body pads them. */
    .manage-shell:has(a[href="/manage/overview"]) .page-shell { padding: 16px 16px 48px; }
    .manage-shell:has(a[href="/manage/overview"]) .page-shell .page-title { font-size: 1.8rem; line-height: 1.2; overflow-wrap: anywhere; }
    .manage-shell:has(a[href="/manage/overview"]) .page-subtitle { margin-bottom: 18px; }
    .manage-body:has(> .cmp-layout),
    .manage-body:has(> .mud-table) { padding: 12px 12px 48px; }
    .manage-body > .mud-container { padding-left: 12px; padding-right: 12px; }

    /* A row of title + buttons (Users, Secrets, Agents, Diagnostics…): let
       the buttons drop under the title instead of squeezing it, and keep
       each button's label on one line. */
    .manage-body .d-flex.flex-row:has(> .mud-typography-h4),
    .manage-body .d-flex.flex-row.page-title,
    .manage-body .page-shell > .d-flex.flex-row:has(> .mud-button-root),
    .mud-container:has(.client-setup-save) > .d-flex.flex-row:first-child,
    .mud-container:has(.client-setup-save) > .d-flex.flex-row:first-child > .d-flex.flex-row {
        flex-wrap: wrap;
        row-gap: 8px;
    }
    .manage-body .d-flex.flex-row:has(> .mud-typography-h4) .mud-button-root,
    .manage-body .page-shell > .d-flex.flex-row .mud-button-root,
    .mud-container:has(.client-setup-save) > .d-flex.flex-row:first-child .mud-button-root { white-space: nowrap; }

    /* Stat tiles: two to a row, the same width, instead of a ragged column
       of whatever width each label happened to need. */
    .manage-body .d-flex.flex-row:has(> .stat-tile) {
        display: grid !important; /* .d-flex is display:flex !important */
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 10px;
    }
    .manage-body .stat-tile { min-width: 0; padding: 14px 14px; }
    .manage-body .stat-tile .stat-value { font-size: 1.6rem; }
    .manage-body .stat-tile .stat-label,
    .manage-body .stat-tile .stat-hint { overflow-wrap: anywhere; }

    /* Console-style insight pages (Cost, Agent activity, Tools insights). */
    .manage-body .ins-shell { padding: 12px 0 24px; }
    .manage-body .ins-tiles,
    .tools-body .ins-tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    /* Tools insights: the meeting filter and picker take the row's width,
       so "Filter meetings…" is not cut to "Filter meetings." */
    .ins-filter .ins-meeting-filter,
    .ins-filter .ins-meeting-select { max-width: none; flex: 1 1 100%; }
    /* 62 bars at 4px + 3px gaps is 430px; on a phone they thin to fit. */
    .ins-bars { gap: 1px; }
    .ins-bars .ins-bar { min-width: 1px; }

    /* --- Stacked tables (MudTable below 600px) ---------------------------
       MudTable stacks each row into label/value lines on a phone, but the
       table kept its intrinsic width — one long email or label made it wider
       than the screen and the values slid out of sight. Fix the table to the
       box, let the value wrap anywhere, and keep the label to its own width.
       Scoped to the Manage shell and Client Setup. */
    .manage-body :is(.mud-xs-table, .mud-sm-table, .mud-md-table) .mud-table-root,
    .mud-container:has(.client-setup-save) :is(.mud-xs-table, .mud-sm-table, .mud-md-table) .mud-table-root { table-layout: fixed; width: 100%; }
    .manage-body :is(.mud-xs-table, .mud-sm-table, .mud-md-table) .mud-table-row,
    .mud-container:has(.client-setup-save) :is(.mud-xs-table, .mud-sm-table, .mud-md-table) .mud-table-row { display: block; }
    /* The cell becomes a block with its label floated left: a value made
       of two parts (Secrets' depositor name over email) stacks right-aligned
       beside the label instead of the two squeezing into narrow columns. */
    .manage-body :is(.mud-xs-table, .mud-sm-table, .mud-md-table) .mud-table-body .mud-table-cell,
    .mud-container:has(.client-setup-save) :is(.mud-xs-table, .mud-sm-table, .mud-md-table) .mud-table-body .mud-table-cell {
        display: block;
        min-width: 0;
        overflow-wrap: anywhere;
        text-align: end !important;
    }
    .manage-body :is(.mud-xs-table, .mud-sm-table, .mud-md-table) .mud-table-body .mud-table-cell::before,
    .mud-container:has(.client-setup-save) :is(.mud-xs-table, .mud-sm-table, .mud-md-table) .mud-table-body .mud-table-cell::before {
        float: left;
        text-align: start;
        padding-right: 12px;
        padding-inline-end: 12px;
    }
    .manage-body :is(.mud-xs-table, .mud-sm-table, .mud-md-table) .mud-table-body .mud-table-cell::after,
    .mud-container:has(.client-setup-save) :is(.mud-xs-table, .mud-sm-table, .mud-md-table) .mud-table-body .mud-table-cell::after {
        content: "";
        display: table;
        clear: both;
    }
    /* A row's last line ends the row — make the break between records
       louder than the break between a record's own lines. */
    .manage-body :is(.mud-xs-table, .mud-sm-table, .mud-md-table) .mud-table-body .mud-table-row + .mud-table-row,
    .mud-container:has(.client-setup-save) :is(.mud-xs-table, .mud-sm-table, .mud-md-table) .mud-table-body .mud-table-row + .mud-table-row {
        border-top: 1px solid var(--card-border);
        padding-top: 4px;
    }
    /* Action cells hold a row of buttons; they wrap rather than run off. */
    .manage-body :is(.mud-xs-table, .mud-sm-table, .mud-md-table) .mud-table-cell .d-flex.flex-row,
    .manage-body :is(.mud-xs-table, .mud-sm-table, .mud-md-table) .mud-table-cell .d-flex,
    .mud-container:has(.client-setup-save) :is(.mud-xs-table, .mud-sm-table, .mud-md-table) .mud-table-cell .d-flex.flex-row { flex-wrap: wrap; justify-content: flex-end; }

    /* Tabs (Users: Delve Group / Clients / Test clients; Client Setup:
       Company / Projects / People). At MudBlazor's tab size the third tab sat
       behind a scroll arrow. Tighter tabs without icons fit all three. */
    .manage-body .mud-tabs-tabbar .mud-tab,
    .mud-container:has(.client-setup-save) .mud-tabs-tabbar .mud-tab {
        min-width: 0 !important; /* MudTabs writes min-width:160px inline */
        padding: 6px 8px;
        font-size: 0.78rem;
        line-height: 1.2;
        white-space: normal;
        flex: 1 1 0;
    }
    .manage-body .mud-tabs-tabbar .mud-tooltip-root,
    .mud-container:has(.client-setup-save) .mud-tabs-tabbar .mud-tooltip-root { flex: 1 1 0; min-width: 0; }
    .manage-body .mud-tabs-tabbar .mud-tab .mud-icon-root,
    .mud-container:has(.client-setup-save) .mud-tabs-tabbar .mud-tab .mud-icon-root { display: none; }
    .manage-body .mud-tabs-tabbar .mud-tabs-scroll-button,
    .mud-container:has(.client-setup-save) .mud-tabs-tabbar .mud-tabs-scroll-button { display: none; }
    .manage-body .mud-tabs-tabbar-wrapper,
    .mud-container:has(.client-setup-save) .mud-tabs-tabbar-wrapper { width: 100%; transform: none !important; }

    /* --- Client Setup (/clients, /manage/clients) ------------------------ */
    .mud-container:has(.client-setup-save) { padding-left: 12px; padding-right: 12px; }
    .mud-container:has(.client-setup-save) > .d-flex.flex-row:first-child .mud-typography-h4 { font-size: 1.8rem; }
    .mud-container:has(.client-setup-save) .mud-paper.pa-4 { padding: 12px !important; }
    .mud-container:has(.client-setup-save) .mud-tabs-panels > .mud-tab-panel { min-width: 0; }
    /* Add-domain and add-project rows: the field takes the row, its button
       keeps its words on one line. */
    .mud-container:has(.client-setup-save) .d-flex.flex-row:has(> .mud-input-control, > .mud-autocomplete, > .mud-select) { flex-wrap: wrap; row-gap: 8px; }
    .mud-container:has(.client-setup-save) .d-flex.flex-row > .mud-input-control { flex: 1 1 160px; min-width: 0; }
    .mud-container:has(.client-setup-save) .d-flex.flex-row > .mud-autocomplete,
    .mud-container:has(.client-setup-save) .d-flex.flex-row > .mud-select { flex: 1 1 100%; min-width: 0; }
    .mud-container:has(.client-setup-save) .mud-button-root { white-space: nowrap; }
    /* Expansion panel titles: name, chip, counts — wrap under each other. */
    .mud-container:has(.client-setup-save) .mud-expand-panel-header .d-flex.flex-row { flex-wrap: wrap; row-gap: 4px; min-width: 0; }
    .mud-container:has(.client-setup-save) .mud-expand-panel-header .mud-typography { overflow-wrap: anywhere; }
    .mud-container:has(.client-setup-save) .mud-expand-panel .mud-expand-panel-content { padding-left: 8px; padding-right: 8px; }

    /* The permission grid (GrantEditor): Inherit/Allow/Deny beside a 55%
       label cell left Allow and Deny off the card. The label takes its own
       line and the three buttons sit under it at full width. */
    .mud-simple-table:has([class*="-inherit"]) table,
    .mud-simple-table:has([class*="-inherit"]) tbody { display: block; width: 100%; }
    .mud-simple-table:has([class*="-inherit"]) tr {
        display: flex;
        flex-direction: column;
        align-items: stretch;
        gap: 4px;
        padding: 8px 0;
        border-bottom: 1px solid var(--mud-palette-table-lines);
    }
    .mud-simple-table:has([class*="-inherit"]) td {
        width: auto !important;
        padding: 0 4px !important;
        border-bottom: none !important;
    }
    .mud-simple-table:has([class*="-inherit"]) .mud-button-group-root { display: flex; width: 100%; }
    .mud-simple-table:has([class*="-inherit"]) .mud-button-group-root .mud-button-root { flex: 1 1 0; min-width: 0; white-space: nowrap; }

    /* --- Agents ----------------------------------------------------------
       Each card's header held name, model chip, status chip, switch and the
       expand button in one row; the switch and expand button were pushed off
       the card. The row wraps; the controls stay together on the right. */
    .manage-body .delve-card > .mud-card-content.pa-6 { padding: 16px !important; }
    .manage-body .delve-card > .mud-card-content > .d-flex.flex-row:first-child { flex-wrap: wrap; row-gap: 4px; }
    .manage-body .delve-card > .mud-card-content > .d-flex.flex-row:first-child > .mud-chip { max-width: 100%; height: auto; min-height: 24px; white-space: normal; }
    .manage-body .delve-card > .mud-card-content > .d-flex.flex-row:first-child > .mud-input-control { flex: 0 0 auto; width: auto; margin: 0; }

    /* --- Integration keys: the card header (name, state, last four) wraps. */
    .manage-body .page-shell .delve-card .d-flex.flex-row:has(> .mud-typography-h5),
    .manage-body .page-shell .delve-card .d-flex.flex-row:has(> .mud-typography-h6) { flex-wrap: wrap; row-gap: 4px; }

    /* --- Comparisons ------------------------------------------------------
       The list and the viewer were two side-by-side columns — 280px of list
       and a 70px sliver of viewer. They stack: the list first (scrolls on
       its own, so it doesn't bury the viewer), the viewer under it. */
    .manage-body .cmp-layout { grid-template-columns: minmax(0, 1fr); }
    .manage-body .cmp-list { max-height: 40vh; }
    .manage-body .cmp-sides { grid-template-columns: minmax(0, 1fr); }
    .manage-body .cmp-issues .mud-chip { height: auto; min-height: 24px; max-width: 100%; white-space: normal; }
    .manage-body .cmp-issues .mud-chip .mud-chip-content { white-space: normal; overflow-wrap: anywhere; }
    .manage-body .cmp-replay,
    .manage-body .cmp-video { max-height: 34vh; }
    .manage-body .cmp-replay { height: 34vh; }

    /* --- Agent activity: a run's head keeps its words, its meta wraps. --- */
    .manage-body .agent-run-head { flex-wrap: wrap; row-gap: 4px; justify-content: flex-start; }
    .manage-body .agent-run-meta { flex-wrap: wrap; white-space: normal; }
    .manage-body .agent-run-pre { white-space: pre-wrap; overflow-wrap: anywhere; }

    /* --- Report: the shelf of reports scrolls sideways on one line rather
       than breaking each title into a four-line column. */
    .report-picker { overflow-x: auto; padding: 0 8px; }
    .report-picker .mud-button-root { flex: 0 0 auto; white-space: nowrap; }

    /* --- Project list: the add picker's 340px minimum ran off the card. --- */
    .manage-body .mud-paper .d-flex.flex-row:has(> .mud-autocomplete),
    .manage-body .mud-paper .d-flex.flex-row:has(> .mud-input-control) { flex-wrap: wrap; }
    .manage-body .mud-paper .d-flex.flex-row > .mud-input-control { min-width: 0 !important; flex: 1 1 100%; }

    /* --- Projects (/projects, staff) --------------------------------------
       Page gutters as elsewhere; the strip's reminder and production-URL
       fields have fixed desktop widths (250/240px) that pushed Remind and
       Save off the card — the field now takes the row, its button follows. */
    .page-shell:has(> .page-title.mb-2),
    .page-shell:has(.project-block) { padding: 16px 16px 48px; }
    .page-shell:has(.project-block) .page-title { font-size: 1.8rem; line-height: 1.2; overflow-wrap: anywhere; }
    .project-strip { padding: 10px 12px; }
    .project-strip .strip-item { flex-wrap: wrap; max-width: 100%; }
    .project-strip .strip-item > .mud-input-control { width: auto !important; flex: 1 1 180px; min-width: 0; }
    .project-columns { padding: 12px; }
    .project-board { min-width: 0; }

    /* --- Layouts (/layouts) — gutters only. ------------------------------ */
    .page-shell:has(.sandbox-mode) { padding: 16px 16px 48px; }
}
