/* apxsh (pack apxds, PRSXA + Pearl AI): spreadsheets. Same colours, radii and fonts as pearl-sheet.css; prefix apxsh-. */
/* ---- header: a labelled, darker Excel button (CHAT-12: white on #15803d is 5:1) */
.apxsh-card .psh-pri{background:#15803d;border-color:#15803d}
.apxsh-card .psh-pri:hover,.apxsh-card .psh-pri:focus-visible{background:#166534;border-color:#166534}
.apxsh-card .apxsh-short{display:none}
.apxsh-hid{display:none!important}
.apxsh-card .psh-tt b{white-space:normal;display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;line-height:1.3}
.apxsh-fsb svg,.apxsh-card .psh-b svg{flex:none}
.apxsh-errb,.apxsh-card .psh-b.apxsh-errb{border-color:#dc2626!important;box-shadow:0 0 0 2px rgba(220,38,38,.18)}
.apxsh-card .psh-pri.apxsh-errb{box-shadow:0 0 0 3px rgba(220,38,38,.45)}
.apxsh-card .psh-b[aria-expanded="true"]{border-color:#16a34a;color:#15803d}
@media (max-width:600px){
  .apxsh-card .psh-top .psh-b .apxsh-long{display:none}
  .apxsh-card .psh-top .psh-pri .apxsh-short{display:inline}
  .apxsh-card .psh-top .psh-pri:disabled .apxsh-long{display:inline}
  .apxsh-card .psh-top .psh-pri:disabled .apxsh-short{display:none}
  .apxsh-card .psh-top .apxsh-fsb{width:40px;padding:0;justify-content:center}
  .apxsh-card .psh-acts .psh-b span{display:inline}
  .apxsh-card .psh-acts .psh-b .apxsh-long{display:none}
  .apxsh-card .psh-acts .psh-b .apxsh-short{display:inline}
  .apxsh-card .psh-acts .psh-b{padding:0 10px}
}

/* ---- tools: find, formulas, chart; filters */
.apxsh-tools{display:flex;align-items:center;gap:8px;padding:8px 14px;border-bottom:1px solid var(--app-border,#e5e7eb)}
.apxsh-find{position:relative;flex:1;min-width:0;display:flex;align-items:center}
.apxsh-find>svg{position:absolute;left:10px;color:var(--app-text-dim,#6b7280);pointer-events:none}
.apxsh-q{width:100%;min-width:0;height:34px;box-sizing:border-box;padding:0 12px 0 32px;border:1px solid var(--app-border,#e5e7eb);border-radius:9px;background:var(--app-bg,#fff);color:var(--app-text,#111827);font:inherit;font-size:13px}
.apxsh-q:focus{outline:0;border-color:#16a34a;box-shadow:0 0 0 3px rgba(22,163,74,.2)}
.apxsh-q::-webkit-search-cancel-button{cursor:pointer}
.apxsh-qn{position:absolute;right:28px;font-size:11.5px;font-weight:600;color:var(--app-text-dim,#6b7280);pointer-events:none;white-space:nowrap}
.apxsh-vh{position:absolute!important;width:1px;height:1px;overflow:hidden;clip:rect(0 0 0 0);white-space:nowrap;margin:0;padding:0}
.apxsh-terr{margin:6px 14px 0;font-size:12.5px;font-weight:600;color:#b91c1c}
.apxsh-terr[hidden]{display:none}
html[data-theme="dark"] .apxsh-terr,html[data-theme="dark"] .apxsh-cherr{color:#fca5a5}
.apxsh-fbar{display:flex;flex-wrap:wrap;gap:6px;padding:8px 14px 0}
.apxsh-fbar[hidden]{display:none}
.apxsh-chip{display:inline-flex;align-items:center;gap:6px;padding:2px 2px 2px 10px;border:1px solid rgba(22,163,74,.45);border-radius:20px;background:rgba(22,163,74,.06);font-size:12px;color:var(--app-text,#111827)}
.apxsh-chip>svg{color:#15803d}
.apxsh-chip label{font-weight:600;white-space:nowrap}
.apxsh-chip input{width:120px;height:28px;padding:0 6px;border:0;border-radius:6px;background:var(--app-bg,#fff);color:inherit;font:inherit;font-size:12.5px}
.apxsh-chip input:focus{outline:2px solid #16a34a}
.apxsh-chx{display:inline-flex;align-items:center;justify-content:center;width:28px;height:28px;padding:0;border:0;border-radius:50%;background:transparent;color:inherit;cursor:pointer}
.apxsh-chx:hover,.apxsh-chx:focus-visible{background:rgba(127,127,127,.15);outline:0}

/* ---- the grid: frozen header row, column menu cue, resize, selection, find, formulas */
.psh .psh-t tr.psh-head td{position:sticky;top:var(--apxsh-hh,25px);z-index:2;background:linear-gradient(rgba(22,163,74,.07),rgba(22,163,74,.07)),var(--app-bg,#fff)}
.psh .psh-t tr.psh-head th.psh-rh{position:sticky;top:var(--apxsh-hh,25px);left:0;z-index:3}
html[data-theme="dark"] .psh .psh-t tr.psh-head td{background:linear-gradient(rgba(134,239,172,.08),rgba(134,239,172,.08)),var(--app-bg,#071a3d)}
.apxsh-card .psh-t thead th.psh-ch{cursor:pointer;position:sticky;user-select:none}
.apxsh-card .psh-t thead th.psh-ch:hover{color:var(--app-text,#111827);background:linear-gradient(rgba(127,127,127,.1),rgba(127,127,127,.1)),var(--app-sidebar,#f8fafc)}
.apxsh-card .psh-t thead th.apxsh-act{color:#15803d;box-shadow:inset 0 -2px 0 #16a34a}
html[data-theme="dark"] .apxsh-card .psh-t thead th.apxsh-act{color:#86efac}
.apxsh-mk{display:inline-flex;gap:1px;margin-left:3px;vertical-align:-1px;color:#15803d}
.apxsh-mk:empty{display:none}
html[data-theme="dark"] .apxsh-mk{color:#86efac}
.apxsh-rz{position:absolute;top:0;bottom:0;right:0;width:8px;cursor:col-resize;touch-action:none;z-index:4}
.apxsh-rz:hover,html.apxsh-resizing .apxsh-rz{background:linear-gradient(90deg,transparent 3px,#16a34a 3px,#16a34a 5px,transparent 5px)}
html.apxsh-resizing,html.apxsh-resizing *{cursor:col-resize!important;user-select:none!important}
.apxsh-card .psh-t tbody th.psh-rh{cursor:pointer}
.apxsh-card .psh-t tbody th.psh-rh:hover{color:var(--app-text,#111827)}
.psh .psh-t td.apxsh-in{background-image:linear-gradient(rgba(22,163,74,.14),rgba(22,163,74,.14))}
html[data-theme="dark"] .psh .psh-t td.apxsh-in{background-image:linear-gradient(rgba(134,239,172,.16),rgba(134,239,172,.16))}
.psh .psh-t td.apxsh-hit{background-image:linear-gradient(rgba(250,204,21,.35),rgba(250,204,21,.35))}
html[data-theme="dark"] .psh .psh-t td.apxsh-hit{background-image:linear-gradient(rgba(250,204,21,.22),rgba(250,204,21,.22))}
.psh .psh-t tr.apxsh-hide{display:none}
.psh .psh-t td.apxsh-fv{font-family:ui-monospace,SFMono-Regular,Menlo,Consolas,monospace;font-size:12px;text-align:left}
.apxsh-card .psh-wrap{user-select:none;-webkit-user-select:none}
.apxsh-card .psh-t td:focus{outline:0}
.apxsh-card .psh-wrap .psh-in{user-select:text;-webkit-user-select:text}

/* ---- status bar */
.apxsh-status{display:flex;align-items:center;justify-content:space-between;flex-wrap:wrap;gap:4px 12px;min-height:32px;padding:5px 14px;border-top:1px solid var(--app-border,#e5e7eb);font-size:12px;color:var(--app-text-dim,#6b7280);font-variant-numeric:tabular-nums}
.apxsh-stats b{font-weight:600;color:var(--app-text,#111827)}
.apxsh-stats i{font-style:normal;margin:0 6px;opacity:.6}
.apxsh-view{display:inline-flex;align-items:center;gap:8px;flex-wrap:wrap}
.apxsh-pill{padding:2px 8px;border-radius:20px;background:rgba(22,163,74,.08);color:#15803d;font-weight:600}
html[data-theme="dark"] .apxsh-pill{color:#86efac;background:rgba(134,239,172,.1)}
.apxsh-ok{display:inline-flex;align-items:center;gap:4px;color:#15803d}
html[data-theme="dark"] .apxsh-ok{color:#86efac}
.apxsh-warn{color:#b45309}
html[data-theme="dark"] .apxsh-warn{color:#fbbf24}
.apxsh-link{border:0;background:transparent;padding:2px 0;color:#2563eb;font:inherit;font-weight:600;cursor:pointer;text-decoration:underline}
/* apx-fx-11: touch range selection */
@media (hover: none){.psh.apxsh-card td.on,.psh.apxsh-card td.apxsh-in{touch-action:none}.apxsh-fxb{min-height:36px;padding:4px 8px;margin-left:4px}}
html[data-theme="dark"] .apxsh-link{color:#93c5fd}
@media (max-width:600px){.apxsh-wide{display:none}}

/* ---- confirm, retry */
.apxsh-confirm{display:flex;flex-wrap:wrap;align-items:center;gap:8px 12px;margin:0 14px 10px;padding:10px 12px;border-radius:10px;border:1px solid rgba(220,38,38,.3);background:rgba(220,38,38,.06);font-size:13px}
.apxsh-confirm>span:first-child{flex:1 1 220px}
.apxsh-cfb{display:flex;gap:8px}
.apxsh-danger{background:#b91c1c!important;border-color:#b91c1c!important;color:#fff!important}
.apxsh-danger:hover,.apxsh-danger:focus-visible{background:#991b1b!important;box-shadow:0 0 0 3px rgba(220,38,38,.25)}
.apxsh-retry{display:inline-flex;align-items:center;gap:5px;height:28px;margin-left:4px;padding:0 10px;border:1px solid currentColor;border-radius:7px;background:transparent;color:inherit;font:inherit;font-weight:700;font-size:12.5px;cursor:pointer;vertical-align:middle}
.apxsh-retry:hover,.apxsh-retry:focus-visible{background:rgba(127,127,127,.12);outline:0}

/* ---- chart */
.apxsh-chart{padding:10px 14px 12px;border-top:1px solid var(--app-border,#e5e7eb)}
.apxsh-chh{display:flex;align-items:center;flex-wrap:wrap;gap:8px;margin-bottom:6px}
.apxsh-chh b{flex:1 1 180px;font-size:13.5px;min-width:0}
.apxsh-seg{display:inline-flex;padding:2px;border:1px solid var(--app-border,#e5e7eb);border-radius:9px}
.apxsh-seg button{height:28px;padding:0 11px;border:0;border-radius:7px;background:transparent;color:var(--app-text,#111827);font:inherit;font-size:12.5px;font-weight:600;cursor:pointer}
.apxsh-seg button[aria-checked="true"]{background:#15803d;color:#fff}
.apxsh-seg button:disabled{opacity:.4;cursor:default}
.apxsh-seg button:focus-visible{outline:2px solid #16a34a;outline-offset:1px}
.apxsh-chv{color:var(--app-text,#111827)}
.apxsh-chv svg{display:block;width:100%;height:auto;max-height:360px}
.apxsh-cherr{margin-top:6px;font-size:12.5px;font-weight:600;color:#b91c1c}
.apxsh-cherr[hidden]{display:none}

/* ---- menus (popover; bottom sheet on phones) */
.apxsh-menu{position:fixed;z-index:2147483300;min-width:240px;max-width:min(340px,calc(100vw - 16px));max-height:calc(100vh - 16px);overflow:auto;padding:6px;border:1px solid var(--app-border,#e5e7eb);border-radius:12px;background:var(--app-bg,#fff);color:var(--app-text,#111827);box-shadow:var(--app-shadow-md,0 10px 28px rgba(15,21,36,.1));font-family:inherit;animation:apxshin .12s ease-out}
.apxsh-mov{position:fixed;inset:0;z-index:2147483300;background:rgba(5,10,25,.45);display:flex;align-items:flex-end;animation:apxshfade .15s ease-out}
.apxsh-menu.is-sheet{position:relative;width:100%;max-width:none;max-height:78vh;border-radius:18px 18px 0 0;padding:4px 8px calc(10px + env(safe-area-inset-bottom,0px));animation:apxshup .18s ease-out}
.apxsh-mh{display:flex;align-items:center;gap:8px;padding:6px 4px 6px 10px;position:relative}
.apxsh-mh[hidden]{display:none}
.apxsh-mh b{flex:1;font-size:15px}
.apxsh-grab{position:absolute;left:50%;top:2px;width:40px;height:4px;margin-left:-20px;border-radius:4px;background:var(--app-border-hi,#cbd5e1)}
.apxsh-mi{display:flex;align-items:center;gap:10px;width:100%;min-height:40px;padding:7px 10px;border:0;border-radius:8px;background:transparent;color:inherit;font:inherit;font-size:13.5px;text-align:left;cursor:pointer}
.apxsh-mi:hover,.apxsh-mi:focus-visible{background:rgba(22,163,74,.08);outline:0}
.apxsh-mi:focus-visible{box-shadow:inset 0 0 0 2px #16a34a}
.apxsh-mi:disabled{opacity:.45;cursor:default}
.apxsh-mic{display:inline-flex;color:var(--app-text-dim,#6b7280)}
.apxsh-mt{flex:1;display:flex;flex-direction:column;min-width:0}
.apxsh-mt small{font-size:11.5px;color:var(--app-text-dim,#6b7280)}
.apxsh-mi kbd{font:600 11px/1 ui-monospace,Menlo,Consolas,monospace;padding:3px 6px;border:1px solid var(--app-border,#e5e7eb);border-radius:5px;color:var(--app-text-dim,#6b7280)}
.apxsh-msep{height:1px;margin:5px 4px;background:var(--app-border,#e5e7eb)}
.apxsh-menu.is-sheet .apxsh-mi{min-height:48px;font-size:15px}
.apxsh-ib{display:inline-flex;align-items:center;justify-content:center;width:36px;height:36px;flex:none;padding:0;border:0;border-radius:9px;background:transparent;color:var(--app-text,#111827);cursor:pointer}
.apxsh-ib:hover{background:rgba(127,127,127,.12)}
.apxsh-ib:focus-visible{outline:2px solid #16a34a;outline-offset:1px}
@keyframes apxshin{from{opacity:0;transform:translateY(-4px)}to{opacity:1;transform:none}}
@keyframes apxshup{from{transform:translateY(100%)}to{transform:none}}
@keyframes apxshfade{from{opacity:0}to{opacity:1}}

/* ---- keyboard shortcuts */
.apxsh-keys{position:fixed;inset:0;z-index:2147483640;display:flex;align-items:center;justify-content:center;padding:16px;background:rgba(5,10,25,.5);animation:apxshfade .15s ease-out}
.apxsh-kbox{width:min(480px,100%);max-height:calc(100vh - 32px);overflow:auto;border-radius:16px;background:var(--app-bg,#fff);color:var(--app-text,#111827);border:1px solid var(--app-border,#e5e7eb);box-shadow:var(--app-shadow-lg,0 24px 70px rgba(15,21,36,.16))}
.apxsh-kh{display:flex;align-items:center;justify-content:space-between;padding:8px 8px 4px 18px}
.apxsh-kh b{font-size:16px}
.apxsh-kbox dl{margin:0;padding:4px 18px 16px}
.apxsh-kbox dl>div{display:flex;gap:14px;padding:8px 0;border-top:1px solid var(--app-border,#e5e7eb);font-size:13.5px}
.apxsh-kbox dt{flex:0 0 46%;font-weight:700;font-family:ui-monospace,SFMono-Regular,Menlo,Consolas,monospace;font-size:12.5px}
.apxsh-kbox dd{margin:0;flex:1;opacity:.85}

/* ---- full screen */
html.apxsh-lock,html.apxsh-lock body{overflow:hidden}
.apxsh-fs{position:fixed;inset:0;z-index:2147483000;display:flex;background:var(--app-bg,#fff);padding:env(safe-area-inset-top,0px) 0 env(safe-area-inset-bottom,0px)}
.psh.is-full{flex:1;min-width:0;min-height:0;margin:0;border:0;border-radius:0;box-shadow:none;display:flex;flex-direction:column}
.psh.is-full .psh-wrap{flex:1;min-height:0;max-height:none}
.psh.is-full .psh-src{display:none}
.apxsh-ph{margin:10px 0 14px;border:1px dashed var(--app-border,#e5e7eb);border-radius:16px}

/* ---- touch: 40px+ targets */
@media (pointer:coarse){
  .apxsh-card .psh-b{min-height:40px}
  .apxsh-card .psh-tabs button{min-height:40px}
  .apxsh-card .psh-t thead th{padding-top:10px;padding-bottom:10px}
  .apxsh-card .psh-t .psh-rh{min-width:40px}
  .apxsh-q{height:40px;font-size:16px}
  .apxsh-chip input{height:36px;font-size:16px}
  .apxsh-chx{width:36px;height:36px}
  .apxsh-seg button{height:36px}
  .apxsh-retry{height:36px}
  .apxsh-mi{min-height:44px}
  .apxsh-mi kbd{display:none}
  .apxsh-ib{width:44px;height:44px}
  .apxsh-rz{width:16px}
}
@media (prefers-reduced-motion:reduce){.apxsh-menu,.apxsh-mov,.apxsh-menu.is-sheet,.apxsh-keys{animation:none}}
.apxsh-q.has-n{padding-right:84px}
/* apx-fx-13: phones: Find gets the whole row while it is in use */
@media (max-width:520px){.apxsh-tools{flex-wrap:wrap}.apxsh-find:focus-within,.apxsh-find:has(.apxsh-q.has-n){flex:1 1 100%}}
