/* Payment Hub admin: one stylesheet for the whole panel (light console, owner decision 2026-10-31).
   Same language as the Starlink4Syria store: near-black canvas, one blue accent, white pill for the
   main action, Readex Pro (display) + IBM Plex Sans Arabic (text). Denser than the store because this
   is a working tool. Layout: sidebar >=1280px, icon rail 768-1279px, top bar + bottom tabs <768px.
   Every tap target is >=44px and form fields are 16px so iOS does not zoom. */

:root {
  color-scheme: light;
  --bg: #f4f6f9;
  --sidebar: #ffffff;
  --surface: #ffffff;
  --surface-2: #f1f3f6;
  --surface-3: #e6e9ee;
  --border: #dde1e7;
  --border-strong: #c9cfd8;
  --hairline: #e6e9ee;
  --text: #141821;
  --text-2: #3a4250;
  --muted: #687180;
  --primary: #0a66d8;
  --primary-ink: #ffffff;
  --primary-soft: #e8f1fd;
  --accent: #e8f1fd;
  --success: #147a3a; --success-soft: #e6f4eb;
  --warning: #9a5800; --warning-soft: #fcf1df;
  --danger: #bf2730;  --danger-soft: #fcebea;
  --info: #0a66d8;    --info-soft: #e8f1fd;
  --hover: #f6f8fa;
  --shadow: 0 1px 2px rgb(16 24 40 / 0.05);
  /* Each section has its own colour so the panel reads at a glance. */
  --section: var(--primary);
  --radius: 12px;
  --radius-sm: 8px;
  --font-body: "IBM Plex Sans Arabic", "Noto Sans Arabic", Tahoma, Arial, sans-serif;
  --font-display: "IBM Plex Sans Arabic", "Noto Sans Arabic", Tahoma, Arial, sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --tabbar-h: 64px;
}
body[data-section="overview"] { --section: #0a66d8; }
body[data-section="accounts"] { --section: #0f8a7a; }
body[data-section="operations"] { --section: #4f46e5; }
body[data-section="matching"] { --section: #b45309; }
body[data-section="projects"] { --section: #7c3aed; }
body[data-section="system"] { --section: #475569; }

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
html, body { max-width: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
p { margin: 0 0 8px; }
ul, ol { margin: 0; padding-inline-start: 20px; }
h1, h2, h3, h4 { font-family: var(--font-display); font-weight: 600; margin: 0; line-height: 1.3; letter-spacing: 0; }
h1 { font-size: clamp(24px, 2.4vw, 32px); }
h2 { font-size: 18px; }
h3 { font-size: 16px; }
h4 { font-size: 15px; }
code, pre, kbd { font-family: var(--font-mono); font-size: 0.9em; }
pre { white-space: pre-wrap; overflow-wrap: anywhere; margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; max-width: 100%; }
button, a, summary, select, label { -webkit-tap-highlight-color: transparent; }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 3px; }
::selection { background: var(--primary-soft); }
[hidden] { display: none !important; }
svg { flex: none; }

/* ---------------------------------------------------------------- shell */
.ph-skip-link {
  position: fixed; z-index: 100; inset-block-start: 8px; inset-inline-start: 8px;
  transform: translateY(-200%); padding: 10px 14px; border-radius: 12px;
  background: var(--text); color: var(--bg);
}
.ph-skip-link:focus { transform: none; }

.ph-app { min-height: 100dvh; display: grid; grid-template-columns: 248px minmax(0, 1fr); }
.ph-sidebar {
  position: sticky; top: 0; height: 100dvh; overflow-y: auto;
  display: flex; flex-direction: column; gap: 24px;
  padding: 20px 14px 16px;
  background: var(--sidebar); border-inline-start: 1px solid var(--hairline);
}
.ph-brand { display: flex; align-items: center; gap: 12px; padding: 4px 8px 18px; border-bottom: 1px solid var(--hairline); }
.ph-brand-mark {
  width: 38px; height: 38px; border-radius: 11px; flex: none;
  display: grid; place-items: center; background: var(--text); color: var(--bg);
}
.ph-brand-mark svg { width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.ph-brand-text strong { display: block; font-family: var(--font-display); font-size: 16px; font-weight: 600; }
.ph-brand-text small { display: block; color: var(--muted); font-size: 12px; }

.ph-nav { display: grid; gap: 2px; }
.ph-nav-item {
  position: relative; display: flex; align-items: center; gap: 12px;
  min-height: 44px; padding: 8px 12px; border-radius: 12px;
  color: var(--text-2); font-size: 14px;
}
.ph-nav-item:hover { background: var(--hover); color: var(--text); }
.ph-nav-item.is-active { background: color-mix(in srgb, var(--section) 10%, white); color: var(--section); font-weight: 600; }
.ph-nav-icon { width: 24px; height: 24px; display: grid; place-items: center; color: var(--muted); }
.ph-nav-item.is-active .ph-nav-icon { color: var(--primary); }
.ph-nav-icon svg, .ph-tab svg, .ph-icon-btn svg, .ph-btn svg {
  width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round;
}

.ph-sidebar-foot { margin-top: auto; display: grid; gap: 10px; padding-top: 14px; border-top: 1px solid var(--hairline); }
.ph-user { display: flex; align-items: center; gap: 10px; padding: 0 6px; min-width: 0; }
.ph-user-avatar {
  width: 34px; height: 34px; border-radius: 50%; flex: none; display: grid; place-items: center;
  background: var(--accent); color: var(--primary); font-weight: 600;
}
.ph-user-text { min-width: 0; }
.ph-user-text strong { display: block; font-size: 14px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ph-user-text small { display: block; color: var(--muted); font-size: 12px; text-align: right; }
.ph-logout-form { margin: 0; }
.ph-build { display: block; padding: 0 6px; color: var(--muted); font-size: 11px; font-family: var(--font-mono); text-align: right; }

.ph-workspace { min-width: 0; }
.ph-appbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 12px;
  min-height: 60px; padding: 8px 32px;
  background: var(--surface);
  border-bottom: 1px solid var(--hairline);
}
.ph-appbar-brand { display: none; }
.ph-appbar-section { color: var(--muted); font-size: 14px; }
.ph-appbar-actions { margin-inline-start: auto; display: flex; align-items: center; gap: 8px; }
.ph-appbar-system { display: none; }
.ph-icon-btn {
  min-width: 44px; min-height: 44px; padding: 0 12px; border-radius: 999px;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text-2);
  cursor: pointer; font-size: 13px;
}
.ph-icon-btn:hover { background: var(--surface-2); color: var(--text); }
.ph-icon-btn.is-active { color: var(--primary); }
kbd { padding: 1px 6px; border: 1px solid var(--border); border-radius: 6px; color: var(--muted); font-size: 11px; }

.ph-main { max-width: 1400px; margin: 0 auto; padding: 28px 32px 96px; min-width: 0; }
.ph-page-head { margin-bottom: 20px; padding: 18px 20px; border: 1px solid var(--border); border-inline-start: 4px solid var(--section); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); }
.ph-eyebrow { margin: 0 0 4px; color: var(--section); font-size: 13px; font-weight: 600; }
.ph-page-head h1 { overflow-wrap: anywhere; text-align: right; }

.ph-tabbar { display: none; }

/* ---------------------------------------------------------------- buttons */
.ph-btn {
  min-height: 40px; padding: 8px 16px; border-radius: var(--radius-sm);
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 1px solid var(--border); background: var(--surface-2); color: var(--text);
  font-size: 14px; font-weight: 500; line-height: 1.35; cursor: pointer; white-space: normal; text-align: center;
  transition: background 0.15s, border-color 0.15s;
}
.ph-btn:hover { background: var(--surface-3); border-color: var(--border-strong); }
.ph-btn:active { transform: translateY(1px); }
.ph-btn:disabled, .ph-btn[aria-disabled="true"] { opacity: 0.45; cursor: not-allowed; }
.ph-btn-primary, .ph-btn-primary:focus-visible { background: var(--primary); border-color: var(--primary); color: var(--primary-ink); }
.ph-btn-primary:hover { background: #0857bb; border-color: #0857bb; }
.ph-btn-warning { background: var(--warning-soft); border-color: #efd3a5; color: var(--warning); }
.ph-btn-danger { background: var(--danger-soft); border-color: #f2c4c2; color: var(--danger); }
.ph-btn-quiet { background: transparent; border-color: transparent; color: var(--muted); }
.ph-btn-quiet:hover { background: var(--hover); color: var(--text); border-color: transparent; }
.ph-btn-sm { min-height: 36px; padding: 6px 14px; font-size: 13px; }
.ph-btn-lg { min-height: 52px; font-size: 16px; }
.ph-btn-block { width: 100%; }
.ph-copy-button.is-copied { border-color: var(--success); color: var(--success); }

/* Operations: amount, parties (from → to), reference with copy and explorer link. */
.ph-op-amount { font-size: 16px; font-weight: 600; font-variant-numeric: tabular-nums; text-align: right; }
.ph-op-success { color: var(--success); }
.ph-op-warning { color: var(--warning); }
.ph-party { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; min-height: 28px; font-size: 13px; }
.ph-party + .ph-party { margin-top: 2px; }
.ph-party-role { min-width: 26px; color: var(--muted); font-size: 12px; }
.ph-party-name { font-weight: 500; }
.ph-party-ours { color: var(--primary); }
.ph-party-ref { font-family: "IBM Plex Mono", ui-monospace, monospace; font-size: 12px; color: var(--muted); word-break: break-all; }
.ph-parties-full .ph-party { padding: 8px 0; border-bottom: 1px solid var(--hairline); }
.ph-parties-full .ph-party:last-child { border-bottom: 0; }
.ph-ref-line { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.ph-ref-line code { white-space: nowrap; }
.ph-copy-mini { min-height: 28px; padding: 2px 10px; font-size: 12px; }
.ph-explorer-link { display: inline-flex; align-items: center; min-height: 28px; font-size: 12px; color: var(--primary); text-decoration: none; }
.ph-explorer-link:hover { text-decoration: underline; }
.ph-table-parties-cell { min-width: 220px; }

/* Form fields: the old pages put .ph-btn on inputs/selects, so style those as fields. */
input.ph-btn, select.ph-btn, textarea.ph-btn, .ph-input, .ph-command-input {
  display: block; width: 100%; min-height: 46px; padding: 10px 14px;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface-2); color: var(--text);
  font-size: 16px; font-weight: 400; text-align: start; white-space: normal;
}
textarea.ph-btn { min-height: 96px; resize: vertical; }
select.ph-btn { appearance: none; height: 46px; padding-inline-start: 14px; padding-inline-end: 40px;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: 16px 50%, 21px 50%; background-size: 5px 5px; background-repeat: no-repeat; }
input.ph-btn:hover, select.ph-btn:hover, textarea.ph-btn:hover { background-color: var(--surface-2); }
input.ph-btn:focus, select.ph-btn:focus, textarea.ph-btn:focus, .ph-input:focus, .ph-command-input:focus {
  outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft);
}
input[type="checkbox"], input[type="radio"] { width: 18px; height: 18px; accent-color: var(--primary); }
.ph-form-control { margin-top: 6px; }
.ph-form-contents { display: contents; }
label { color: var(--text-2); font-size: 14px; }
.ph-field { display: grid; gap: 6px; }
.ph-field > span { font-size: 14px; color: var(--text-2); }
.ph-review-choice { display: flex; align-items: center; gap: 10px; min-height: 44px; margin-top: 8px; }

/* ---------------------------------------------------------------- surfaces */
.ph-grid { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 12px; min-width: 0; }
.ph-grid > *, .ph-minw-0, .ph-section-title > * { min-width: 0; }
.ph-card {
  grid-column: span 4; min-width: 0;
  padding: 20px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow);
  overflow-wrap: anywhere;
}
.ph-card-half { grid-column: span 6; }
.ph-card-wide { grid-column: span 8; }
.ph-card-full { grid-column: 1 / -1; }
.ph-card-success { border-color: #bfe3cb; }
.ph-card-danger { border-color: #f2c4c2; }
.ph-border-strong { border-color: var(--border-strong); }
.ph-card > h2, .ph-card > h3 { margin-bottom: 8px; }
.ph-card-label { color: var(--muted); font-size: 13px; }
.ph-metric { margin-top: 6px; font-family: var(--font-display); font-size: 28px; font-weight: 600; line-height: 1.2; font-variant-numeric: tabular-nums; }
.ph-metric-sm { font-size: 19px; }
.ph-subtle { color: var(--muted); font-size: 13px; }
.ph-success { color: var(--success); }
.ph-warning { color: var(--warning); }
.ph-danger { color: var(--danger); }

.ph-section { margin-top: 28px; }
.ph-section:first-child { margin-top: 0; }
.ph-section-title { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.ph-section-title h2 { font-size: 18px; }
.ph-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.ph-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.ph-toolbar-card {
  display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap;
  padding: 18px 20px; border: 1px solid var(--hairline); border-radius: var(--radius); background: var(--surface);
}

.ph-kpi-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.ph-kpi { min-width: 0; padding: 18px; border: 1px solid var(--hairline); border-radius: var(--radius); background: var(--surface); }
.ph-kpi-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; color: var(--muted); font-size: 13px; }
.ph-kpi-value { margin-top: 8px; font-family: var(--font-display); font-size: 30px; font-weight: 600; line-height: 1.15; font-variant-numeric: tabular-nums; }
.ph-kpi-note { margin-top: 6px; color: var(--muted); font-size: 12px; }
.ph-currency-strip { display: flex; align-items: flex-end; gap: 18px; flex-wrap: wrap; margin-top: 10px; }
.ph-currency-strip strong { display: block; font-size: 18px; }
.ph-currency-strip span { color: var(--muted); font-size: 12px; }

.ph-meta-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 8px; }
.ph-meta-item, .ph-balance-item { min-width: 0; padding: 12px; border-radius: var(--radius-sm); background: var(--surface-2); font-size: 14px; }
.ph-balance-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 8px; margin-top: 12px; }
.ph-mini-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--hairline); }
.ph-list-row { padding: 12px 0; border-bottom: 1px solid var(--hairline); }
.ph-list-row:last-child { border-bottom: 0; padding-bottom: 0; }
.ph-friendly-note { margin-top: 10px; padding: 10px 12px; border-radius: var(--radius-sm); background: var(--surface-2); color: var(--muted); font-size: 13px; }
.ph-empty { padding: 36px 16px; text-align: center; }
.ph-empty strong { display: block; font-size: 15px; }
.ph-empty span { display: block; margin-top: 4px; color: var(--muted); font-size: 13px; }

.ph-technical, .ph-archive, .ph-filter-advanced { margin-top: 12px; border: 1px solid var(--hairline); border-radius: var(--radius-sm); }
.ph-technical > summary, .ph-archive > summary, .ph-filter-advanced > summary {
  min-height: 44px; display: flex; align-items: center; padding: 8px 14px; cursor: pointer;
  color: var(--muted); font-size: 13px; font-weight: 500;
}
.ph-filter-advanced > summary { color: var(--primary); }
.ph-technical[open] > summary, .ph-archive[open] > summary { border-bottom: 1px solid var(--hairline); }
.ph-technical-body, .ph-archive-body { padding: 12px 14px; font-size: 13px; }

/* ---------------------------------------------------------------- status + identity */
.ph-status {
  display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px;
  background: var(--surface-2); color: var(--text-2);
  font-size: 12px; font-weight: 600; white-space: nowrap; line-height: 1.6;
}
.ph-status::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; flex: none; }
.ph-status-success, .ph-status-ok { color: var(--success); background: var(--success-soft); }
.ph-status-warning { color: var(--warning); background: var(--warning-soft); }
.ph-status-danger, .ph-status-error { color: var(--danger); background: var(--danger-soft); }
.ph-status-info { color: var(--info); background: var(--info-soft); }
.ph-status-neutral { color: var(--muted); background: var(--hover); }
.ph-status-group { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }

.ph-ltr { direction: ltr; unicode-bidi: isolate; display: inline-block; max-width: 100%; text-align: left; }
.ph-num, .ph-amount { direction: ltr; unicode-bidi: isolate; font-variant-numeric: tabular-nums; }
.ph-break-anywhere, .ph-entity-name { overflow-wrap: anywhere; word-break: break-word; }
.ph-one-line { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ph-technical-id { direction: ltr; unicode-bidi: isolate; color: var(--muted); font-family: var(--font-mono); font-size: 12px; overflow-wrap: anywhere; }
.ph-provider-mark {
  width: 40px; height: 40px; flex: none; display: grid; place-items: center;
  border-radius: 11px; background: var(--accent); color: var(--primary); font-size: 12px; font-weight: 600;
}

.ph-account-identity {
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  padding: 18px 20px; margin-bottom: 12px;
  border: 1px solid var(--hairline); border-radius: var(--radius); background: var(--surface);
}
.ph-account-identity-main { flex: 1 1 260px; min-width: 0; }
.ph-account-identity h2 { font-size: 20px; }
.ph-account-identity-meta { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 4px; color: var(--muted); font-size: 13px; }
.ph-account-identity-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.ph-account-truth-axes { display: grid; gap: 6px; }

.ph-page-tabs {
  display: flex; gap: 4px; width: fit-content; max-width: 100%; margin-bottom: 16px; padding: 4px;
  border: 1px solid var(--hairline); border-radius: 999px; background: var(--surface);
  overflow-x: auto; scrollbar-width: none;
}
.ph-page-tab { min-height: 40px; display: inline-flex; align-items: center; padding: 6px 16px; border-radius: 999px; color: var(--muted); font-size: 14px; white-space: nowrap; }
.ph-page-tab:hover { color: var(--text); }
.ph-page-tab.is-active { background: var(--section); color: #fff; }

.ph-owner-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 260px), 1fr)); gap: 12px; margin-block: 14px; }
.ph-owner-grid > .ph-card { grid-column: auto; }
.ph-owner-summary { line-height: 1.8; }
.ph-owner-steps { display: grid; gap: 6px; padding-inline-start: 22px; }

/* ---------------------------------------------------------------- filters, tables, operations */
.ph-filter-grid { align-items: end; }
.ph-filter-grid > label { display: block; min-width: 0; }
.ph-active-filters { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 12px; padding: 10px 12px; border: 1px solid var(--hairline); border-radius: var(--radius-sm); background: var(--surface); }
.ph-filter-badge { display: inline-flex; align-items: center; gap: 4px; padding: 4px 10px; border-radius: 999px; background: var(--primary-soft); font-size: 12px; }
.ph-filter-badge strong { color: var(--muted); font-weight: 500; }

.ph-data-panel { min-width: 0; overflow: hidden; box-shadow: var(--shadow); border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.ph-data-panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; min-height: 56px; padding: 12px 16px; border-bottom: 1px solid var(--hairline); }
.ph-data-panel-title { font-family: var(--font-display); font-size: 16px; font-weight: 600; }
.ph-data-panel-sub { color: var(--muted); font-size: 12px; }
.ph-table-wrap { max-width: 100%; overflow-x: auto; }
.ph-data-table { width: 100%; border-collapse: collapse; }
.ph-data-table th {
  padding: 10px 14px; text-align: right; white-space: nowrap;
  color: var(--muted); font-size: 12px; font-weight: 500; border-bottom: 1px solid var(--border); background: var(--surface-2);
}
.ph-data-table td { padding: 10px 14px; border-bottom: 1px solid var(--hairline); font-size: 14px; vertical-align: middle; }
.ph-data-table tbody tr:last-child td { border-bottom: 0; }
.ph-data-table tbody tr:hover { background: var(--hover); }
.ph-data-table-compact td { padding-block: 8px; }
.ph-table-primary { font-size: 14px; font-weight: 500; }
.ph-table-secondary { color: var(--muted); font-size: 12px; }
.ph-table-amount { font-variant-numeric: tabular-nums; font-weight: 600; white-space: nowrap; }
.ph-table-account { display: flex; align-items: center; gap: 10px; min-width: 160px; }
.ph-table-account .ph-provider-mark { width: 32px; height: 32px; border-radius: 9px; font-size: 11px; }
.ph-table-actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.ph-table-actions .ph-btn { min-height: 36px; padding: 6px 14px; font-size: 13px; }
.ph-reference-cell { display: grid; gap: 4px; justify-items: start; max-width: 260px; }
.ph-reference-cell .ph-technical-id { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ph-reference-line { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 4px 0; }
.ph-pagination-disabled { min-height: 36px; padding: 6px 14px; display: inline-flex; align-items: center; border: 1px solid var(--hairline); border-radius: 999px; color: var(--muted); font-size: 13px; opacity: 0.5; }
.ph-operation-card { overflow: hidden; }
.ph-operation-meta { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-top: 10px; color: var(--muted); font-size: 12px; }

/* Plain tables inside cards (old pages) */
.ph-card table:not(.ph-data-table) { width: 100%; border-collapse: collapse; font-size: 14px; }
.ph-card table:not(.ph-data-table) th, .ph-card table:not(.ph-data-table) td { padding: 8px 10px; border-bottom: 1px solid var(--hairline); text-align: right; }
.ph-card table:not(.ph-data-table) th { color: var(--muted); font-weight: 500; font-size: 12px; }

/* ---------------------------------------------------------------- command dialog + toast */
.ph-command-dialog {
  width: min(560px, calc(100vw - 24px)); padding: 0; margin-top: 12vh;
  border: 1px solid var(--border); border-radius: 20px; background: var(--surface); color: var(--text);
  box-shadow: 0 24px 64px rgb(16 24 40 / 0.18);
}
.ph-command-dialog::backdrop { background: rgb(16 24 40 / 0.35); }
.ph-command-head { display: flex; gap: 8px; padding: 12px; border-bottom: 1px solid var(--hairline); }
.ph-command-list { display: grid; padding: 6px; max-height: 60vh; overflow-y: auto; }
.ph-command-link { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 48px; padding: 8px 12px; border-radius: 12px; }
.ph-command-link:hover, .ph-command-link:focus-visible { background: var(--surface-2); outline: none; }
.ph-command-link small { color: var(--muted); font-size: 12px; }
.ph-command-empty { padding: 20px; color: var(--muted); text-align: center; }
.ph-toast {
  position: fixed; z-index: 120; inset-inline: 0; margin: 0 auto; bottom: calc(24px + env(safe-area-inset-bottom));
  width: fit-content; max-width: calc(100vw - 32px); padding: 10px 16px; border-radius: var(--radius-sm);
  background: var(--text); color: var(--bg); font-size: 14px; font-weight: 500;
}

/* ---------------------------------------------------------------- login */
.ph-login-body { min-height: 100dvh; display: grid; place-items: center; padding: 24px 16px; }
.ph-login { width: min(400px, 100%); }
.ph-login-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 36px; font-family: var(--font-display); font-size: 17px; font-weight: 600; }
.ph-login h1 { font-size: 34px; }
.ph-login-lead { margin: 8px 0 28px; color: var(--muted); }
.ph-login-form { display: grid; gap: 16px; }
.ph-login-form .ph-btn { margin-top: 8px; }
.ph-login-error { margin: 0 0 16px; padding: 10px 14px; border-radius: var(--radius-sm); background: var(--danger-soft); color: var(--danger); font-size: 14px; }
.ph-login-foot { margin-top: 24px; color: var(--muted); font-size: 13px; }

/* ---------------------------------------------------------------- tablet: icon rail */
@media (max-width: 1279px) {
  .ph-app { grid-template-columns: 76px minmax(0, 1fr); }
  .ph-sidebar { padding: 16px 10px; align-items: center; gap: 18px; }
  .ph-brand { padding: 0 0 14px; justify-content: center; width: 100%; }
  .ph-brand-text, .ph-user-text, .ph-build, .ph-logout-form span { display: none; }
  .ph-nav { width: 100%; }
  .ph-nav-item { justify-content: center; min-height: 52px; padding: 8px; }
  .ph-nav-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .ph-user { justify-content: center; padding: 0; }
  .ph-logout-form .ph-btn { padding: 0; min-width: 44px; }
  .ph-main { padding: 24px 24px 72px; }
  .ph-appbar { padding-inline: 24px; }
  .ph-kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .ph-card, .ph-card-wide { grid-column: span 6; }
  .ph-filter-grid > label { grid-column: span 6 !important; }
}

/* ---------------------------------------------------------------- phone: top bar + bottom tabs */
@media (max-width: 767px) {
  body { font-size: 15px; }
  .ph-app { display: block; }
  .ph-sidebar { display: none; }
  .ph-appbar { min-height: 56px; padding: 6px 16px; padding-top: max(6px, env(safe-area-inset-top)); }
  .ph-appbar-brand { display: inline-flex; }
  .ph-appbar-brand .ph-brand-mark { width: 34px; height: 34px; border-radius: 10px; }
  .ph-appbar-section { font-size: 15px; color: var(--text); font-weight: 500; }
  .ph-appbar-system { display: inline-flex; }
  .ph-command-hint { display: none; }
  .ph-icon-btn { padding: 0; }
  .ph-main { padding: 20px 16px calc(var(--tabbar-h) + 32px + env(safe-area-inset-bottom)); }
  .ph-page-head { margin-bottom: 18px; }
  .ph-grid { gap: 10px; }
  .ph-grid > *, .ph-filter-grid > label { grid-column: 1 / -1 !important; }
  .ph-card, .ph-card-half, .ph-card-wide, .ph-card-full { grid-column: 1 / -1; padding: 16px; border-radius: 14px; }
  .ph-kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .ph-kpi { padding: 14px; }
  .ph-kpi-value, .ph-metric { font-size: 24px; }
  .ph-owner-grid { grid-template-columns: 1fr; }
  .ph-mini-grid { grid-template-columns: 1fr; }
  .ph-btn-sm, .ph-table-actions .ph-btn { min-height: 44px; }
  .ph-toolbar-card, .ph-account-identity { padding: 16px; }
  .ph-page-tabs { width: 100%; border-radius: 14px; }

  .ph-copy-mini, .ph-explorer-link { min-height: 36px; }
  .ph-table-parties-cell { min-width: 0; }
  /* Tables become cards; cells carry data-label. */
  .ph-data-table thead { display: none; }
  .ph-data-table, .ph-data-table tbody { display: block; width: 100%; }
  .ph-data-table tr { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px 12px; padding: 14px 16px; border-bottom: 1px solid var(--hairline); }
  .ph-data-table td { display: block; padding: 0; border: 0; min-width: 0; }
  .ph-data-table td::before { content: attr(data-label); display: block; margin-bottom: 2px; color: var(--muted); font-size: 12px; }
  .ph-table-main-cell, .ph-data-table td.ph-table-detail-cell, .ph-data-table td.ph-table-reference-cell, .ph-data-table td.ph-table-actions-cell { grid-column: 1 / -1; }
  .ph-table-main-cell::before, .ph-data-table td.ph-table-detail-cell::before { display: none; }
  .ph-table-actions { justify-content: flex-start; }

  .ph-tabbar {
    position: fixed; z-index: 40; inset-inline: 0; bottom: 0;
    display: grid; grid-template-columns: repeat(5, minmax(0, 1fr));
    min-height: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
    padding: 6px 6px env(safe-area-inset-bottom);
    background: var(--surface);
    border-top: 1px solid var(--hairline);
  }
  .ph-tab {
    min-width: 0; min-height: 52px; display: grid; justify-items: center; align-content: center; gap: 2px;
    border-radius: 12px; color: var(--muted); font-size: 11px; line-height: 1.2; text-align: center;
  }
  .ph-tab svg { width: 22px; height: 22px; }
  .ph-tab.is-active { color: var(--section); }
  .ph-toast { bottom: calc(var(--tabbar-h) + 16px + env(safe-area-inset-bottom)); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}
