/*
 * Shared phone and tablet behaviour, loaded after each screen's stylesheet.
 *
 * Colours come from tokens.css. They used to be written in by hand here, so
 * the application changed palette below 900px and had no dark theme on a
 * phone at all. The layout rules are unchanged.
 */
[hidden] { display: none !important; }
img, svg, video { max-width: 100%; }
button, a, summary, input, select, textarea { touch-action: manipulation; }
.app-brand-row .logo { display: flex; align-items: center; min-width: 0; }
.navigation-toggle { display: none; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 9px 12px; border: 1px solid var(--line-2); border-radius: 8px; background: var(--surface); color: var(--ink); font: 600 14px/1.4 var(--sans); cursor: pointer; flex-shrink: 0; }
.navigation-toggle svg, .account-menu svg { fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex-shrink: 0; }
.navigation-toggle[aria-expanded="true"] { background: var(--surface-3); border-color: var(--brand-text); }
.app-context { min-width: 0; overflow-wrap: anywhere; }
.account-menu { position: relative; flex-shrink: 0; font: 14px/1.5 var(--sans); color: var(--ink-2); }
.account-menu > summary { list-style: none; display: flex; align-items: center; gap: 8px; cursor: pointer; min-height: 44px; padding: 8px 10px; border: 1px solid transparent; border-radius: 8px; }
.account-menu > summary::-webkit-details-marker { display: none; }
.account-menu[open] > summary { background: var(--surface-2); border-color: var(--line); }
.account-short-label { display: none; }
.account-name { max-width: 260px; overflow-wrap: anywhere; }
.account-menu-panel { position: absolute; top: calc(100% + 6px); right: 0; width: min(280px, calc(100vw - 32px)); padding: 16px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 12px 32px rgba(20, 25, 20, 0.11); z-index: 60; }
.account-menu-panel p { margin: 0 0 12px; overflow-wrap: anywhere; }
.account-menu-panel small { display: block; color: var(--ink-3); margin-top: 4px; }
.account-menu-panel > a { display: flex; align-items: center; min-height: 44px; margin-bottom: 8px; }
.account-menu-panel .btn { width: 100%; min-height: 44px; justify-content: center; }
.app-body > *, .grid > *, .billing-form-grid > *, .billing-metrics > *, .ops-split > *, .row-split > *, .row-split-even > * { min-width: 0; }
.app-body :is(h1, h2, h3, p, dd, .breadcrumb, .card-link), .messages li { overflow-wrap: anywhere; }
.table-scroll, .billing-table-wrap, .register-tabs, .ops-nav, .tabs, .ops-check-strip { overscroll-behavior-x: contain; scrollbar-width: thin; }
.table-scroll, .billing-table-wrap { position: relative; }
.table-scroll:focus-visible, .billing-table-wrap:focus-visible, .ops-check-strip:focus-visible { outline: 2px solid var(--brand-text); outline-offset: -3px; }

@media (max-width: 1100px) and (min-width: 901px) {
  .app { grid-template-columns: 210px minmax(0, 1fr); }
  .story-page .app { grid-template-columns: 200px minmax(0, 1fr); }
  .app-body, .story-page .app-body { padding: 24px; }
  .app-topbar, .story-page .app-topbar { padding-inline: 24px; }
  .account-name { max-width: 170px; }
  .billing-heading { flex-wrap: wrap; }
}

@media (max-width: 900px) {
  html { scroll-padding-top: 84px; }
  .app, .story-page .app { display: block; min-height: 100dvh; }
  .app-side, .story-page .app-side, .report-workspace .app-side {
    display: block; position: relative; inset: 0 0 auto; height: auto; overflow: visible;
    padding: 0; z-index: 50; border: 0; border-bottom: 1px solid var(--line);
    background: var(--surface); color: var(--ink);
  }
  .navigation-ready .app-side { position: sticky; }
  .app-brand-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 10px max(16px, env(safe-area-inset-right)) 10px max(16px, env(safe-area-inset-left)); min-height: 68px; }
  .app-side .app-brand-row .logo { display: flex; padding: 0; margin: 0; gap: 9px; border: 0; background: transparent; }
  .app-side .app-brand-row .logo img { width: 38px; height: 38px; flex-shrink: 0; border-radius: 50%; }
  .app-side .app-brand-row .logo .wordmark { color: var(--ink); font: 700 14px/1.5 var(--serif, Georgia, serif); letter-spacing: .04em; }
  .app-side .app-brand-row .logo .descriptor { display: block; color: var(--ink-3); font-size: 9px; margin-top: 1px; letter-spacing: .07em; }
  .navigation-toggle { display: inline-flex; }
  .app-side > .app-navigation, .story-page .app-side > .app-navigation, .report-workspace .app-side > .app-navigation { display: block; padding: 16px; }
  .navigation-ready .app-side > .app-navigation { display: none; position: absolute; inset: 100% 0 auto; max-height: calc(100dvh - 76px); overflow-y: auto; overscroll-behavior-y: contain; padding-bottom: max(20px, env(safe-area-inset-bottom)); border-bottom: 1px solid var(--line); background: var(--surface); box-shadow: 0 16px 30px rgba(20, 25, 20, 0.12); }
  .navigation-ready .app-side > .app-navigation.navigation-open { display: block; }
  .app-side .app-navigation .nav-group { margin: 0 0 18px; }
  .app-side .app-navigation .nav-group:last-child { margin-bottom: 0; }
  .app-side .app-navigation .nav-group h4 { color: var(--ink-3); font-size: 11px; margin: 0 12px 8px; }
  .app-side .app-navigation a, .story-page .app-side .app-navigation a { display: flex; align-items: center; gap: 10px; min-height: 46px; padding: 10px 12px; margin: 2px 0; border-radius: 8px; color: var(--ink-2); font-size: 15px; }
  .app-side .app-navigation a:hover, .app-side .app-navigation a[aria-current="page"] { background: var(--surface-2); color: var(--ink); border-left-color: var(--oa-green); }
  .app-side .sidebar-foot { display: none; }
  .app-topbar, .story-page .app-topbar, .report-workspace .app-topbar { position: relative; padding: 4px 16px; min-height: 52px; gap: 10px; z-index: 30; }
  .app-context { font-size: 12px; line-height: 1.5; }
  .app-context > .muted { display: none; }
  .app-context .tracking-breadcrumb { font-size: 12px; }
  .app-body, .story-page .app-body { padding: 24px max(16px, env(safe-area-inset-right)) max(28px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left)); }
  .app-body [id] { scroll-margin-top: 84px; }
  .app .grid-2 { grid-template-columns: repeat(auto-fit, minmax(min(280px, 100%), 1fr)); }
  .app .grid-3 { grid-template-columns: repeat(auto-fit, minmax(min(240px, 100%), 1fr)); }
  .app .grid-4 { grid-template-columns: repeat(auto-fit, minmax(min(200px, 100%), 1fr)); }
  .app .dimension-grid { grid-template-columns: repeat(auto-fit, minmax(min(260px, 100%), 1fr)); }
  .app :is(input, select, textarea), .story-page .register-filters select, .story-page .register-search input,
  .billing-page :is(input, select, textarea), .report-filters :is(input, select),
  .site-header ~ main :is(input, select, textarea) { font-size: 16px; max-width: 100%; }
  .app :is(input:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]), select),
  main :is(input:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]), select) { min-height: 46px; min-width: 0; }
  .app textarea { min-height: 120px; }
  input[type="file"] { width: 100%; overflow: hidden; }
  .app .google-review-form input[type="file"] { font-size: 16px; }
  input[type="checkbox"], input[type="radio"] { width: 20px; height: 20px; flex-shrink: 0; }
  .btn, .btn-small, .tracking-button, .story-actions .icon-button, .detail-heading .icon-button { min-height: 44px; min-width: 44px; justify-content: center; font-size: 14px; white-space: normal; text-align: center; }
  .story-page .app-topbar .btn { font-size: 14px; }
  :is(.tabs, .register-tabs, .ops-nav, .update-tabs) a { min-height: 46px; display: inline-flex; align-items: center; font-size: 13px; }
  .publisher-shortcuts a, .active-filters a { min-height: 36px; display: inline-flex; align-items: center; padding-block: 8px; }
  :is(.billing-pagination, .register-pagination, .report-pagination, .pagination) a { min-height: 44px; display: inline-flex; align-items: center; justify-content: center; padding: 8px 12px; }
  .billing-providers, .ops-discoveries { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .billing-heading, .record-header { flex-wrap: wrap; }
  .billing-value { overflow-wrap: anywhere; }
  .billing-provider-actions > a, .media-card footer a { min-height: 40px; display: inline-flex; align-items: center; }

  /* The public site shares the same compact, keyboard-operable disclosure. */
  .site-header { position: relative; top: 0; z-index: 50; }
  .navigation-ready .site-header { position: sticky; }
  .site-nav { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; min-height: 72px; padding-block: 12px; }
  .site-nav .logo { min-width: 0; gap: 9px; }
  .site-nav .logo img { width: 38px; height: 38px; flex-shrink: 0; }
  .site-nav .logo .wordmark { font-size: 17px; }
  .site-nav nav { flex-basis: 100%; }
  .site-nav nav ul { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 4px; width: 100%; }
  .site-nav nav a { display: flex; align-items: center; min-height: 46px; padding: 10px 12px; font-size: 16px; }
  .navigation-ready #public-navigation { display: none; position: absolute; top: 100%; left: 0; right: 0; max-height: calc(100dvh - 84px); overflow-y: auto; padding: 12px 16px 20px; background: var(--surface); border-bottom: 1px solid var(--line); box-shadow: 0 16px 30px rgba(20, 25, 20, 0.12); }
  .navigation-ready #public-navigation.navigation-open { display: block; }
  .site-footer a { display: inline-flex; align-items: center; min-height: 40px; }
}

@media (max-width: 600px) {
  .account-name { display: none; }
  .account-short-label { display: inline; }
  .account-menu > summary { padding-inline: 8px; font-size: 13px; }
  .app-context > .strong { font-size: 12px; }
  .app-context .pill { margin: 3px 0 0 !important; display: inline-block; font-size: 10px; }
  .app-body h1 { font-size: clamp(26px, 6.8vw, 33px); line-height: 1.25; letter-spacing: -.7px; }
  .app-body h2 { line-height: 1.3; }
  .app .grid, .app .dimension-grid { grid-template-columns: minmax(0, 1fr); }
  .app .kv { grid-template-columns: minmax(0, 1fr); gap: 4px; }
  .app .kv dd { margin-bottom: 12px; overflow-wrap: anywhere; }
  main .kv { grid-template-columns: minmax(0, 1fr); gap: 4px; }
  main .kv dd { margin-bottom: 12px; overflow-wrap: anywhere; }
  .app-body .truncate { white-space: normal; overflow-wrap: anywhere; }
  .app .panel { padding: 18px; }
  .app .pill { max-width: 100%; white-space: normal; }
  .app .row-between { align-items: flex-start; }
  .app .filters { flex-wrap: wrap; }
  .app .filters > * { min-width: 0; max-width: 100%; }
  .site-nav .logo .descriptor { display: none; }
  .site-nav { padding-inline: 16px; }
  .site-nav .logo .wordmark { font-size: 15px; }
  .site-nav nav ul { grid-template-columns: 1fr; }
  .section-form { padding-block: 32px 48px; }
  .section-form .panel { padding: 22px 18px; }
  .section-form .btn { width: 100%; min-height: 48px; }
  .site-footer .footer-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 28px 18px; }
  .site-footer .footer-grid > div:first-child { grid-column: 1 / -1; }
  .site-footer a { font-size: 14px; overflow-wrap: anywhere; }
  .billing-heading, .tracking-header, .report-heading { gap: 16px; margin-bottom: 22px; }
  .billing-heading p, .tracking-subtitle { font-size: 14px; line-height: 1.6; }
  .billing-actions { width: 100%; gap: 8px; }
  .billing-actions > :is(a, form) { flex: 1 1 135px; }
  .billing-actions form .btn { width: 100%; }
  .ops-nav { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0; overflow: visible; }
  .ops-nav a { padding: 10px 5px; font-size: 12px; white-space: normal; justify-content: center; text-align: center; }
  .ops-stats { gap: 10px; }
  .ops-stats > a { padding: 15px; }
  .ops-stats span { font-size: 12px; }
  .ops-stats > a:last-child:nth-child(odd) { grid-column: 1 / -1; display: flex; justify-content: space-between; align-items: center; gap: 16px; }
  .ops-stats > a:last-child:nth-child(odd) strong { margin: 0; }
  .billing-metrics { gap: 10px; }
  .billing-metric { padding: 18px; }
  .billing-value { font-size: 30px; }
  .billing-providers, .ops-discoveries { grid-template-columns: minmax(0, 1fr); padding: 0 16px 16px; }
  .billing-provider { padding: 16px; }
  .billing-provider-title h3 { font-size: 15px; line-height: 1.5; }
  .billing-account-values { flex-wrap: wrap; gap: 18px; }
  .billing-account-values strong { font-size: 22px; }
  .billing-scope { display: grid; grid-template-columns: minmax(0, 1fr); gap: 8px; }
  .billing-scope select { width: 100%; max-width: none; }
  .billing-scope button { margin-top: 4px; }
  .billing-filters { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; align-items: end; }
  .billing-filters label, .billing-filters label:first-of-type { min-width: 0; }
  .billing-filters label:first-of-type { grid-column: 1 / -1; }
  .billing-filters > button { min-width: 0; }
  .billing-section-head { gap: 12px; }
  .billing-section-note, .billing-caption { font-size: 12px; line-height: 1.65; }
  .billing-form, .billing-detail { padding: 20px 16px; }
  .billing-form-grid { gap: 22px; }
  .billing-field :is(input:not([type="checkbox"]), select, textarea) { width: 100%; }
  .billing-form-actions { gap: 10px; }
  .billing-form-actions .btn { flex: 1; }
  .billing-detail dl { grid-template-columns: minmax(0, 1fr); gap: 18px; }
  .ops-attention { padding: 18px; }
  .ops-attention-list strong { font-size: 14px; }
  .ops-attention-list span { font-size: 13px; }
  .ops-metric-row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .ops-inline-details > summary, .billing-breakdown > summary { min-height: 48px; padding: 16px; line-height: 1.6; }

  /* Cards use the existing cells and headers, so every value and action remains available. */
  :is(.app-body, .briefing-main) table.mobile-cards-ready { display: block; width: 100%; min-width: 0 !important; position: relative; }
  .mobile-cards-ready > thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0, 0, 0, 0); clip-path: inset(50%); white-space: nowrap; }
  .mobile-cards-ready > tbody { display: block; }
  :is(.app-body, .briefing-main) .mobile-cards-ready > tbody > tr { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px 18px; padding: 20px 16px; border-bottom: 1px solid var(--line); }
  :is(.app-body, .briefing-main) .mobile-cards-ready > tbody > tr:last-child { border-bottom: 0; }
  :is(.app-body, .briefing-main) .mobile-cards-ready > tbody > tr > td { display: block; min-width: 0 !important; max-width: none !important; width: auto !important; padding: 0; border: 0; white-space: normal; overflow-wrap: anywhere; font-size: 14px; line-height: 1.6; }
  .mobile-cards-ready > tbody > tr > td::before { content: attr(data-mobile-label); display: block; color: var(--ink-3); font: 600 11px/1.5 var(--sans); margin-bottom: 5px; }
  .mobile-cards-ready > tbody > tr > td:first-child, .mobile-cards-ready .mobile-cell-wide { grid-column: 1 / -1; }
  .mobile-cards-ready > tbody > tr > td:first-child::before, .mobile-cards-ready td[colspan]::before { display: none; }
  .mobile-cards-ready > tbody > tr > td:first-child > a { font-size: 16px; font-weight: 600; }
  .mobile-cards-ready :is(.truncate, .nowrap) { white-space: normal; overflow: visible; text-overflow: clip; overflow-wrap: anywhere; max-width: 100% !important; }
  :is(.app-body, .briefing-main) .mobile-cards-ready td small { font-size: 12px; line-height: 1.6; }
  .mobile-cards-ready td > a { display: inline-block; min-height: 44px; padding-block: 10px; }
  .mobile-cards-ready .ops-health { font-size: 12px; }
  .mobile-cards-ready .billing-empty { padding: 12px 0; }

  .register-tools { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .register-tools .tracking-button { min-height: 44px; padding: 9px; font-size: 12px; min-width: 0; }
  .register-tools .tracking-button:first-child:last-child, .register-tools .tracking-button:last-child:nth-child(odd) { grid-column: 1 / -1; }
  .register-filters { flex-wrap: wrap; }
  .register-filters > :not(.register-search) { flex: 1 1 120px; min-width: 0; width: auto; }
  .register-filters .apply-button { min-height: 46px; }
  .register-tabs { gap: 20px; }
  .register-tabs a { font-size: 13px; }
  .story-title { font-size: 15px; line-height: 1.6; }
  .tracking-enhanced .register-table:not(.history-table) td.selection-cell { display: flex !important; position: absolute; top: 8px; right: 8px; }
  .story-select { display: flex; align-items: center; justify-content: center; width: 44px; height: 44px; margin: 0; cursor: pointer; }
  .story-select input { margin: 0; }
  .tracking-enhanced .story-cell { padding-right: 40px !important; }
  .selection-bar button { min-height: 44px; font-size: 13px; }
  .selection-bar button:last-child { font-size: 12px; }
  .story-address { font-size: 12px; line-height: 1.6; }
  .story-publisher, .status-detail, .google-row-state { font-size: 12px; }
  .status-cell a.status-detail, .status-cell .google-row-state { display: inline-flex; align-items: center; min-height: 36px; }
  .register-table:not(.history-table) .story-checked, .story-checked > span { font-size: 12px; }
  .tracking-header-actions { flex-wrap: wrap; gap: 10px; }
  .tracking-updated { white-space: normal; font-size: 11px; }
  .tracking-stats .stat-note { font-size: 11px; }
  .tracking-stats .stat-label { font-size: 12px; }
  .tracking-drawer { max-height: 100dvh; }
  .detail-heading, .detail-body { padding: 20px 16px; }
  .detail-address > a, .detail-facts span, .detail-accordion p, .detail-accordion p span, .detail-accordion p small { font-size: 12px; }
  .detail-facts strong, .detail-accordion > summary { font-size: 14px; }
  .detail-accordion > summary { min-height: 44px; }
  .detail-address .icon-button, .record-source .icon-button { min-width: 44px; min-height: 44px; }
  .detail-footer { padding: 12px 16px max(16px, env(safe-area-inset-bottom)); flex-wrap: wrap; }
  .detail-footer > :is(a, form) { flex: 1 1 135px; }
  .detail-footer button { width: 100%; }
  .record-header { flex-direction: column; padding: 18px; }
  .record-header > .row { flex-wrap: wrap; align-items: stretch; width: 100%; }
  .record-header > .row > :is(a, form) { flex: 1 1 130px; }
  .record-header form .btn { width: 100%; }
  .google-search-action, .google-save-bar { flex-wrap: wrap; }
  .google-search-action > .tracking-button, .google-save-bar > :is(a, button) { flex: 1 1 140px; }
  .google-checkbox { min-height: 44px; }
  .google-review-step { padding: 20px 16px; }
  .admin-source-review { padding: 20px 16px; }
  .admin-source-review .row .btn { flex: 1 1 140px; }
  .report-filters { grid-template-columns: minmax(0, 1fr); padding: 18px 16px; }
  .report-filters > div, .report-filters > div:first-child, .report-filters > div:nth-child(4), .report-filters > div:nth-child(5), .report-filters .report-search, .report-filters .report-filter-actions { grid-column: auto; }
  .report-filter-actions { justify-content: space-between; }
  .report-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); width: 100%; gap: 10px; }
  .report-actions .btn { padding-inline: 10px; }
  .report-export { padding: 18px 16px; }
  .report-totals { justify-content: space-between; gap: 12px; }
  .report-totals span { font-size: 12px; }
  .media-card footer, .media-channels a { flex-wrap: wrap; }
  .media-card footer div { gap: 10px; flex-wrap: wrap; }
  .media-card footer a { padding-inline: 4px; min-height: 44px; }
  .update-card footer .btn { flex: 1 1 130px; }
  .update-card footer form { flex: 1 1 130px; }
  .update-card footer form .btn { width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .navigation-toggle, .account-menu, .mobile-cards-ready * { transition: none; }
}
@media print {
  .navigation-toggle, .account-menu { display: none !important; }
}

/* Subject scope stays visible in tracking, campaign and report filters. */
.subject-filters { grid-column: 1 / -1; flex: 1 0 100%; min-width: 0; width: 100%; box-sizing: border-box; border: 1px solid var(--line, #dce4dd); border-radius: 12px; padding: 1rem; }
.subject-filters legend { font-weight: 700; padding: 0 .4rem; }
.subject-filters .row { display: flex; flex-wrap: wrap; gap: .75rem; margin: .4rem 0; }
.subject-choice { display: flex !important; align-items: center; gap: .6rem; min-height: 44px; padding: .5rem .75rem; border: 1px solid var(--line, #dce4dd); border-radius: 8px; cursor: pointer; }
.subject-choice input[type=checkbox] { width: 18px; height: 18px; margin: 0; flex-shrink: 0; }
.subject-filters .field { flex: 1 1 220px; min-width: 0; }
.subject-filters select { width: 100%; min-height: 44px; }
@media (max-width: 600px) { .subject-choice { width: 100%; box-sizing: border-box; } }

.campaign-search-form { flex-wrap: wrap; }
