/* ==========================================================================
   CompanyIT design system
   Font: IBM Plex Sans Arabic (OFL, self-hosted). Icons: Lucide sprite (ISC).
   One token set; every page uses the same components. RTL-first, mobile-first.
   ========================================================================== */

@font-face { font-family: "IBM Plex Sans Arabic"; font-style: normal; font-weight: 400; font-display: swap;
  src: url("fonts/ibm-plex-sans-arabic-arabic-400-normal.woff2") format("woff2"); unicode-range: U+0600-06FF, U+0750-077F, U+0870-089F, U+08A0-08FF, U+FB50-FDFF, U+FE70-FEFF, U+200C-200E, U+2010-2011, U+204F, U+2E41; }
@font-face { font-family: "IBM Plex Sans Arabic"; font-style: normal; font-weight: 500; font-display: swap;
  src: url("fonts/ibm-plex-sans-arabic-arabic-500-normal.woff2") format("woff2"); unicode-range: U+0600-06FF, U+0750-077F, U+0870-089F, U+08A0-08FF, U+FB50-FDFF, U+FE70-FEFF, U+200C-200E, U+2010-2011, U+204F, U+2E41; }
@font-face { font-family: "IBM Plex Sans Arabic"; font-style: normal; font-weight: 600; font-display: swap;
  src: url("fonts/ibm-plex-sans-arabic-arabic-600-normal.woff2") format("woff2"); unicode-range: U+0600-06FF, U+0750-077F, U+0870-089F, U+08A0-08FF, U+FB50-FDFF, U+FE70-FEFF, U+200C-200E, U+2010-2011, U+204F, U+2E41; }
@font-face { font-family: "IBM Plex Sans Arabic"; font-style: normal; font-weight: 700; font-display: swap;
  src: url("fonts/ibm-plex-sans-arabic-arabic-700-normal.woff2") format("woff2"); unicode-range: U+0600-06FF, U+0750-077F, U+0870-089F, U+08A0-08FF, U+FB50-FDFF, U+FE70-FEFF, U+200C-200E, U+2010-2011, U+204F, U+2E41; }
@font-face { font-family: "IBM Plex Sans Arabic"; font-style: normal; font-weight: 400; font-display: swap; src: url("fonts/ibm-plex-sans-arabic-latin-400-normal.woff2") format("woff2"); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215; }
@font-face { font-family: "IBM Plex Sans Arabic"; font-style: normal; font-weight: 500; font-display: swap; src: url("fonts/ibm-plex-sans-arabic-latin-500-normal.woff2") format("woff2"); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215; }
@font-face { font-family: "IBM Plex Sans Arabic"; font-style: normal; font-weight: 600; font-display: swap; src: url("fonts/ibm-plex-sans-arabic-latin-600-normal.woff2") format("woff2"); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215; }
@font-face { font-family: "IBM Plex Sans Arabic"; font-style: normal; font-weight: 700; font-display: swap; src: url("fonts/ibm-plex-sans-arabic-latin-700-normal.woff2") format("woff2"); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215; }

:root {
  /* Brand */
  --navy-950: #0b1730; --navy-900: #10213f; --navy-800: #182d52; --navy-700: #24406f;
  --blue-600: #2563c9; --blue-700: #1d4fa3; --blue-50: #ecf2fc; --blue-100: #d8e5fa;
  --teal-600: #0a9b93; --teal-700: #08807a; --teal-50: #e6f6f5;
  /* Surfaces & text */
  --bg: #f4f6fa; --surface: #ffffff; --surface-2: #f8fafc; --border: #e2e7ef; --border-strong: #cdd5e1;
  --text: #15213a; --text-2: #3e4a61; --muted: #637089; --faint: #8a95a8;
  /* Semantic states (always paired with a text label) */
  --ok: #0f7a4a; --ok-bg: #e5f5ec; --warn: #9a5a00; --warn-bg: #fff3dc; --bad: #b42318; --bad-bg: #fde9e7;
  --info: #1d4fa3; --info-bg: #ecf2fc; --wait: #5b3fc4; --wait-bg: #efeafe; --neutral: #4b5568; --neutral-bg: #eef1f5;
  /* Data viz series (validated: CVD ΔE ≥ 19, contrast ≥ 3:1) */
  --series-1: #2563c9; --series-2: #0a9b93;
  /* Type scale */
  --fs-xs: .75rem; --fs-sm: .8125rem; --fs-md: .9375rem; --fs-lg: 1.0625rem; --fs-xl: 1.25rem; --fs-2xl: 1.5rem; --fs-3xl: 1.875rem;
  /* Spacing, radius, shadow */
  --sp-1: 4px; --sp-2: 8px; --sp-3: 12px; --sp-4: 16px; --sp-5: 20px; --sp-6: 24px; --sp-8: 32px;
  --r-sm: 6px; --r-md: 10px; --r-lg: 14px; --r-pill: 999px;
  --sh-1: 0 1px 2px rgba(16, 33, 63, .06); --sh-2: 0 4px 14px rgba(16, 33, 63, .08); --sh-focus: 0 0 0 3px rgba(37, 99, 201, .35);
  --touch: 44px;
  --sidebar-w: 256px; --bottom-nav-h: 64px;
  --ease: cubic-bezier(.2, .7, .2, 1);
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
html, body {
  font-family: "IBM Plex Sans Arabic", "Segoe UI", Tahoma, Arial, sans-serif;
  background: var(--bg); color: var(--text); font-size: 15px; line-height: 1.6;
  margin: 0;
}
/* clip, not hidden: "hidden" on html+body makes body its own scroller, which breaks position:sticky and scrollIntoView. */
body { overflow-x: clip; }
h1, h2, h3, h4, h5, h6 { font-family: inherit; color: var(--text); line-height: 1.35; }
a { color: var(--blue-600); text-decoration: none; }
a:hover { color: var(--blue-700); text-decoration: underline; }
img, svg { max-width: 100%; }
[dir="ltr"], .ltr { unicode-bidi: plaintext; }
.bdi { unicode-bidi: isolate; }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.small, small { font-size: var(--fs-sm); }
.pre-wrap { white-space: pre-wrap; overflow-wrap: anywhere; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* Focus: always visible for keyboard users */
:focus-visible { outline: none; box-shadow: var(--sh-focus); border-radius: var(--r-sm); }
.btn:focus-visible, .form-control:focus, .form-select:focus { box-shadow: var(--sh-focus); border-color: var(--blue-600); }
.skip-link { position: absolute; inset-inline-start: 8px; top: -60px; background: var(--navy-900); color: #fff; padding: 8px 14px; border-radius: var(--r-sm); z-index: 2000; }
.skip-link:focus { top: 8px; }

/* Icons */
.ic { width: 1.15em; height: 1.15em; flex-shrink: 0; vertical-align: -0.2em; }
.ic-lg { width: 1.5rem; height: 1.5rem; }
.ic-xl { width: 2.25rem; height: 2.25rem; }
/* Directional icons are authored for RTL (back = →); mirror them in English. */
[dir="ltr"] .ic.flip { transform: scaleX(-1); }

/* ---------------------------------------------------------------- Shell */
.app-shell { display: flex; min-height: 100vh; min-height: 100dvh; }
.app-sidebar {
  width: var(--sidebar-w); flex-shrink: 0; background: var(--navy-900); color: #c9d4e8;
  position: sticky; top: 0; height: 100vh; height: 100dvh; overflow-y: auto; padding: var(--sp-4) var(--sp-3);
  display: flex; flex-direction: column; gap: var(--sp-2);
}
.brand { display: flex; align-items: center; gap: var(--sp-3); color: #fff; text-decoration: none; font-weight: 700; padding: var(--sp-2) var(--sp-2) var(--sp-4); }
.brand:hover { color: #fff; text-decoration: none; }
.brand-mark { display: grid; place-items: center; width: 36px; height: 36px; border-radius: var(--r-md); background: linear-gradient(135deg, var(--blue-600), var(--teal-600)); color: #fff; font-size: .85rem; letter-spacing: .02em; }
.brand-text { display: flex; flex-direction: column; line-height: 1.2; }
.brand-mark.has-logo { background: #fff; padding: 4px; }
.brand-mark.has-logo img { display: block; max-width: 100%; max-height: 100%; object-fit: contain; }
.account-brand { display: flex; flex-direction: column; align-items: center; gap: var(--sp-2); text-align: center; padding-bottom: var(--sp-4); margin-bottom: var(--sp-4); border-bottom: 1px solid var(--border); }
.account-logo { display: block; height: 64px; width: auto; max-width: 200px; }
.account-company { font-weight: 700; color: var(--text); font-size: var(--fs-md); line-height: 1.4; }
.brand-text small { color: #8fa3c4; font-weight: 500; font-size: var(--fs-xs); }
.app-nav { display: flex; flex-direction: column; gap: 2px; }
.app-nav .nav-section { font-size: var(--fs-xs); color: #8094b6; margin: var(--sp-4) var(--sp-3) var(--sp-1); font-weight: 600; }
.app-nav .nav-link { display: flex; align-items: center; gap: var(--sp-3); color: #c9d4e8; padding: 9px var(--sp-3); border-radius: var(--r-md); font-size: var(--fs-md); min-height: 40px; transition: background .15s var(--ease), color .15s; }
.app-nav .nav-link .ic { opacity: .85; }
.app-nav .nav-link:hover { background: rgba(255,255,255,.07); color: #fff; text-decoration: none; }
.app-nav .nav-link.active { background: rgba(37, 99, 201, .28); color: #fff; font-weight: 600; box-shadow: inset 3px 0 0 var(--teal-600); }
[dir="rtl"] .app-nav .nav-link.active { box-shadow: inset -3px 0 0 var(--teal-600); }

.app-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.app-topbar {
  position: sticky; top: 0; z-index: 50; display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3);
  padding: 10px var(--sp-6); background: rgba(255,255,255,.92); backdrop-filter: saturate(1.4) blur(8px); border-bottom: 1px solid var(--border);
}
.topbar-start, .topbar-end { display: flex; align-items: center; gap: var(--sp-2); min-width: 0; }
.topbar-brand { display: none; }
.icon-btn { position: relative; display: inline-grid; place-items: center; width: var(--touch); height: var(--touch); border-radius: var(--r-md); color: var(--text-2); background: transparent; border: 1px solid transparent; }
.icon-btn:hover { background: var(--surface-2); border-color: var(--border); color: var(--text); text-decoration: none; }
.count-dot { position: absolute; top: 2px; inset-inline-end: 0; min-width: 18px; height: 18px; padding: 0 5px; border-radius: var(--r-pill); background: var(--bad); color: #fff; font-size: 11px; font-weight: 700; display: grid; place-items: center; line-height: 1; }
.user-chip { display: flex; align-items: center; gap: var(--sp-2); padding: 4px 6px 4px 12px; border-radius: var(--r-pill); border: 1px solid var(--border); background: var(--surface); }
[dir="rtl"] .user-chip { padding: 4px 12px 4px 6px; }
a.user-chip { color: inherit; text-decoration: none; }
a.user-chip:hover { background: var(--surface-2, var(--surface)); }
.avatar { display: inline-grid; place-items: center; width: 32px; height: 32px; border-radius: 50%; background: var(--blue-100); color: var(--blue-700); font-weight: 700; font-size: var(--fs-sm); flex-shrink: 0; }
.avatar.lg { width: 44px; height: 44px; font-size: var(--fs-md); }
.user-chip .name { font-weight: 600; font-size: var(--fs-sm); max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.app-content { padding: var(--sp-6); max-width: 1440px; width: 100%; margin-inline: auto; flex: 1; }
/* Interactive pages render after the live connection is up: show a quiet skeleton meanwhile. */
.app-content:empty::before { content: ""; display: block; height: 160px; border-radius: var(--r-lg); background: linear-gradient(90deg, #eef1f6 25%, #f6f8fb 37%, #eef1f6 63%); background-size: 400% 100%; animation: shimmer 1.2s ease-in-out infinite; }

/* Bottom navigation (mobile) */
.bottom-nav { display: none; }
.bottom-nav a { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; min-height: var(--touch); color: var(--muted); font-size: 11px; font-weight: 600; text-decoration: none; }
.bottom-nav a .ic { width: 22px; height: 22px; }
.bottom-nav a.active { color: var(--blue-600); }
.bottom-nav a.primary-action .bubble { display: grid; place-items: center; width: 46px; height: 46px; margin-top: -18px; border-radius: 50%; background: var(--blue-600); color: #fff; box-shadow: 0 6px 16px rgba(37, 99, 201, .35); }
.bottom-nav a.primary-action .bubble .ic { width: 24px; height: 24px; }

/* ---------------------------------------------------------------- Layout primitives */
.page-head { display: flex; justify-content: space-between; align-items: flex-start; flex-wrap: wrap; gap: var(--sp-3); margin-bottom: var(--sp-5); }
.page-head h1 { font-size: var(--fs-2xl); font-weight: 700; margin: 0; }
.page-head .subtitle { color: var(--muted); margin: 4px 0 0; font-size: var(--fs-md); }
.page-head .actions { display: flex; gap: var(--sp-2); flex-wrap: wrap; align-items: center; }
.crumb { display: inline-flex; align-items: center; gap: 4px; color: var(--muted); font-size: var(--fs-sm); margin-bottom: 4px; }
.grid { display: grid; gap: var(--sp-4); }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-main { grid-template-columns: minmax(0, 2fr) minmax(280px, 1fr); }
.stack { display: flex; flex-direction: column; gap: var(--sp-4); }
.row-flex { display: flex; align-items: center; gap: var(--sp-2); flex-wrap: wrap; }
.spacer { flex: 1; }
.min-w-0 { min-width: 0; }

/* Cards */
.card-box, .ui-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); padding: var(--sp-5); margin-bottom: var(--sp-4); box-shadow: var(--sh-1); min-width: 0; }
.grid > .card-box, .grid > .ui-card, .stack > .ui-card, .stack > .card-box { margin-bottom: 0; }
.card-box h2, .ui-card h2, .ui-card .card-title { font-size: var(--fs-lg); font-weight: 600; margin: 0 0 var(--sp-3); display: flex; align-items: center; gap: var(--sp-2); }
.ui-card .card-head { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-2); margin-bottom: var(--sp-3); }
.ui-card .card-head h2 { margin: 0; }
.ui-card.flush { padding: 0; }
.ui-card.flush .card-head { padding: var(--sp-4) var(--sp-5) 0; }
.card-link { display: block; color: inherit; text-decoration: none; transition: border-color .15s, box-shadow .15s, transform .15s var(--ease); }
.card-link:hover { border-color: var(--blue-100); box-shadow: var(--sh-2); text-decoration: none; color: inherit; }

/* Stat cards */
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(165px, 1fr)); gap: var(--sp-3); margin-bottom: var(--sp-5); }
.kpi { position: relative; display: flex; flex-direction: column; gap: 4px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); padding: var(--sp-4); text-decoration: none; color: inherit; box-shadow: var(--sh-1); min-height: 112px; transition: border-color .15s, box-shadow .15s; }
a.kpi:hover { border-color: var(--blue-100); box-shadow: var(--sh-2); text-decoration: none; color: inherit; }
.kpi .kpi-top { display: flex; align-items: center; gap: var(--sp-2); color: var(--muted); font-size: var(--fs-sm); font-weight: 500; }
.kpi .kpi-top .ic { color: var(--blue-600); }
.kpi .kpi-value { font-size: var(--fs-3xl); font-weight: 700; line-height: 1.15; font-variant-numeric: tabular-nums; }
.kpi .kpi-value .unit { font-size: var(--fs-md); font-weight: 500; color: var(--muted); margin-inline-start: 4px; }
.kpi .kpi-note { font-size: var(--fs-xs); color: var(--muted); }
.kpi .kpi-label { font-size: var(--fs-sm); color: var(--muted); }
.kpi.bad .kpi-value { color: var(--bad); }
.kpi.warn .kpi-value { color: var(--warn); }
.kpi.good .kpi-value { color: var(--ok); }
.kpi .kpi-info { position: absolute; top: 12px; inset-inline-end: 12px; color: var(--faint); cursor: help; }
.delta { display: inline-flex; align-items: center; gap: 2px; font-size: var(--fs-xs); font-weight: 600; padding: 1px 8px; border-radius: var(--r-pill); width: fit-content; }
.delta.up-good, .delta.down-good { color: var(--ok); background: var(--ok-bg); }
.delta.up-bad, .delta.down-bad { color: var(--bad); background: var(--bad-bg); }
.delta.flat { color: var(--neutral); background: var(--neutral-bg); }

/* Badges (status always has text; color is secondary) */
.badge-status, .chip { display: inline-flex; align-items: center; gap: 6px; font-size: var(--fs-xs); font-weight: 600; padding: 3px 10px; border-radius: var(--r-pill); background: var(--neutral-bg); color: var(--neutral); white-space: nowrap; line-height: 1.5; }
.badge-status::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; flex-shrink: 0; }
.chip::before { display: none; }
.badge-status.s-new { background: var(--info-bg); color: var(--info); }
.badge-status.s-progress { background: var(--warn-bg); color: var(--warn); }
.badge-status.s-wait { background: var(--wait-bg); color: var(--wait); }
.badge-status.s-done { background: var(--ok-bg); color: var(--ok); }
.badge-status.s-closed { background: var(--neutral-bg); color: var(--neutral); }
.badge-status.s-bad { background: var(--bad-bg); color: var(--bad); }
.chip.role { background: var(--blue-50); color: var(--blue-700); }

/* Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: var(--sp-2); font-weight: 600; border-radius: var(--r-md); padding: 8px 16px; min-height: 40px; font-size: var(--fs-md); border-width: 1px; transition: background .15s, border-color .15s, color .15s, box-shadow .15s; }
.btn-sm { min-height: 34px; padding: 5px 12px; font-size: var(--fs-sm); }
.btn-lg { min-height: 52px; padding: 12px 22px; font-size: var(--fs-lg); border-radius: var(--r-lg); }
.btn-primary { background: var(--blue-600); border-color: var(--blue-600); color: #fff; }
.btn-primary:hover, .btn-primary:focus { background: var(--blue-700); border-color: var(--blue-700); color: #fff; }
.btn-accent { background: var(--teal-600); border-color: var(--teal-600); color: #fff; }
.btn-accent:hover { background: var(--teal-700); border-color: var(--teal-700); color: #fff; }
.btn-outline-primary { color: var(--blue-600); border-color: var(--blue-100); background: var(--surface); }
.btn-outline-primary:hover { background: var(--blue-50); color: var(--blue-700); border-color: var(--blue-100); }
.btn-outline-secondary { color: var(--text-2); border-color: var(--border); background: var(--surface); }
.btn-outline-secondary:hover { background: var(--surface-2); color: var(--text); border-color: var(--border-strong); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }
.btn:disabled, .btn.disabled { opacity: .55; }
.btn .spinner { width: 16px; height: 16px; border: 2px solid currentColor; border-inline-end-color: transparent; border-radius: 50%; animation: spin .7s linear infinite; }

/* Forms */
.form-label { font-weight: 600; font-size: var(--fs-sm); color: var(--text-2); margin-bottom: 6px; }
.form-control, .form-select { border-radius: var(--r-md); border-color: var(--border-strong); min-height: 42px; font-size: var(--fs-md); color: var(--text); }
.form-control-sm, .form-select-sm { min-height: 34px; font-size: var(--fs-sm); }
textarea.form-control { min-height: 96px; }
.form-text { color: var(--muted); font-size: var(--fs-sm); }
.field { margin-bottom: var(--sp-4); }
.req::after { content: " *"; color: var(--bad); }

/* Filters */
.filters { display: flex; flex-wrap: wrap; gap: var(--sp-2); margin-bottom: var(--sp-4); align-items: center; }
.filters > * { width: auto; min-width: 150px; }
.filters .search { flex: 1 1 260px; position: relative; }
.filters .search .ic { position: absolute; top: 50%; transform: translateY(-50%); inset-inline-start: 12px; color: var(--faint); pointer-events: none; }
.filters .search input { padding-inline-start: 38px; width: 100%; }
.filter-toggle { display: none; }
.more-filters { display: contents; }
.filters .form-control, .filters .form-select { width: auto; flex: 1 1 160px; max-width: 260px; }
/* Headings focused by navigation (tabindex -1) don't need a focus frame. */
[tabindex="-1"]:focus, h1:focus { box-shadow: none; outline: none; }
.chips-row { display: flex; gap: var(--sp-2); flex-wrap: wrap; margin-bottom: var(--sp-3); }
.chip-btn { border: 1px solid var(--border); background: var(--surface); color: var(--text-2); border-radius: var(--r-pill); padding: 6px 14px; font-size: var(--fs-sm); font-weight: 600; min-height: 36px; display: inline-flex; align-items: center; gap: 6px; }
.chip-btn:hover { border-color: var(--border-strong); }
.chip-btn.active { background: var(--navy-900); border-color: var(--navy-900); color: #fff; }
.chip-btn .n { font-size: var(--fs-xs); opacity: .8; }

/* Tables (become cards on small screens: td[data-label]) */
.table-wrap { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); overflow: hidden; box-shadow: var(--sh-1); margin-bottom: var(--sp-3); }
.table-wrap .table { margin: 0; }
.table { background: var(--surface); --bs-table-bg: transparent; }
.table th { font-size: var(--fs-xs); color: var(--muted); font-weight: 600; white-space: nowrap; background: var(--surface-2); border-bottom: 1px solid var(--border); padding: 10px 14px; }
.table td { vertical-align: middle; font-size: var(--fs-md); padding: 12px 14px; border-color: var(--border); }
.table-hover tbody tr:hover > * { background: #f7f9fd; }
.table .row-link { color: var(--text); font-weight: 600; }
.table .row-link:hover { color: var(--blue-600); }
.cell-sub { display: block; color: var(--muted); font-size: var(--fs-xs); font-weight: 400; }

/* Empty / loading */
.empty-state { text-align: center; padding: var(--sp-8) var(--sp-4); color: var(--muted); }
.empty-state .ic-xl { color: var(--faint); margin-bottom: var(--sp-2); }
.empty-state h3 { font-size: var(--fs-lg); color: var(--text); margin: 0 0 4px; }
.empty-state p { margin: 0 auto var(--sp-3); max-width: 46ch; }
.skeleton { display: block; height: 14px; border-radius: 6px; background: linear-gradient(90deg, #eef1f6 25%, #f6f8fb 37%, #eef1f6 63%); background-size: 400% 100%; animation: shimmer 1.2s ease-in-out infinite; margin-bottom: 10px; }
.skeleton.block { height: 96px; border-radius: var(--r-lg); }
@keyframes shimmer { 0% { background-position: 100% 0; } 100% { background-position: 0 0; } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* Alerts / toasts */
.alert { border-radius: var(--r-md); border: 1px solid transparent; display: flex; gap: var(--sp-2); align-items: flex-start; padding: 12px 14px; font-size: var(--fs-md); }
.alert .ic { margin-top: 3px; }
.alert-danger { background: var(--bad-bg); color: var(--bad); border-color: #f6c9c4; }
.alert-success { background: var(--ok-bg); color: var(--ok); border-color: #bfe6cf; }
.alert-warning { background: var(--warn-bg); color: var(--warn); border-color: #f3dca8; }
.alert-info { background: var(--info-bg); color: var(--info); border-color: var(--blue-100); }
.alert.toast-in { animation: rise .2s var(--ease); }
.draft-banner { background: var(--warn-bg); border: 1px solid #f3dca8; color: #6b4300; border-radius: var(--r-md); padding: 10px 14px; margin-bottom: var(--sp-4); font-size: var(--fs-sm); }
details.help { margin: 0 0 var(--sp-4); }
details.help > summary { cursor: pointer; color: var(--blue-600); font-size: var(--fs-sm); font-weight: 600; list-style: none; display: inline-flex; align-items: center; gap: 6px; min-height: 32px; }
details.help > summary::-webkit-details-marker { display: none; }
details.help[open] > div { margin-top: 6px; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--r-md); padding: 10px 14px; color: var(--text-2); font-size: var(--fs-sm); }

/* Lists of items (cards) */
.item-list { display: flex; flex-direction: column; gap: var(--sp-2); }
.item { display: flex; gap: var(--sp-3); align-items: center; padding: 12px 14px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-md); color: inherit; text-decoration: none; min-height: 56px; }
a.item:hover { border-color: var(--blue-100); background: #fbfcff; text-decoration: none; color: inherit; }
.item .item-main { flex: 1; min-width: 0; }
.item .item-title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: block; }
.item .item-sub { font-size: var(--fs-sm); color: var(--muted); }
.item .item-icon { display: grid; place-items: center; width: 40px; height: 40px; border-radius: var(--r-md); background: var(--blue-50); color: var(--blue-600); flex-shrink: 0; }
.item .item-icon.teal { background: var(--teal-50); color: var(--teal-700); }
.item .item-icon.warn { background: var(--warn-bg); color: var(--warn); }
.item .item-icon.bad { background: var(--bad-bg); color: var(--bad); }

/* Hero (role homes) */
.hero { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-4); flex-wrap: wrap; background: linear-gradient(120deg, var(--navy-900), var(--navy-700)); color: #fff; border-radius: var(--r-lg); padding: var(--sp-6); margin-bottom: var(--sp-5); }
.hero h1 { color: #fff; font-size: var(--fs-2xl); margin: 0 0 4px; }
.hero p { color: #c3d0e6; margin: 0; }
.hero .btn-lg { min-width: 200px; }

/* Ticket conversation */
.thread { display: flex; flex-direction: column; gap: var(--sp-3); }
.msg { max-width: 92%; border: 1px solid var(--border); border-radius: var(--r-lg); padding: 10px 14px; background: var(--surface); }
.msg.from-requester { align-self: flex-start; background: var(--surface-2); }
.msg.from-staff { align-self: flex-end; background: var(--blue-50); border-color: var(--blue-100); }
.msg.internal { align-self: stretch; max-width: 100%; background: #fff8e6; border: 1px dashed #e6b54a; }
.msg.system { align-self: center; background: transparent; border: none; color: var(--muted); font-size: var(--fs-sm); text-align: center; }
.msg .msg-meta { display: flex; gap: var(--sp-2); align-items: center; font-size: var(--fs-xs); color: var(--muted); margin-bottom: 4px; flex-wrap: wrap; }
.msg .msg-meta strong { color: var(--text-2); }
.internal-tag { display: inline-flex; align-items: center; gap: 4px; color: #7a4d00; background: #ffecb8; border-radius: var(--r-pill); padding: 1px 8px; font-weight: 700; }
.composer { border: 1px solid var(--border); border-radius: var(--r-lg); overflow: hidden; background: var(--surface); }
.composer .tabs { display: flex; border-bottom: 1px solid var(--border); background: var(--surface-2); }
.composer .tabs button { flex: 1; border: 0; background: transparent; padding: 10px; font-weight: 600; color: var(--muted); min-height: var(--touch); display: inline-flex; justify-content: center; align-items: center; gap: 6px; }
.composer .tabs button.active { color: var(--blue-700); background: var(--surface); box-shadow: inset 0 -2px 0 var(--blue-600); }
.composer .tabs button.active.internal { color: #7a4d00; box-shadow: inset 0 -2px 0 #e6b54a; background: #fffcf2; }
.composer textarea { border: 0; border-radius: 0; min-height: 110px; }
.composer textarea:focus { box-shadow: none; }
.composer .composer-foot { display: flex; justify-content: space-between; align-items: center; gap: var(--sp-2); padding: 8px 12px; border-top: 1px solid var(--border); flex-wrap: wrap; }
.composer.is-internal { border-color: #e6b54a; }

/* Detail header */
.detail-head { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); padding: var(--sp-5); margin-bottom: var(--sp-4); box-shadow: var(--sh-1); }
.detail-head .ref { font-size: var(--fs-sm); color: var(--muted); font-weight: 600; letter-spacing: .02em; }
.detail-head h1 { font-size: var(--fs-xl); font-weight: 700; margin: 4px 0 var(--sp-3); overflow-wrap: anywhere; }
.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: var(--sp-3); margin: 0; }
.facts > div { min-width: 0; }
.facts dt { font-size: var(--fs-xs); color: var(--muted); font-weight: 600; margin-bottom: 2px; }
.facts dd { margin: 0; font-weight: 600; overflow-wrap: anywhere; }
.action-bar { display: flex; flex-wrap: wrap; gap: var(--sp-2); margin-top: var(--sp-4); padding-top: var(--sp-4); border-top: 1px solid var(--border); }

/* Timeline */
.timeline { list-style: none; padding: 0; margin: 0; }
.timeline li { position: relative; border-inline-start: 2px solid var(--border); padding: 4px var(--sp-4) var(--sp-4); }
.timeline li::before { content: ""; position: absolute; inset-inline-start: -7px; top: 9px; width: 12px; height: 12px; border-radius: 50%; background: var(--surface); border: 3px solid var(--blue-600); }
.timeline li.ok::before { border-color: var(--ok); }
.timeline li.warn::before { border-color: var(--warn); }
.timeline li.bad::before { border-color: var(--bad); }
.timeline .t-meta { font-size: var(--fs-xs); color: var(--muted); }

/* SLA meter */
.meter { height: 8px; border-radius: var(--r-pill); background: var(--neutral-bg); overflow: hidden; }
.meter > span { display: block; height: 100%; border-radius: var(--r-pill); background: var(--ok); }
.meter.warn > span { background: #d88a00; }
.meter.bad > span { background: var(--bad); }

/* Charts */
.chart { position: relative; width: 100%; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart .gridline { stroke: #e8ecf2; stroke-width: 1; }
.chart .axis-label { fill: var(--muted); font-size: 11px; font-family: inherit; }
.chart .series-1 { stroke: var(--series-1); }
.chart .series-2 { stroke: var(--series-2); }
.chart .dot-1 { fill: var(--series-1); }
.chart .dot-2 { fill: var(--series-2); }
.chart .hit { fill: transparent; cursor: pointer; }
.chart .hit:hover, .chart .hit:focus { fill: rgba(37,99,201,.06); outline: none; }
.chart .bar { fill: var(--series-1); }
.chart .bar.s2 { fill: var(--series-2); }
.chart .bar-hit { cursor: pointer; }
.chart .bar-hit:hover .bar, .chart .bar-hit:focus .bar { opacity: .82; }
.chart .value-label { fill: var(--text-2); font-size: 11px; font-weight: 600; font-family: inherit; }
.chart-tip { position: absolute; z-index: 5; pointer-events: none; background: var(--navy-950); color: #fff; padding: 8px 10px; border-radius: var(--r-sm); font-size: var(--fs-xs); box-shadow: var(--sh-2); min-width: 140px; }
.chart-tip .row { display: flex; align-items: center; gap: 6px; justify-content: space-between; }
.legend { display: flex; flex-wrap: wrap; gap: var(--sp-4); font-size: var(--fs-sm); color: var(--text-2); margin-bottom: var(--sp-2); }
.legend .key { display: inline-flex; align-items: center; gap: 6px; }
.legend .sw { width: 14px; height: 4px; border-radius: 2px; display: inline-block; }
.stackbar { display: flex; height: 14px; border-radius: var(--r-pill); overflow: hidden; gap: 2px; background: var(--surface); }
.stackbar a { display: block; height: 100%; min-width: 4px; }
.dist-legend { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 6px var(--sp-4); margin-top: var(--sp-3); font-size: var(--fs-sm); }
.dist-legend a { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-2); color: var(--text-2); min-height: 32px; }
.bar-list { width: 100%; border-collapse: separate; border-spacing: 0 4px; font-size: var(--fs-sm); }
.bar-list th { font-weight: 500; white-space: nowrap; padding-inline-end: .6rem; width: 1%; color: var(--text-2); }
.bar-list .bar-cell { width: 100%; }
.bar-list .bar { display: block; height: 12px; min-width: 2px; background: var(--series-1); border-start-end-radius: 4px; border-end-end-radius: 4px; }
.bar-list .bar-val { padding-inline-start: .5rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.table-alt summary { font-size: var(--fs-sm); color: var(--blue-600); cursor: pointer; margin-top: var(--sp-2); min-height: 32px; }

/* Quick ticket */
.choice-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--sp-3); }
.choice { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: var(--sp-2); text-align: center; padding: var(--sp-4) var(--sp-2); min-height: 108px; border: 1.5px solid var(--border); border-radius: var(--r-lg); background: var(--surface); color: var(--text); font-weight: 600; cursor: pointer; transition: border-color .15s, background .15s, transform .15s var(--ease); }
.choice .ic { width: 28px; height: 28px; color: var(--blue-600); }
.choice small { font-weight: 400; color: var(--muted); font-size: var(--fs-xs); }
.choice:hover { border-color: var(--blue-100); background: #fbfcff; }
.choice.selected { border-color: var(--blue-600); background: var(--blue-50); box-shadow: var(--sh-focus); }
.choice.security .ic { color: var(--bad); }
.seg { display: flex; border: 1px solid var(--border-strong); border-radius: var(--r-md); overflow: hidden; }
.seg button { flex: 1; border: 0; background: var(--surface); padding: 10px 8px; min-height: var(--touch); font-weight: 600; color: var(--text-2); border-inline-end: 1px solid var(--border); }
.seg button:last-child { border-inline-end: 0; }
.seg button.active { background: var(--navy-900); color: #fff; }
.file-drop { display: flex; align-items: center; gap: var(--sp-3); border: 1.5px dashed var(--border-strong); border-radius: var(--r-lg); padding: var(--sp-4); background: var(--surface-2); position: relative; min-height: 64px; }
.file-drop input[type=file] { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.file-chip { display: inline-flex; align-items: center; gap: 6px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-pill); padding: 4px 10px; font-size: var(--fs-sm); max-width: 100%; }
.success-panel { text-align: center; padding: var(--sp-8) var(--sp-4); }
.success-panel .ok-icon { width: 64px; height: 64px; border-radius: 50%; background: var(--ok-bg); color: var(--ok); display: grid; place-items: center; margin: 0 auto var(--sp-3); }
.success-panel .ticket-no { font-size: var(--fs-2xl); font-weight: 700; letter-spacing: .02em; direction: ltr; unicode-bidi: isolate; }
.sticky-submit { position: sticky; bottom: 0; background: linear-gradient(to top, var(--bg) 70%, transparent); padding: var(--sp-3) 0; }

/* Kanban & calendar */
.kanban { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: var(--sp-3); }
.kanban-col { background: #eef1f6; border-radius: var(--r-lg); padding: var(--sp-3); min-height: 120px; }
.kanban-col h3 { font-size: var(--fs-sm); font-weight: 700; display: flex; justify-content: space-between; }
.kanban-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-md); padding: 10px 12px; margin-bottom: var(--sp-2); font-size: var(--fs-sm); display: block; color: inherit; text-decoration: none; box-shadow: var(--sh-1); }
.cal-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; }
.cal-cell { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-sm); min-height: 92px; padding: 4px; font-size: var(--fs-xs); overflow: hidden; }
.cal-cell .d { font-weight: 700; color: var(--muted); }
.cal-cell.other { opacity: .45; }

/* Quick grid (more page) */
.quick-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: var(--sp-3); }
.quick-card { display: flex; align-items: center; gap: var(--sp-3); background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); padding: 14px; text-decoration: none; color: var(--text); min-height: 64px; box-shadow: var(--sh-1); }
.quick-card:hover { border-color: var(--blue-100); text-decoration: none; color: var(--text); box-shadow: var(--sh-2); }
.quick-card .item-icon { display: grid; place-items: center; width: 40px; height: 40px; border-radius: var(--r-md); background: var(--blue-50); color: var(--blue-600); flex-shrink: 0; }
.quick-section { font-size: var(--fs-sm); font-weight: 700; color: var(--muted); margin: var(--sp-5) 0 var(--sp-2); }

/* Misc carried over */
.signin-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); padding: var(--sp-8); width: 100%; max-width: 460px; box-shadow: var(--sh-2); }
.blank-layout { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: var(--sp-4); background: radial-gradient(circle at 20% 0%, #e7eefb, var(--bg) 55%); }
.kb-body { line-height: 1.85; }
.kb-body h1, .kb-body h2, .kb-body h3 { margin-top: 1.2em; }
.comment { border: 1px solid var(--border); border-radius: var(--r-md); padding: .6rem .8rem; margin-bottom: .6rem; background: var(--surface); }
.comment.internal { background: #fff8e6; border-color: #f0d38a; }
.comment .c-meta { font-size: var(--fs-xs); color: var(--muted); margin-bottom: .25rem; }
.nav-tabs .nav-link { color: var(--text-2); font-weight: 600; min-height: 42px; }
.nav-tabs .nav-link.active { color: var(--blue-700); }
.list-group-item { border-color: var(--border); }
.list-group-item.active { background: var(--navy-900); border-color: var(--navy-900); }

#blazor-error-ui { background: #fff3dc; color: #6b4300; bottom: 0; box-shadow: 0 -1px 2px rgba(0,0,0,.2); display: none; left: 0; padding: .7rem 1.25rem; position: fixed; width: 100%; z-index: 1000; }
#blazor-error-ui .dismiss { cursor: pointer; position: absolute; inset-inline-end: .75rem; top: .5rem; }
.valid.modified:not([type=checkbox]) { outline: 1px solid #26b050; }
.invalid { outline: 1px solid #e50000; }
.validation-message { color: var(--bad); font-size: var(--fs-sm); }

/* ---------------------------------------------------------------- Responsive */
@media (max-width: 1199px) {
  .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-main { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 899px) {
  html, body { font-size: 15px; }
  .app-sidebar { display: none; }
  .topbar-brand { display: flex; align-items: center; gap: var(--sp-2); color: var(--text); font-weight: 700; text-decoration: none; }
  .topbar-brand .brand-mark { width: 32px; height: 32px; }
  .app-topbar { padding: 8px var(--sp-3); }
  .user-chip .name, .topbar-end .lang-btn span { display: none; }
  .user-chip { padding: 2px; border: none; background: none; }
  .app-content { padding: var(--sp-4) var(--sp-3) calc(var(--bottom-nav-h) + var(--sp-6) + env(safe-area-inset-bottom)); }
  .bottom-nav {
    display: flex; position: fixed; inset-inline: 0; bottom: 0; z-index: 60; height: calc(var(--bottom-nav-h) + env(safe-area-inset-bottom));
    padding: 4px 4px env(safe-area-inset-bottom); background: rgba(255,255,255,.97); border-top: 1px solid var(--border); box-shadow: 0 -4px 16px rgba(16,33,63,.06);
  }
  /* Keyboard open: get the nav out of the way of the field being typed in. */
  body:has(input:focus, textarea:focus, select:focus) .bottom-nav { display: none; }
  /* The send button always sits above the bottom bar, focused or not: the bar hides while typing, and if the
     button dropped into its place the tap that ends typing would land on the bar reappearing under the finger. */
  .sticky-submit { bottom: calc(var(--bottom-nav-h) + env(safe-area-inset-bottom)); }
  .page-head h1 { font-size: var(--fs-xl); }
  .page-head { margin-bottom: var(--sp-4); }
  .page-head .actions .btn { min-height: var(--touch); }
  .grid-2, .grid-3 { grid-template-columns: minmax(0, 1fr); }
  .hero { padding: var(--sp-5); }
  .hero .btn-lg { width: 100%; }
  .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--sp-2); }
  .kpi { min-height: 96px; padding: var(--sp-3); }
  .kpi .kpi-value { font-size: var(--fs-2xl); }
  .choice-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .filters { flex-direction: column; align-items: stretch; }
  .filters > *, .filters .form-control, .filters .form-select { width: 100%; min-width: 0; max-width: none; }
  .filters .search { flex: 0 0 auto; }
  .filters.collapsible .more-filters { display: none; }
  .filters.collapsible.open .more-filters { display: contents; }
  .filter-toggle { display: inline-flex; }
  .btn, .form-control, .form-select { min-height: var(--touch); }
  .btn-sm { min-height: 40px; }
  .chip-btn { min-height: var(--touch); }
  .form-control, .form-select { min-width: var(--touch); }
  .card-box, .ui-card, .detail-head { padding: var(--sp-4); border-radius: var(--r-md); }
  .msg { max-width: 100%; }
  .cal-cell { min-height: 64px; }

  /* Tables → cards. Each cell carries data-label; cells marked .hide-sm are dropped. */
  .rtable thead { display: none; }
  .rtable, .rtable tbody, .rtable tr, .rtable td { display: block; width: 100%; }
  .rtable tr { border-bottom: 1px solid var(--border); padding: var(--sp-3) var(--sp-4); position: relative; }
  .rtable td { border: none; padding: 2px 0; font-size: var(--fs-md); }
  .rtable td[data-label]:not(.primary)::before { content: attr(data-label) ": "; color: var(--muted); font-size: var(--fs-sm); }
  .rtable td.primary { font-weight: 600; font-size: var(--fs-lg); padding-bottom: 4px; }
  .rtable td.hide-sm { display: none; }
  .rtable td.inline-sm { display: inline-block; width: auto; margin-inline-end: var(--sp-2); }
  .rtable td.inline-sm::before { content: none !important; }
  .table-hover tbody tr:hover > * { background: transparent; }
}

@media (max-width: 380px) {
  .kpi-grid { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .kpi .kpi-value { font-size: var(--fs-xl); }
  .bottom-nav a { font-size: 10px; }
}

@media (min-width: 1600px) {
  .app-content { padding: var(--sp-8); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; scroll-behavior: auto !important; }
}

@media print {
  .app-sidebar, .app-topbar, .bottom-nav, .no-print, #blazor-error-ui, #components-reconnect-modal, .skip-link { display: none !important; }
  .app-content { padding: 0; max-width: none; }
  body, html { background: #fff; }
  .card-box, .ui-card, .kpi { break-inside: avoid; box-shadow: none; }
  .print-page-break { break-before: page; }
  a { color: inherit; }
}

/* Horizontal bars (HTML, RTL-aware) */
.hbars { display: flex; flex-direction: column; gap: var(--sp-3); }
.hbar-row { display: grid; grid-template-columns: minmax(90px, 160px) minmax(0, 1fr); gap: var(--sp-3); align-items: center; }
.hbar-label { font-size: var(--fs-sm); color: var(--text-2); font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hbar-tracks { display: flex; flex-direction: column; gap: 3px; padding-inline-end: 36px; }
.hbar { display: flex; align-items: center; height: 14px; min-width: 2px; border-start-end-radius: 4px; border-end-end-radius: 4px; position: relative; text-decoration: none; }
.hbar.s1 { background: var(--series-1); }
.hbar.s2 { background: var(--series-2); }
.hbar span { position: absolute; inset-inline-start: calc(100% + 6px); font-size: 11px; font-weight: 600; color: var(--text-2); font-variant-numeric: tabular-nums; }
.hbar:hover, .hbar:focus-visible { filter: brightness(.9); text-decoration: none; }
.chart a:focus-visible circle:last-child { stroke: var(--navy-950); stroke-width: 2; }
@media (max-width: 899px) { .hbar-row { grid-template-columns: minmax(0, 1fr); gap: 4px; } }

/* Executive report (screen + print) */
.exec-report { max-width: 980px; margin-inline: auto; }
.report-cover { background: linear-gradient(120deg, var(--navy-900), var(--navy-700)); color: #fff; border-radius: var(--r-lg); padding: var(--sp-6); margin-bottom: var(--sp-5); }
.report-brand { display: flex; align-items: center; gap: var(--sp-4); padding-bottom: var(--sp-4); margin-bottom: var(--sp-4); border-bottom: 1px solid rgba(255,255,255,.18); }
.report-logo { flex: 0 0 auto; background: #fff; border-radius: var(--r-md); padding: 8px 10px; display: grid; place-items: center; }
.report-logo img { display: block; height: 52px; width: auto; max-width: 160px; }
.report-company { min-width: 0; }
.report-company-main { color: #fff; font-weight: 700; font-size: var(--fs-lg); line-height: 1.35; }
.report-company-alt { color: #a9c1e8; font-weight: 600; font-size: var(--fs-sm); letter-spacing: .01em; margin-top: 2px; }
@media (max-width: 599px) { .report-logo img { height: 40px; } .report-company-main { font-size: var(--fs-md, 1rem); } }
.report-title { color: #fff; font-size: var(--fs-2xl); margin: 4px 0 var(--sp-4); }
.report-meta { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: var(--sp-3); margin: 0; }
.report-meta dt { color: #a9c1e8; font-size: var(--fs-xs); font-weight: 600; }
.report-meta dd { margin: 0; font-weight: 600; }
.report-section { margin-bottom: var(--sp-6); }
.report-section > h2 { font-size: var(--fs-lg); font-weight: 700; border-bottom: 2px solid var(--border); padding-bottom: 6px; margin-bottom: var(--sp-3); }
.report-summary { padding-inline-start: 1.2em; margin-bottom: var(--sp-2); }
.report-summary li { margin-bottom: 6px; line-height: 1.8; }
.print-report { max-width: 1000px; margin: 0 auto; padding: var(--sp-6) var(--sp-4); background: var(--surface); }

@media print {
  @page { size: A4; margin: 14mm 12mm; }
  html, body { -webkit-print-color-adjust: exact; print-color-adjust: exact; font-size: 12.5px; }
  .blank-layout { display: block; min-height: 0; padding: 0; background: #fff; }
  .print-report { padding: 0; max-width: none; }
  /* Small blocks stay whole; long sections may split so pages don't end half empty. */
  .kpi-grid, .chart, .report-summary, .report-cover, tr { break-inside: avoid; }
  /* A4 is narrower than the phone breakpoint: undo the phone-only layouts so print keeps real tables and side labels. */
  .rtable { display: table; width: 100%; }
  .rtable thead { display: table-header-group; }
  .rtable tbody { display: table-row-group; }
  .rtable tr { display: table-row; padding: 0; border: 0; }
  .rtable td, .rtable td.hide-sm, .rtable td.inline-sm { display: table-cell; width: auto; padding: 6px 8px; border-bottom: 1px solid var(--border); font-size: 12px; }
  .rtable td[data-label]:not(.primary)::before { content: none; }
  .rtable td.primary { font-size: 12px; }
  .hbar-row { grid-template-columns: 150px minmax(0, 1fr); gap: var(--sp-3); }
  .hbars { gap: 6px; }
  .report-section > h2 { break-after: avoid; }
  .table-alt > summary { display: none; }
  .kpi-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .kpi { min-height: 0; padding: 10px; }
  .kpi .kpi-value { font-size: 1.35rem; }
}
