@import url("https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.1/css/all.min.css");
@import url("https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap");

:root {
    --bg: #f3f6fb;
    --surface: #ffffff;
    --surface-muted: #f8fafc;
    --text: #0f172a;
    --muted: #64748b;
    --border: #dbe3ef;
    --border-strong: #b8c5db;
    --brand: #1f4ed8;
    --brand-strong: #1d40b0;
    --danger: #b42318;
    --danger-bg: #fee4e2;
    --ok: #067647;
    --shadow: 0 6px 18px rgba(15, 23, 42, 0.08);
}

/* -----------------------------------------------------------------------------------------
   Unified "Back" navigation control (.ww-back-btn).
   -----------------------------------------------------------------------------------------
   Every page-level Back button across the app shares this style and behavior. Behavior is
   provided by the wwGoBack() helper in assets/js/auth.js — see the inline JSDoc there.
   Markup pattern:
     <div class="ww-back-row">
       <button type="button" class="ww-back-btn"
               onclick="return wwGoBack(event)" aria-label="Back">
         <span class="ww-back-emoji" aria-hidden="true">🔙</span>
         <span>Back</span>
       </button>
     </div>
   Use a <button> for page-back controls (no href to chase). On pages that previously had
   per-page back classes (.cal-back-link / .set-back-link / .hol-back-link / .pol-back-link
   / .sch-back-link / .acc-back-btn / .pto-back-btn / .ms-back), this class is the one
   replacement — the old rules may remain in their pages until those pages are refactored
   but they are no longer attached to any markup.
   ----------------------------------------------------------------------------------------- */
.ww-back-row { margin: 0 0 10px; }
.ww-back-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    padding: 0.42rem 0.8rem;
    border-radius: 12px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
    font: inherit;
    font-weight: 600;
    font-size: 14px;
    line-height: 1.2;
    cursor: pointer;
    text-decoration: none;
    transition: background-color 0.12s ease, border-color 0.12s ease;
}
.ww-back-btn:hover { background: var(--surface-muted); border-color: var(--border-strong); }
.ww-back-btn:active { background: var(--surface-muted); }
.ww-back-btn:focus-visible {
    outline: 2px solid var(--brand);
    outline-offset: 2px;
}
.ww-back-emoji { font-size: 1.15rem; line-height: 1; }

/* -----------------------------------------------------------------------------------------
   Memory anchor strips — cross-surface operational orientation (“why am I seeing this?”).
   Not tracing: short human copy + optional quiet links. Pages may override in dark UIs.
   ----------------------------------------------------------------------------------------- */
.ww-memory-anchor {
    margin: 0 0 16px;
    padding: 12px 14px;
    border-radius: 10px;
    background: var(--surface-muted);
    border: 1px solid var(--border);
    font-size: 13px;
    line-height: 1.5;
    color: var(--muted);
}
.ww-memory-anchor--compact {
    margin-bottom: 12px;
    padding: 10px 12px;
    font-size: 12.5px;
}
.ww-memory-anchor__title {
    margin: 0 0 6px;
    font-size: 11px;
    font-weight: 650;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--muted);
    opacity: 0.9;
}
.ww-memory-anchor__why {
    margin: 0;
    color: var(--text);
    font-weight: 500;
    opacity: 0.94;
}
.ww-memory-anchor__links {
    margin: 8px 0 0;
    font-size: 12.5px;
    line-height: 1.45;
}
.ww-memory-anchor__links a {
    color: var(--brand);
    font-weight: 550;
    margin-right: 14px;
    text-decoration: none;
    border-bottom: 1px solid transparent;
}
.ww-memory-anchor__links a:hover {
    border-bottom-color: rgba(31, 78, 216, 0.35);
}
@media (max-width: 720px) {
    .ww-memory-anchor__links {
        display: flex;
        flex-direction: column;
        align-items: flex-start;
        gap: 6px;
    }
    .ww-memory-anchor__links a { margin-right: 0; }
}

/* -----------------------------------------------------------------------------------------
   Personal "Remember this" widget — quiet bookmark control reused across surfaces.
   Strictly personal continuity memory. No queues, no assignments, no statuses.
   ----------------------------------------------------------------------------------------- */
.ww-remember {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    margin: 8px 0 0;
}
.ww-remember__btn {
    min-height: 36px;
    padding: 0 14px;
    font-size: 13px;
    font-weight: 600;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text, inherit);
    cursor: pointer;
    line-height: 1;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    -webkit-tap-highlight-color: transparent;
}
.ww-remember__btn:hover { background: var(--surface-muted); }
.ww-remember__btn[aria-pressed="true"] {
    background: var(--surface-muted);
    border-color: var(--border);
    color: var(--muted);
}
.ww-remember__btn:disabled { opacity: 0.6; cursor: default; }
.ww-remember__status {
    font-size: 12px;
    color: var(--muted);
    line-height: 1.3;
    min-height: 1.2em;
}
.ww-remember__note {
    width: 100%;
    box-sizing: border-box;
    margin-top: 8px;
    padding: 8px 10px;
    font-size: 13.5px;
    line-height: 1.45;
    min-height: 44px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: var(--surface);
    font-family: inherit;
    resize: vertical;
}
.ww-remember__note[hidden] { display: none !important; }
.ww-remember--row { width: 100%; }
@media (max-width: 480px) {
    .ww-remember__btn { width: 100%; justify-content: center; }
}

/* -----------------------------------------------------------------------------------------
   Personal "Return here later" pause-point widget — single-tap return continuity.
   Personal-only, never a queue, never assigned. Mirrors the calm rhythm of .ww-remember
   but uses a softer (secondary) palette so the two controls read as different verbs:
   "Remember this"      = permanent personal memory
   "Return here later"  = paused operational context
   ----------------------------------------------------------------------------------------- */
.ww-pause {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    margin: 6px 0 0;
}
.ww-pause__btn {
    min-height: 36px;
    padding: 0 14px;
    font-size: 13px;
    font-weight: 600;
    border-radius: 999px;
    border: 1px dashed var(--border);
    background: transparent;
    color: var(--muted);
    cursor: pointer;
    line-height: 1;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    -webkit-tap-highlight-color: transparent;
}
.ww-pause__btn:hover { background: var(--surface-muted); color: inherit; }
.ww-pause__btn[aria-pressed="true"] {
    background: var(--surface-muted);
    border-style: solid;
    color: var(--text, inherit);
}
.ww-pause__btn:disabled { opacity: 0.6; cursor: default; }
.ww-pause__status {
    font-size: 12px;
    color: var(--muted);
    line-height: 1.3;
    min-height: 1.2em;
}
.ww-pause--compact .ww-pause__btn { min-height: 32px; font-size: 12px; padding: 0 12px; }
.ww-pause__extras {
    width: 100%;
    flex: 1 1 100%;
    margin-top: 4px;
}
.ww-pause__lab {
    display: block;
    font-size: 11px;
    color: var(--muted);
    font-weight: 600;
    margin-bottom: 4px;
}
.ww-pause__note {
    width: 100%;
    min-height: 48px;
    max-height: 120px;
    font: inherit;
    font-size: 14px;
    padding: 8px 10px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: var(--surface, #fff);
    resize: vertical;
}
@media (max-width: 480px) {
    .ww-pause__btn { width: 100%; justify-content: center; }
}

* { box-sizing: border-box; }

/* Selects: stay within layout, clip long selected text (list still scrolls natively) */
select,
.ms-select,
.ms-group-box select {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    box-sizing: border-box;
}
select {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    padding-right: 28px;
}
.ms-group-box,
.ms-field,
.ms-row,
.field-row,
.ms-field-row,
.ms-group-box .field,
.field {
    min-width: 0;
}
.ms-group-box .field {
    display: flex;
    flex-direction: column;
    min-width: 0;
    align-items: stretch;
    gap: 4px;
    overflow: visible;
}

/* Multi-field horizontal rows (share space, no grow past container) */
.ms-row,
.field-row,
.ms-field-row {
    display: flex;
    gap: 6px;
    min-width: 0;
}
.ms-row select,
.field-row select,
.ms-field-row select {
    flex: 1;
    min-width: 0;
    width: 0;
    max-width: 100%;
}

/* Inside / Outside (and extraction row): equal split; beat inline max-width:110px on selects */
#ms_opening_card_hd .ms-window-color-row {
    display: flex;
    gap: 6px;
    flex-wrap: nowrap;
    align-items: flex-end;
    min-width: 0;
}
#ms_opening_card_hd .ms-window-color-pair {
    flex: 1 1 0;
    min-width: 0;
    width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}
#ms_opening_card_hd .ms-window-color-row select {
    flex: 1 1 auto;
    min-width: 0 !important;
    width: 100% !important;
    max-width: 100% !important;
}

body,
input,
select,
textarea,
button {
    font-family: Inter, Arial, sans-serif;
    font-size: 13px;
    color: #1f2a36;
}

body {
    margin: 0;
    background: var(--bg);
}

a { color: inherit; }

.navbar, .nav {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    padding: 10px 14px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    box-shadow: var(--shadow);
    position: sticky;
    top: 0;
    z-index: 10;
}

.nav-links {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    flex: 1;
    min-width: 0;
}

.nav-user {
    margin-left: auto;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
}

.nav-username {
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    padding: 6px 10px;
    border-radius: 8px;
    background: var(--surface-muted);
    border: 1px solid var(--border);
}

.logo {
    font-weight: 700;
    font-size: 15px;
    margin-right: 8px;
    color: var(--brand);
    flex-shrink: 0;
    position: relative;
}
.logo a { display: flex; align-items: center; text-decoration: none; color: inherit; }
.nav-logo-img { max-height: 36px; max-width: 180px; object-fit: contain; }
.logo-fallback { font-weight: 700; font-size: 15px; color: var(--brand); }
.nav-store-num { font-size: 14px; font-weight: 600; color: var(--muted); margin-left: 6px; }
.nav-gear-icon { display: block; vertical-align: middle; }

.navbar a, .nav a, .nav button, .navbar button {
    text-decoration: none;
    border: 1px solid var(--border);
    background: var(--surface-muted);
    color: var(--text);
    border-radius: 8px;
    padding: 7px 10px;
    font-size: 13px;
    cursor: pointer;
}

.navbar a:hover, .nav a:hover, .nav button:hover, .navbar button:hover {
    background: #eef3ff;
    border-color: #c9d7ff;
}

/* Boneyard nav — dark pill; same footprint as other navbar links */
.nav a.nav-boneyard {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 7px 10px;
    font-size: 13px;
    font-weight: 400;
    color: #ffffff;
    text-decoration: none;
    border-radius: 8px;
    white-space: nowrap;
    background: #111111;
    border: 1px solid #333333;
    position: relative;
    transition: background 0.12s ease, border-color 0.12s ease, transform 0.12s ease, box-shadow 0.12s ease;
}
.nav a.nav-boneyard .nav-boneyard-icon {
    color: #ff4444;
    font-size: 0.92em;
    line-height: 1;
    flex-shrink: 0;
}
.nav a.nav-boneyard:hover {
    background: #1a1a1a;
    border-color: #ff4444;
    color: #ffffff;
    transform: translateY(-1px);
}
.nav a.nav-boneyard.nav-boneyard--has-items {
    border-color: #ff4444;
    box-shadow: 0 0 6px rgba(255, 68, 68, 0.3);
}
.nav a.nav-boneyard.nav-boneyard--has-items:hover {
    box-shadow: 0 0 8px rgba(255, 68, 68, 0.35);
}
.nav a.nav-boneyard.nav-boneyard--has-items::after {
    content: "";
    position: absolute;
    top: 5px;
    right: 6px;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #ff4444;
    box-shadow: 0 0 0 1px #111111;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 18px;
}

h1, h2, h3 {
    margin: 0 0 12px;
    font-weight: 700;
}

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: var(--shadow);
}

.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 12px;
}

.dash-card {
    padding: 16px;
    min-height: 96px;
}

.dash-card .label {
    color: var(--muted);
    font-size: 12px;
}

.dash-card .value {
    margin-top: 8px;
    font-size: 26px;
    font-weight: 700;
    color: var(--brand);
}

/* Default tables */
table {
    width: 100%;
    border-collapse: collapse;
    background: var(--surface);
    border: 1px solid var(--border-strong);
    border-radius: 10px;
    overflow: hidden;
}

th, td {
    border-bottom: 1px solid var(--border);
    padding: 9px 10px;
    text-align: left;
    font-size: 14px;
}

th {
    background: var(--surface-muted);
    color: var(--muted);
    font-weight: 600;
}

tr:hover td {
    background: #f8fbff;
}

/* Ledger-style tables: vertical + horizontal rules, zebra, strong hover */
table.data-rows {
    width: 100%;
    border-collapse: collapse;
    background: var(--surface);
    border: 1px solid var(--border-strong);
    border-radius: 8px;
    overflow: hidden;
    margin-top: 8px;
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.06);
}

table.data-rows th,
table.data-rows td {
    border-right: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
    padding: 10px 12px;
    vertical-align: middle;
}

table.data-rows th:last-child,
table.data-rows td:last-child {
    border-right: none;
}

table.data-rows thead th {
    background: #e8edf5;
    color: var(--text);
    font-weight: 600;
    font-size: 13px;
    border-bottom: 2px solid var(--border-strong);
}

table.data-rows tbody tr {
    cursor: pointer;
    transition: background-color 0.14s ease, box-shadow 0.14s ease;
}

table.data-rows tbody tr:nth-child(even) td {
    background: #f7f9fc;
}

table.data-rows tbody tr:hover td {
    background: #d4e4fc !important;
    box-shadow: inset 4px 0 0 var(--brand);
}

input, select, textarea, button {
    font-family: inherit;
}

input, select, textarea {
    border: 1px solid var(--border);
    background: #fff;
    border-radius: 8px;
    padding: 8px 10px;
    font-size: 14px;
}

button {
    border: 1px solid var(--border);
    background: var(--surface-muted);
    color: var(--text);
    border-radius: 8px;
    padding: 8px 10px;
    font-size: 13px;
    cursor: pointer;
}

button:hover { background: #eef3ff; }
button:disabled { opacity: 0.55; cursor: not-allowed; }

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

.btn-primary:hover { background: var(--brand-strong); }

.btn-danger {
    background: var(--danger-bg);
    color: var(--danger);
    border-color: #fecdca;
}

.muted { color: var(--muted); }

a.email-link {
    color: blue;
    text-decoration: underline;
    cursor: pointer;
}
a.email-link:hover {
    color: darkblue;
}

.ww-comm-ops-line { margin: 4px 0; font-size: 13px; line-height: 1.45; }
.ww-comm-ops-line--ok { color: #15803d; font-weight: 600; }
.ww-comm-ops-line--warn { color: #92400e; }
.ww-comm-ops-muted { color: var(--muted); font-size: 12px; margin: 0; }
.ww-comm-ops-hint { font-size: 12px; color: #92400e; margin: 6px 0 0; line-height: 1.4; }
.ww-comm-ops-hidden { display: none !important; }
.ww-comm-ops-dim { opacity: 0.5; pointer-events: none; }
button.ww-comm-ops-dim { pointer-events: none; }
.ww-comm-transport-panel {
    margin: 0 0 10px; padding: 10px 12px; border-radius: 8px;
    border: 1px solid var(--border); background: var(--surface-muted); font-size: 13px; line-height: 1.45;
}
.ww-comm-transport-panel--ok { border-color: #bbf7d0; background: #f0fdf4; }
.ww-comm-transport-panel--warn { border-color: #fde68a; background: #fffbeb; }
.ww-comm-ops-chip { display: inline-block; font-size: 11px; font-weight: 600; padding: 3px 8px; border-radius: 999px; margin: 2px 4px 2px 0; border: 1px solid var(--border); background: var(--surface-muted); color: var(--muted); }
.ww-comm-ops-chip--ok { color: #15803d; border-color: #bbf7d0; background: #f0fdf4; }
.ww-comm-ops-chip--warn { color: #92400e; border-color: #fde68a; background: #fffbeb; }
.ww-comm-cap-strip {
    display: flex; flex-wrap: wrap; gap: 6px; align-items: center;
    margin: 0 0 8px; font-size: 12px; line-height: 1.4;
}
.ww-comm-cap-chip {
    display: inline-block; padding: 4px 10px; border-radius: 999px;
    border: 1px solid var(--border); background: var(--surface-muted); color: var(--muted);
    font-weight: 600; white-space: nowrap;
}
.ww-comm-cap-chip--ok { color: #15803d; border-color: #bbf7d0; background: #f0fdf4; }
.ww-comm-cap-chip--warn { color: #92400e; border-color: #fde68a; background: #fffbeb; }
.inv-po-chain {
    display: flex; flex-wrap: wrap; align-items: center; gap: 4px 6px;
    margin-top: 8px; font-size: 11px; color: var(--muted);
}
.inv-po-chain-step {
    padding: 3px 8px; border-radius: 999px; border: 1px solid var(--border);
    background: var(--surface-muted); font-weight: 600;
}
.inv-po-chain-step--done { color: #15803d; border-color: #bbf7d0; background: #f0fdf4; }
.inv-po-chain-arrow { color: var(--muted); font-size: 10px; user-select: none; }
.pto-notice-line { font-size: 12px; margin-top: 4px; color: var(--muted); }
.pto-notice-line--ok { color: #15803d; }
.pto-notice-line--warn { color: #92400e; }

/* Communication Setup (users.html) — compact operational layout */
.ww-comm-setup { font-size: 13px; line-height: 1.45; }
.ww-comm-setup-lead { font-size: 12px; margin: 0 0 8px; line-height: 1.45; color: var(--muted); }
.ww-comm-setup-top {
    display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between;
    gap: 8px; margin: 0 0 12px;
}
.ww-comm-advanced-link {
    font-size: 12px; font-weight: 600; color: var(--brand, #2563eb); text-decoration: none;
}
.ww-comm-advanced-link:hover { text-decoration: underline; }
.ww-comm-health-chip {
    display: inline-block; font-size: 11px; font-weight: 650; padding: 4px 10px;
    border-radius: 999px; border: 1px solid var(--border); background: var(--surface-muted);
}
.ww-comm-health-chip--ok { color: #15803d; border-color: #bbf7d0; background: #f0fdf4; }
.ww-comm-health-chip--warn { color: #92400e; border-color: #fde68a; background: #fffbeb; }
.ww-comm-health-chip--off { color: #64748b; border-color: #cbd5e1; background: #f1f5f9; }
.ww-comm-health-chip--muted { color: var(--muted); }
.ww-comm-provider-row { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 8px; margin-bottom: 6px; }
.ww-comm-setup-field--grow { flex: 1 1 12rem; min-width: 10rem; }
.ww-comm-provider-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 4px 0 0; }
.ww-comm-test-msg { font-size: 11px; max-width: 100%; }
.ww-comm-setup-section { margin: 0 0 12px; padding: 0 0 10px; border-bottom: 1px solid var(--border); }
.ww-comm-setup-section:last-of-type { border-bottom: none; padding-bottom: 0; }
.ww-comm-setup-h {
    margin: 0 0 6px; font-size: 11px; font-weight: 800; letter-spacing: 0.06em;
    text-transform: uppercase; color: var(--muted);
}
.ww-comm-setup-meta { margin: 0 0 8px; font-size: 11px; color: var(--muted); }
.ww-comm-setup-status { margin: 0 0 8px; font-size: 12px; }
.ww-comm-setup-status-details { margin: 0; }
.ww-comm-setup-status-details summary { cursor: pointer; list-style: none; }
.ww-comm-setup-status-details summary::-webkit-details-marker { display: none; }
.ww-comm-setup-status-head { margin: 0; font-weight: 650; }
.ww-comm-setup-status-head--ok { color: #15803d; }
.ww-comm-setup-status-head--warn { color: #92400e; }
.ww-comm-setup-status-count { font-weight: 500; color: var(--muted); font-size: 11px; }
.ww-comm-setup-status-body { margin: 6px 0 0; padding: 6px 8px; border-radius: 6px; background: var(--surface-muted); }
.ww-comm-setup-status-body .ww-comm-ops-line { margin: 0 0 3px; font-size: 11px; }
.ww-comm-setup-check {
    display: inline-flex; align-items: center; gap: 6px; margin: 0 0 8px;
    font-size: 12px; font-weight: 600; cursor: pointer;
}
.ww-comm-setup-check input { width: auto; min-height: auto; height: auto; margin: 0; }
.ww-comm-setup-check--inline { margin: 0 0 0 8px; font-weight: 500; font-size: 11px; }
.ww-comm-setup-grid {
    display: grid; grid-template-columns: 1fr 1fr; gap: 6px 10px;
}
.ww-comm-setup-field { display: flex; flex-direction: column; gap: 2px; margin: 0; font-size: 11px; color: var(--muted); }
.ww-comm-setup-field span { font-weight: 600; }
.ww-comm-setup-field input,
.ww-comm-setup-field select {
    width: 100%; box-sizing: border-box; padding: 5px 8px; font-size: 13px;
    min-height: 32px; border-radius: 6px; border: 1px solid var(--border);
}
.ww-comm-setup-field--full { grid-column: 1 / -1; }
.ww-comm-setup-field--port { grid-column: 1 / -1; }
.ww-comm-setup-field--port input[type="number"] { width: 5rem; display: inline-block; }
.ww-comm-transport-panel {
    display: flex; flex-wrap: wrap; gap: 4px 12px; margin: 6px 0 8px;
    padding: 6px 8px; border-radius: 6px; font-size: 11px; line-height: 1.4;
    border: 1px solid var(--border); background: var(--surface-muted);
}
.ww-comm-transport-panel--ok { border-color: #bbf7d0; background: #f0fdf4; }
.ww-comm-transport-panel--warn { border-color: #fde68a; background: #fffbeb; }
.ww-comm-setup-advanced { margin: 4px 0 0; font-size: 12px; }
.ww-comm-setup-advanced summary {
    cursor: pointer; font-weight: 600; color: var(--muted); padding: 4px 0;
    list-style: none;
}
.ww-comm-setup-advanced summary::-webkit-details-marker { display: none; }
.ww-comm-routing-details {
    margin: 0 0 12px;
    padding: 0 0 10px;
    border-bottom: 1px solid var(--border);
}
.ww-comm-routing-summary {
    cursor: pointer;
    list-style: none;
    margin: 0 0 8px;
    user-select: none;
}
.ww-comm-routing-summary::-webkit-details-marker { display: none; }
.ww-comm-routing-summary::before {
    content: '▸';
    display: inline-block;
    margin-right: 6px;
    font-size: 11px;
    color: var(--muted);
    transition: transform 0.15s ease;
}
.ww-comm-routing-details[open] > .ww-comm-routing-summary::before { transform: rotate(90deg); }
.ww-comm-smtp-fields { display: grid; gap: 6px; margin-top: 8px; padding-top: 8px; border-top: 1px dashed var(--border); }
.ww-comm-smtp-test { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 4px; }
.ww-comm-setup-footer {
    display: flex; flex-wrap: wrap; align-items: center; gap: 8px;
    margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--border);
}
.ww-notify-route-channels { display: none; }
.ww-notify-route-table {
    display: flex; flex-direction: column; gap: 0;
    border: 1px solid var(--border); border-radius: 8px; overflow: hidden; background: #fff;
}
.ww-notify-route-row { border-bottom: 1px solid var(--border); }
.ww-notify-route-row:last-child { border-bottom: none; }
.ww-notify-route-row-toggle {
    display: grid; grid-template-columns: minmax(6rem, 1fr) auto auto minmax(4.5rem, 1fr) auto;
    align-items: center; gap: 6px 8px; width: 100%; border: none; background: transparent;
    padding: 7px 10px; cursor: pointer; text-align: left; font: inherit; color: inherit;
    min-height: 34px; box-sizing: border-box;
}
.ww-notify-route-row-toggle:hover { background: #f8fafc; }
.ww-notify-route-row-main { display: contents; }
.ww-notify-route-row-title { font-weight: 600; font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ww-notify-route-row-pills { display: contents; }
.ww-notify-route-pill {
    font-size: 10px; font-weight: 600; padding: 3px 8px; border-radius: 999px;
    background: #f1f5f9; color: #64748b; border: 1px solid #e2e8f0; white-space: nowrap;
}
.ww-notify-route-pill.is-on { color: #15803d; border-color: #bbf7d0; background: #f0fdf4; }
.ww-notify-route-row-recip {
    font-size: 11px; color: var(--muted); text-align: right; overflow: hidden;
    text-overflow: ellipsis; white-space: nowrap;
}
.ww-notify-route-row-names { font-weight: 600; color: var(--text); }
.ww-notify-route-status { display: none; }
.ww-notify-route-row-caret { font-size: 11px; color: var(--muted); justify-self: end; }
.ww-notify-route-row-body { padding: 8px 10px 10px; border-top: 1px dashed var(--border); background: #fafbfc; }
.ww-notify-route-row-help { margin: 8px 0 6px; font-size: 11px; color: var(--muted); line-height: 1.4; }
.ww-notify-route-chip-list { display: flex; flex-direction: column; gap: 6px; margin-bottom: 8px; }
.ww-notify-route-rec-chip {
    display: flex; flex-wrap: wrap; align-items: center; gap: 4px 6px;
    padding: 6px 8px; border-radius: 6px; border: 1px solid var(--border); background: #fff;
}
.ww-notify-route-chip {
    display: inline-flex; align-items: center; padding: 2px 8px; border-radius: 999px;
    font-size: 10px; font-weight: 700; border: 1px solid var(--border); background: #f8fafc;
    color: #475569; line-height: 1.3;
}
.ww-notify-route-chip--name { background: #eef2ff; border-color: #c7d2fe; color: #3730a3; font-size: 11px; }
.ww-notify-route-chip--toggle { cursor: pointer; opacity: 0.65; }
.ww-notify-route-chip--toggle.is-on { opacity: 1; background: #ecfdf5; border-color: #a7f3d0; color: #065f46; }
.ww-notify-route-chip--remove {
    margin-left: auto; cursor: pointer; border-radius: 4px; padding: 0 6px;
    background: transparent; font-size: 14px; line-height: 1.2;
}
.ww-notify-route-chip--remove:hover { background: #fee2e2; border-color: #fecaca; color: #991b1b; }
.ww-notify-sms-fields { display: inline-flex; flex-wrap: wrap; gap: 4px; width: 100%; }
.ww-notify-sms-fields input {
    flex: 1 1 6rem; min-width: 5rem; padding: 4px 6px; font-size: 11px;
    border-radius: 4px; border: 1px solid var(--border);
}
.ww-notify-route-add {
    display: flex; flex-wrap: wrap; gap: 6px; align-items: center;
}
.ww-notify-route-add select {
    flex: 1 1 10rem; min-height: 30px; font-size: 12px; padding: 4px 6px; border-radius: 6px;
}
.ww-notify-route-autosave { font-size: 10px; }
.ww-notify-route-save-inline {
    font-size: 11px; padding: 4px 8px; border-radius: 6px; border: 1px solid var(--border);
    background: var(--surface); cursor: pointer; color: var(--muted);
}
.ww-notify-route-save-inline:hover { background: #f1f5f9; }
.ww-notify-route-statusline { margin: 6px 0 0; font-size: 11px; min-height: 1em; }
.ww-notify-route-empty { margin: 8px 10px; font-size: 12px; }
@media (max-width: 720px) {
    .ww-comm-setup-grid { grid-template-columns: 1fr; }
    .ww-notify-route-row-toggle {
        grid-template-columns: 1fr auto auto auto;
        grid-template-rows: auto auto;
    }
    .ww-notify-route-row-title { grid-column: 1 / -1; }
    .ww-notify-route-row-recip { grid-column: 1 / 3; text-align: left; }
    .ww-notify-route-add select, .ww-notify-route-add .btn-small { width: 100%; }
}

/* ===== Mobile / Phone friendly (all pages) ===== */
html {
    -webkit-text-size-adjust: 100%;
}
body {
    overflow-x: hidden;
}
.container {
    padding-left: 12px;
    padding-right: 12px;
}
/* Table horizontal scroll on narrow screens */
.table-wrap,
.inv-table-wrap,
.audit-table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin-bottom: 12px;
}
table.data-rows,
table {
    min-width: 420px;
}
@media (max-width: 640px) {
    .nav { padding: 8px 10px; gap: 6px; }
    .nav-links { gap: 6px; }
    .nav a, .nav button { padding: 6px 8px; font-size: 12px; }
    .nav-logo-img { max-height: 32px; max-width: 140px; }
    .logo-fallback { font-size: 14px; }
    .container { padding: 10px 10px 20px; }
    .container h1, .container h2 { font-size: 1.25rem; }
    table.data-rows th, table.data-rows td,
    th, td { padding: 7px 8px; font-size: 13px; }
    .dashboard-grid { grid-template-columns: 1fr; gap: 10px; }
    .dash-card { min-height: 80px; padding: 12px; }
    .dash-card .value { font-size: 22px; }
    .card { padding: 12px; }
}
@media (max-width: 480px) {
    .nav { flex-direction: column; align-items: stretch; }
    .nav-user { margin-left: 0; justify-content: flex-start; }
    .nav-username { max-width: 140px; }
    .container { padding: 8px 8px 16px; }
    table.data-rows th, table.data-rows td,
    th, td { padding: 6px 6px; font-size: 12px; }
}
/* Toolbar/row wrappers */
.toolbar, .row, .form-row, .actions {
    flex-wrap: wrap;
}
.toolbar input, .toolbar select {
    min-width: 120px;
    max-width: 100%;
}
/* Jobs / associates / invoice list headers: buttons + filter on one row; select not full-width */
.toolbar .header-controls {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    min-width: 0;
}
.toolbar .header-controls select,
.toolbar .header-controls select.header-filter {
    width: auto !important;
    max-width: 200px;
    min-width: 6.5rem;
    flex: 0 1 auto;
    display: inline-block;
}
.toolbar .header-controls label.muted {
    display: inline !important;
    margin: 0 !important;
    flex-shrink: 0;
    white-space: nowrap;
}
/* Cards/modals full width on mobile */
.card-body, .work-card, .pwd-dialog {
    width: min(92vw, 560px) !important;
    max-width: 92vw;
}
/* Form inputs full width on small screens */
@media (max-width: 480px) {
    .form-row input, .form-row select { min-width: 0; width: 100%; }
    .pw-field input { min-width: 0; width: 100%; }
    .panel { padding: 12px; }
}

/* Global unsaved-changes modal (assets/js/unsaved_changes.js) */
.ww-unsaved-modal {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 200000;
    align-items: center;
    justify-content: center;
    padding: 16px;
    background: rgba(15, 23, 42, 0.45);
    box-sizing: border-box;
}
.ww-unsaved-modal-box {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 20px 22px;
    max-width: 420px;
    width: 100%;
    box-shadow: 0 20px 40px rgba(15, 23, 42, 0.18);
}
.ww-unsaved-modal-box h3 {
    margin: 0 0 10px;
    font-size: 1.15rem;
}
.ww-unsaved-msg {
    margin: 0 0 18px;
    line-height: 1.45;
    font-size: 15px;
    color: var(--text);
}
.ww-unsaved-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: flex-end;
}
.ww-unsaved-actions button {
    min-height: 44px;
    padding: 10px 16px;
}
button.ww-unsaved-dirty,
.btn-primary.ww-unsaved-dirty {
    box-shadow: 0 0 0 2px rgba(31, 78, 216, 0.5);
}

/* Scheduling menu: right-click logo to open (no toolbar button) */
.logo .nav-scheduling {
    position: absolute;
    left: 0;
    top: 100%;
    margin-top: 4px;
    z-index: 50;
}
.nav-scheduling-menu {
    display: none;
    position: absolute;
    left: 0;
    top: 0;
    min-width: 11rem;
    padding: 6px 0;
    margin: 0;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    box-shadow: var(--shadow);
    z-index: 30;
}
.nav-scheduling.open .nav-scheduling-menu {
    display: block;
}
.nav-scheduling-menu a {
    display: block;
    padding: 8px 14px;
    font-size: 14px;
    font-weight: 500;
    text-decoration: none;
    color: var(--text);
    border: none;
    background: transparent;
    border-radius: 0;
}
.nav-scheduling-menu a:hover {
    background: var(--surface-muted);
}

/* Measure UI — bordered section groups (opening card, etc.) */
.ms-group-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    align-items: start;
}
@media (max-width: 720px) {
    .ms-group-grid {
        grid-template-columns: 1fr;
    }
    #ms_opening_card_hd .ms-lower-grid {
        grid-column: 1;
        grid-template-columns: 1fr;
    }
    #ms_opening_card_hd .ms-lower-grid .ms-box-model,
    #ms_opening_card_hd .ms-lower-grid .ms-box-oriel,
    #ms_opening_card_hd .ms-lower-grid .ms-box-trim,
    #ms_opening_card_hd .ms-lower-grid .ms-box-mull {
        grid-column: 1;
        grid-row: auto;
    }
}
.ms-group-box {
    border: 1px solid #d1d5db;
    border-radius: 6px;
    padding: 6px 8px;
    margin-bottom: 6px;
    background: #fafafa;
    width: 100%;
    min-width: 0;
    overflow: hidden;
    box-sizing: border-box;
}
.ms-group-box * {
    font-family: inherit;
}
.ms-group-box h3,
.ms-group-box .title,
.ms-group-box .header,
.ms-group-title {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    color: #5b6b7c;
    margin-bottom: 6px;
}
.ms-group-box label {
    font-size: 12px;
    font-weight: 600;
    color: #2a3a4a;
    margin-bottom: 2px;
}
.ms-group-box input {
    font-size: 13px;
    font-weight: 400;
}
.ms-group-box select {
    font-size: 13px;
    font-weight: 400;
    height: 32px;
    line-height: 32px;
    padding-top: 0;
    padding-bottom: 0;
    padding-left: 10px;
    padding-right: 28px;
    display: flex;
    align-items: center;
}
.ms-group-box .radio,
.ms-group-box .toggle,
.ms-group-box small,
.ms-group-box .ms-measure-radio,
.ms-group-box .ms-osize {
    font-size: 12px;
}
.ms-radio-row {
    display: flex;
    gap: 10px;
    margin-top: 4px;
}
.ms-osize {
    margin-top: 6px;
    font-size: 12px;
}

/* Opening card: compact controls + scroll (measure UI) */
#ms_opening_card_hd .ms-card-body {
    max-height: 75vh;
    min-height: 0;
    overflow-y: auto;
}
#ms_opening_card_hd .ms-card-body input:not([type='checkbox']):not([type='radio']):not([type='hidden']):not([type='image']),
#ms_opening_card_hd .ms-card-body select {
    box-sizing: border-box;
}
#ms_opening_card_hd .ms-card-body input:not([type='checkbox']):not([type='radio']):not([type='hidden']):not([type='image']) {
    height: 30px;
    font-size: 13px;
}
#ms_opening_card_hd .ms-card-body select {
    height: 32px;
    line-height: 32px;
    padding-top: 0;
    padding-bottom: 0;
    padding-left: 10px;
    padding-right: 28px;
    font-size: 13px;
    display: flex;
    align-items: center;
}
#ms_opening_card_hd .ms-group-grid > .ms-hd-color-cell {
    display: flex;
    flex-direction: column;
    min-height: 0;
}
#ms_opening_card_hd .ms-group-grid > .ms-hd-color-cell > .ms-group-box {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
}
#ms_opening_card_hd .ms-group-grid > .ms-group-box {
    min-height: 0;
}
#ms_opening_card_hd .ms-group-grid > .ms-lower-grid {
    grid-column: 1 / -1;
    min-width: 0;
}
.ms-lower-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    align-items: start;
}
.ms-lower-grid > .ms-group-box {
    margin-bottom: 0;
}
.ms-lower-grid .ms-box-model {
    grid-column: 1;
    grid-row: 1;
}
.ms-lower-grid .ms-box-oriel {
    grid-column: 2;
    grid-row: 1;
}
.ms-lower-grid .ms-box-trim {
    grid-column: 1;
    grid-row: 2;
}
.ms-lower-grid .ms-box-mull {
    grid-column: 2;
    grid-row: 2;
}

.ms-group-grid > *,
.ms-lower-grid > * {
    min-width: 0;
}

/* Rows with control + ? ref button — shrink middle, fixed button (measure/index has competing inline rules) */
.ms-input-row,
.ms-field {
    display: flex;
    align-items: center;
    gap: 6px;
    min-width: 0;
}
#ms_opening_card_hd .ms-field input {
    flex: 1;
    min-width: 0;
    width: 100%;
}

#ms_opening_card_hd .ms-meas-row {
    display: flex;
    align-items: center;
    gap: 6px;
    min-width: 0;
}
#ms_opening_card_hd .ms-meas-row input.ms-meas-decimal {
    flex: 1;
    min-width: 0 !important;
    width: 100% !important;
    max-width: 100%;
}
#ms_opening_card_hd .ms-meas-row .ms-meas-ref-btn {
    flex: 0 0 auto;
    width: 26px !important;
    height: 26px !important;
}
#ms_opening_card_hd .ms-size-row {
    grid-template-columns: 110px minmax(0, 1fr) auto !important;
    min-width: 0;
}
#ms_opening_card_hd .ms-input-wrap {
    min-width: 0 !important;
    max-width: 100%;
}
#ms_opening_card_hd .ms-input-wrap input.ms-num-input,
#ms_opening_card_hd .ms-input-wrap input.ms-meas-decimal {
    min-width: 0 !important;
    max-width: 100% !important;
}
#ms_opening_card_hd .ms-help.ms-meas-ref-btn {
    flex-shrink: 0 !important;
    width: 26px !important;
    height: 26px !important;
    margin-left: 0 !important;
}

/* Photo Admin — save options modal (above PA editor z-index ~26000) */
.pa-modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 30000;
}

.pa-modal.hidden {
    display: none;
}

.pa-modal-card {
    background: #fff;
    border-radius: 10px;
    padding: 16px;
    width: 320px;
    max-width: calc(100vw - 32px);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    color: var(--text);
}

.pa-modal-title {
    font-weight: 600;
    margin-bottom: 10px;
}

.pa-modal-body {
    font-size: 14px;
}

.pa-radio {
    display: block;
    margin: 6px 0;
    cursor: pointer;
}

.pa-radio input {
    margin-right: 8px;
    vertical-align: middle;
}

.pa-modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 12px;
}

.btn-secondary {
    background: var(--surface-muted);
    color: var(--text);
    border: 1px solid var(--border);
}

.btn-secondary:hover {
    background: #eef3ff;
}

/* Measure Admin — simple dropdown lists */
.sl-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
    align-items: start;
}

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

.sl-box {
    border: 1px solid #d5dde5;
    border-radius: 8px;
    margin-bottom: 12px;
    padding: 10px 12px;
}

.sl-box.sl-full {
    margin-bottom: 14px;
}

.sl-grid .sl-box {
    margin-bottom: 0;
}

.sl-box h3 {
    margin: 0 0 6px 0;
    font-size: 13px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.02em;
    color: #5b6b7c;
}

.sl-box label {
    font-weight: 600;
    font-size: 12px;
    text-transform: uppercase;
    margin-bottom: 4px;
    display: block;
    color: #5b6b7c;
    letter-spacing: 0.02em;
}

.sl-box label.sl-color-label {
    text-transform: none;
    letter-spacing: normal;
    color: var(--text);
    font-size: 13px;
}

.sl-dropdown,
.sl-box select {
    width: 100%;
    height: 34px;
    line-height: 34px;
    padding: 4px 10px;
    font-size: 14px;
    box-sizing: border-box;
}

.sl-dropdown {
    width: 100%;
    max-width: 100%;
    border: 1px solid #d5dde5;
    border-radius: 6px;
    background: #fff;
    color: var(--text);
}

.sl-dropdown:focus {
    outline: none;
    border-color: var(--brand, #5c4d7a);
    box-shadow: 0 0 0 1px rgba(92, 77, 122, 0.2);
}

input.sl-inline-input {
    width: 100%;
    max-width: 100%;
    height: 32px;
    padding: 4px 10px;
    font-size: 14px;
    line-height: 1.2;
    box-sizing: border-box;
    border: 1px solid #d5dde5;
    border-radius: 6px;
    background: #fff;
    color: var(--text);
}

input.sl-inline-input:focus {
    outline: none;
    border-color: var(--brand, #5c4d7a);
    box-shadow: 0 0 0 1px rgba(92, 77, 122, 0.2);
}

.sl-dropdown option.sl-opt-default {
    font-weight: 600;
}

.sl-row {
    display: flex;
    align-items: center;
    margin-bottom: 4px;
}

.sl-row.default .sl-input {
    border-color: var(--brand, #5c4d7a);
    box-shadow: 0 0 0 1px rgba(92, 77, 122, 0.2);
}

.sl-row.sl-color-defaults {
    flex-wrap: wrap;
    align-items: flex-end;
    justify-content: flex-start;
    gap: 12px;
    margin-bottom: 0;
}

.sl-color-label {
    flex: 1;
    min-width: 140px;
    font-size: 13px;
    color: var(--text);
}

.sl-input {
    flex: 1;
    min-width: 0;
    height: 26px;
    padding: 2px 6px;
    font-size: 13px;
    border: 1px solid #d5dde5;
    border-radius: 6px;
    box-sizing: border-box;
    background: #fff;
}

.sl-input:read-only {
    background: var(--surface-muted);
    color: var(--muted);
}

@media (max-width: 768px) {
    .sl-grid {
        grid-template-columns: 1fr;
    }
}

/* --- Photos gallery (/photos/index.html) — mobile / tablet --- */
body.cg-page .pg-hidden {
    display: none !important;
}

/* Shared top bar: gallery + slide viewer */
body.cg-page .pg-topbar,
body.cg-page .pg-viewer-topbar {
    /* 48px back column, flexible center (logo absolutely centered in row), auto actions */
    grid-template-columns: 48px 1fr auto;
    align-items: center;
    position: relative;
    box-sizing: border-box;
}

body.cg-page .pg-topbar {
    display: none;
    gap: 0;
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding-top: 4px;
}

body.cg-page .pg-topbar .pg-back,
body.cg-page .pg-topbar .pg-topbar-back,
body.cg-page .pg-viewer-topbar .pg-back {
    grid-column: 1;
    justify-self: start;
    z-index: 2;
}

body.cg-page .pg-topbar .pg-logo,
body.cg-page .pg-viewer-topbar .pg-logo {
    grid-column: 2;
    justify-self: center;
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1;
    pointer-events: none;
}

body.cg-page .pg-topbar .pg-actions,
body.cg-page .pg-viewer-topbar .pg-actions {
    grid-column: 3;
    justify-self: end;
    z-index: 2;
    min-width: 0;
}

body.cg-page .pg-head-spacer {
    grid-column: 1;
    width: 48px;
    min-width: 48px;
    justify-self: start;
    z-index: 0;
    pointer-events: none;
}

body.cg-page .pg-topbar-back,
body.cg-page .pg-topbar .pg-back {
    color: #94a3b8;
    text-decoration: none;
    font-size: 1.1rem;
    font-weight: 600;
    padding: 6px 4px;
}

body.cg-page .pg-topbar-back:hover,
body.cg-page .pg-topbar .pg-back:hover {
    color: #f1f5f9;
}

body.cg-page .pg-store-logo,
body.cg-page .pg-logo {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    object-fit: contain;
    background: #1e293b;
}

body.cg-page .pg-actions {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
}

body.cg-page .cg-desktop-modal-head.pg-viewer-topbar .pg-actions {
    flex-wrap: nowrap;
}

body.cg-page .cg-desktop-modal-head.pg-viewer-topbar #cg_mod_title {
    text-align: right;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: min(200px, 28vw);
}

body.cg-page .pg-topbar-actions-wrap {
    position: relative;
    flex-shrink: 0;
}

body.cg-page .pg-topbar-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

body.cg-page .pg-dropdown {
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    min-width: 200px;
    max-width: min(92vw, 280px);
    background: #1e2a38;
    border-radius: 8px;
    padding: 6px;
    z-index: 1000;
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.45);
    border: 1px solid #334155;
}

body.cg-page .pg-dropdown-item {
    padding: 8px 12px;
    cursor: pointer;
    border-radius: 6px;
    font-size: 0.88rem;
    color: #e2e8f0;
}

body.cg-page .pg-dropdown-item:hover {
    background: #3f5a75;
}

body.cg-page .pg-dropdown-item--on {
    background: #2563eb;
    color: #fff;
}

body.cg-page .pg-dropdown-item--on:hover {
    background: #3b82f6;
}

body.cg-page .pg-topbar-btn {
    padding: 8px 10px;
    border-radius: 8px;
    border: 1px solid #334155;
    background: #1e293b;
    color: #e2e8f0;
    font-size: 0.78rem;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
    white-space: nowrap;
}

body.cg-page .pg-topbar-btn:hover {
    border-color: #475569;
    background: #334155;
}

/* Filter panel components (mobile category picker) */
body.cg-page .pg-filter-search-wrap {
    padding: 8px 8px 4px;
    flex-shrink: 0;
}

body.cg-page .pg-filter-search {
    width: 100%;
    padding: 10px 12px;
    border-radius: 8px;
    border: 1px solid #334155;
    background: #0f172a;
    color: #e2e8f0;
    font-size: 0.9rem;
    box-sizing: border-box;
    font-family: inherit;
}

body.cg-page .pg-filter-search::placeholder {
    color: #64748b;
}

body.cg-page .pg-filter-search:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.15);
}

body.cg-page .pg-filter-list {
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    flex: 1 1 auto;
    min-height: 0;
    padding: 2px 0;
}

body.cg-page .pg-filter-divider {
    height: 1px;
    background: #334155;
    margin: 4px 8px;
    flex-shrink: 0;
}

body.cg-page .pg-filter-loc-wrap {
    padding: 4px 8px 2px;
    flex-shrink: 0;
}

body.cg-page .pg-filter-loc-label {
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    color: #64748b;
    text-transform: uppercase;
    padding: 0 4px 4px;
    display: block;
}

body.cg-page .pg-filter-loc {
    width: 100%;
    padding: 10px 12px;
    border-radius: 8px;
    border: 1px solid #334155;
    background: #0f172a;
    color: #e2e8f0;
    font-size: 0.9rem;
    box-sizing: border-box;
    font-family: inherit;
}

body.cg-page .pg-filter-loc::placeholder {
    color: #64748b;
}

body.cg-page .pg-filter-loc:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.15);
}

body.cg-page .pg-filter-clear-wrap {
    padding: 4px 8px 8px;
    flex-shrink: 0;
}

body.cg-page .pg-filter-clear-btn {
    width: 100%;
    padding: 10px;
    border-radius: 8px;
    border: 1px solid #475569;
    background: #334155;
    color: #f8fafc;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
}

body.cg-page .pg-filter-clear-btn:hover {
    background: #475569;
}

body.cg-page .pg-filter-empty {
    padding: 16px 12px;
    text-align: center;
    color: #64748b;
    font-size: 0.85rem;
}

body.cg-page .pg-viewer-topbar.cg-mobile-modal-head {
    display: none;
    padding: 6px 10px;
    border-bottom: 1px solid #334155;
    flex-shrink: 0;
}

body.cg-page .cg-mod-head.pg-viewer-topbar {
    display: grid;
}

body.cg-page .pg-viewer-topbar .pg-viewer-back,
body.cg-page .pg-viewer-topbar button.pg-back {
    padding: 6px 10px;
    border-radius: 8px;
    border: 1px solid #475569;
    background: #334155;
    color: #f8fafc;
    cursor: pointer;
    font-weight: 600;
    font-size: 1rem;
    font-family: inherit;
    pointer-events: auto;
}

body.cg-page .pg-viewer-topbar .pg-viewer-back:hover,
body.cg-page .pg-viewer-topbar button.pg-back:hover {
    background: #475569;
}

body.cg-page .pg-viewer-topbar.cg-mobile-modal-head #pg-current-cat {
    text-align: right;
    font-size: 0.8rem;
    color: #94a3b8;
    line-height: 1.25;
    max-width: 42vw;
    overflow: hidden;
    text-overflow: ellipsis;
}

body.cg-page #pg-viewer {
    touch-action: none;
}

body.cg-page.cg-modal-open {
    overflow: hidden;
    touch-action: none;
}

@media (max-width: 900px) {
    body.cg-page .cg-desktop-top {
        display: none !important;
    }

    body.cg-page .pg-topbar {
        display: grid;
    }

    body.cg-page .cg-chips {
        display: none !important;
    }

    body.cg-page .cg-loc-row {
        display: none !important;
    }

    body.cg-page .pg-dropdown {
        max-width: min(92vw, 380px);
        min-width: min(80vw, 320px);
        max-height: 70vh;
        overflow: hidden;
        display: flex;
        flex-direction: column;
        padding: 0;
    }

    body.cg-page .pg-dropdown.pg-hidden {
        display: none !important;
    }

    body.cg-page .pg-dropdown .pg-dropdown-item {
        padding: 11px 14px;
        font-size: 0.92rem;
    }

    body.cg-page .pg-filter-search,
    body.cg-page .pg-filter-loc {
        font-size: 16px;
    }

    body.cg-page .pg-viewer-topbar.cg-mobile-modal-head {
        display: grid;
    }

    body.cg-page .cg-desktop-modal-head {
        display: none !important;
    }

    body.cg-page #cg_modal_back.cg-open {
        padding: 0;
        background: #0b1622;
        align-items: stretch;
        justify-content: stretch;
    }

    body.cg-page #cg_modal_back.cg-open #cg_modal {
        flex: 1 1 auto;
        width: 100%;
        min-height: 0;
        height: 100%;
        max-width: none;
        max-height: none;
        border-radius: 0;
        border: none;
        box-shadow: none;
    }

    body.cg-page #cg_modal_back.cg-open #pg-viewer {
        flex: 1;
        min-height: 0;
        overflow: hidden;
        touch-action: none;
    }

    body.cg-page #cg_modal_back.cg-open #cg_mod_body {
        overflow: hidden !important;
        flex: 1;
        min-height: 0;
        max-height: none;
        touch-action: none;
    }

    body.cg-page #cg_modal_back.cg-open #cg_mod_body img.cg-full {
        max-width: 100%;
        max-height: min(85dvh, calc(100dvh - 140px));
        width: auto;
        height: auto;
        object-fit: contain;
        touch-action: none;
    }

    body.cg-page #cg_modal_back.cg-open #cg_mod_body .cg-pair-scroll {
        max-height: min(85dvh, calc(100dvh - 140px));
        touch-action: pan-x pinch-zoom;
        -webkit-overflow-scrolling: touch;
    }

    body.cg-page #cg_modal_back.cg-open #cg_mod_body .cg-pair-pane img {
        touch-action: none;
    }
}

/* ----- Operational nearby context (bounded “around this time” strip) ----- */
.op-nearby-pack {
    margin: 14px 0;
    padding: 0;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--surface-muted);
}
.op-nearby-sum-btn {
    list-style: none;
    cursor: pointer;
    padding: 12px 14px;
    font-size: 14px;
    font-weight: 650;
    color: var(--muted);
    line-height: 1.45;
}
.op-nearby-sum-btn::-webkit-details-marker { display: none; }
.op-nearby-sum-sub {
    display: block;
    font-size: 12px;
    font-weight: 500;
    margin-top: 4px;
    color: var(--muted);
    opacity: 0.92;
}
.op-nearby-inner { padding: 0 12px 12px; }
.op-nearby-note { font-size: 12px; line-height: 1.45; margin: 0 0 8px; }
.op-nearby-status { line-height: 1.45; }
.op-nearby-err { color: #b91c1c; }
.op-nearby-row {
    padding: 10px 0;
    border-top: 1px solid var(--border);
    font-size: 14px;
    line-height: 1.45;
}
.op-nearby-row:first-of-type { border-top: none; padding-top: 2px; }
.op-nearby-sum { font-weight: 600; word-break: break-word; }
.op-nearby-meta { font-size: 12px; margin-top: 4px; }
.op-nearby-rhythm {
    font-size: 12px;
    color: var(--muted);
    font-style: italic;
    margin-top: 6px;
    line-height: 1.4;
}
.op-nearby-links {
    margin-top: 8px;
    display: flex;
    flex-wrap: wrap;
    gap: 6px 12px;
    font-size: 13px;
}
.op-nearby-links a {
    color: var(--brand, #2563eb);
    font-weight: 600;
    text-decoration: none;
}
.op-nearby-links a:hover { text-decoration: underline; }
