/* Cyndi Patent Monitor - shared design system (no build step).
   Tokens follow the public homepage (paper / dusty blue / sage / gold, Quicksand display).
   Components: app header + nav, page head, cards, KPI tiles, buttons, forms, chips, tables,
   badges, tabs, pager, alerts, dialogs, toasts, sub-nav (admin), empty / skeleton states. */

@font-face {
  font-family: "Quicksand";
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url(../fonts/quicksand-latin.woff2) format("woff2");
}

:root {
  --paper: #faf9f5;
  --paper-2: #f3f1ea;
  --card: #ffffff;
  --line: #e6e2d7;
  --line-strong: #d9d3c4;
  --ink: #26384b;
  --ink-2: #4f6274;
  --muted: #5f6b78;
  --blue: #6f8fae;
  --blue-deep: #48698c;
  --blue-soft: #e8eef4;
  --sage: #98ac95;
  --sage-deep: #5f7a5c;
  --sage-soft: #e9efe6;
  --gold: #c7b48a;
  --gold-deep: #8a744a;
  --gold-soft: #f4eedf;
  --danger: #a8483f;
  --danger-soft: #f7e6e3;
  --primary-grad: linear-gradient(135deg, #5a7da2, #46678a);
  --radius: 18px;
  --radius-md: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(38, 56, 75, .05), 0 6px 22px rgba(38, 56, 75, .06);
  --shadow-lg: 0 2px 6px rgba(38, 56, 75, .08), 0 22px 48px rgba(38, 56, 75, .18);
  /* Chinese (plan step 3): Quicksand has Latin only, so CJK glyphs come from the system fonts listed after it */
  --display: "Quicksand", "Avenir Next", "Nunito", "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei",
             "Noto Sans CJK SC", system-ui, sans-serif;
  --text: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", "PingFang SC",
          "Microsoft YaHei", "Noto Sans CJK SC", "Source Han Sans SC", sans-serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", Consolas, "Liberation Mono", monospace;
  --control: 36px;
  --page-max: 1360px;
  /* mobile shell (phones <= 760px override several of these below) */
  --gutter: 20px;              /* page side padding (14px on phones) */
  --header-h: 58px;            /* top bar height (52px on phones) */
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
  --tabbar-h: 0px;             /* 52px on phones while the tab bar is shown */
  --bottom-ui: 0px;            /* fixed chrome at the bottom of the viewport: tab bar + home indicator */
  --shell-top: calc(var(--header-h) + 1px + var(--safe-t));  /* bottom edge of the sticky top bar (page sticky bars: top: var(--shell-top)) */
  --kb: 0px;                   /* on-screen keyboard overlap, phones (app.js) */
}
html.hdr-hidden { --shell-top: var(--safe-t); }             /* phones: the top bar slid away (app.js) */

/* ── Base ─────────────────────────────────────────────────────────── */
* { box-sizing: border-box; }
[hidden] { display: none !important; }  /* component display rules must not beat the attribute */
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column;
  font: 14px/1.55 var(--text); color: var(--ink); background: var(--paper);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--blue-deep); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { font-family: var(--display); color: var(--ink); line-height: 1.25; margin: 0; }
h1 { font-size: 26px; font-weight: 700; }
h2 { font-size: 19px; font-weight: 700; }
h3 { font-size: 16px; font-weight: 700; }
h4 { font-size: 14px; font-weight: 700; }
p { margin: 0 0 10px; }
code, pre, .mono { font-family: var(--mono); font-size: 12.5px; }
hr { border: 0; border-top: 1px solid var(--line); margin: 16px 0; }
img { max-width: 100%; }
:focus-visible { outline: 3px solid var(--blue-deep); outline-offset: 2px; border-radius: 6px; }
.sr-only { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden;
           clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
.skip-link { position: absolute; left: 12px; top: -80px; z-index: 60; background: var(--card); padding: 8px 12px;
             border-radius: var(--radius-sm); box-shadow: var(--shadow); }
.skip-link:focus { top: 8px; }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

/* ── App header ───────────────────────────────────────────────────── */
.app-header {
  position: sticky; top: 0; z-index: 10;
  background: rgba(250, 249, 245, .92); backdrop-filter: saturate(1.4) blur(8px);
  -webkit-backdrop-filter: saturate(1.4) blur(8px); border-bottom: 1px solid var(--line);
  padding-top: var(--safe-t);
}
.app-header .bar { max-width: var(--page-max); margin: 0 auto; height: var(--header-h);
                   padding: 0 max(var(--gutter), var(--safe-r)) 0 max(var(--gutter), var(--safe-l));
                   display: flex; align-items: center; gap: 18px; }
.brand { display: flex; align-items: center; gap: 9px; color: var(--blue-deep); text-decoration: none; flex: none; }
.brand:hover { text-decoration: none; }
.brand img { width: 34px; height: auto; display: block; }
.brand .name { font: 700 15px/1.1 var(--display); letter-spacing: .14em; text-transform: uppercase; }
.brand .product { display: block; font: 600 10.5px/1.2 var(--text); letter-spacing: .04em; color: var(--muted);
                  text-transform: none; margin-top: 2px; }
.main-nav { display: flex; gap: 2px; flex: 1; min-width: 0; overflow-x: auto; scrollbar-width: none; }
.main-nav::-webkit-scrollbar { display: none; }
.main-nav a { display: inline-flex; align-items: center; gap: 6px; height: 36px; padding: 0 12px; border-radius: 999px;
              color: var(--ink-2); font-weight: 600; white-space: nowrap; text-decoration: none; }
.main-nav a:hover { background: var(--paper-2); color: var(--ink); }
.main-nav a[aria-current="page"] { background: var(--blue-soft); color: var(--blue-deep); }
.header-tools { display: flex; align-items: center; gap: 8px; flex: none; }
.user-menu { position: relative; }
.user-menu > summary { list-style: none; cursor: pointer; display: inline-flex; align-items: center; gap: 8px;
                       height: 36px; padding: 0 6px 0 10px; border-radius: 999px; border: 1px solid var(--line);
                       background: var(--card); color: var(--ink-2); font-weight: 600; }
.user-menu > summary::-webkit-details-marker { display: none; }
.user-menu .avatar { width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center;
                     background: var(--blue-soft); color: var(--blue-deep); font: 700 12px/1 var(--display); }
.user-menu .menu { position: absolute; right: 0; top: 44px; min-width: 230px; background: var(--card);
                   border: 1px solid var(--line); border-radius: var(--radius-md); box-shadow: var(--shadow-lg);
                   padding: 6px; z-index: 30; }
.user-menu .menu .who { padding: 8px 10px 10px; border-bottom: 1px solid var(--line); margin-bottom: 4px; }
.user-menu .menu .who b { display: block; color: var(--ink); }
.user-menu .menu .who span { font-size: 12px; color: var(--muted); }
.user-menu .menu a, .user-menu .menu button {
  display: flex; width: 100%; align-items: center; gap: 8px; padding: 8px 10px; border-radius: var(--radius-sm);
  color: var(--ink-2); background: none; border: 0; font: inherit; text-align: left; cursor: pointer; text-decoration: none; }
.user-menu .menu a:hover, .user-menu .menu button:hover { background: var(--paper-2); color: var(--ink); }
.user-menu .menu .sep { height: 1px; background: var(--line); margin: 4px 0; }
.icon { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8;
        stroke-linecap: round; stroke-linejoin: round; vertical-align: -3px; }
.icon-sm { width: 15px; height: 15px; }
.tool-link { position: relative; display: inline-grid; place-items: center; width: 36px; height: 36px;
             border-radius: 50%; color: var(--ink-2); }
.tool-link:hover { background: var(--paper-2); text-decoration: none; }
.tool-link .dot { position: absolute; top: 4px; right: 3px; min-width: 16px; height: 16px; padding: 0 4px;
                  border-radius: 999px; background: var(--blue-deep); color: #fff; font: 700 10px/16px var(--text); }

/* ── Trial banner (base.html #trial-banner; app.js shows it, hidden for the day once dismissed) ── */
.trial-banner { background: var(--gold-soft); border-bottom: 1px solid #e6dabd; color: #5e4e2c; font-size: 12.5px; line-height: 1.35; }
.trial-banner .bar { max-width: var(--page-max); margin: 0 auto; display: flex; align-items: center; gap: 10px; min-height: 34px;
                     padding: 3px max(var(--gutter), var(--safe-r)) 3px max(var(--gutter), var(--safe-l)); }
.trial-text { flex: 1 1 auto; min-width: 0; }
.trial-text a { color: inherit; font-weight: 600; text-decoration: underline; text-underline-offset: 2px; }
.trial-short { display: none; }
.trial-close { flex: none; display: inline-grid; place-items: center; width: 28px; height: 28px; margin-right: -6px; padding: 0;
               border: 0; border-radius: 50%; background: none; color: inherit; cursor: pointer; }
.trial-close:hover { background: rgba(94, 78, 44, .1); }

/* ── Page layout ──────────────────────────────────────────────────── */
.app-main { flex: 1; width: 100%; max-width: var(--page-max); margin: 0 auto;
            padding: 24px max(var(--gutter), var(--safe-r)) 48px max(var(--gutter), var(--safe-l)); }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap;
             margin-bottom: 18px; }
.page-head > div:first-child { flex: 1 1 380px; min-width: 0; }
.page-head .sub { color: var(--muted); margin: 4px 0 0; max-width: 78ch; }
.page-head .actions { display: flex; gap: 8px; flex-wrap: wrap; }
.app-footer { border-top: 1px solid var(--line); color: var(--muted); font-size: 12px; }
.app-footer .bar { max-width: var(--page-max); margin: 0 auto;
                   padding: 14px max(var(--gutter), var(--safe-r)) 14px max(var(--gutter), var(--safe-l)); display: flex; gap: 14px;
                   flex-wrap: wrap; justify-content: space-between; }
.layout-split { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 22px; align-items: start; }
.subnav { position: sticky; top: 78px; display: flex; flex-direction: column; gap: 2px; }
.subnav .label { font: 700 11px/1 var(--display); letter-spacing: .14em; text-transform: uppercase;
                 color: var(--muted); padding: 6px 12px 8px; }
.subnav a { display: flex; align-items: center; gap: 9px; padding: 9px 12px; border-radius: var(--radius-sm);
            color: var(--ink-2); font-weight: 600; text-decoration: none; }
.subnav a:hover { background: var(--paper-2); color: var(--ink); }
.subnav a[aria-current="page"], .subnav a[aria-current="location"] { background: var(--blue-soft); color: var(--blue-deep); }
.subnav .sep { display: block; height: 1px; background: var(--line); margin: 8px 12px; flex: none; }
/* admin console on phones: one switcher button (_admin_nav.html) opens the sub-nav in App.sheet */
.admin-switch { display: flex; align-items: center; gap: 8px; width: 100%; min-height: 44px; padding: 0 14px; margin-bottom: 12px;
                border: 1px solid var(--line); border-radius: var(--radius-md); background: var(--card); color: var(--ink);
                font: 600 14px/1 var(--text); cursor: pointer; text-align: left; }
.admin-switch .k { color: var(--muted); font: 700 11px/1 var(--display); letter-spacing: .12em; text-transform: uppercase; }
.admin-switch .chev { margin-left: auto; color: var(--muted); }
@media (max-width: 760px) { .layout-split:has(> .admin-switch) > #admin-subnav { display: none; } }  /* strip stays until AC-1 adds the switcher */
.sheet .subnav { position: static; display: flex; flex-direction: column; gap: 2px; overflow: visible; border: 0; padding: 0; }
.sheet .subnav .label { display: none; }
.sheet .subnav a { min-height: 48px; white-space: normal; font-size: 15px; }

/* ── Cards / panels / KPI ─────────────────────────────────────────── */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow);
        padding: 18px 20px; }
.card + .card { margin-top: 16px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px;
             flex-wrap: wrap; }
.card-head .hint, .hint { color: var(--muted); font-size: 12.5px; }
.card.flush { padding: 0; overflow: hidden; }
.card.flush > .card-head { padding: 14px 18px 0; }
.inset { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius-md); padding: 12px 14px; }
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 18px; }
.kpi { display: block; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius-md);
       padding: 14px 16px; color: var(--ink); text-decoration: none; box-shadow: var(--shadow); }
a.kpi:hover, button.kpi:hover { border-color: var(--line-strong); text-decoration: none; }
button.kpi { font: inherit; text-align: left; cursor: pointer; width: 100%; }
.kpi[aria-pressed="true"] { border-color: var(--blue); box-shadow: 0 0 0 2px var(--blue-soft); }
.kpi .v { display: block; font: 700 26px/1.15 var(--display); font-variant-numeric: tabular-nums; }
.kpi .l { display: block; color: var(--muted); font-size: 12.5px; margin-top: 2px; }
.kpi.k-high .v { color: var(--danger); }
.kpi.k-medium .v { color: var(--gold-deep); }
.kpi.k-low .v { color: var(--blue-deep); }
.kpi.k-ok .v { color: var(--sage-deep); }
.kpi.k-warn { border-color: #e5c9c4; background: #fdf6f5; }
.kpi.k-warn .v { color: var(--danger); }

/* ── Buttons ──────────────────────────────────────────────────────── */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; height: var(--control);
       padding: 0 15px; border-radius: 999px; border: 1px solid var(--line-strong); background: var(--card);
       color: var(--ink); font: 600 13.5px/1 var(--text); cursor: pointer; white-space: nowrap; text-decoration: none;
       transition: background .15s, border-color .15s, box-shadow .15s; }
.btn:hover { border-color: var(--blue); text-decoration: none; }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--primary-grad); color: #fff; border-color: transparent;
               box-shadow: 0 4px 12px rgba(70, 103, 138, .22); }
.btn-primary:hover { border-color: transparent; box-shadow: 0 6px 16px rgba(70, 103, 138, .3); }
.btn-ghost { border-color: transparent; background: transparent; color: var(--ink-2); }
.btn-ghost:hover { background: var(--paper-2); border-color: transparent; }
.btn-danger { color: var(--danger); border-color: #e3c3be; background: #fff; }
.btn-danger:hover { border-color: var(--danger); background: var(--danger-soft); }
.btn-danger.solid { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn-sm { height: 30px; padding: 0 11px; font-size: 12.5px; }
.btn-icon { width: var(--control); padding: 0; }
.btn-sm.btn-icon { width: 30px; }
.btn-group { display: inline-flex; gap: 6px; flex-wrap: wrap; }
.link-btn { background: none; border: 0; padding: 0; color: var(--blue-deep); font: inherit; cursor: pointer; }
.link-btn:hover { text-decoration: underline; }
.star { background: none; border: 0; cursor: pointer; padding: 2px; color: var(--line-strong); font-size: 17px;
        line-height: 1; }
.star[aria-pressed="true"] { color: #c99a2e; }
.star .icon { fill: none; }
.star[aria-pressed="true"] .icon { fill: currentColor; }
.btn[aria-pressed="true"] { background: var(--blue-soft); border-color: var(--blue); color: var(--blue-deep); }

/* ── Forms ────────────────────────────────────────────────────────── */
.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field > label, .field > .label { font-size: 12px; font-weight: 600; color: var(--ink-2); }
.field .help { font-size: 12px; color: var(--muted); }
.field .err { font-size: 12px; color: var(--danger); }
input[type=text], input[type=search], input[type=email], input[type=password], input[type=number],
input[type=date], input[type=url], select, textarea {
  height: var(--control); padding: 0 11px; border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
  background: #fff; color: var(--ink); font: 13.5px/1.3 var(--text); min-width: 0; width: 100%; }
textarea { height: auto; min-height: 84px; padding: 9px 11px; line-height: 1.5; resize: vertical; }
select { padding-right: 28px; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 3px var(--blue-soft); }
input[type=checkbox], input[type=radio] { width: 16px; height: 16px; accent-color: var(--blue-deep); margin: 0; }
.check { display: inline-flex; align-items: center; gap: 7px; cursor: pointer; font-size: 13px; color: var(--ink-2); }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px 14px; }
.form-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 14px; flex-wrap: wrap; }
.search-input { position: relative; }
.search-input .icon { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--muted); }
.search-input input { padding-left: 34px; }

/* ── Filter bar / chips ───────────────────────────────────────────── */
.filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; }
.filters .field { flex: 1 1 150px; max-width: 240px; }
.filters .field.grow { flex: 3 1 260px; max-width: none; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 12px; border-radius: 999px;
        border: 1px solid var(--line-strong); background: #fff; color: var(--ink-2); font: 600 12.5px/1 var(--text);
        cursor: pointer; white-space: nowrap; }
.chip:hover { border-color: var(--blue); }
.chip[aria-pressed="true"] { background: var(--blue-soft); border-color: var(--blue); color: var(--blue-deep); }
.chip .x { font-size: 14px; line-height: 1; color: var(--muted); }
.chip .count { font-weight: 700; color: var(--muted); }
.active-filters { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-top: 10px; font-size: 12.5px;
                  color: var(--muted); }

/* ── Tables ───────────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13.5px; }
.table th { position: sticky; top: 0; z-index: 1; background: var(--paper-2); color: var(--ink-2); text-align: left;
            font: 700 12px/1.2 var(--text); padding: 10px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.table td { padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
.table tbody tr:hover { background: #fcfbf8; }
.table tr.is-open { background: var(--blue-soft); }
.table tr.is-selected { background: #f4f7fa; }
.table tr.is-selected td:first-child { box-shadow: inset 3px 0 0 var(--blue); }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }
.table .nowrap { white-space: nowrap; }
.table .title-cell { min-width: 260px; }
.table .row-link { color: var(--ink); font-weight: 600; }
.table .row-link:hover { color: var(--blue-deep); }
.table .sub { display: block; color: var(--muted); font-size: 12px; margin-top: 2px; }
.th-sort { background: none; border: 0; padding: 0; font: inherit; color: inherit; cursor: pointer;
           display: inline-flex; align-items: center; gap: 4px; }
.th-sort .arrow { color: var(--line-strong); }
th[aria-sort="ascending"] .th-sort .arrow, th[aria-sort="descending"] .th-sort .arrow { color: var(--blue-deep); }
.table .sel { width: 36px; }
.table-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
              padding: 12px 16px; color: var(--muted); font-size: 12.5px; }
.state-row td { text-align: center; color: var(--muted); padding: 34px 12px; }
@media (max-width: 760px) {
  .table.responsive thead { display: none; }
  .table.responsive, .table.responsive tbody, .table.responsive tr, .table.responsive td { display: block; width: 100%; }
  .table.responsive tr { border-bottom: 1px solid var(--line); padding: 8px 4px; }
  .table.responsive td { border: 0; padding: 4px 10px; }
  .table.responsive td[data-label]::before { content: attr(data-label); display: inline-block; min-width: 92px;
                                              color: var(--muted); font-size: 12px; font-weight: 600; }
  .table.responsive td.title-cell { min-width: 0; }
  .table.responsive td.hide-sm { display: none; }
  .table.responsive td.num { text-align: left; }
  .table.responsive tfoot { display: block; }
}
/* Phones: table rows as compact cards. Roles on <td>:
   .cell-title / .title-cell = first line, left;  .cell-end = first line, right (badge / status);
   .cell-meta = own muted line;  .cell-inl = inline muted chunk, "·"-separated;  .cell-actions = 44px button row;
   .hide-sm / .is-empty = hidden.  tr.more-sm hidden until the table gets .show-all.  a.stretch = whole card tappable.
   A table that uses cards-sm must NOT also carry .responsive. Never put cell-inl on a cell that can be hidden
   when it is the FIRST inline cell (the next one would then start with a dot). */
@media (max-width: 760px) {
  .table.cards-sm, .table.cards-sm tbody, .table.cards-sm tfoot { display: block; width: 100%; }
  .table.cards-sm thead { display: none; }
  .table.cards-sm tr { display: flex; flex-wrap: wrap; align-items: baseline; gap: 3px 10px; position: relative;
                       padding: 12px 16px; border-bottom: 1px solid var(--line); }
  .table.cards-sm tr::before { content: ""; order: -1; flex: 0 0 100%; height: 0; }   /* line break after title + end */
  .table.cards-sm tbody tr:last-child { border-bottom: 0; }
  .table.cards-sm tbody tr:hover { background: none; }
  .table.cards-sm td { display: block; flex: 1 1 100%; min-width: 0; padding: 0; border: 0; background: none;
                       text-align: left; overflow-wrap: anywhere; }
  .table.cards-sm td.cell-title, .table.cards-sm td.title-cell { order: -3; flex: 1 1 0; font-weight: 600; color: var(--ink); }
  .table.cards-sm td.cell-end { order: -2; flex: 0 0 auto; margin-left: auto; text-align: right; }
  .table.cards-sm td.cell-meta { order: 1; color: var(--muted); font-size: 12.5px; line-height: 1.45; }   /* after the inline line */
  .table.cards-sm td.cell-inl { flex: 0 1 auto; color: var(--muted); font-size: 12.5px; }
  .table.cards-sm td.cell-inl ~ td.cell-inl::before { content: "\00b7\00a0"; }    /* "~" so a hidden cell in between does not drop the dot */
  .table.cards-sm td.cell-actions { order: 3; display: flex; flex-wrap: wrap; gap: 8px; margin-top: 6px; }
  .table.cards-sm td.cell-actions .btn { height: 44px; }
  .table.cards-sm td.cell-actions .btn-icon { width: 44px; }
  .table.cards-sm td.cell-actions .btn-group { flex: 1 1 auto; flex-wrap: wrap; gap: 8px; }
  .table.cards-sm td.cell-actions .push-end { margin-left: auto; }
  .table.cards-sm td.hide-sm, .table.cards-sm td.is-empty { display: none; }
  .table.cards-sm tr.more-sm { display: none; }
  .table.cards-sm.show-all tr.more-sm { display: flex; }
  .table.cards-sm tr.state-row { display: block; }
  .table.cards-sm tr.state-row td { padding: 24px 12px; text-align: center; }
  .table.cards-sm .stretch::after { content: ""; position: absolute; inset: 0; }
  .table.cards-sm tr :is(button, summary, input, select, .cell-actions a) { position: relative; z-index: 1; }
  .table.cards-sm tfoot td { font-weight: 700; }
  .table.cards-sm .num { text-align: left; }
}

/* ── Badges / tags ────────────────────────────────────────────────── */
.badge { display: inline-flex; align-items: center; gap: 5px; height: 22px; padding: 0 9px; border-radius: 999px;
         font: 700 11.5px/1 var(--text); white-space: nowrap; border: 1px solid transparent; }
.rel-high { background: var(--danger-soft); color: var(--danger); }
.rel-medium { background: var(--gold-soft); color: var(--gold-deep); }
.rel-low { background: var(--blue-soft); color: var(--blue-deep); }
.rel-none { background: var(--paper-2); color: var(--muted); }
.rel-pending { background: #fff; color: var(--blue-deep); border-color: #bfcfdf; border-style: dashed; }
.rel-error { background: #fff; color: var(--danger); border-color: #dca9a2; border-style: dashed; }
.threat-critical { background: #7f2a24; color: #fff; }
.threat-high { background: var(--danger-soft); color: var(--danger); }
.threat-medium { background: var(--gold-soft); color: var(--gold-deep); }
.threat-low, .threat-none { background: var(--paper-2); color: var(--muted); }
.st-ok { background: var(--sage-soft); color: var(--sage-deep); }
.st-warn { background: var(--gold-soft); color: var(--gold-deep); }
.st-bad { background: var(--danger-soft); color: var(--danger); }
.st-info { background: var(--blue-soft); color: var(--blue-deep); }
.st-muted { background: var(--paper-2); color: var(--muted); }
.tag-company { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; color: var(--ink); white-space: nowrap; }
.tag-company::before { content: ""; width: 4px; height: 14px; border-radius: 2px; background: var(--c, var(--line-strong)); }
.tag-domain { display: inline-flex; align-items: center; gap: 6px; color: var(--ink-2); font-size: 12.5px; }
.tag-domain::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--c, var(--blue)); flex: none; }
/* taxonomy v4: "GPU · Client" (App.domainTag with a segment): the suffix never breaks; on phones the chip stays
   one line and the name gives way first. A retired v3 domain (old reports, archived labels) has a hollow dot
   (its title names the old list). */
.tag-domain.has-seg { max-width: 100%; min-width: 0; }
.tag-domain .tn { min-width: 0; }
.tag-domain .ts { color: var(--muted); white-space: nowrap; }
@media (max-width: 760px) { .tag-domain.has-seg .tn { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; } }
.tag-domain.is-legacy::before { background: none; box-shadow: inset 0 0 0 2px var(--c, var(--blue)); }
.count-pill { display: inline-flex; min-width: 20px; height: 18px; padding: 0 6px; border-radius: 999px; align-items: center;
              justify-content: center; background: var(--paper-2); color: var(--muted); font: 700 11px/1 var(--text); }

/* ── Tabs / pager ─────────────────────────────────────────────────── */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 16px; overflow-x: auto; }
.tab { background: none; border: 0; border-bottom: 2px solid transparent; padding: 10px 14px; margin-bottom: -1px;
       color: var(--ink-2); font: 600 13.5px/1 var(--text); cursor: pointer; white-space: nowrap; text-decoration: none; }
.tab:hover { color: var(--ink); text-decoration: none; }
.tab[aria-selected="true"], .tab[aria-current="page"] { color: var(--blue-deep); border-bottom-color: var(--blue-deep); }
.pager { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.pager select { width: auto; height: 30px; }

/* ── Alerts / states ──────────────────────────────────────────────── */
.alert { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: var(--radius-md);
         border: 1px solid; margin-bottom: 16px; font-size: 13.5px; }
.alert .icon { margin-top: 1px; }
.alert-info { background: var(--blue-soft); border-color: #cddae7; color: var(--ink); }
.alert-warn { background: var(--gold-soft); border-color: #e6dabd; color: #5e4e2c; }
.alert-danger { background: var(--danger-soft); border-color: #e5c4bf; color: #6e2c26; }
.alert-ok { background: var(--sage-soft); border-color: #cfdccc; color: #3c5139; }
.empty { text-align: center; color: var(--muted); padding: 40px 16px; }
.empty .icon { width: 34px; height: 34px; color: var(--line-strong); margin-bottom: 8px; }
.skeleton { display: block; height: 12px; border-radius: 6px; background: linear-gradient(90deg, var(--paper-2), #ece9e0, var(--paper-2));
            background-size: 200% 100%; animation: shimmer 1.2s infinite; }
@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }
.spinner { width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--blue-soft); border-top-color: var(--blue-deep);
           animation: spin .8s linear infinite; display: inline-block; vertical-align: -3px; }
@keyframes spin { to { transform: rotate(360deg); } }
.progress { height: 8px; background: var(--paper-2); border-radius: 999px; overflow: hidden; }
.progress > span { display: block; height: 100%; background: var(--primary-grad); border-radius: 999px; transition: width .4s; }

/* ── Dialog / toast ───────────────────────────────────────────────── */
dialog.modal { border: 0; padding: 0; border-radius: var(--radius); box-shadow: var(--shadow-lg); width: min(560px, calc(100vw - 32px));
               color: var(--ink); background: var(--card); }
dialog.modal::backdrop { background: rgba(38, 56, 75, .38); }
dialog.modal .m-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 16px 20px 0; }
dialog.modal .m-body { padding: 12px 20px; }
dialog.modal .m-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 0 20px 18px; }
dialog.modal.wide { width: min(780px, calc(100vw - 32px)); }          /* moved here from admin.html */
dialog.modal.sheet { width: min(440px, calc(100vw - 32px)); }
dialog.modal .m-body > .card { border: 0; border-radius: 0; box-shadow: none; padding: 0; }  /* a page card shown in App.sheet */
.sheet-grip, .tb-title, .tb-back, .tabbar, .to-top { display: none; }
/* action / link list in sheets (More sheet, App.sheet actions, page drill-downs) */
.sheet-list { display: flex; flex-direction: column; gap: 2px; }
.sheet-list > a, .sheet-list > button {
  display: flex; align-items: center; gap: 12px; width: 100%; min-height: 48px; padding: 0 12px; border: 0;
  border-radius: var(--radius-md); background: none; color: var(--ink); font: 600 15px/1.25 var(--text);
  text-align: left; text-decoration: none; cursor: pointer; -webkit-tap-highlight-color: transparent; }
.sheet-list > a:hover, .sheet-list > button:hover, .sheet-list > a:active, .sheet-list > button:active {
  background: var(--paper-2); text-decoration: none; }
.sheet-list .icon { color: var(--ink-2); }
.sheet-list .count-pill { margin-left: auto; }
.sheet-list > .danger, .sheet-list > .danger .icon { color: var(--danger); }
.sheet-list > [aria-disabled="true"], .sheet-list > :disabled { opacity: .5; }
.sheet-list > .sheet-label { padding: 14px 12px 4px; font: 700 11px/1 var(--display); letter-spacing: .14em;
                             text-transform: uppercase; color: var(--muted); }
.sheet-list > .sep { height: 1px; background: var(--line); margin: 6px 12px; }
.sheet-list .grow { flex: 1 1 auto; min-width: 0; }
.sheet-list .num { margin-left: auto; font-weight: 700; font-variant-numeric: tabular-nums; }
.sheet-list .sl-text { display: flex; flex-direction: column; gap: 2px; flex: 1 1 auto; min-width: 0; }
.sheet-list .sl-desc { font: 400 12.5px/1.35 var(--text); color: var(--muted); }
.sheet-list > :has(.sl-desc) { min-height: 56px; padding-top: 8px; padding-bottom: 8px; }
.sheet-list .badge { margin-left: auto; }
.sheet-list > [aria-pressed="true"] { color: var(--blue-deep); }
.sheet-list > [aria-pressed="true"]::after { content: "\2713"; margin-left: auto; font-weight: 700; }
.sheet-list > .sheet-row { display: flex; align-items: center; gap: 12px; min-height: 48px; padding: 0 12px; }  /* non-link row */
.acct-who { display: flex; align-items: center; gap: 12px; min-width: 0; }
.acct-who .avatar { width: 40px; height: 40px; flex: none; border-radius: 50%; display: grid; place-items: center;
                    background: var(--blue-soft); color: var(--blue-deep); font: 700 16px/1 var(--display); }
.acct-who h3 { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.acct-who .muted { display: block; font-size: 12.5px; }
@keyframes sheet-up { from { transform: translateY(32px); opacity: .5; } to { transform: none; opacity: 1; } }
.toasts { position: fixed; z-index: 50; top: auto; left: auto; right: max(16px, var(--safe-r)); bottom: calc(16px + var(--bottom-ui));
          display: flex; flex-direction: column; gap: 8px; max-width: min(420px, calc(100vw - 32px));
          margin: 0; padding: 0; border: 0; background: none; overflow: visible; color: inherit; pointer-events: none; }
          /* (margin/padding/border/background/top/left reset the UA [popover] style: app.js puts the stack in the top layer) */
.toast { background: var(--ink); color: #fff; padding: 11px 14px; border-radius: var(--radius-md); box-shadow: var(--shadow-lg);
         font-size: 13.5px; display: flex; gap: 10px; align-items: flex-start; animation: toast-in .2s ease-out;
         pointer-events: auto; cursor: pointer; }   /* tap / click dismisses (app.js) */
.toast.ok { background: #3f5a3c; }
.toast.err { background: #7d342d; }
@keyframes toast-in { from { transform: translateY(8px); opacity: 0; } to { transform: none; opacity: 1; } }
.selbar { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(18px + var(--safe-b)); z-index: 20; background: var(--ink);
          color: #fff; border-radius: 999px; box-shadow: var(--shadow-lg); padding: 8px 8px 8px 18px;
          display: flex; align-items: center; gap: 10px; max-width: calc(100vw - 24px); flex-wrap: wrap;
          width: max-content; }
.selbar .btn { background: rgba(255, 255, 255, .1); color: #fff; border-color: rgba(255, 255, 255, .2); height: 32px; }
.selbar .btn:hover { background: rgba(255, 255, 255, .2); }
.selbar .btn-primary { background: #fff; color: var(--ink); }

/* ── Content helpers ──────────────────────────────────────────────── */
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.nowrap { white-space: nowrap; }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.stack { display: flex; flex-direction: column; gap: 10px; }
.mt-0 { margin-top: 0 !important; } .mt-1 { margin-top: 8px; } .mt-2 { margin-top: 16px; } .mt-3 { margin-top: 24px; }
.mb-1 { margin-bottom: 8px; } .mb-2 { margin-bottom: 16px; }
.dl { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 7px 16px; font-size: 13.5px; margin: 0; }
.dl dt { color: var(--muted); font-weight: 600; }
.dl dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.prose { font-size: 14px; line-height: 1.65; color: var(--ink); }
.prose p { margin: 0 0 10px; }
.prose ul { margin: 0 0 10px; padding-left: 20px; }
.codeblock { position: relative; background: #22313f; color: #dfe7ee; border-radius: var(--radius-md); padding: 14px 16px;
             overflow-x: auto; font: 12.5px/1.6 var(--mono); white-space: pre; }
.codeblock + .copy-btn, .copy-row { margin-top: 6px; }
.kv-list { list-style: none; margin: 0; padding: 0; }
.kv-list li { display: flex; justify-content: space-between; gap: 10px; padding: 7px 0; border-bottom: 1px solid var(--line); }
.kv-list li:last-child { border-bottom: 0; }
.bar-row { display: grid; grid-template-columns: 140px minmax(0, 1fr) 60px; gap: 10px; align-items: center; font-size: 12.5px;
           margin: 5px 0; }
.bar-track { height: 10px; background: var(--paper-2); border-radius: 999px; overflow: hidden; display: flex; }
.bar-track > span { display: block; height: 100%; }
/* disclosure card: <details class="card fold"><summary>Title</summary><div class="fold-body">…</div></details> */
details.card.fold { padding: 0; }
.fold > summary { cursor: pointer; padding: 12px 18px; font-weight: 700; list-style: none; display: flex;
                  align-items: center; gap: 8px; }
.fold > summary::-webkit-details-marker { display: none; }
.fold > summary::after { content: "+"; margin-left: auto; color: var(--muted); }
.fold[open] > summary::after { content: "–"; }
.fold-body { padding: 0 18px 14px; }

/* ── Responsive ───────────────────────────────────────────────────── */
@media (max-width: 1080px) {
  .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .layout-split { grid-template-columns: minmax(0, 1fr); }
  .subnav { position: static; flex-direction: row; overflow-x: auto; border-bottom: 1px solid var(--line); padding-bottom: 6px; }
  .subnav .label, .subnav .sep { display: none; }
  .subnav a { white-space: nowrap; }
}
/* tablets and small laptops: the user's name pushed "Reports" out of the nav at 768px */
@media (max-width: 1000px) {
  .user-menu .um-name { display: none; }
  .user-menu > summary { padding: 0 4px; }
}
@media (max-width: 760px) {
  .grid-2, .grid-3 { grid-template-columns: minmax(0, 1fr); }
  .filters .field { max-width: none; flex-basis: 45%; }
  .card { padding: 14px 14px; }
  .dl { grid-template-columns: minmax(0, 1fr); gap: 2px 0; }
  .dl dt { margin-top: 6px; }
  .bar-row { grid-template-columns: 90px minmax(0, 1fr) 46px; }
  .hide-sm { display: none !important; }
}

/* ── Mobile shell (phones, <= 760px) ──────────────────────────────── */
/* One bottom bar at a time: the tab bar, OR a selection bar (body.has-selbar), OR the patent dock (body.has-dock).
   Page sticky bars: position: sticky; top: var(--shell-top); transition: top .22s ease; z-index: 6 (max one, <= 60px). */
@media (max-width: 760px) {
  :root { --gutter: 14px; --header-h: 52px; --bottom-ui: var(--safe-b); }
  body { font-size: 15px; }
  h1 { font-size: 22px; }
  h2 { font-size: 18px; }
  .prose { font-size: 15.5px; line-height: 1.6; }
  html:has(dialog.modal[open]) { overflow: hidden; }          /* no background scrolling behind a sheet */

  /* top bar: emblem + wordmark at the top of a page, the page title once its h1 scrolled away (app.js);
     slides away while scrolling down, back on any scroll up */
  .app-header { transition: transform .22s ease; }
  .app-header.is-hidden { transform: translateY(-100%); }
  .app-header .bar { gap: 8px; }
  .brand { min-height: 44px; }
  .brand img { width: 32px; }
  .brand .name { font-size: 14px; }
  .brand .product { display: none; }
  .tb-title { flex: 1 1 auto; min-width: 0; font: 700 17px/1.2 var(--display); color: var(--ink);
              white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .app-header.show-title .brand-text { display: none; }
  .app-header.show-title .brand { position: relative; }            /* emblem only (32px): 44px-wide invisible hit area */
  .app-header.show-title .brand::after { content: ""; position: absolute; inset: 0 -6px; }
  .app-header.show-title .tb-title, .tb-back:not([hidden]) ~ .tb-title { display: block; }
  .has-tabbar .main-nav, .has-tabbar .user-menu { display: none; }
  .header-tools { margin-left: auto; margin-right: -8px; gap: 0; }
  .tool-link { width: 44px; height: 44px; }
  .tb-back:not([hidden]) { display: inline-grid; place-items: center; flex: none; width: 44px; height: 44px; margin-left: -12px;
                           border: 0; background: none; color: var(--blue-deep); cursor: pointer; }
  .tb-back:not([hidden]) + .brand { display: none; }
  .app-main { padding-top: 16px; padding-bottom: 32px; }
  .app-footer .bar { padding-top: 12px; padding-bottom: 12px; gap: 4px 14px; font-size: 11.5px; }
  /* trial banner: one compact line ("Free trial until … · Terms"), 44px-wide close target */
  .trial-banner .bar { min-height: 36px; padding-top: 0; padding-bottom: 0; gap: 4px; }
  .trial-text { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .trial-long { display: none; }
  .trial-short { display: inline; }
  .trial-close { width: 44px; height: 36px; margin-right: -14px; border-radius: 0; }

  /* bottom tab bar: Patents · Search · Analytics · Reports · More */
  body.has-tabbar { --tabbar-h: 52px; --bottom-ui: calc(var(--tabbar-h) + var(--safe-b)); padding-bottom: var(--bottom-ui); }
  .tabbar { position: fixed; z-index: 25; left: 0; right: 0; bottom: 0; display: grid; grid-auto-flow: column;
            grid-auto-columns: minmax(0, 1fr); height: var(--bottom-ui); padding: 0 var(--safe-r) var(--safe-b) var(--safe-l);
            background: rgba(250, 249, 245, .94); -webkit-backdrop-filter: saturate(1.4) blur(10px); backdrop-filter: saturate(1.4) blur(10px);
            border-top: 1px solid var(--line); -webkit-touch-callout: none; transition: transform .2s ease; }
  html.is-typing .tabbar { transform: translateY(110%); visibility: hidden; }     /* keyboard open */
  .tabbar > a, .tabbar > button {
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; min-width: 0;
    height: var(--tabbar-h); padding: 0 2px; border: 0; background: none; color: var(--muted);
    font: 600 11px/1.15 var(--text); text-decoration: none; cursor: pointer; -webkit-tap-highlight-color: transparent; }
  .tabbar .ti { display: grid; place-items: center; width: 52px; height: 28px; border-radius: 999px; transition: background .15s; }
  .tabbar .icon { width: 22px; height: 22px; }
  .tabbar .tl { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .tabbar [aria-current] { color: var(--blue-deep); }
  .tabbar [aria-current] .ti { background: var(--blue-soft); }
  .tabbar > :active .ti { background: var(--paper-2); }
  .tabbar .avatar { width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center;
                    border: 1.5px solid currentColor; font: 700 11px/1 var(--display); }
  .tabbar [aria-current] .avatar { background: var(--blue-deep); border-color: var(--blue-deep); color: #fff; }
  body.has-selbar .tabbar, body.has-dock .tabbar { visibility: hidden; }  /* one bottom bar at a time */
  body:has(.selbar:not([hidden])) .tabbar { visibility: hidden; }        /* (separate rule: no :has support must not drop the line above) */

  /* back to top: appears briefly while scrolling up far down a page (app.js) */
  .to-top:not([hidden]) { position: fixed; z-index: 24; right: max(12px, var(--safe-r)); bottom: calc(var(--bottom-ui) + 12px);
    display: grid; place-items: center; width: 44px; height: 44px; border-radius: 50%; border: 1px solid var(--line-strong);
    background: rgba(255, 255, 255, .96); color: var(--ink); box-shadow: var(--shadow-lg); cursor: pointer; animation: toast-in .2s ease-out; }
  html.is-typing .to-top, body.has-selbar .to-top, body.has-dock .to-top { display: none; }
  body:has(.selbar:not([hidden])) .to-top { display: none; }

  /* toasts sit above the tab bar (and above a docked selection bar / patent dock) */
  .toasts { left: max(12px, var(--safe-l)); right: max(12px, var(--safe-r)); bottom: calc(var(--bottom-ui) + 10px);
            width: auto; max-width: none; }

  /* selection bar docks over the tab bar (one row, 60px + inset); secondary actions go to an overflow sheet */
  .selbar { z-index: 30; left: 0; right: 0; bottom: 0; transform: none; width: auto; max-width: none; min-height: var(--bottom-ui);
            border-radius: 18px 18px 0 0; padding: 8px max(12px, var(--safe-r)) calc(8px + var(--safe-b)) max(12px, var(--safe-l));
            flex-wrap: nowrap; justify-content: flex-start; gap: 8px; overflow-x: auto; scrollbar-width: none;
            overscroll-behavior-x: contain; box-shadow: 0 -6px 24px rgba(38, 56, 75, .18); }
  .selbar::-webkit-scrollbar { display: none; }
  .selbar > * { flex: none; }
  .selbar .btn { height: 44px; }                                    /* 60px bar, real 44px targets */

  /* every dialog is a bottom sheet on phones (lifted above the on-screen keyboard: --kb, app.js) */
  dialog.modal, dialog.modal.wide, dialog.modal.sheet {
    width: 100%; max-width: 100%; margin: auto 0 var(--kb); max-height: calc(100% - var(--safe-t) - 24px - var(--kb));
    border-radius: 20px 20px 0 0; padding: 0 var(--safe-r) var(--safe-b) var(--safe-l); overscroll-behavior: contain;
    animation: sheet-up .24s cubic-bezier(.2, .8, .2, 1); }
  dialog.modal .m-head { position: sticky; top: 0; z-index: 2; background: var(--card); padding: 12px 16px 8px; }
  dialog.modal .m-body { padding: 8px 16px 12px; }
  dialog.modal .m-foot { position: sticky; bottom: 0; z-index: 2; background: var(--card); padding: 10px 16px 12px;
                         border-top: 1px solid var(--line); }
  dialog.modal .m-foot:empty { display: none; }
  dialog.modal .m-foot .btn { flex: 1 1 0; min-width: 0; }
  dialog.modal .m-head [data-close], dialog.modal .m-head [data-sheet-close] { width: 44px; height: 44px; margin: -8px -12px -8px 0; }
  dialog.sheet .sheet-grip { display: block; width: 40px; height: 5px; margin: 8px auto 0; border-radius: 3px; background: var(--line-strong); }

  [data-overflow] { display: none !important; }    /* listed in the sheet opened by [data-overflow-open] (app.js) */

  /* shared page helpers */
  .more-btn { width: 100%; height: 44px; margin-top: 6px; }       /* "Show all N" / "Show 15 more" */
  .page-head.compact-sm { flex-wrap: nowrap; align-items: center; margin-bottom: 12px; }
  .page-head.compact-sm > div:first-child { flex: 1 1 auto; }
  .page-head.compact-sm .sub { display: none; }
  .page-head.compact-sm .actions { flex-wrap: nowrap; align-items: center; }
  .btn.icon-sm-only { width: var(--control); padding: 0; }         /* label hidden on phones: <span class="hide-sm">Label</span> */

  /* KPI grids: auto-fit gave ONE column in cards < 312px wide */
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kpis.compact-sm { grid-template-columns: repeat(var(--kpi-cols, 3), minmax(0, 1fr)); gap: 8px; margin-bottom: 12px; }
  .kpis.compact-sm .kpi { padding: 10px; min-height: 64px; box-shadow: none; }
  .kpis.compact-sm .kpi .v { font-size: 20px; }
  .kpis.compact-sm .kpi .l { font-size: 11.5px; line-height: 1.25; }
  .kpis.compact-sm .kpi .s { display: none; }
}
@media (min-width: 761px) { .show-sm { display: none !important; } }

/* iOS Safari zooms the page when a field under 16px gets focus; !important beats page-level sizes
   (login 14.5px, search 15px, pager 13.5px) */
@media (max-width: 760px), (pointer: coarse) {
  input[type=text], input[type=search], input[type=email], input[type=password], input[type=number], input[type=date],
  input[type=url], input[type=tel], input:not([type]), select, textarea { font-size: 16px !important; }
}

/* ── Touch screens ────────────────────────────────────────────────── */
@media (pointer: coarse) {
  :root { --control: 44px; }
  .btn-sm { height: 36px; }
  .btn-sm.btn-icon { width: 36px; }
  .chip { height: 36px; }
  .tab { padding-top: 13px; padding-bottom: 13px; }
  .main-nav a, .tool-link, .user-menu > summary { height: 44px; min-width: 44px; }
  .user-menu .menu a, .user-menu .menu button, .subnav a { min-height: 44px; }
  .pager select { height: 36px; }
  /* invisible hit area: 36px-high small buttons / chips and the 23px star become 44px targets without layout change */
  :where(.btn-sm, .chip, .star) { position: relative; }
  :where(.btn-sm, .chip)::after { content: ""; position: absolute; inset: -4px 0; }
  .star::after { content: ""; position: absolute; inset: -10px; }
}

/* report / summary e-mail dialogs: a plain user's own confirmed address, read-only (App.mailPolicy) */
textarea.mail-own { min-height: 0; height: auto; resize: none; background: var(--paper); color: var(--ink-2); }

/* ── Reports split view (weekly_report.html + custom_summary.html), phones ──
   Detail view: the page head, tabs and the in-card back/actions give way to the sticky .rp-bar. Those hide rules
   only apply on pages that adopted the phone markup (nav.tabs.rp-tabs + .rp-bar), so a page without it keeps its
   own back button. */
.rp-bar { display: none; }
@media (max-width: 760px) {
  .app-main:has(> .rp-tabs):has(.rp-split.has-sel) > .page-head, .app-main:has(.rp-split.has-sel) > .rp-tabs { display: none; }
  .rp-tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; padding: 3px; border: 0; border-radius: 999px;
             background: var(--paper-2); margin-bottom: 14px; }
  .rp-tabs .tab { height: 44px; margin: 0; border: 0; border-radius: 999px; display: flex; align-items: center; justify-content: center; }
  .rp-tabs .tab[aria-current="page"] { background: var(--card); box-shadow: var(--shadow); }
  .rp-item { position: relative; min-height: 56px; padding: 10px 36px 10px 12px; border-left: 0; }
  .rp-item + .rp-item { border-top: 1px solid var(--line); }
  .rp-item::after { content: ""; position: absolute; right: 16px; top: 50%; width: 8px; height: 8px;
                    border-top: 2px solid var(--line-strong); border-right: 2px solid var(--line-strong); transform: translateY(-50%) rotate(45deg); }
  .rp-bar { display: flex; align-items: center; gap: 2px; position: sticky; top: var(--shell-top); z-index: 6; min-height: 52px;
            padding: 4px 6px; margin: -16px calc(-1 * var(--gutter)) 12px; background: rgba(250, 249, 245, .94);
            -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); transition: top .22s ease; }
  .rp-bar .btn { height: 44px; }
  .rp-bar .btn-icon { width: 44px; }
  .rp-bar .grow { flex: 1; }
  .app-main:has(> .rp-tabs) .rp-head :is(.rp-back, .rp-actions) { display: none !important; }
  .rp-head h2 { font-size: 21px; }
  .rp-view .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .rp-view .kpis > .kpi:first-child { grid-column: 1 / -1; }
  .rp-view .kpi { padding: 10px 12px; }
  .rp-view .kpi .v { font-size: 22px; }
}

/* ── Chinese UI (html lang="zh-CN", plan step 3) ── */
/* the uppercase small labels are spaced for Latin capitals; Chinese needs little tracking */
html:lang(zh-CN) .subnav .label, html:lang(zh-CN) .admin-switch .k, html:lang(zh-CN) .sheet-list > .sheet-label,
html:lang(zh-CN) .fs > legend { letter-spacing: .04em; }
/* language switch (_lang_switch.html) on the bare pages; in the user menu and the More sheet it is a menu row */
.bare .lang-switch { display: inline-flex; align-items: center; gap: 6px; padding: 0; border: 0; background: none;
                     color: var(--blue-deep); font: inherit; cursor: pointer; }
.bare .lang-switch:hover { text-decoration: underline; }
/* sign-in / sign-up footer: on a line of its own under the links (no separator in the markup: English unchanged) */
.bare .login-foot .lang-switch { display: flex; width: fit-content; margin: 10px auto 0; font-weight: 600; }

/* ── Deep-analysis collapse (App.renderAnalysis): phones show the executive summary + "Read the full analysis" ── */
.da-toggle { display: none; margin-top: 12px; }
@media (max-width: 760px) { .da:not(.da-open) .da-sec:not(.da-summary) { display: none; } .da-toggle { display: inline-flex; } }

@media print {
  .app-header, .app-footer, .selbar, .toasts, .no-print, .tabbar, .to-top, .p-dock, dialog, .trial-banner { display: none !important; }
  body { background: #fff; padding-bottom: 0 !important; }
  .card { box-shadow: none; }
  .da .da-sec { display: block !important; }
  .da-toggle { display: none !important; }
}
