/* ════════════════════════════════════════════════════════════════════════
   StrataByte Pay: the StrataByte PBX "Operator console" design language
   (PBX docs/design/operator-console/spec.md, tokens from apps/web/src/styles.css).

   Rows, not cards. One flat surface with hairline sections. One primary
   button per view. Cyan only for live or current, and only on navy. State is
   a dot and a word. Light and dark themes come from the tokens below.

   Fonts are self-hosted (CSP font-src 'self'), all SIL Open Font Licence
   (see ../fonts/OFL-*.txt): IBM Plex Sans for the interface, IBM Plex Mono
   for machine strings, Rajdhani 700 for the wordmark. Rajdhani 500 and Share
   Tech Mono are kept for the printed invoice letter only.
   ════════════════════════════════════════════════════════════════════════ */

@font-face { font-family: 'IBM Plex Sans'; font-style: normal; font-weight: 400; font-display: swap; src: url('../fonts/plex-sans-400.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: 'IBM Plex Sans'; font-style: normal; font-weight: 500; font-display: swap; src: url('../fonts/plex-sans-500.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: 'IBM Plex Sans'; font-style: normal; font-weight: 600; font-display: swap; src: url('../fonts/plex-sans-600.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: 'IBM Plex Sans'; font-style: normal; font-weight: 400; font-display: swap; src: url('../fonts/plex-sans-ext-400.woff2') format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: 'IBM Plex Sans'; font-style: normal; font-weight: 500; font-display: swap; src: url('../fonts/plex-sans-ext-500.woff2') format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: 'IBM Plex Sans'; font-style: normal; font-weight: 600; font-display: swap; src: url('../fonts/plex-sans-ext-600.woff2') format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: 'IBM Plex Mono'; font-style: normal; font-weight: 400; font-display: swap; src: url('../fonts/plex-mono-400.woff2') format('woff2'); }
@font-face { font-family: 'Rajdhani'; font-weight: 700; font-display: swap; src: url('../fonts/rajdhani-700.woff2') format('woff2'); }
@font-face { font-family: 'Rajdhani'; font-weight: 500; font-display: optional; src: url('../fonts/rajdhani-500.woff2') format('woff2'); }
@font-face { font-family: 'Share Tech Mono'; font-weight: 400; font-display: swap; src: url('../fonts/share-tech-mono-400.woff2') format('woff2'); }

/* ── Tokens: light theme (the PBX's, unchanged) ─────────────────────────── */
:root {
  color-scheme: light;

  /* Chrome: navy in both themes, so the brand cyan only ever sits on navy. */
  --chrome: #1a1a2e;
  --chrome-hover: #24253f;
  --chrome-active: #2c2d4a;
  --chrome-line: #34365a;
  --chrome-text: #c4c6d9;
  --chrome-muted: #9396b3;
  --chrome-strong: #ffffff;
  --signal: #00d4ff;

  /* Content */
  --bg: #ffffff;
  --subtle: #f6f7f9;
  --muted: #eef0f3;
  --sel: #edf1f7;
  --line: #e4e6eb;
  --line-strong: #d3d6dd;
  --field: #878d9e;
  --text: #151823;
  --text-2: #4a5063;
  --text-3: #606679;
  --primary: #1a1a2e;
  --primary-hover: #2c2d4a;
  --on-primary: #ffffff;
  --link: #006c8f;
  --focus: #0080ab;
  --active: #008fb5;
  --live: #008fb5;
  --live-bg: #e2f6fc;
  --live-text: #005a75;
  --ok: #1f8048;
  --ok-text: #176a3a;
  --ok-bg: #e6f4ec;
  --warn: #b35f00;
  --warn-text: #8a4800;
  --warn-bg: #fff3e2;
  --bad: #c8302c;
  --bad-text: #b0261f;
  --bad-bg: #fdecea;
  --off: #878d9e;
  --c-ans: #3b4f8c;

  --shadow-pop: 0 8px 24px rgb(16 18 27 / 0.14), 0 0 0 1px rgb(16 18 27 / 0.08);
  --shadow-bar: 0 6px 20px rgb(16 18 27 / 0.22);
  --scrim: rgb(16 18 27 / 0.4);
  --select-chevron: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%234a5063' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");

  /* Density follows the pointer: 32 px controls and 40 px rows with a mouse. */
  --ctl: 32px;
  --ctl-sm: 28px;
  --ctl-lg: 40px;
  --row: 40px;
  --sidebar: 232px;
  --topbar: 52px;

  --font-sans: 'IBM Plex Sans', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'IBM Plex Mono', ui-monospace, 'Cascadia Mono', Consolas, monospace;
  --font-brand: 'Rajdhani', 'IBM Plex Sans', system-ui, sans-serif;

  /* Older names still used by inline styles in admin.js. */
  --success: var(--ok-text);
  --warning: var(--warn-text);
  --error: var(--bad-text);
  --grey: var(--text-3);
  --grey-light: var(--text-2);
  --cyan: var(--active);
}

/* ── Tokens: dark theme (device setting, unless someone chose light) ────── */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --chrome: #181a2c; --chrome-hover: #22243a; --chrome-active: #2a2c47; --chrome-line: #2f3150;
    --bg: #13161e; --subtle: #191d27; --muted: #222836; --sel: #1e2534;
    --line: #272d3a; --line-strong: #343b4a; --field: #6b7387;
    --text: #e7e9ee; --text-2: #b2b7c4; --text-3: #9096a5;
    --primary: #e7e9ee; --primary-hover: #ffffff; --on-primary: #13161e;
    --link: #5cceee; --focus: #38d6ff; --active: #00d4ff;
    --live: #00d4ff; --live-bg: #10303b; --live-text: #74e2ff;
    --ok: #3dbd70; --ok-text: #72d69c; --ok-bg: #16291f;
    --warn: #eda33d; --warn-text: #f4bd70; --warn-bg: #2e2416;
    --bad: #f06a65; --bad-text: #ff8f87; --bad-bg: #341b1d;
    --off: #6b7387; --c-ans: #4a5fa8;
    --shadow-pop: 0 8px 24px rgb(0 0 0 / 0.5), 0 0 0 1px #343b4a;
    --shadow-bar: 0 6px 20px rgb(0 0 0 / 0.5);
    --scrim: rgb(0 0 0 / 0.6);
    --select-chevron: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23b2b7c4' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  }
}
/* The same dark tokens for <html data-theme="dark"> (kept identical to the block above). */
:root[data-theme="dark"] {
  color-scheme: dark;
  --chrome: #181a2c; --chrome-hover: #22243a; --chrome-active: #2a2c47; --chrome-line: #2f3150;
  --bg: #13161e; --subtle: #191d27; --muted: #222836; --sel: #1e2534;
  --line: #272d3a; --line-strong: #343b4a; --field: #6b7387;
  --text: #e7e9ee; --text-2: #b2b7c4; --text-3: #9096a5;
  --primary: #e7e9ee; --primary-hover: #ffffff; --on-primary: #13161e;
  --link: #5cceee; --focus: #38d6ff; --active: #00d4ff;
  --live: #00d4ff; --live-bg: #10303b; --live-text: #74e2ff;
  --ok: #3dbd70; --ok-text: #72d69c; --ok-bg: #16291f;
  --warn: #eda33d; --warn-text: #f4bd70; --warn-bg: #2e2416;
  --bad: #f06a65; --bad-text: #ff8f87; --bad-bg: #341b1d;
  --off: #6b7387; --c-ans: #4a5fa8;
  --shadow-pop: 0 8px 24px rgb(0 0 0 / 0.5), 0 0 0 1px #343b4a;
  --shadow-bar: 0 6px 20px rgb(0 0 0 / 0.5);
  --scrim: rgb(0 0 0 / 0.6);
  --select-chevron: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23b2b7c4' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
}
:root[data-theme="light"] { color-scheme: light; }

/* Phones: 40 px controls. Touch screens: every control at least 44 px. */
@media (max-width: 719px) { :root { --ctl: 40px; --ctl-lg: 40px; --row: 52px; } }
@media (pointer: coarse) { :root { --ctl: 44px; --ctl-sm: 44px; --ctl-lg: 44px; --row: 52px; } }

/* ── Base ───────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { color-scheme: light dark; background: var(--bg); color: var(--text); -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  min-height: 100vh; background: var(--bg); color: var(--text);
  font-family: var(--font-sans); font-size: 14px; line-height: 20px; font-weight: 400;
  -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale;
}
a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { font-weight: 600; color: var(--text); }
strong, b { font-weight: 600; }
code { font-family: var(--font-mono); font-size: 13px; }
svg { flex-shrink: 0; }
[hidden] { display: none !important; }
::selection { background: var(--sel); }

/* A 2 px ring with a 2 px gap on everything; on navy it is the brand cyan. */
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.sidebar :focus-visible, .mobile-bar :focus-visible, .topbar :focus-visible, .auth-brand :focus-visible { outline-color: var(--signal); }

.num { font-variant-numeric: tabular-nums; }
.mono { font-family: var(--font-mono); font-size: 13px; }
.muted { color: var(--text-3); }
.hint { font-size: 13px; line-height: 18px; color: var(--text-3); }
.nowrap { white-space: nowrap; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

@keyframes sb-pop { from { opacity: 0; transform: scale(0.98); } }
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Logo (markup and motion as stratabyte.co.uk) ───────────────────────── */
.logo-wrap {
  display: inline-grid; grid-template-columns: 22px auto; column-gap: 9px; align-items: center;
  color: #ffffff; text-decoration: none;
}
.logo-wrap:hover { text-decoration: none; }
.logo-icon { width: 22px; height: 22px; display: grid; grid-template-columns: repeat(3, 1fr); gap: 2px; flex-shrink: 0; }
.logo-icon span { background: #00d4ff; border-radius: 1px; animation: blockPulse 2s ease-in-out infinite; }
.logo-icon span:nth-child(even) { background: rgba(0, 212, 255, 0.3); animation-delay: .4s; }
@keyframes blockPulse { 0%, 100% { opacity: 1; } 50% { opacity: .35; } }
.logo-name {
  font-family: var(--font-brand); font-weight: 700; font-size: 20px; letter-spacing: 2px;
  color: #ffffff; text-transform: uppercase; line-height: 1;
}
.logo-name span { color: #00d4ff; }
.logo-scope { grid-column: 2; margin-top: 4px; font-size: 12px; line-height: 16px; font-weight: 500; color: var(--chrome-muted); }

/* ── Buttons ────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: var(--ctl); padding: 0 12px; border: 1px solid var(--line-strong); border-radius: 6px;
  background: var(--bg); color: var(--text); font: inherit; font-size: 14px; font-weight: 500; line-height: 20px;
  white-space: nowrap; text-decoration: none; cursor: pointer;
  transition: background-color .15s ease-out, border-color .15s ease-out, color .15s ease-out;
}
.btn:hover { background: var(--subtle); text-decoration: none; }
.btn svg { width: 16px; height: 16px; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
.btn-primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.btn-ghost:hover { background: var(--muted); color: var(--text); }
.btn-danger { color: var(--bad-text); }
.btn-sm { height: var(--ctl-sm); padding: 0 10px; font-size: 13px; }
.btn-block { width: 100%; }
.btn:disabled, .btn[aria-disabled="true"] { background: var(--muted); border-color: var(--muted); color: var(--text-3); cursor: not-allowed; }
.spinner {
  width: 14px; height: 14px; border-radius: 50%; border: 2px solid currentColor; border-right-color: transparent;
  display: inline-block; animation: spin .8s linear infinite; flex-shrink: 0;
}

/* ── Forms ──────────────────────────────────────────────────────────────── */
label { font-size: 14px; line-height: 20px; font-weight: 500; color: var(--text); }
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; min-width: 0; }
.field .hint { margin-top: -2px; }
input:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]), select, textarea {
  width: 100%; height: var(--ctl); padding: 0 10px; border: 1px solid var(--field); border-radius: 6px;
  background: var(--bg); color: var(--text); font: inherit; font-size: 14px; line-height: 20px;
}
textarea { height: auto; min-height: 80px; padding: 6px 10px; }
select {
  appearance: none; -webkit-appearance: none; padding-right: 32px; cursor: pointer;
  background-image: var(--select-chevron); background-repeat: no-repeat; background-position: right 8px center; background-size: 16px;
}
input::placeholder { color: var(--text-3); opacity: 1; }
input:disabled, select:disabled { background: var(--subtle); border-color: var(--line-strong); color: var(--text-3); cursor: not-allowed; }
input[type="checkbox"] { width: 16px; height: 16px; accent-color: var(--primary); flex-shrink: 0; }
.field-row, .form-cols { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 16px; }
.addr-3 { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr) minmax(0, 1fr); gap: 0 16px; }
.check-row { display: inline-flex; align-items: center; gap: 8px; font-weight: 400; cursor: pointer; }
.form-toggles { display: flex; flex-direction: column; gap: 10px; margin: 4px 0 16px; }
.form-error-line, .pay-error { font-size: 13px; line-height: 18px; color: var(--bad-text); margin-top: 8px; }
.form-error-line:empty, .pay-error:empty { display: none; }
.form-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
@media (max-width: 719px) {
  .field-row, .form-cols, .addr-3 { grid-template-columns: 1fr; }
}

/* ── App shell: navy sidebar, flat canvas ───────────────────────────────── */
.shell { display: grid; grid-template-columns: var(--sidebar) minmax(0, 1fr); min-height: 100vh; }
.sidebar {
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
  display: flex; flex-direction: column; padding: 16px 12px 12px;
  background: var(--chrome); color: var(--chrome-text);
}
.sidebar .brand { padding: 4px 8px 20px; }
.side-nav { display: flex; flex-direction: column; gap: 2px; }
.side-nav a {
  position: relative; display: flex; align-items: center; gap: 10px; min-height: 36px; padding: 0 10px;
  border-radius: 6px; color: var(--chrome-text); text-decoration: none;
}
.side-nav a svg { width: 16px; height: 16px; color: var(--chrome-muted); }
.side-nav a:hover { background: var(--chrome-hover); color: var(--chrome-strong); }
.side-nav a.active, .side-nav a[aria-current="page"] { background: var(--chrome-active); color: var(--chrome-strong); font-weight: 500; }
.side-nav a.active::before, .side-nav a[aria-current="page"]::before {
  content: ''; position: absolute; left: 0; top: 8px; bottom: 8px; width: 3px; border-radius: 0 2px 2px 0; background: var(--signal);
}
.side-nav a.active svg, .side-nav a[aria-current="page"] svg { color: var(--signal); }
.side-foot { margin-top: auto; padding-top: 12px; border-top: 1px solid var(--chrome-line); display: flex; flex-direction: column; gap: 4px; }
.side-foot .btn-ghost { justify-content: flex-start; color: var(--chrome-text); padding: 0 10px; }
.side-foot .btn-ghost:hover { background: var(--chrome-hover); color: var(--chrome-strong); }
.side-foot .btn-ghost svg { color: var(--chrome-muted); }
.user-chip { display: flex; align-items: center; gap: 10px; padding: 6px 10px; min-width: 0; }
.avatar {
  width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; flex-shrink: 0;
  background: var(--chrome-active); color: var(--chrome-strong); font-size: 13px; font-weight: 600;
}
.who { display: flex; flex-direction: column; min-width: 0; }
.who strong, .who span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.who strong { color: var(--chrome-strong); font-weight: 500; }
.who span { font-size: 12px; line-height: 16px; color: var(--chrome-muted); }

.mobile-bar { display: none; }
.nav-backdrop { display: none; }
.nav-toggle {
  width: 44px; height: 44px; display: inline-flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  border: 0; border-radius: 6px; background: none; cursor: pointer;
}
.nav-toggle span { display: block; width: 18px; height: 2px; border-radius: 1px; background: var(--chrome-strong); }
.nav-toggle:hover { background: var(--chrome-hover); }

.main { min-width: 0; width: 100%; max-width: 1240px; padding: 20px 24px 48px; }

@media (max-width: 719px) {
  .shell { grid-template-columns: minmax(0, 1fr); align-content: start; }
  .mobile-bar {
    display: flex; align-items: center; gap: 8px; position: sticky; top: 0; z-index: 30;
    height: var(--topbar); padding: 0 12px 0 4px; background: var(--chrome);
  }
  .mobile-bar .logo-scope { display: none; }
  .sidebar {
    position: fixed; z-index: 50; top: 0; bottom: 0; left: 0; width: min(280px, 85vw); height: auto;
    transform: translateX(-100%); visibility: hidden; transition: transform .2s ease-out, visibility .2s;
  }
  .shell.nav-open .sidebar { transform: none; visibility: visible; box-shadow: var(--shadow-bar); }
  .shell.nav-open .nav-backdrop { display: block; position: fixed; inset: 0; z-index: 40; background: var(--scrim); }
  .main { padding: 14px 16px 40px; }
}

/* ── Page header: title (and count), then actions on the right ──────────── */
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; min-height: 32px; margin-bottom: 20px; }
.page-head h1 { font-size: 20px; line-height: 28px; }
.page-head .count { margin-left: 6px; color: var(--text-3); font-weight: 400; }
.page-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
@media (max-width: 719px) { .page-head h1 { font-size: 18px; line-height: 26px; } }

/* ── Sections: a heading over a hairline, never a box ───────────────────── */
.section { margin-bottom: 32px; min-width: 0; }
.section + .section, #billing + .section, .tab-pane > * + .section { border-top: 1px solid var(--line); padding-top: 20px; }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; min-height: 32px; margin-bottom: 8px; }
.section-head h2 { font-size: 16px; line-height: 24px; }
.section-head .meta { font-size: 13px; line-height: 18px; color: var(--text-3); }
.section-title { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; min-width: 0; }
.section-actions { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.narrow { max-width: 720px; }

/* Key-value rows: label, value, action on the right. */
.kv-row { display: grid; grid-template-columns: 160px minmax(0, 1fr) auto; gap: 4px 16px; align-items: center; min-height: 40px; padding: 6px 0; border-bottom: 1px solid var(--line); }
.kv-row > :first-child { color: var(--text-2); }
.kv-row dd { overflow-wrap: anywhere; }
@media (max-width: 719px) { .kv-row { grid-template-columns: minmax(0, 1fr) auto; } .kv-row > :first-child { grid-column: 1 / -1; font-size: 13px; } }

/* "Live": the list updates by itself. A quiet dot and a word. */
.live-dot { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; line-height: 18px; color: var(--text-3); }
.live-dot::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: var(--live); }

/* Flash messages */
.flash { display: flex; flex-direction: column; gap: 8px; margin-bottom: 16px; }
.flash-item { display: flex; align-items: flex-start; gap: 8px; padding: 10px 12px; border-radius: 6px; }
.flash-item svg { width: 16px; height: 16px; margin-top: 2px; }
.flash-item.success { background: var(--ok-bg); color: var(--ok-text); }
.flash-item.error { background: var(--bad-bg); color: var(--bad-text); }

/* ── Quick-view tabs and the filter bar ─────────────────────────────────── */
.list-toolbar { display: flex; align-items: flex-end; justify-content: space-between; gap: 8px 16px; flex-wrap: wrap; margin-bottom: 4px; }
.filter-tabs { display: flex; gap: 20px; overflow-x: auto; scrollbar-width: none; }
.filter-tabs a, .filter-tabs button {
  position: relative; display: inline-flex; align-items: center; height: 36px; padding: 0; border: 0; background: none;
  font: inherit; font-size: 14px; color: var(--text-2); white-space: nowrap; cursor: pointer; text-decoration: none;
}
.filter-tabs a:hover, .filter-tabs button:hover { color: var(--text); text-decoration: none; }
.filter-tabs .active { color: var(--text); font-weight: 500; }
.filter-tabs .active::after { content: ''; position: absolute; left: 0; right: 0; bottom: 0; height: 2px; border-radius: 1px; background: var(--active); }
#invoice-search, .list-toolbar input[type="search"] { width: 280px; max-width: 100%; margin-bottom: 4px; }
.tab-rule { border-bottom: 1px solid var(--line); }

/* ── Tables: rows with hairlines, no cards, no zebra ────────────────────── */
.table-scroll { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 14px; line-height: 20px; }
.table th {
  height: 32px; padding: 0 12px; text-align: left; white-space: nowrap;
  font-size: 12px; line-height: 16px; font-weight: 500; color: var(--text-3); border-bottom: 1px solid var(--line);
}
.table td { height: var(--row); padding: 8px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table th:first-child, .table td:first-child { padding-left: 4px; }
.table th:last-child, .table td:last-child { padding-right: 4px; }
.table tbody tr:hover { background: var(--subtle); }
.table .tight { width: 1%; white-space: nowrap; }
.table .r, .table th.amount-h, .table td.amount { text-align: right; }
.table td.amount, .table td.num, .table td.date { font-variant-numeric: tabular-nums; white-space: nowrap; }
.table td.date { color: var(--text-2); }
.table td.mono { font-size: 13px; color: var(--text-2); }
.cell-name { font-weight: 500; color: var(--text); }
.sub, .ref-sub { display: block; font-size: 13px; line-height: 18px; font-weight: 400; color: var(--text-3); }
.per { margin-left: 1px; font-size: 13px; color: var(--text-3); }
.desc-cell { max-width: 320px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text-2); }
.rowlink { cursor: pointer; }
.row-actions { text-align: right; white-space: nowrap; }
.row-actions > * + * { margin-left: 4px; }
.row-actions form { display: inline-flex; }
.col-actions { width: 1%; text-align: right; white-space: nowrap; }
.link-sm { font-size: 13px; }
.menu-trigger {
  width: 28px; height: 28px; display: inline-grid; place-items: center; border: 0; border-radius: 6px;
  background: none; color: var(--text-2); opacity: .7; cursor: pointer;
}
.menu-trigger svg { width: 16px; height: 16px; }
.menu-trigger:hover, .menu-trigger:focus-visible, .menu-trigger.open { opacity: 1; background: var(--muted); color: var(--text); }
@media (pointer: coarse) { .menu-trigger { width: 44px; height: 44px; opacity: 1; } }
@media (max-width: 719px) { .col-hide-sm { display: none; } }

/* ── Status: a dot and a word (the data says PAID; it reads "Paid") ─────── */
.badge {
  --dot: var(--off);
  position: relative; display: inline-block; padding-left: 14px; white-space: nowrap;
  font-size: 13px; line-height: 18px; font-weight: 400; color: var(--text-2); text-transform: lowercase;
}
.badge::first-letter { text-transform: uppercase; }
.badge::before { content: ''; position: absolute; left: 0; top: 50%; width: 8px; height: 8px; margin-top: -4px; border-radius: 50%; background: var(--dot); }
.badge.paid, .badge.active, .badge.trialing, .badge.succeeded { --dot: var(--ok); }
.badge.pending, .badge.past_due, .badge.incomplete, .badge.unpaid, .badge.open, .badge.processing { --dot: var(--warn); }
.badge.failed, .badge.suspended { --dot: var(--bad); }
.badge.void, .badge.canceled, .badge.cancelled, .badge.refunded, .badge.partially_refunded, .badge.expired, .badge.incomplete_expired { --dot: transparent; }
.badge.void::before, .badge.canceled::before, .badge.cancelled::before, .badge.refunded::before,
.badge.partially_refunded::before, .badge.expired::before, .badge.incomplete_expired::before { border: 1.5px solid var(--off); }
/* Exceptions are badges: tinted, 20 px, never wrapping. */
.badge.disputed, .badge.fraud {
  height: 20px; padding: 0 6px; margin-left: 6px; border-radius: 4px; line-height: 20px;
  font-size: 12px; font-weight: 500; background: var(--bad-bg); color: var(--bad-text);
}
.badge.disputed::before, .badge.fraud::before { content: none; }

/* ── Empty, loading and error states inside the table area ──────────────── */
.state-box, .empty { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; padding: 20px 4px; color: var(--text-2); }
.state-box svg { width: 20px; height: 20px; margin-bottom: 6px; color: var(--text-3); }
.state-box.loading svg { animation: spin 1s linear infinite; }
.st-t { font-weight: 500; color: var(--text); }
.st-s { font-size: 13px; line-height: 18px; color: var(--text-3); }

/* ── Stat strip: figures separated by hairlines, no boxes ───────────────── */
.kpi-row, .summary-strip { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); margin-bottom: 28px; }
.summary-strip { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.kpi, .ss-cell, .ss-gauge { display: flex; flex-direction: column; min-width: 0; padding: 4px 20px; border-left: 1px solid var(--line); }
.kpi:first-child, .ss-cell:first-child { padding-left: 0; border-left: 0; }
.k-label, .ss-label, .gl { font-size: 13px; line-height: 18px; color: var(--text-2); }
.k-value, .ss-fig { font-size: 24px; line-height: 32px; font-weight: 600; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.k-sub, .ss-sub { font-size: 13px; line-height: 18px; color: var(--text-3); }
.ss-gauge { justify-content: center; }
.g-top { display: flex; justify-content: space-between; align-items: baseline; }
.gp { font-size: 13px; font-weight: 500; font-variant-numeric: tabular-nums; color: var(--text); }
.ss-track { height: 6px; margin: 8px 0 6px; border-radius: 3px; background: var(--muted); overflow: hidden; }
.ss-fill { width: 0; height: 100%; border-radius: 3px; background: var(--ok); transition: width .6s ease-out; }
@media (max-width: 899px) {
  .kpi-row { grid-template-columns: repeat(2, minmax(0, 1fr)); row-gap: 16px; }
  .kpi:nth-child(odd) { padding-left: 0; border-left: 0; }
}
@media (max-width: 719px) {
  .summary-strip { grid-template-columns: minmax(0, 1fr); row-gap: 14px; }
  .ss-cell, .ss-gauge { padding: 0; border-left: 0; }
  .k-value, .ss-fig { font-size: 20px; line-height: 28px; }
}

/* Revenue bars: one quiet series, labels under the axis. */
.spark { display: flex; align-items: flex-end; gap: 16px; height: 64px; margin: 16px 0 32px; box-shadow: 0 1px 0 var(--line-strong); }
.spark .bar { position: relative; flex: 1; max-width: 64px; border-radius: 2px 2px 0 0; background: var(--c-ans); }
.spark .bar span { position: absolute; top: 100%; left: 50%; transform: translateX(-50%); margin-top: 6px; font-size: 12px; line-height: 16px; color: var(--text-3); white-space: nowrap; }

/* ── Row menu (⋯): floats, so it has the one shadow ─────────────────────── */
.rowmenu {
  position: fixed; z-index: 80; min-width: 210px; padding: 4px; border-radius: 8px;
  background: var(--bg); color: var(--text); box-shadow: var(--shadow-pop); animation: sb-pop .15s ease-out;
}
.rowmenu .mh { padding: 6px 8px 4px; font-size: 12px; line-height: 16px; font-weight: 500; color: var(--text-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rowmenu button {
  display: flex; align-items: center; gap: 8px; width: 100%; min-height: 32px; padding: 0 8px; border: 0; border-radius: 6px;
  background: none; font: inherit; font-size: 14px; color: var(--text); text-align: left; cursor: pointer;
}
.rowmenu button svg { width: 16px; height: 16px; color: var(--text-2); }
.rowmenu button:hover, .rowmenu button:focus-visible { background: var(--subtle); }
.rowmenu button.danger, .rowmenu button.danger svg { color: var(--bad-text); }
.rowmenu .sep { height: 1px; margin: 4px 0; background: var(--line); }

/* ── Side sheet (new invoice, new subscription) ─────────────────────────── */
.drawer { position: fixed; inset: 0; z-index: 60; }
.drawer-overlay { position: absolute; inset: 0; background: var(--scrim); opacity: 0; transition: opacity .2s ease-out; }
.drawer.open .drawer-overlay { opacity: 1; }
.drawer-panel {
  position: absolute; top: 0; right: 0; bottom: 0; width: min(600px, 100%); display: flex; flex-direction: column;
  background: var(--bg); color: var(--text); box-shadow: var(--shadow-pop);
  opacity: 0; transform: translateX(24px); transition: opacity .2s ease-out, transform .2s ease-out;
}
.drawer.open .drawer-panel { opacity: 1; transform: none; }
.drawer-head, .modal-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 16px 12px 20px; border-bottom: 1px solid var(--line); }
.drawer-head h2, .modal-head h2 { font-size: 16px; line-height: 24px; }
.drawer-body { flex: 1; overflow-y: auto; padding: 20px; }
.modal-x {
  width: 32px; height: 32px; display: grid; place-items: center; border: 0; border-radius: 6px;
  background: none; color: var(--text-2); font-size: 22px; line-height: 1; cursor: pointer;
}
.modal-x:hover { background: var(--muted); color: var(--text); }

/* ── Dialog ─────────────────────────────────────────────────────────────── */
.modal { position: fixed; inset: 0; z-index: 70; display: grid; place-items: center; padding: 16px; }
.modal-overlay { position: absolute; inset: 0; background: var(--scrim); }
.modal-card {
  position: relative; width: min(560px, 100%); max-height: calc(100vh - 32px); overflow-y: auto;
  border-radius: 8px; background: var(--bg); color: var(--text); box-shadow: var(--shadow-pop); animation: sb-pop .15s ease-out;
}
.modal-body { padding: 20px; }
.modal-meta { margin-top: 16px; font-size: 13px; line-height: 18px; color: var(--text-3); }
.modal-meta:empty { display: none; }
.modal-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--line); }

/* Results after a create or save */
.result-box { display: none; margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--line); }
.result-box.show { display: block; }
.result-box > .lbl { font-weight: 500; color: var(--ok-text); }
.copy-row { display: flex; gap: 8px; }
.copy-row input[readonly]:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]),
input.mono:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]) { font-family: var(--font-mono); font-size: 13px; }
.result-note { margin: 4px 0 8px; font-size: 13px; line-height: 18px; color: var(--text-3); }
.result-detail { margin-top: 8px; font-size: 13px; line-height: 18px; color: var(--text-2); }

/* Line items (invoice and subscription forms) */
.line-items-head, .li-row { display: grid; grid-template-columns: minmax(0, 1fr) 64px 112px 84px 32px; gap: 8px; align-items: center; }
.line-items-head { font-size: 12px; line-height: 16px; font-weight: 500; color: var(--text-3); padding-bottom: 6px; }
.line-items { display: flex; flex-direction: column; gap: 8px; }
.li-unit, .li-tax { position: relative; display: block; }
.li-unit i, .li-tax i { position: absolute; top: 50%; transform: translateY(-50%); font-style: normal; color: var(--text-3); pointer-events: none; }
.li-unit i { left: 10px; }
.li-tax i { right: 10px; }
.li-unit input { padding-left: 24px !important; }
.li-tax input { padding-right: 26px !important; }
.li-del { width: 32px; height: 32px; display: grid; place-items: center; border: 0; border-radius: 6px; background: none; color: var(--text-3); font-size: 18px; cursor: pointer; }
.li-del:hover { background: var(--bad-bg); color: var(--bad-text); }
.line-items-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 8px; }
.line-total { color: var(--text-2); }
.line-total strong { margin-left: 6px; color: var(--text); font-variant-numeric: tabular-nums; }
@media (max-width: 619px) {
  .line-items-head { display: none; }
  .li-row { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) minmax(0, 1fr) 32px; padding-bottom: 8px; border-bottom: 1px solid var(--line); }
  .li-row > :first-child { grid-column: 1 / -1; }
}

/* PBX page: compact forms inside rows, and the link form */
.inline-form { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.inline-form + .inline-form { margin-top: 6px; }
.inline-form select { width: auto; max-width: 100%; }
.inline-form label { display: inline-flex; align-items: center; gap: 6px; font-weight: 400; font-size: 13px; }
.form-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)) auto; gap: 16px; align-items: end; }
.form-grid > label { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
@media (max-width: 899px) { .form-grid { grid-template-columns: minmax(0, 1fr); } .form-grid .btn { justify-self: start; } }

/* ── Customer billing page ──────────────────────────────────────────────── */
.sub-block { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 56px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.section-head + .sub-block { border-top: 1px solid var(--line); }
.sub-name { font-weight: 500; }
.sub-name .badge { margin-left: 8px; }
.sub-meta { font-size: 13px; line-height: 18px; color: var(--text-2); }
.sub-meta .amount { color: var(--text); font-variant-numeric: tabular-nums; }
.sub-meta .dot { margin: 0 6px; color: var(--text-3); }
.pm-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 48px; padding: 6px 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.pm-current { display: flex; align-items: center; gap: 4px 12px; flex-wrap: wrap; min-width: 0; }
.pm-brand { display: inline-flex; align-items: center; gap: 8px; }
.pm-brand svg { width: 16px; height: 16px; color: var(--text-2); }
.pm-brand strong { font-weight: 500; font-variant-numeric: tabular-nums; }
#pm-panel { padding-top: 16px; }
.pm-actions { display: flex; gap: 8px; margin-top: 16px; }

/* ── Sign-in (focused): navy brand panel, one task ──────────────────────── */
.auth-shell { display: grid; grid-template-columns: minmax(300px, 400px) minmax(0, 1fr); min-height: 100vh; }
.auth-brand { display: flex; flex-direction: column; justify-content: space-between; gap: 24px; padding: 28px 32px; background: var(--chrome); color: var(--chrome-text); }
.auth-brand-foot { font-size: 13px; line-height: 20px; color: var(--chrome-muted); }
.auth-brand-foot a { color: var(--chrome-text); }
.auth-main { display: flex; align-items: center; justify-content: center; padding: 48px 24px; background: var(--bg); color: var(--text); }
.auth-wrap { width: 100%; max-width: 380px; }
.auth-card .head h1 { font-size: 28px; line-height: 36px; }
.auth-card .head p { margin-top: 4px; color: var(--text-2); }
.auth-card .body { margin-top: 24px; }
.auth-card input:not([type="checkbox"]):not([type="hidden"]), .auth-card .btn { height: var(--ctl-lg); }
.auth-card .hint { margin: -6px 0 16px; }
.auth-foot { margin-top: 24px; font-size: 13px; line-height: 18px; color: var(--text-3); }
.main .auth-card { max-width: 480px; }
.main .auth-card .head h1 { font-size: 20px; line-height: 28px; }
@media (max-width: 719px) {
  .auth-shell { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto 1fr; }
  .auth-brand { flex-direction: row; align-items: center; height: var(--topbar); padding: 0 16px; }
  .auth-brand .logo-scope, .auth-brand-foot { display: none; }
  .auth-main { align-items: flex-start; padding: 32px 16px; }
  .auth-card .head h1 { font-size: 24px; line-height: 32px; }
}

/* ── Checkout (focused): navy top bar, invoice and card side by side ────── */
.topbar { display: flex; align-items: center; height: var(--topbar); padding: 0 24px; background: var(--chrome); }
.topbar .logo-wrap { grid-template-columns: 22px auto auto; }
.topbar .logo-scope { grid-column: 3; margin: 0 0 0 12px; padding-left: 12px; border-left: 1px solid var(--chrome-line); font-size: 13px; }
.checkout-page { max-width: 1000px; margin: 0 auto; padding: 32px 24px 48px; }
.checkout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 400px); gap: 0 48px; align-items: start; }
.pay-side { min-width: 0; padding-left: 48px; border-left: 1px solid var(--line); min-height: 240px; }
.checkout.solo { grid-template-columns: minmax(0, 440px); justify-content: center; }
.checkout.solo .invoice-side { display: none; }
.checkout.solo .pay-side { padding: 0; border: 0; min-height: 0; }
.doc-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.doc-head h1 { font-size: 20px; line-height: 28px; }
.doc-stamp { position: relative; padding-left: 14px; font-size: 13px; line-height: 18px; color: var(--text-2); white-space: nowrap; }
.doc-stamp::before { content: ''; position: absolute; left: 0; top: 50%; width: 8px; height: 8px; margin-top: -4px; border-radius: 50%; background: var(--warn); }
.doc-line { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 40px; padding: 6px 0; border-bottom: 1px solid var(--line); }
.doc-meta .doc-line:first-child { border-top: 1px solid var(--line); }
.doc-line .l { color: var(--text-2); }
.doc-line .v { text-align: right; overflow-wrap: anywhere; font-variant-numeric: tabular-nums; }
.doc-items { margin-top: 24px; }
.doc-items:not(:empty) { border-top: 1px solid var(--line-strong); }
.doc-item { display: flex; justify-content: space-between; gap: 16px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.di-d { min-width: 0; overflow-wrap: anywhere; }
.di-a { white-space: nowrap; font-variant-numeric: tabular-nums; }
.doc-item .q { margin-left: 4px; color: var(--text-3); font-variant-numeric: tabular-nums; }
.doc-total { margin-top: 8px; }
.doc-total .doc-line { border-bottom: 0; min-height: 32px; padding: 2px 0; }
.doc-due { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; margin-top: 8px; padding-top: 12px; border-top: 1px solid var(--line-strong); }
.doc-due .l { font-weight: 500; }
.doc-due .amount { font-size: 28px; line-height: 36px; font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.doc-due .cur { margin-right: 1px; }
.text-ok { color: var(--ok-text); }
.discount-note { margin-top: 8px; font-size: 13px; line-height: 18px; color: var(--ok-text); }
.state { display: flex; flex-direction: column; align-items: flex-start; gap: 8px; }
.state h3 { font-size: 20px; line-height: 28px; }
.state p { color: var(--text-2); }
.state .btn { margin-top: 8px; }
.ic svg { width: 24px; height: 24px; }
.ic.ok { color: var(--ok); }
.ic.err { color: var(--bad); }
.dots { display: flex; gap: 4px; height: 20px; align-items: center; }
.dots span { width: 6px; height: 6px; border-radius: 50%; background: var(--text-3); animation: dot 1.2s ease-in-out infinite; }
.dots span:nth-child(2) { animation-delay: .15s; }
.dots span:nth-child(3) { animation-delay: .3s; }
@keyframes dot { 0%, 80%, 100% { opacity: .25; } 40% { opacity: 1; } }
#st-pay > label { display: block; margin-bottom: 8px; }
#payment-element { min-height: 120px; }
#pay-btn { margin-top: 20px; }
.secure-line { display: flex; align-items: center; gap: 6px; margin-top: 12px; font-size: 13px; line-height: 18px; color: var(--text-3); }
.secure-line svg { width: 14px; height: 14px; }
.checkout-foot { margin-top: 40px; padding-top: 16px; border-top: 1px solid var(--line); }
@media (max-width: 819px) {
  .checkout { grid-template-columns: minmax(0, 1fr); }
  .pay-side { padding: 24px 0 0; margin-top: 24px; border-left: 0; border-top: 1px solid var(--line-strong); min-height: 0; }
  .checkout.solo .pay-side { margin-top: 0; }
  .checkout-page { padding: 20px 16px 40px; }
  .topbar { padding: 0 16px; }
}
@media (max-width: 479px) { .topbar .logo-scope { display: none; } }

/* ── Invoice "letter": StrataByte letterhead (white paper in both themes) ─
   Matched to the posted Docmail letter; only the on-screen frame changed. */
/* Admin print-all: the chosen view, then one sheet after another (one per printed page). */
.print-filter { max-width: 820px; margin: 0 auto 16px; }
.print-filter p { margin: 0 0 8px; color: var(--text-2); }
.invoice-sheet + .invoice-sheet { margin-top: 24px; }
.invoice-sheet { max-width: 820px; margin: 0 auto; background: #fff; color: #222433;
  border-radius: 8px; overflow: hidden; border: 1px solid var(--line);
  font-family: 'Rajdhani','Segoe UI',sans-serif; padding: 24px; }

/* shared 3×3 logo grid (odd cells solid, even cells faded) */
.ish-grid { display: grid; grid-template-columns: repeat(3,19px); grid-auto-rows: 19px; gap: 7px; }
.ish-grid span { border-radius: 2px; background: #00D4FF; }
.ish-grid span:nth-child(even) { opacity: .3; }

/* header panel — proportioned to the letter (dark band ≈ 110px, cyan strip ≈ 19px) */
.ish-head { background: #1A1A2E; display: flex; justify-content: space-between; align-items: center;
  gap: 1.5rem; flex-wrap: nowrap; padding: 0 2rem; min-height: 110px; border-radius: 16px 16px 0 0; }
.ish-brand { display: flex; align-items: center; gap: 1.1rem; }
.ish-word { font-weight: 700; font-size: 4.1rem; line-height: 1; letter-spacing: .08em; }
.ish-no { white-space: nowrap; }
.ish-word b { color: #fff; font-weight: 700; }
.ish-word i { color: #00D4FF; font-style: normal; }
.ish-meta { text-align: right; }
.ish-doc { font-size: .72rem; letter-spacing: .35em; text-transform: uppercase; color: #00D4FF; font-weight: 700; }
.ish-no { font-family: ui-monospace,'Share Tech Mono',monospace; color: #fff; font-size: 1.05rem; margin: .2rem 0 .55rem; }
.ish-badge { display: inline-block; padding: .22rem .65rem; border-radius: 999px; font-size: .6rem;
  letter-spacing: .14em; font-weight: 700; color: #fff; }
.ish-badge--paid { background: #006680; }
.ish-badge--pending { background: #3c3e54; }
.ish-badge--refund { background: #966e23; }
.ish-badge--void { background: #4a4d63; }

/* slogan strip — fused to the base of the header panel (one masthead), as on the letter */
.ish-ribbon { background: #00D4FF; color: #1A1A2E; font-weight: 700;
  font-size: .6rem; letter-spacing: .4em; text-transform: uppercase;
  display: flex; align-items: center; justify-content: center; min-height: 19px; padding: 0 1rem;
  border-radius: 0 0 16px 16px; }

/* body */
.ish-body { padding: 2rem 1.5rem 1.6rem; position: relative; }
.ish-body > * { position: relative; z-index: 1; }
.ish-mark { position: absolute; inset: 0; z-index: 0; display: flex; align-items: center; justify-content: center;
  pointer-events: none; opacity: .045; }
.ish-mark .ish-grid { grid-template-columns: repeat(3,56px); grid-auto-rows: 56px; gap: 14px; }
.ish-mark .ish-grid span { background: #1A1A2E; border-radius: 7px; }
/* watermark is for the printed letterhead only — hide it in the on-screen invoice */
@media screen { .ish-mark { display: none; } }

.ish-parties { display: flex; justify-content: space-between; gap: 1.5rem; flex-wrap: nowrap; margin-bottom: 1.9rem; }
.ish-dates { flex-shrink: 0; }
.ish-lbl { display: block; text-transform: uppercase; letter-spacing: .18em; font-size: .6rem;
  color: #9498a8; font-weight: 700; margin-bottom: .25rem; }
.ish-to strong { display: block; font-size: 1.15rem; color: #1A1A2E; }
.ish-to { color: #5a5e70; font-size: .92rem; line-height: 1.55; }
.ish-dates { text-align: right; display: flex; flex-direction: column; gap: .7rem; }
.ish-dates b { color: #222433; font-weight: 700; }

.ish-table { width: 100%; border-collapse: collapse; margin-bottom: 1.5rem; }
.ish-table thead th { background: #1A1A2E; color: #fff; text-align: left; font-size: .64rem;
  letter-spacing: .14em; text-transform: uppercase; padding: .65rem .9rem; }
.ish-table thead th:last-child { text-align: right; }
.ish-table tbody td { padding: .9rem; border-bottom: 1px solid #e8eaf0; color: #333; }
.ish-table tbody td.amt { text-align: right; font-family: ui-monospace,'Share Tech Mono',monospace; color: #0096b9; }
.ish-table th.amt { text-align: right; }
.ish-table .ish-qty { text-align: center; white-space: nowrap; width: 1%; }
.ish-table thead th.ish-qty { text-align: center; }

.ish-totals { margin-left: auto; width: 300px; max-width: 100%; }
.ish-totals .row { display: flex; justify-content: space-between; padding: .42rem 0; font-size: .95rem; color: #5a5e70; }
.ish-totals .muted span:last-child { color: #9498a8; }
.ish-totals .grand { border-top: 2px solid #1A1A2E; margin-top: .45rem; padding-top: .75rem;
  font-size: 1.3rem; font-weight: 700; color: #1A1A2E; }
.ish-totals .grand span:last-child { color: #0096b9; font-family: ui-monospace,'Share Tech Mono',monospace; }

.ish-note { margin-top: 1.7rem; padding-top: 1.05rem; border-top: 1px dashed #d4d7e0;
  font-size: .85rem; color: #6a6e80; line-height: 1.7; }

/* footer panel — proportioned to the letter (≈ 105px tall, contacts spread like the SVG) */
.ish-foot { background: #1A1A2E; color: #fff; padding: 0 2rem; min-height: 105px; border-radius: 16px;
  margin-top: 20px; display: flex; flex-direction: column; justify-content: center; gap: .55rem; }
.ish-contacts { display: flex; align-items: center; justify-content: center; gap: 3rem;
  flex-wrap: wrap; font-size: .82rem; }
.ish-c { display: inline-flex; align-items: center; gap: .5rem; }
.ish-ic { width: 15px; height: 15px; flex-shrink: 0; }
.ish-div { width: 1px; height: 18px; background: #00D4FF; opacity: .35; }
.ish-reg { text-align: center; color: #8892A4; font-size: .62rem; letter-spacing: .1em; margin-top: .65rem; }

@media (max-width: 600px) {
  .invoice-sheet { padding: 12px; }
  /* keep the masthead inline (brand left, meta right) — shrink to fit 1 row */
  .ish-head { gap: .5rem; padding: 1rem .8rem; min-height: 0; align-items: center; }
  .ish-brand { gap: .5rem; min-width: 0; }
  .ish-brand .ish-grid { display: none; }   /* drop the grid icon on mobile to give the wordmark its full size */
  .ish-word { font-size: 10.8vw; letter-spacing: .02em; }
  .ish-meta { flex-shrink: 0; }
  .ish-doc { font-size: .54rem; }
  .ish-no { font-size: .72rem; margin: .1rem 0 .3rem; }
  .ish-badge { font-size: .52rem; padding: .16rem .45rem; }
  .ish-ribbon { letter-spacing: .25em; padding: .35rem .9rem; text-align: center; }
  .ish-body { padding: 1.5rem 1.15rem; }
  .ish-parties { flex-direction: column; }
  .ish-dates { text-align: left; }
  .ish-to { word-break: break-word; }
  .ish-totals { width: 100%; margin-left: 0; }
  .ish-note { word-break: break-word; }
  .ish-foot { padding: 1.1rem 1.1rem .9rem; }
  .ish-contacts { flex-direction: column; gap: .55rem; font-size: .82rem; text-align: center; }
  .ish-div { display: none; }
  .ish-table thead th, .ish-table tbody td { padding: .6rem .55rem; }
}

/* ── Print: reproduce the posted docmail letter EXACTLY (unchanged) ───────────
   letter-background.svg (design space, 561pt-wide panels) is printed by Docmail
   via:  printed = 0.9166 × design,  centred with 14.2mm side / 12mm top-bottom
   margins (barcode gap). So the recipient sees these PRINTED sizes:
     masthead 86pt  (dark 73.3pt + cyan slogan 12.8pt)   footer 69.7pt
     corner radius 9pt · wordmark 52pt · slogan 6.9pt/.4em · logo cell 12.8pt gap 4.6pt
     footer text 8.7pt · "Registered" 5.5pt · panels rounded, NOT full-bleed.
   @page margins give the equal white frame; panels = content-box width.          */
@media print {
  .sidebar, .mobile-bar, .nav-backdrop, .page-head, .flash, .no-print { display: none !important; }
  .invoice-sheet + .invoice-sheet { margin-top: 0 !important; break-before: page; page-break-before: always; }
  .shell { display: block !important; min-height: 0 !important; }
  .main { padding: 0 !important; max-width: none !important; }
  html, body { background: #fff !important; }

  .invoice-sheet {
    max-width: none !important; width: 100% !important; box-shadow: none !important; border: 0 !important;
    border-radius: 0 !important; padding: 0 !important; margin: 0 !important;
    min-height: 273mm; display: flex; flex-direction: column;          /* 297 − 2×12 */
  }

  /* masthead = dark header (73.3pt) + fused cyan slogan (12.8pt), rounded 9pt */
  .ish-head {
    border-radius: 9pt 9pt 0 0 !important; min-height: 73.3pt; box-sizing: border-box;
    padding: 0 14pt !important; gap: 10pt; flex-wrap: nowrap; align-items: center;
  }
  .ish-grid { grid-template-columns: repeat(3, 12.8pt); grid-auto-rows: 12.8pt; gap: 4.6pt; }
  .ish-grid span { border-radius: 1.8pt; }
  .ish-word { font-size: 44pt; letter-spacing: .08em; line-height: 1; }   /* full-size, fits beside the meta block */
  .ish-meta { flex-shrink: 0; }
  .ish-doc  { font-size: 6.5pt; }
  .ish-no   { font-size: 10pt; margin: .15rem 0 .3rem; }
  .ish-badge { font-size: 5.5pt; padding: .18rem .5rem; }
  .ish-ribbon {
    border-radius: 0 0 9pt 9pt !important; min-height: 12.8pt; box-sizing: border-box;
    padding: 0 !important; display: flex; align-items: center; justify-content: center;
    font-size: 6.9pt; letter-spacing: .4em;
  }

  /* body grows; parties+table stay at top, totals+note drop to the bottom
     (just above the footer) like the letter's closing block */
  .ish-body { flex: 1 0 auto; display: flex; flex-direction: column;
    padding: 22pt 14pt 16pt !important; }
  .ish-totals { margin-top: auto; }

  /* footer = rounded panel (9pt), 69.7pt tall, pinned to page bottom */
  .ish-foot {
    border-radius: 9pt !important; margin: 0 !important; margin-top: auto !important;
    min-height: 69.7pt; box-sizing: border-box; padding: 0 18pt !important;
    display: flex; flex-direction: column; justify-content: center; gap: 6pt;
  }
  .ish-contacts { justify-content: center; width: 100%; gap: 35pt; font-size: 8.7pt; letter-spacing: .03em; }
  .ish-c   { gap: 5pt; }
  .ish-ic  { width: 12pt; height: 12pt; }
  .ish-div { height: 25pt; width: .5pt; opacity: .35; }
  .ish-reg { font-size: 5.5pt; letter-spacing: .08em; margin-top: 4pt; }

  .ish-head, .ish-ribbon, .ish-foot, .ish-table thead th, .ish-grid span,
  .ish-badge, .ish-div, .ish-mark, .ish-ic {
    -webkit-print-color-adjust: exact; print-color-adjust: exact;
  }
  @page { size: A4; margin: 12mm 14.2mm; }
}

/* ── Reduced motion: nothing moves; the logo stands still ───────────────── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition: none !important;
  }
  .logo-icon span { animation: none !important; }
}
