/* ================================================================
   GRADAX client area on a phone. Loaded after every other client sheet, so it only has to say what
   changes below 768px: a compact top bar, a tab bar at the bottom like an app, tighter type and
   rows that read in one glance. Desktop is untouched apart from the initials avatar.
   ================================================================ */

/* Initials avatar (contacts without a photo of their own), every size */
.gxc-initials {
    display: inline-grid; place-items: center; flex: none; background: var(--gx-ink); color: #fff;
    font: 700 12px/1 var(--gx-font); letter-spacing: .02em;
}
.gxc-me .gxc-me-pic { width: 30px; height: 30px; border-radius: 9px; object-fit: cover; }
.gxc-amounts { display: flex; flex-direction: column; gap: 0; }
.gxc-amounts span { display: block; }
.gxc-amounts span + span { font-size: .78em; color: var(--gx-ink-2); }

/* Drawer: who is signed in, at the top */
.gxc-dme {
    display: flex; align-items: center; gap: 12px; margin: 2px 0 10px; padding: 12px; border-radius: 14px;
    background: var(--gx-paper); border: 1px solid var(--gx-rule); color: var(--gx-ink) !important; text-decoration: none !important;
}
.gxc-dme-pic { width: 42px; height: 42px; border-radius: 12px; object-fit: cover; font-size: 14px; }
.gxc-dme > span:not(.gxc-initials) { flex: 1; min-width: 0; display: grid; }
.gxc-dme b { font-size: 15px; line-height: 1.3; }
.gxc-dme small { font-size: 12.5px; color: var(--gx-ink-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gxc-dme-go { width: 16px !important; height: 16px !important; color: var(--gx-ink-3); }

/* Tab bar: phones only */
.gxc-tabbar { display: none; }

@media (max-width: 767px) {
    body.customers { --gx-bar: 56px; --gx-tabbar: calc(62px + env(safe-area-inset-bottom, 0px)); font-size: 15px; }
    body.customers:has(.gxc-tabbar) { padding-bottom: var(--gx-tabbar); }

    /* ---------- Top bar: logo, bell, avatar. The menu lives in the tab bar. ---------- */
    .gxc-top { background: rgb(255 255 255 / .92); }
    .gxc-top-in { padding: 0 12px 0 16px; gap: 6px; }
    .gxc-brand img { width: 100px; }
    .gxc-iconbtn { width: 40px; height: 40px; border-radius: 11px; }
    .gxc-bell { border-color: transparent; background: transparent; box-shadow: none; }
    .gxc-me { height: 40px; padding: 0 4px; border-color: transparent; background: transparent; box-shadow: none; }
    .gxc-me .gxc-me-pic { width: 32px; height: 32px; border-radius: 50%; }
    body.customers:has(.gxc-tabbar) .gxc-top .gxc-burger { display: none; }
    .gxc-pop-panel { position: fixed; top: calc(var(--gx-bar) + 6px); right: 10px; left: 10px; width: auto; }

    /* ---------- Tab bar ---------- */
    .gxc-tabbar {
        position: fixed; z-index: 1029; left: 0; right: 0; bottom: 0; display: grid; grid-auto-flow: column; grid-auto-columns: 1fr;
        height: var(--gx-tabbar); padding: 6px 6px env(safe-area-inset-bottom, 0px);
        background: rgb(255 255 255 / .94); -webkit-backdrop-filter: saturate(180%) blur(16px); backdrop-filter: saturate(180%) blur(16px);
        border-top: 1px solid var(--gx-rule);
    }
    .gxc-tab {
        position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
        min-width: 0; height: 50px; padding: 0 2px; border: 0; border-radius: 12px; background: none; cursor: pointer;
        font: 600 11px/1.1 var(--gx-font); color: var(--gx-ink-3) !important; text-decoration: none !important;
        -webkit-tap-highlight-color: transparent; transition: color .15s ease;
    }
    .gxc-tab .gxc-i { width: 22px; height: 22px; transition: transform .2s var(--gx-ease); }
    .gxc-tab span { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
    .gxc-tab:active .gxc-i { transform: scale(.9); }
    .gxc-tab.is-active { color: var(--gx-ink) !important; }
    .gxc-tab.is-active::before { content: ""; position: absolute; top: -7px; width: 22px; height: 3px; border-radius: 0 0 3px 3px; background: var(--gx-accent); }
    .gxc-tab.is-active .gxc-i { stroke-width: 2.1; }

    /* Drawer opens as a sheet from the bottom on a phone */
    .gxc-drawer-nav { inset: auto 0 0 0; width: 100vw; height: auto; max-height: 88dvh; border-radius: 22px 22px 0 0; border: 0; padding-bottom: env(safe-area-inset-bottom, 0px); }
    .gxc-drawer-nav[open] { animation: gxc-rise .32s var(--gx-ease); }
    .gxc-drawer-nav .gxc-sheet-head { padding: 10px 12px 10px 18px; border-bottom: 0; }
    .gxc-drawer-nav .gxc-sheet-head::before { content: ""; position: absolute; top: 8px; left: 50%; width: 38px; height: 4px; margin-left: -19px; border-radius: 4px; background: var(--gx-rule-2); }
    .gxc-drawer-nav .gxc-sheet-head img { width: 96px; margin-top: 10px; }
    .gxc-drawer-nav .gxc-sheet-body { padding: 0 12px 18px; }
    .gxc-dl { min-height: 46px; font-size: 15px; }
    .gxc-dl.is-active { background: var(--gx-paper); color: var(--gx-ink) !important; box-shadow: inset 0 0 0 1px var(--gx-rule); }
    .gxc-dl.is-active .gxc-i { color: var(--gx-accent); }
    .gxc-dl-title { margin: 14px 12px 4px; }
    .gxc-ntc-item { padding: 12px 10px; }

    /* ---------- Page rhythm ---------- */
    body.customers #content .row > .col-md-12:is(.gxc-page, .gxc-home) { padding-left: 0; padding-right: 0; }
    body.customers #content .row:has(> .col-md-12:is(.gxc-page, .gxc-home)) { margin-left: 0; margin-right: 0; }
    body.customers #content { padding-top: 18px; padding-bottom: 28px; }
    body.customers .footer { padding: 16px 0; font-size: 12px; text-align: center; }
    body.customers .footer .container { padding-bottom: 0; }
    .gxc-page { gap: 16px; }
    .gxc-phead { gap: 12px; }
    .gxc-phead h1 { font-size: 27px; letter-spacing: -0.035em; }
    .gxc-phead p { font-size: 14px; margin-top: 6px; }
    .gxc-phead-actions { width: 100%; display: grid; grid-template-columns: repeat(auto-fit, minmax(0, 1fr)); }
    .gxc-phead-actions .gxc-btn, .gxc-phead-actions .btn { width: 100%; padding: 0 10px; }
    body.customers #content :is(h4, h3):is(.section-heading, .customer-statement-heading, .section-heading-company-profile, .section-heading-announcements),
    body.customers #content .project-name { font-size: 26px !important; margin-bottom: 14px !important; }
    body.customers .btn, .gxc-btn { min-height: 44px; }
    body.customers .btn-sm, body.customers .btn-xs { min-height: 36px; }

    /* ---------- Home ---------- */
    .gxc-home { gap: 20px; }
    .gxc-hello { gap: 14px; }
    .gxc-hello h1 { font-size: 26px; }
    .gxc-hello-co { font-size: 13px; }
    .gxc-hello-actions { width: 100%; display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
    .gxc-hello-actions .gxc-btn { width: 100%; min-height: 46px; padding: 0 10px; font-size: 13.5px; white-space: normal; text-align: center; line-height: 1.2; }
    .gxc-hello-actions .gxc-btn:only-child { grid-column: 1 / -1; }

    .gxc-hello-actions .gxc-btn .gxc-i { display: none; }

    /* Everything else waiting: one compact row each (icon, what, how many) */
    .gxc-attn { grid-template-columns: 1fr; gap: 8px; }
    .gxc-tile { display: grid; grid-template-columns: 40px minmax(0, 1fr) auto; align-items: center; gap: 12px; padding: 12px 14px; border-radius: 16px; }
    .gxc-tile > div { display: grid; grid-template-columns: minmax(0, 1fr) auto; column-gap: 10px; align-items: baseline; }
    .gxc-tile-icon { width: 40px; height: 40px; border-radius: 12px; }
    .gxc-tile-icon .gxc-i { width: 19px; height: 19px; }
    .gxc-tile-label { grid-column: 1; grid-row: 1; font-size: 14px; font-weight: 700; color: var(--gx-ink); }
    .gxc-tile .gxc-figure { grid-column: 2; grid-row: 1 / span 2; align-self: center; margin: 0; font-size: 22px; }
    .gxc-tile p { grid-column: 1; margin: 1px 0 0; font-size: 12.5px; line-height: 1.35; color: var(--gx-ink-3); }
    .gxc-tile-list { grid-column: 1 / -1; margin: 8px 0 0; gap: 4px; }
    .gxc-tile-list a { align-items: center; min-height: 48px; margin: 0; padding: 8px 10px; border-radius: 12px; background: var(--gx-paper); }
    .gxc-tile-list span { flex: 1; display: grid; gap: 1px; white-space: normal; }
    .gxc-tile-list span, .gxc-tile-list small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
    .gxc-tile-list small { font-size: 12px; }
    .gxc-tile-go { position: static; width: 16px !important; height: 16px !important; }
    .gxc-tile.is-calm { grid-template-columns: 40px minmax(0, 1fr); }
    .gxc-tile.is-calm > div { display: block; }

    /* What is to pay: the first thing a client sees, an ink card across the width */
    .gxc-tile.gxc-tile-pay { grid-template-columns: 44px minmax(0, 1fr) auto; gap: 14px; padding: 18px; background: var(--gx-ink); border-color: var(--gx-ink); color: #fff !important; box-shadow: 0 12px 28px -14px rgb(21 23 28 / .55); }
    .gxc-tile.gxc-tile-pay .gxc-tile-icon { width: 44px; height: 44px; border-radius: 13px; background: rgb(255 255 255 / .1); color: #fff; }
    .gxc-tile.gxc-tile-pay.is-stop .gxc-tile-icon { background: rgb(234 95 14 / .22); color: #ffb48a; }
    .gxc-tile.gxc-tile-pay > div { display: block; }
    .gxc-tile.gxc-tile-pay .gxc-tile-label { font-size: 13px; font-weight: 600; color: rgb(255 255 255 / .66); }
    .gxc-tile.gxc-tile-pay .gxc-figure { font-size: 24px; color: #fff; }
    .gxc-tile.gxc-tile-pay .gxc-figure span + span { font-size: 18px; color: rgb(255 255 255 / .82); }
    .gxc-tile.gxc-tile-pay p { margin-top: 4px; color: rgb(255 255 255 / .7); }
    .gxc-tile.gxc-tile-pay p strong { color: #ffb48a; }
    .gxc-tile.gxc-tile-pay .gxc-tile-go { color: rgb(255 255 255 / .6); }

    .gxc-split { gap: 16px; }
    .gxc-card { border-radius: 16px; padding: 4px 6px 6px; }
    .gxc-card-head { padding: 12px 10px 6px; }
    .gxc-card-head h2 { font-size: 16px; }
    .gxc-sec-head h2 { font-size: 18px; }
    .gxc-link { min-height: 36px; font-size: 13px; }

    /* Invoice rows: number and amount on one line, date and status on the next */
    .gxc-row { grid-template-columns: 36px minmax(0, 1fr) auto; grid-template-areas: "i m a" "i d s"; column-gap: 12px; row-gap: 4px; padding: 12px 8px; align-items: center; }
    .gxc-row-icon { grid-area: i; align-self: start; width: 36px; height: 36px; }
    .gxc-row-main { grid-area: m; display: contents; }
    .gxc-row-main b { grid-area: m; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
    .gxc-row-main small { grid-area: d; font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
    .gxc-row-amount { grid-area: a; justify-self: end; font-size: 14px; }
    .gxc-row-status { grid-area: s; grid-column: auto; justify-self: end; }
    .gxc-row-status .label { padding: 3px 8px; font-size: 11px; }

    .gxc-feed-mini .gxc-ntc-item { padding: 10px 8px; gap: 10px; }
    .gxc-feed-mini .gxc-ntc-icon { width: 34px; height: 34px; }
    .gxc-feed-mini .gxc-ntc-body span { -webkit-line-clamp: 1; }

    /* Projects: a horizontal shelf instead of a tall stack */
    .gxc-pgrid { display: flex; gap: 10px; margin: 0; padding: 2px 0 6px; overflow-x: auto; scroll-snap-type: x mandatory; scrollbar-width: none; }
    .gxc-pgrid::-webkit-scrollbar { display: none; }
    .gxc-pgrid > .gxc-pcard { flex: 0 0 82%; scroll-snap-align: start; padding: 16px; }
    .gxc-pgrid > .gxc-pcard:only-child { flex-basis: 100%; }
    .gxc-pcard b { font-size: 15px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

    /* ---------- Summary tiles above lists: one swipeable strip ---------- */
    .gxc-stats, .gxc-pstats { display: flex; gap: 10px; margin: 0; padding: 2px 0 4px; overflow-x: auto; scroll-snap-type: x proximity; scrollbar-width: none; }
    .gxc-stats::-webkit-scrollbar { display: none; }
    .gxc-stat { flex: 0 0 auto; min-width: 136px; max-width: 78%; padding: 12px 14px; border-radius: 14px; scroll-snap-align: start; }
    .gxc-stat span { font-size: 12px; white-space: nowrap; }
    .gxc-stat b { font-size: 20px; margin-top: 4px; }
    .gxc-stat b.gxc-amounts span + span { font-size: 16px; color: var(--gx-ink-2); }
    .gxc-pstats .gxc-stat b { font-size: 17px; min-height: 0; }
    .gxc-pstats .gxc-stat { min-width: 150px; }
    body.customers dl.tw-grid:has(> a[href*="/clients/"]) { display: flex; gap: 10px; margin: 0 0 20px !important; padding: 2px 0 4px; overflow-x: auto; scrollbar-width: none; }
    body.customers dl.tw-grid > a[href*="/clients/"] { flex: 0 0 auto; min-width: 128px; }
    body.customers dl.tw-grid > a[href*="/clients/"] dd > div { font-size: 20px !important; }

    /* ---------- List pages ---------- */
    .gxc-toolbar { gap: 10px; }
    .gxc-seg { width: 100%; }
    .gxc-chip { height: 36px; padding: 0 12px; font-size: 13px; }
    .gxc-search input { height: 44px; font-size: 16px; }
    .gxc-list { border-radius: 16px; }
    .gxc-list ul { padding: 4px; }
    .gxc-lrow, .gxc-lrow.has-amount { grid-template-columns: 36px minmax(0, 1fr) auto; column-gap: 12px; row-gap: 3px; padding: 12px 10px; align-items: center; }
    .gxc-lrow .gxc-row-icon { width: 36px; height: 36px; border-radius: 10px; align-self: start; }
    .gxc-lrow-main b { font-size: 14px; }
    .gxc-lrow-main small { font-size: 12px; }
    .gxc-lrow-amount { font-size: 14px; align-self: start; padding-top: 1px; }
    .gxc-lrow-cell.is-first { font-size: 12px; align-self: center; }
    .gxc-lrow-status .gxc-pill { height: 24px; padding: 0 9px; font-size: 11px; }
    .gxc-emptystate { padding: 40px 20px; }

    /* ---------- Ticket ---------- */
    .gxc-facts { padding: 14px 16px; }
    .gxc-facts dl > div { padding: 9px 0; font-size: 13px; }
    .gxc-msg { grid-template-columns: 1fr; gap: 0; }
    .gxc-msg-avatar { display: none; }
    .gxc-msg-body { padding: 12px 14px 14px; border-radius: 16px; }
    .gxc-msg.is-team .gxc-msg-body { border-left: 1px solid var(--gx-rule); background: #fbfbfc; }
    .gxc-msg:not(.is-team) .gxc-msg-body { margin-left: 18px; }
    .gxc-msg.is-team .gxc-msg-body { margin-right: 18px; }
    .gxc-msg-body header { gap: 4px 8px; }
    .gxc-msg-body time { margin-left: 0; width: 100%; font-size: 12px; }
    .gxc-msg-text { font-size: 15px; }
    .gxc-composer { padding: 14px; border-radius: 16px; }
    .gxc-composer-bar { display: grid; grid-template-columns: 1fr; }
    .gxc-composer-bar > * { width: 100%; justify-content: center; }
    .gxc-formcard { padding: 16px; }
    .gxc-field input, .gxc-field select, .gxc-field textarea, body.customers .form-control { font-size: 16px; }

    /* ---------- Stock Perfex views still in use (tables, panels) ---------- */
    body.customers .panel_s, body.customers .panel { border-radius: 16px; margin-bottom: 14px; }
    body.customers .panel-heading { padding: 14px 16px !important; }
    body.customers .table-responsive, body.customers .dataTables_wrapper { overflow-x: auto; -webkit-overflow-scrolling: touch; }
    body.customers .table > thead > tr > th, body.customers .table > tbody > tr > td { padding: 10px 12px; font-size: 13.5px; }
    body.customers .dataTables_wrapper .dataTables_filter, body.customers .dataTables_wrapper .dataTables_length { float: none; text-align: left; }
    body.customers .dataTables_wrapper .dataTables_filter input { width: 100%; margin: 0; }
    body.customers .modal-dialog { margin: 12px; }
    body.customers .bootstrap-select:not(.input-group-btn), body.customers .bootstrap-select[class*="col-"] { width: 100% !important; }
    body.customers .form-group .bootstrap-select > .dropdown-toggle { width: 100%; }
    body.customers .nav-tabs > li > a { padding: 12px 10px; font-size: 13.5px; }
}

@media (max-width: 359px) {
    .gxc-hello-actions { grid-template-columns: 1fr; }
    .gxc-tab span { font-size: 10px; }
}

@keyframes gxc-rise { from { transform: translateY(24px); opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .gxc-drawer-nav[open] { animation: none; } .gxc-tab .gxc-i { transition: none; } }
