/* == Module header (D6). Purpose/Status are hand-written; Module-Map.py --check verifies the rest. ==
   Purpose:   (add a one-line purpose)
   Status:    active
   Loaded by: customer-portal.html, customer-welcome.html, support-desk.html, support-sessions.html,
              support-verify-email.html
   Replaces:  none
   History:   64, 311, 315, 316, 682
   == end of module header == */
@layer app {
    :root {
        --bg: #f3f6fa;
        --surface: #fff;
        --text: #192b40;
        --muted: #617488;
        --line: #d5dfe9;
        --blue: #2169b0;
        --green: #137d48;
        --red: #b73138;
        --amber: #977100;
        color-scheme: light
    }

    .dark {
        --bg: #111820;
        --surface: #1b2530;
        --text: #eef3f8;
        --muted: #a8b8c8;
        --line: #344150;
        --blue: #398feb;
        --green: #58d889;
        --red: #ff8289;
        --amber: #f0bf57;
        color-scheme: dark
    }

    * {
        box-sizing: border-box
    }

    body {
        margin: 0;
        background: var(--bg);
        color: var(--text);
        font: 14px system-ui, sans-serif
    }

    header {
        display: flex;
        align-items: center;
        gap: 24px;
        padding: 14px 26px;
        background: var(--surface);
        border-bottom: 1px solid var(--line);
        position: sticky;
        top: 0;
        z-index: 5
    }

    .brand {
        width: 174px;
        height: 72px;
        object-fit: contain
    }

    nav {
        display: flex;
        gap: 8px
    }

    nav a {
        padding: 12px 14px;
        text-decoration: none;
        color: var(--text);
        border-bottom: 2px solid transparent
    }

    nav a.active {
        color: var(--blue);
        border-color: var(--blue)
    }

    .header-right {
        margin-left: auto;
        display: flex;
        align-items: center;
        gap: 14px
    }

    a {
        color: var(--blue)
    }

    main {
        max-width: 1440px;
        margin: auto;
        padding: 26px
    }

    h1 {
        font-size: 27px;
        margin: 0 0 8px
    }

    h2 {
        font-size: 19px;
        margin: 0 0 16px
    }

    p {
        line-height: 1.6
    }

    .muted,
    small {
        color: var(--muted)
    }

    button,
    input,
    select,
    textarea {
        font: inherit;
        color: inherit
    }

    button,
    .button {
        border: 1px solid var(--line);
        background: var(--surface);
        border-radius: 6px;
        padding: 9px 14px;
        cursor: pointer;
        text-decoration: none
    }

    button:disabled {
        opacity: .55;
        cursor: wait
    }

    .primary {
        background: var(--blue);
        border-color: var(--blue);
        color: #fff
    }

    input,
    select,
    textarea {
        width: 100%;
        padding: 10px 12px;
        border: 1px solid var(--line);
        border-radius: 6px;
        background: var(--bg)
    }

    textarea {
        min-height: 115px;
        resize: vertical
    }

    label {
        display: flex;
        flex-direction: column;
        gap: 7px;
        font-weight: 550
    }

    form {
        display: grid;
        gap: 18px
    }

    .grid {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 20px
    }

    .full {
        grid-column: 1/-1
    }

    .card {
        background: var(--surface);
        border: 1px solid var(--line);
        border-radius: 9px;
        padding: 22px;
        margin: 18px 0
    }

    .toolbar {
        display: flex;
        align-items: center;
        gap: 10px;
        flex-wrap: wrap;
        margin: 16px 0
    }

    .toolbar input,
    .toolbar select {
        width: auto;
        max-width: 100%
    }

    .toolbar .right {
        margin-left: auto
    }

    .stats {
        display: grid;
        grid-template-columns: repeat(4, 1fr);
        gap: 14px
    }

    .stats .card {
        margin: 8px 0
    }

    .stats strong {
        display: block;
        font-size: 28px;
        margin-top: 8px
    }

    .table-wrap {
        overflow: auto;
        border: 1px solid var(--line);
        border-radius: 8px
    }

    table {
        width: 100%;
        border-collapse: collapse;
        background: var(--surface);
        text-align: left
    }

    td,
    th {
        padding: 14px 16px;
        border-bottom: 1px solid var(--line)
    }

    th {
        font-size: 12px;
        color: var(--muted);
        background: var(--bg)
    }

    tr:last-child td {
        border-bottom: 0
    }

    .good {
        color: var(--green)
    }

    .bad {
        color: var(--red)
    }

    .warn {
        color: var(--amber)
    }

    .badge {
        display: inline-block;
        border: 1px solid var(--line);
        border-radius: 20px;
        padding: 4px 10px;
        font-size: 12px
    }

    .photos {
        display: flex;
        align-items: center;
        gap: 12px;
        flex-wrap: wrap
    }

    .photos img,
    .photo-add {
        width: 100px;
        height: 100px;
        object-fit: cover;
        border-radius: 6px;
        border: 1px solid var(--line)
    }

    .photo-add {
        font-size: 30px;
        background: var(--bg)
    }

    .photo-buttons {
        display: flex;
        flex-direction: column;
        gap: 8px
    }

    .photo-wrap {
        position: relative
    }

    .photo-wrap button {
        position: absolute;
        right: 0;
        top: 0;
        padding: 2px 7px
    }

    .check {
        display: flex;
        flex-direction: row;
        align-items: center;
        font-weight: 400;
        padding: 7px 0
    }

    .check input {
        width: auto
    }

    .message {
        border-bottom: 1px solid var(--line);
        padding: 18px 0;
        white-space: pre-wrap
    }

    .message small {
        display: block;
        margin-bottom: 8px
    }

    .message img {
        width: 100px;
        height: 90px;
        object-fit: cover;
        margin: 10px 8px 0 0
    }

    .private {
        border-left: 3px solid var(--amber);
        padding-left: 14px
    }

    .verify {
        max-width: 540px;
        margin: 8vh auto;
        background: var(--surface);
        border: 1px solid var(--line);
        border-radius: 10px
    }

    .verify .brand {
        width: 210px;
        height: 95px
    }

    .link-start {
        max-width: 540px;
        margin: 40px auto
    }

    .empty {
        padding: 40px;
        text-align: center;
        color: var(--muted)
    }

    #notice:not(:empty) {
        padding: 12px 16px;
        margin-bottom: 18px;
        border: 1px solid var(--blue);
        border-radius: 6px
    }

    dialog {
        background: var(--surface);
        color: var(--text);
        border: 1px solid var(--line);
        border-radius: 10px;
        padding: 24px;
        max-width: calc(100vw - 24px)
    }

    dialog::backdrop {
        background: #0008
    }

    #login-dialog {
        width: 540px;
        height: min(740px, 90vh);
        padding: 12px
    }

    iframe {
        width: 100%;
        height: 95%;
        border: 0
    }

    .close {
        float: right;
        font-size: 20px;
        padding: 2px 10px
    }

    .split {
        display: grid;
        grid-template-columns: minmax(0, 2fr) minmax(240px, 1fr);
        gap: 24px
    }

    summary {
        cursor: pointer;
        padding: 10px 0
    }

    #page>p {
        color: var(--muted)
    }

    @media(max-width:760px) {
        header {
            padding: 10px 14px;
            gap: 8px;
            flex-wrap: wrap
        }

        .brand {
            width: 130px;
            height: 50px
        }

        /* BSS 682 (2026-11-02, every screen fits the Duo): the top bar's own nav only; a bare "nav" also moved the staff
           desk's tab row (Monitoring, Tickets) below its tiles and table on the Duo and phones */
        header nav {
            order: 3;
            width: 100%;
            overflow: auto
        }

        header nav a {
            padding: 10px;
            white-space: nowrap
        }

        main {
            padding: 16px
        }

        .grid,
        .split {
            grid-template-columns: 1fr
        }

        .stats {
            grid-template-columns: repeat(2, 1fr)
        }

        .card {
            padding: 16px
        }

        .full {
            grid-column: auto
        }

        h1 {
            font-size: 23px
        }

        td,
        th {
            padding: 10px
        }

        .toolbar input {
            width: 100%
        }
    }

    /* V46.64: larger visible artwork, compact header controls. Original logo retained. */
    header {
        padding: 6px 20px;
        gap: 18px
    }

    header>a:first-child {
        display: block;
        position: relative;
        flex: 0 0 164px;
        width: 164px;
        height: 90px;
        overflow: hidden
    }

    header .brand {
        display: block;
        width: 164px;
        height: auto;
        max-width: none;
        transform: translateY(-10px)
    }

    .header-right {
        gap: 8px
    }

    .header-right button {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        min-height: 34px;
        line-height: 20px;
        padding: 6px 12px
    }

    .header-right #theme {
        width: 34px; /* BSS 315 (2026-10-15, review O2): from ui-layer-296: same reason */
        --ui-theme-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='4'/%3E%3Cpath d='M12 2v2M12 20v2M4.9 4.9l1.4 1.4M17.7 17.7l1.4 1.4M2 12h2M20 12h2M4.9 19.1l1.4-1.4M17.7 6.3l1.4-1.4'/%3E%3C/svg%3E") /* BSS 315 (2026-10-15, review O2): from ui-layer-296: the sun (the moon below) */
    }

    /* BSS 315 (2026-10-15, review O2): from ui-layer-296: the public support page's theme button draws the same sun / moon as the other pages. */
    html.dark .header-right #theme {
        --ui-theme-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M21 12.8A9 9 0 1 1 11.2 3a7 7 0 0 0 9.8 9.8Z'/%3E%3C/svg%3E")
    }

    .header-right #theme::before {
        content: "";
        flex: none;
        width: 18px;
        height: 18px;
        background: currentColor;
        -webkit-mask: var(--ui-theme-icon) center / contain no-repeat;
        mask: var(--ui-theme-icon) center / contain no-repeat
    }

    .header-right #login {
        white-space: nowrap
    }

    @media(max-width:760px) {
        header {
            padding: 6px 12px;
            gap: 8px
        }

        header>a:first-child {
            flex-basis: 142px;
            width: 142px;
            height: 78px
        }

        header .brand {
            width: 142px;
            transform: translateY(-9px)
        }

        .header-right {
            gap: 6px
        }

        .header-right button {
            min-height: 44px
        }

        .header-right #theme {
            width: 44px
        }
    }

    #login-dialog {
        width: 440px;
        height: fit-content;
        max-height: calc(100dvh - 24px);
        padding: 0;
        overflow: hidden;
        border-radius: 12px
    }

    #login-dialog .close {
        float: none;
        display: flex;
        align-items: center;
        justify-content: center;
        width: 32px;
        height: 32px;
        margin: 8px 8px 0 auto;
        padding: 0;
        font-size: 22px;
        border: 0;
        background: transparent;
        color: var(--text)
    }

    #login-frame {
        display: block;
        width: 100%;
        height: 620px;
        max-height: calc(100dvh - 88px);
        border: 0;
        background: var(--surface)
    }

    /* BSS 311 (2026-10-15, review O2): from ui-layer-277 (iPhone pass): fingertip-sized sort and person buttons on touch screens (app-header-account.css
       has the same rule for the pages that load it; the support pages load this file instead); the extra room is
       invisible padding, so nothing moves. */
    @media(pointer:coarse) {
        button.sort31,
        .person-button {  /* BSS 316 (2026-10-15): the user name is now a link (open in a new tab) */
            padding-top: 8px;
            padding-bottom: 8px;
            margin-top: -8px;
            margin-bottom: -8px
        }
    }

    /* BSS 311 (2026-10-15, review O2): from ui-layer-277 (iPhone pass): typing boxes use 16px text on phones, so the iPhone does not zoom
       the page in when one is tapped (the public request form loads only this stylesheet). The `:is(body,
           dialog.ui-dialog)` prefix gives the rule the popup field rule's
       specificity above, so the later rule (this one) wins inside popups too. */
    @media(max-width:800px),(pointer:coarse) and (max-height:600px) {
        :is(body,
            dialog.ui-dialog) :is(input:not([type=checkbox]):not([type=radio]):not([type=range]):not([type=file]):not([type=color]):not([type=submit]):not([type=button]):not([type=image]):not([type=reset]),
            select,textarea) {
            font-size: 16px
        }
    }

    /* BSS 311 (2026-10-15, review O2): from ui-layer-277 (iPhone pass): phones and tablets: the sites table (staff Monitoring and the customer
       portal) keeps its full words and slides sideways; touch screens get a finger-sized tap area on a contact's phone
       link without moving anything. */
    @media(max-width:900px),(pointer:coarse) and (max-width:1366px) {
        .sites163 table {
            table-layout: auto;
            width: max-content;
            min-width: 100%
        }

        .sites163 :is(th,td) {
            width: auto
        }

        .sites163 td {
            overflow-wrap: normal
        }
    }

    @media(pointer:coarse) {
        .ticket-contact-text172 strong>a {
            display: inline-block;
            padding: 6px 0;
            margin: -6px 0
        }
    }

    /* BSS 682 (2026-11-02, every screen fits the Duo): the top tab row's buttons fold into one three-dot More button when they
       do not fit beside the tabs (desk-actions-fit.js); the folded buttons stay in the page, hidden, so the menu can click them. */
    html body #page .page-actions141>.desk-folded682{display:none}
    html body #page .page-actions141>.desk-more682{display:inline-flex;flex:none}
    html body #page .desk-more682>button{display:inline-grid;place-items:center;width:40px;height:40px;min-height:40px;padding:0;border:0;border-radius:50%;background:none;color:var(--muted);cursor:pointer}
    html body #page .desk-more682>button:hover{background:var(--hover,#8882)}
    html body #page .desk-more682 svg{width:20px;height:20px;fill:none;stroke:currentColor;stroke-width:2.6;stroke-linecap:round;stroke-linejoin:round}
    /* BSS 682: still a little too wide (the folded Duo, 444 px): a narrower three-dot button (still 40 px tall to tap) */
    html body #page>.module-tabs84.desk-tight682 .desk-more682>button{width:28px;border-radius:14px}
    /* BSS 682: the tabs you are not on, icon only (desk-actions-fit.js adds the class only when the row does not fit) */
    html body #page>.module-tabs84>a.desk-icon682>.desk-word682{display:none}
}

/* priority rules. Rules above sit in the app layer; these plain rules
   win over any of them (what !important used to do), and compete with each other as before. */
.header-right #theme {
    padding: 0;
    /* BSS 315 (2026-10-15, review O2): from ui-layer-296: centred drawn icon; header-layout.css forces header buttons */
    font-size: 0;
    /* BSS 315 (2026-10-15, review O2): from ui-layer-296: hides the glyph text; same reason */
    line-height: 0;
    /* BSS 315 (2026-10-15, review O2): from ui-layer-296: same reason */
    display: flex;
    /* BSS 315 (2026-10-15, review O2): from ui-layer-296: same reason */
    align-items: center;
    /* BSS 315 (2026-10-15, review O2): from ui-layer-296: same reason */
    justify-content: center;
}
