/* Héxagône design system — shared finish layer for every application module. */
:root {
  color-scheme: light;
  --bg: #f2f6fc;
  --bg-layer-1: rgba(37, 99, 235, .065);
  --bg-layer-2: rgba(14, 165, 233, .04);
  --surface: rgba(255, 255, 255, .74);
  --surface-strong: rgba(255, 255, 255, .86);
  --surface-soft: rgba(248, 250, 255, .78);
  --surface-muted: rgba(238, 243, 250, .82);
  --glass: rgba(255, 255, 255, .7);
  --glass-strong: rgba(255, 255, 255, .84);
  --glass-soft: rgba(248, 250, 255, .62);
  --text: #172538;
  --muted: #65758b;
  --line: rgba(54, 83, 122, .13);
  --line-strong: rgba(54, 83, 122, .22);
  --accent: #2563eb;
  --accent-strong: #1d4ed8;
  --accent-soft: rgba(37, 99, 235, .11);
  --danger: #dc3545;
  --enterprise-canvas: #f2f6fc;
  --enterprise-rule: rgba(54, 83, 122, .13);
  --enterprise-gold: #c58b2c;
  --hex-grid-lines: linear-gradient(to right, rgba(143,117,67,.13) 1px, transparent 1px), linear-gradient(to bottom, rgba(143,117,67,.13) 1px, transparent 1px);
  --hex-blueprint-art: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 620 460' fill='none' stroke='%23a8833f' stroke-width='1.3'%3E%3Cpath d='M52 54h218v132h-92v218H52zM270 54h290v132H376v-44h-84M270 186h106v218H270M376 186h184v218H376M52 186h126M178 186v83M376 54v88M560 186v72'/%3E%3Cpath d='M178 269a42 42 0 0 1 42 42M334 186a42 42 0 0 1 42 42M376 312a42 42 0 0 0 42-42M270 260h30m-15-15v30M91 54v-22h140v22M52 348H28v-90h24M420 404v22h100v-22' stroke-dasharray='5 5'/%3E%3Cpath d='M40 438h540M40 432v12m540-12v12M590 42v376m-6-376h12m-12 376h12' stroke-width='.8'/%3E%3Ctext x='290' y='32' fill='%23a8833f' stroke='none' font-family='sans-serif' font-size='10' letter-spacing='2'%3EPLAN - ATELIER%3C/text%3E%3C/svg%3E");
  --product-radius: 15px;
  --hex-radius: 15px;
  --hex-radius-small: 10px;
  --radius-xl: 18px;
  --radius-lg: 15px;
  --radius-md: 11px;
  --shadow: 0 18px 46px rgba(25, 54, 94, .075), 0 3px 10px rgba(25, 54, 94, .035);
  --shadow-soft: 0 8px 24px rgba(25, 54, 94, .065);
  --product-shadow: 0 16px 40px rgba(25, 54, 94, .07);
  --glass-shadow: 0 18px 46px rgba(25, 54, 94, .075), inset 0 1px 0 rgba(255, 255, 255, .75);
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", Inter, "Segoe UI", sans-serif;
  font-family: var(--font);
  font-synthesis: none;
  text-rendering: optimizeLegibility;
}

html[data-theme="dark"] {
  color-scheme: dark;
  --bg: #141517;
  --bg-layer-1: rgba(37, 99, 235, .065);
  --bg-layer-2: rgba(14, 165, 233, .035);
  --enterprise-canvas: #141517;
  --surface: rgba(30, 32, 36, .76);
  --surface-strong: rgba(34, 36, 40, .88);
  --surface-soft: rgba(40, 42, 46, .78);
  --surface-muted: rgba(26, 28, 31, .84);
  --glass: rgba(30, 32, 36, .74);
  --glass-strong: rgba(34, 36, 40, .86);
  --glass-soft: rgba(40, 42, 46, .7);
  --text: #f0f1f3;
  --muted: #b0b4bb;
  --line: rgba(230, 234, 240, .12);
  --line-strong: rgba(230, 234, 240, .2);
  --accent: #60a5fa;
  --accent-strong: #93c5fd;
  --accent-soft: rgba(37, 99, 235, .2);
  --danger: #fb7185;
  --enterprise-rule: rgba(230, 234, 240, .12);
  --hex-grid-lines: linear-gradient(to right, rgba(212,174,103,.22) 1px, transparent 1px), linear-gradient(to bottom, rgba(212,174,103,.22) 1px, transparent 1px);
  --shadow: 0 20px 52px rgba(0, 0, 0, .28), 0 3px 12px rgba(0, 0, 0, .16);
  --shadow-soft: 0 10px 30px rgba(0, 0, 0, .2);
  --product-shadow: 0 18px 46px rgba(0, 0, 0, .24);
  --glass-shadow: 0 20px 52px rgba(0, 0, 0, .26), inset 0 1px 0 rgba(255, 255, 255, .045);
}

html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  color: var(--text) !important;
  background: var(--bg) !important;
  font-family: var(--font) !important;
  font-weight: 400;
  letter-spacing: 0;
}
html body.hex-workspace-body {
  color: var(--text) !important;
  background: var(--bg) !important;
  font-family: var(--font) !important;
}

::selection { color: #211a0e; background: #edd4a7; }
:where(h1, h2, h3, h4, h5, .section-head h2, .planning-context strong) {
  color: var(--text);
  font-family: var(--font);
  letter-spacing: -.025em;
  font-weight: 650;
}
:where(p, small, label, li, td, th) { letter-spacing: 0; }

/* Quiet surfaces: hierarchy comes from alignment and fine rules, not shadows. */
:where(.topbar, .toolbar, .panel, .card, .table-panel, .editor-panel, .editor-card,
  .modal-card, .summary-grid article, .kpi-grid article, .admin-edit-card,
  .location-column, .order-column, .order-card, .stock-item, .movement-row) {
  border: 1px solid var(--line) !important;
  border-radius: 8px !important;
  background: var(--surface-strong) !important;
  box-shadow: none !important;
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
}
/* Higher-specificity pass neutralizes older module themes while preserving their data and layouts. */
body.hex-workspace-body :is(.topbar, .toolbar, .panel, .card, .table-panel, .editor-panel,
  .editor-card, .modal-card, .summary-grid article, .kpi-grid article, .admin-edit-card,
  .dashboard-card, .workspace-card, .stat-card, .stock-item, .order-card, .movement-row,
  .planner-shell, .planner-toolbar, .gantt-nav, .app-header, .header-menu-panel,
  .legend-panel, .pdf-controls, .dialog-head, .dialog-section, .day-hours-panel,
  .phase-editor-list, .auth-card) {
  border-color: var(--line) !important;
  border-radius: 8px !important;
  background: var(--surface-strong) !important;
  box-shadow: none !important;
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
}
body.hex-workspace-body :is(.topbar, .toolbar, .panel, .card, .table-panel, .editor-panel,
  .editor-card, .modal-card, .summary-grid article, .kpi-grid article, .admin-edit-card,
  .dashboard-card, .workspace-card, .stat-card, .stock-item, .order-card, .movement-row,
  .planner-shell, .planner-toolbar, .gantt-nav, .app-header, .header-menu-panel,
  .legend-panel, .pdf-controls, .dialog-head, .dialog-section, .day-hours-panel,
  .phase-editor-list, .auth-card)::before { display: none !important; }
body.hex-workspace-body .auth-screen {
  background: var(--bg) !important;
}
body.hex-workspace-body .auth-card {
  width: min(94vw, 400px);
  padding: 24px;
}
:where(.topbar, .toolbar, .panel, .card, .table-panel, .editor-panel, .editor-card,
  .modal-card, .summary-grid article, .kpi-grid article)::before { display: none !important; }

/* Controls share one clear height, focus treatment and fast feedback. */
:where(button, input, select, textarea, .primary-btn, .secondary-btn, .mini-btn,
  .icon-btn, .icon-action, .row-icon-btn) {
  min-width: 0;
  border-radius: 6px !important;
  font: inherit;
  letter-spacing: 0;
  box-shadow: none !important;
  transition: background-color 140ms ease-in-out, border-color 140ms ease-in-out,
    color 140ms ease-in-out, transform 140ms ease-in-out;
}
:where(input, select, textarea) {
  border-color: var(--line-strong) !important;
  background: var(--surface) !important;
  color: var(--text) !important;
}
:where(input, select) { min-height: 40px; }
:where(textarea) { min-height: 88px; }
:where(button, .secondary-btn, .mini-btn, .icon-btn, .icon-action, .row-icon-btn) {
  border-color: var(--line-strong) !important;
  background: var(--surface-strong) !important;
  color: var(--text) !important;
}
:where(button, .secondary-btn, .mini-btn, .icon-btn, .icon-action, .row-icon-btn):hover:not(:disabled) {
  border-color: #c58b2c !important;
  background: var(--surface-soft) !important;
}
:where(button, .secondary-btn, .mini-btn, .icon-btn, .icon-action, .row-icon-btn):active:not(:disabled) {
  transform: translateY(1px);
}
:where(.primary-btn, button.primary-btn) {
  border-color: #bd8426 !important;
  background: #d7a347 !important;
  color: #241b0c !important;
  font-weight: 620;
}
:where(.primary-btn, button.primary-btn):hover:not(:disabled) { background: #e0b15f !important; }
:where(.danger-btn, .delete-btn, .btn-danger) { color: var(--danger) !important; }
:where(button, a, input, select, textarea):focus-visible {
  outline: 2px solid color-mix(in srgb, var(--accent) 68%, white 32%);
  outline-offset: 2px;
}
:where(input, select, textarea):focus { box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 16%, transparent) !important; }
:where(button, a, input, select, textarea) { touch-action: manipulation; }

/* Data views */
table { border-collapse: separate; border-spacing: 0; }
:where(th) {
  color: var(--muted) !important;
  background: var(--surface-muted) !important;
  font-size: .72rem;
  font-weight: 620;
  text-transform: none;
}
:where(td, th) { border-color: var(--line) !important; }
tbody tr { transition: background-color 140ms ease-in-out; }
tbody tr:hover { background: color-mix(in srgb, var(--accent) 6%, var(--surface) 94%) !important; }
:where(.empty-state, .empty-inline, .empty-note, .expense-empty, .empty-order, .empty-drop) {
  color: var(--muted) !important;
  border-color: var(--line-strong) !important;
}
.skeleton {
  border-radius: 6px;
  background: linear-gradient(90deg, var(--surface-muted), var(--surface-soft), var(--surface-muted));
  background-size: 200% 100%;
  animation: hex-skeleton 1.2s ease-in-out infinite;
}
@keyframes hex-skeleton { to { background-position: -200% 0; } }

/* Application navigation */
.workspace-sidebar {
  color: #e8eaec !important;
  background: #17191b !important;
  border-color: #2c3033 !important;
  box-shadow: none !important;
}
.workspace-sidebar-brand { border-color: #2c3033 !important; }
.workspace-nav-heading {
  color: #858d95 !important;
  font-size: .66rem !important;
  font-weight: 650 !important;
  letter-spacing: .055em !important;
  text-transform: uppercase;
}
.workspace-nav-link {
  min-height: 38px;
  margin: 2px 0;
  border: 1px solid transparent !important;
  border-radius: 6px !important;
  color: #b9bec4 !important;
  font-size: .82rem;
  transition: background-color 140ms ease-in-out, color 140ms ease-in-out;
}
.workspace-nav-link:hover {
  background: #222629 !important;
  color: #f3f4f5 !important;
}
.workspace-nav-link.is-active {
  border-color: #3b3529 !important;
  background: #29251e !important;
  color: #e0b15f !important;
}
.workspace-nav-link.is-active .workspace-nav-icon { color: #e0b15f; }
.workspace-sidebar-footer { border-color: #2c3033 !important; }
.workspace-user, .workspace-footer-action { color: #b9bec4 !important; }
.workspace-user-avatar { background: #34383c !important; color: #fff !important; }
.workspace-mobilebar { background: #17191b !important; border-color: #2c3033 !important; box-shadow: none !important; }

@media (min-width: 1024px) {
  body.hex-workspace-body:not(.workspace-sidebar-collapsed) { grid-template-columns: 232px minmax(0, 1fr) !important; }
  body.hex-workspace-body:not(.workspace-sidebar-collapsed) > .workspace-sidebar { width: 232px !important; }
  body.hex-workspace-body :is(.page-shell, .directory-shell, .app-shell, .invoice-shell, .finance-shell) {
    max-width: 1600px !important;
    padding: 24px 28px 40px !important;
    gap: 16px !important;
  }
  body.hex-workspace-body > .app-root { padding: 24px 28px 40px !important; }
}

/* Common page hierarchy, controls, and summaries across the separate business modules. */
body.hex-workspace-body :is(.hero-card, .hero, .app-header) h1,
body.hex-workspace-body .topbar h1 {
  margin: 0;
  color: var(--text) !important;
  font-size: clamp(1.2rem, 1.45vw, 1.55rem) !important;
  font-weight: 650 !important;
  letter-spacing: -.035em !important;
  line-height: 1.2;
}
body.hex-workspace-body :is(.hero-card, .hero, .topbar) :is(p, .session-label) {
  color: var(--muted) !important;
  font-size: .78rem;
  line-height: 1.45;
}
body.hex-workspace-body :is(.section-head, .panel-head, .dashboard-head, .view-head) {
  align-items: center;
  gap: 12px;
}
body.hex-workspace-body :is(.section-head h2, .panel-head h2, .dashboard-head h2, .view-head h2) {
  color: var(--text) !important;
  font-size: .98rem !important;
  font-weight: 640 !important;
  letter-spacing: -.02em;
}
body.hex-workspace-body :is(.section-head small, .panel-head small, .dashboard-head p, .view-head p) {
  color: var(--muted) !important;
  font-size: .75rem;
  line-height: 1.45;
}
body.hex-workspace-body :is(.controls-card, .toolbar, .filters, .workspace-toolbar) {
  border-color: var(--line) !important;
  border-radius: 8px !important;
  background: var(--surface-strong) !important;
  box-shadow: none !important;
}
body.hex-workspace-body :is(.summary-grid, .kpi-grid, .stats-grid) {
  gap: 10px !important;
}
body.hex-workspace-body :is(.summary-grid article, .kpi-grid article, .stats-grid > *) {
  min-width: 0;
  border: 1px solid var(--line) !important;
  border-top: 2px solid color-mix(in srgb, var(--accent) 72%, var(--line) 28%) !important;
  border-radius: 7px !important;
  background: var(--surface-strong) !important;
  box-shadow: none !important;
}
body.hex-workspace-body :is(.summary-grid span, .kpi-grid span, .stats-grid span) {
  color: var(--muted) !important;
  font-size: .71rem !important;
  font-weight: 560 !important;
  letter-spacing: 0 !important;
  text-transform: none !important;
}
body.hex-workspace-body :is(.summary-grid strong, .kpi-grid strong, .stats-grid strong) {
  color: var(--text) !important;
  font-size: clamp(1rem, 1.35vw, 1.3rem) !important;
  font-weight: 650 !important;
  font-variant-numeric: tabular-nums;
}
body.hex-workspace-body :is(.view-tab, .messages-tabs button, .manage-tab, .view-btn) {
  border: 1px solid transparent !important;
  border-radius: 6px !important;
  transition: color 140ms ease-in-out, background-color 140ms ease-in-out, border-color 140ms ease-in-out;
}
body.hex-workspace-body :is(.view-tab.is-active, .messages-tabs button.is-active, .manage-tab.active, .view-btn.active) {
  border-color: color-mix(in srgb, var(--accent) 36%, var(--line) 64%) !important;
  background: var(--accent-soft) !important;
  color: var(--text) !important;
}

/* Portal */
body.home-view-portals, body.home-view-login {
  background: var(--bg) !important;
}
body.home-view-portals .home-shell { max-width: 1240px !important; }
body.home-view-portals .hero-card, body.home-view-portals .chooser-card,
body.home-view-login .auth-home-card {
  border: 1px solid var(--line) !important;
  border-radius: 8px !important;
  background: var(--surface) !important;
  box-shadow: none !important;
}
.portal-link {
  border: 1px solid var(--line) !important;
  border-left: 2px solid var(--accent) !important;
  border-radius: 7px !important;
  background: var(--surface) !important;
  box-shadow: none !important;
  transition: border-color 150ms ease-in-out, background-color 150ms ease-in-out, transform 150ms ease-in-out !important;
}
.portal-link:hover {
  border-color: var(--line-strong) !important;
  border-left-color: var(--accent) !important;
  background: var(--surface-soft) !important;
  box-shadow: none !important;
  transform: translateY(-1px);
}
.portal-icon { border: 1px solid color-mix(in srgb, var(--accent) 22%, var(--line) 78%); color: var(--accent-strong); }

/* Keep every viewport usable; allow horizontal data tables without clipping the page. */
@media (max-width: 760px) {
  :where(.topbar, .toolbar, .panel, .card, .table-panel, .editor-panel, .editor-card, .modal-card) { border-radius: 7px !important; }
  :where(button, input, select, textarea, .primary-btn, .secondary-btn, .mini-btn, .icon-btn, .icon-action, .row-icon-btn) { min-height: 44px; }
  :where(input, select, textarea) { font-size: 16px !important; }
  :where(.table-scroll, .table-wrap, .responsive-table, .compact-scroll) {
    max-width: 100%; overflow-x: auto; overscroll-behavior-inline: contain; -webkit-overflow-scrolling: touch;
  }
  .workspace-nav-link { min-height: 44px; }
  .portal-link { min-height: 76px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}

/* Product-wide redesign: clear page hierarchy, useful density, and calm surfaces. */
body.hex-workspace-body {
  --page-gutter: clamp(16px, 2vw, 32px);
  --section-gap: 16px;
}
body.hex-workspace-body :is(.page-shell, .directory-shell, .app-shell, .invoice-shell, .finance-shell) {
  width: 100% !important;
  max-width: 1880px !important;
  margin-inline: auto !important;
}
body.hex-workspace-body :is(.page-shell, .directory-shell, .app-shell, .finance-shell) {
  padding: max(20px, env(safe-area-inset-top)) var(--page-gutter) max(28px, env(safe-area-inset-bottom)) !important;
  gap: var(--section-gap) !important;
}
body.hex-workspace-body .invoice-shell {
  width: 100% !important;
  /* Invoice tables need more canvas than editorial pages, especially on desktop. */
  max-width: 2200px !important;
  padding: max(18px, env(safe-area-inset-top)) var(--page-gutter) max(22px, env(safe-area-inset-bottom)) !important;
  gap: 12px !important;
}
body.hex-workspace-body :is(.list-card, .directory-shell > .list-card) { min-width: 0; }
body.hex-workspace-body .app-shell:has(#reportForm) { max-width: 1480px !important; }
body.hex-workspace-body #reportForm { gap: 14px !important; }
body.hex-workspace-body #reportForm > .panel { padding: 18px !important; }
body.hex-workspace-body #reportForm > .panel > h2,
body.hex-workspace-body #reportForm > .panel > .panel-head { margin-bottom: 14px; }
body.hex-workspace-body #reportForm .grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; gap: 12px; }
body.hex-workspace-body #reportForm .employees-panel,
body.hex-workspace-body #reportForm .subpanel { border: 1px solid var(--line) !important; border-radius: 8px !important; background: var(--surface-soft) !important; padding: 14px !important; }
body.hex-workspace-body #reportForm .employees-panel { margin-top: 16px; }
body.hex-workspace-body #reportForm .panel-head { align-items: flex-start; }
body.hex-workspace-body #reportForm .hours-total { border: 1px solid var(--line) !important; border-radius: 7px !important; background: var(--accent-soft) !important; padding: 10px 14px !important; }
body.hex-workspace-body #reportForm :is(.days-container, .materials-rows, .preset-equipment-rows, .employees-list) { gap: 10px !important; }
body.hex-workspace-body #reportForm .actions-row { align-items: center; gap: 10px; padding: 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); }
body.hex-workspace-body .section-head { padding-bottom: 10px; border-bottom: 1px solid var(--line); }
body.hex-workspace-body :is(.hero-card, .hero, .topbar) { border-top: 2px solid var(--accent) !important; }
body.hex-workspace-body :is(.meta, .eyebrow, .feedback) { color: var(--muted) !important; }

/* Directory: turn the long, oversized contact stack into a scannable two-column index. */
body.hex-workspace-body .directory-shell > .list-card { padding: 18px; }
body.hex-workspace-body .directory-list {
  display: grid !important;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0 14px;
  overflow: visible !important;
  border: 0 !important;
  border-radius: 0 !important;
  background: transparent !important;
}
body.hex-workspace-body .entry-row {
  min-height: 76px;
  padding: 12px 10px !important;
  border: 0 !important;
  border-bottom: 1px solid var(--line) !important;
  border-radius: 0 !important;
  background: transparent !important;
  transition: background-color 140ms ease-in-out, border-color 140ms ease-in-out;
}
body.hex-workspace-body .entry-row:hover { background: var(--surface-soft) !important; }
body.hex-workspace-body .entry-avatar { width: 38px; height: 38px; border-radius: 8px !important; }
body.hex-workspace-body .entry-main { gap: 3px; }
body.hex-workspace-body .entry-main strong { font-size: .9rem; font-weight: 620; }
body.hex-workspace-body .entry-main small { font-size: .74rem; }

/* Projects: show a compact, balanced portfolio instead of one card per full-width row. */
body.hex-workspace-body.chantiers-page .list-card { padding: 18px; }
body.hex-workspace-body.chantiers-page .sites-list {
  grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  align-items: start;
  gap: 10px !important;
}
body.hex-workspace-body.chantiers-page .site-row {
  min-height: 106px;
  grid-template-columns: 76px minmax(0, 1fr) auto 12px !important;
  grid-template-rows: auto auto;
  gap: 8px 10px !important;
  padding: 12px !important;
  border-radius: 8px !important;
  background: var(--surface) !important;
  box-shadow: none !important;
  transition: background-color 140ms ease-in-out, border-color 140ms ease-in-out;
}
body.hex-workspace-body.chantiers-page .site-row:hover,
body.hex-workspace-body.chantiers-page .site-row:focus-within {
  border-color: color-mix(in srgb, var(--accent) 48%, var(--line-strong)) !important;
  background: color-mix(in srgb, var(--accent) 4%, var(--surface)) !important;
}
body.hex-workspace-body.chantiers-page .site-reference { grid-row: 1 / span 2; align-self: start; font-size: .76rem; }
body.hex-workspace-body.chantiers-page .site-main { gap: 3px; }
body.hex-workspace-body.chantiers-page .site-main > strong { font-size: .9rem; font-weight: 630; }
body.hex-workspace-body.chantiers-page .site-context,
body.hex-workspace-body.chantiers-page .site-address { font-size: .72rem; }
body.hex-workspace-body.chantiers-page .site-dates { grid-column: 2; grid-row: 2; display: block; text-align: left; font-size: .72rem; }
body.hex-workspace-body.chantiers-page .site-dates small { display: none; }
body.hex-workspace-body.chantiers-page .site-dates strong { font-size: .72rem; }
body.hex-workspace-body.chantiers-page .status-btn { grid-column: 3; grid-row: 1; align-self: start; min-height: 28px; padding-inline: 8px; font-size: .68rem; }
body.hex-workspace-body.chantiers-page .site-arrow { grid-column: 4; grid-row: 1; font-size: 1rem; }

/* Finance and invoices: support large datasets without wasting the available canvas. */
body.hex-workspace-body .invoice-shell > .topbar {
  min-height: auto;
  grid-template-columns: minmax(150px, 210px) minmax(0, 1fr) auto !important;
  gap: 16px;
  padding: 12px 14px;
}
body.hex-workspace-body .invoice-shell > .topbar .brand { gap: 10px; }
body.hex-workspace-body .invoice-shell > .topbar .brand .logo { width: 42px !important; height: 42px !important; object-fit: contain; }
body.hex-workspace-body .invoice-shell > .topbar .brand h1 { font-size: 1.12rem !important; }
body.hex-workspace-body .invoice-shell > .topbar .brand p { font-size: .72rem; }
body.hex-workspace-body .invoice-shell > .topbar .toolbar {
  grid-template-columns: minmax(220px, 1.5fr) minmax(140px, .8fr) minmax(160px, 1fr) auto auto !important;
  gap: 8px;
}
body.hex-workspace-body .invoice-shell > .topbar .toolbar label > span { position: static; width: auto; height: auto; margin: 0 0 4px; font-size: .68rem; }
body.hex-workspace-body .invoice-shell > .topbar .toolbar input,
body.hex-workspace-body .invoice-shell > .topbar .toolbar select { min-height: 38px; }
body.hex-workspace-body .invoice-shell > .topbar .topbar-actions { gap: 6px; }
body.hex-workspace-body .summary-grid { grid-template-columns: repeat(6, minmax(0, 1fr)); }
body.hex-workspace-body .summary-grid article { min-height: 84px; padding: 12px 14px; }
body.hex-workspace-body .kpi-grid .kpi-main {
  border-color: color-mix(in srgb, var(--accent) 34%, var(--line)) !important;
  background: var(--accent-soft) !important;
  color: var(--text) !important;
}
body.hex-workspace-body .kpi-grid .kpi-main :is(span, strong, small) { color: var(--text) !important; }
body.hex-workspace-body .kpi-grid .kpi-main strong { color: var(--accent-strong) !important; }
body.hex-workspace-body .invoice-groups { padding: 8px; }
body.hex-workspace-body .month-group { gap: 6px; margin-bottom: 12px; }
body.hex-workspace-body .exercise-head { position: sticky; top: 0; z-index: 4; padding: 9px 12px; border-radius: 7px; background: var(--surface-muted) !important; box-shadow: none !important; }
body.hex-workspace-body .invoice-table { min-width: 1120px; }
body.hex-workspace-body .invoice-table th,
body.hex-workspace-body .invoice-table td { padding: 9px 10px; }
body.hex-workspace-body .invoice-table td { font-size: .78rem; }

/* Planning: remove the oversized dark banner and restore a balanced command header. */
body.hex-workspace-body #app-root > .app-header {
  min-height: 68px !important;
  margin: 10px 10px 0 !important;
  padding: 9px 14px !important;
  border: 1px solid var(--line) !important;
  border-top: 2px solid var(--accent) !important;
  border-radius: 8px !important;
  background: var(--surface) !important;
  color: var(--text) !important;
}
body.hex-workspace-body #app-root > .app-header .logo { display: none !important; }
body.hex-workspace-body #app-root > .app-header .planning-context { margin: 0 auto 0 8px; }
body.hex-workspace-body #app-root > .app-header .planning-context strong { font-size: 1.05rem; }
body.hex-workspace-body #app-root > .app-header .header-menu-panel { gap: 8px; }
body.hex-workspace-body #app-root > .app-header .pdf-controls,
body.hex-workspace-body #app-root > .app-header .pdf-summary-controls {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 12px;
  padding: 8px 10px !important;
  border: 1px solid var(--line) !important;
  border-radius: 7px !important;
  background: var(--surface-soft) !important;
}
body.hex-workspace-body #app-root > .app-header .export-control-heading { display: grid; gap: 2px; }
body.hex-workspace-body #app-root > .app-header .export-control-heading small { font-size: .66rem; }
body.hex-workspace-body #app-root > .app-header .export-control-fields { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
body.hex-workspace-body #app-root > .app-header .export-control-fields label { font-size: .68rem; }
body.hex-workspace-body #app-root > .app-header .export-control-fields :is(select, input, button) { min-height: 36px; }
body.hex-workspace-body #app-root > .layout { padding: 12px !important; gap: 12px !important; }
body.hex-workspace-body #app-root .planner-shell { border-radius: 8px !important; box-shadow: none !important; }
body.hex-workspace-body #app-root .sidebar { border-radius: 8px !important; }

/* Atelier: visually group location columns and make stock operations easier to scan. */
body.hex-workspace-body.inventory-page .workspace-card { padding: 16px !important; }
body.hex-workspace-body.inventory-page .view-tabs { gap: 4px; padding: 4px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface-muted); }
body.hex-workspace-body.inventory-page .view-tab { min-height: 38px; padding: 0 12px; font-size: .8rem; }
body.hex-workspace-body.inventory-page .locations-board { grid-template-columns: repeat(auto-fit, minmax(min(100%, 310px), 1fr)) !important; gap: 12px !important; }
body.hex-workspace-body.inventory-page .location-column { padding: 12px !important; }
body.hex-workspace-body.inventory-page .stock-item { padding: 10px !important; }
body.hex-workspace-body.inventory-page .stock-actions { display: grid !important; grid-template-columns: 34px 34px minmax(0, 1fr) auto; gap: 6px !important; align-items: center; }
body.hex-workspace-body.inventory-page .stock-actions > * { min-width: 0; }
body.hex-workspace-body.inventory-page .stock-actions :is(button, select) { min-height: 36px !important; padding: 0 8px !important; font-size: .72rem !important; }
body.hex-workspace-body.inventory-page .stock-actions select { grid-column: 1 / -1; width: 100%; }
body.hex-workspace-body.inventory-page .preparation-board,
body.hex-workspace-body.inventory-page .assets-board { gap: 12px !important; }
body.hex-workspace-body.inventory-page .order-card { padding: 14px !important; }

/* Consistent focus, selection, and keyboard navigation in dense records. */
body.hex-workspace-body :is(.site-row, .entry-row, .invoice-table tr):focus-within {
  outline: 2px solid color-mix(in srgb, var(--accent) 48%, transparent);
  outline-offset: -2px;
}
body.hex-workspace-body :is(.entry-row, .site-row, .invoice-table tr) { transition-duration: 140ms; }

@media (max-width: 1100px) {
  body.hex-workspace-body .invoice-shell > .topbar { grid-template-columns: 1fr auto !important; }
  body.hex-workspace-body .invoice-shell > .topbar .toolbar { grid-column: 1 / -1; grid-row: 2; }
  body.hex-workspace-body .summary-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  body.hex-workspace-body.chantiers-page .sites-list { grid-template-columns: 1fr !important; }
  body.hex-workspace-body #app-root > .app-header { align-items: flex-start; flex-wrap: wrap; }
  body.hex-workspace-body #app-root > .app-header .header-right { margin-left: auto; }
}
@media (max-width: 760px) {
  body.hex-workspace-body { --page-gutter: 12px; --section-gap: 12px; }
  body.hex-workspace-body :is(.page-shell, .directory-shell, .app-shell, .finance-shell, .invoice-shell) {
    padding: max(12px, env(safe-area-inset-top)) var(--page-gutter) max(20px, env(safe-area-inset-bottom)) !important;
  }
  body.hex-workspace-body .directory-list { grid-template-columns: 1fr; }
  body.hex-workspace-body #reportForm .grid.two { grid-template-columns: 1fr !important; }
  body.hex-workspace-body #reportForm > .panel { padding: 14px !important; }
  body.hex-workspace-body #reportForm .panel-head { flex-direction: column; }
  body.hex-workspace-body #reportForm .hours-total { width: 100%; }
  body.hex-workspace-body #reportForm .actions-row { position: sticky; bottom: max(8px, env(safe-area-inset-bottom)); z-index: 10; flex-wrap: wrap; box-shadow: 0 -8px 22px rgba(20, 24, 28, .08); }
  body.hex-workspace-body .directory-shell > .list-card { padding: 14px; }
  body.hex-workspace-body.chantiers-page .site-row {
    grid-template-columns: 62px minmax(0, 1fr) auto !important;
    min-height: 100px;
    gap: 7px 8px !important;
    padding: 10px !important;
  }
  body.hex-workspace-body.chantiers-page .site-reference { font-size: .7rem; }
  body.hex-workspace-body.chantiers-page .status-btn { grid-column: 2 / 4; grid-row: 2; justify-self: start; }
  body.hex-workspace-body.chantiers-page .site-dates { grid-column: 2 / 4; grid-row: 3; }
  body.hex-workspace-body.chantiers-page .site-arrow { grid-column: 3; grid-row: 1; }
  body.hex-workspace-body .invoice-shell { height: auto !important; min-height: 100dvh; overflow: visible !important; }
  body.hex-workspace-body .invoice-shell > .topbar { grid-template-columns: minmax(0, 1fr) auto !important; }
  body.hex-workspace-body .invoice-shell > .topbar .toolbar {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) !important;
    grid-column: 1 / -1;
  }
  body.hex-workspace-body .invoice-shell > .topbar .toolbar .search-field { grid-column: 1 / -1; }
  body.hex-workspace-body .invoice-shell > .topbar .toolbar .page-feedback { grid-column: 1 / -1; }
  body.hex-workspace-body .summary-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  body.hex-workspace-body .summary-grid article { min-height: 76px; padding: 10px; }
  body.hex-workspace-body .workspace, body.hex-workspace-body .table-panel { min-height: 50vh; height: auto; overflow: visible; }
  body.hex-workspace-body .invoice-groups { height: auto; overflow: visible; }
  body.hex-workspace-body #app-root > .app-header { margin: 6px 6px 0 !important; padding: 10px !important; }
  body.hex-workspace-body #app-root > .app-header .planning-context { min-width: 120px; }
  body.hex-workspace-body #app-root > .app-header .header-menu-panel { flex-basis: 100%; display: grid; grid-template-columns: 1fr; }
  body.hex-workspace-body #app-root > .app-header .pdf-controls,
  body.hex-workspace-body #app-root > .app-header .pdf-summary-controls { grid-template-columns: 1fr; }
  body.hex-workspace-body #app-root > .layout { padding: 8px !important; }
  body.hex-workspace-body.inventory-page .workspace-toolbar { align-items: stretch; }
  body.hex-workspace-body.inventory-page .view-tabs { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  body.hex-workspace-body.inventory-page .view-tab { justify-content: center; white-space: normal; }
  body.hex-workspace-body.inventory-page .stock-actions { grid-template-columns: 40px 40px minmax(0, 1fr); }
  body.hex-workspace-body.inventory-page .stock-actions select { grid-column: 1 / -1; }
}

/* Atelier: make each storage location a clear, color-coded inventory zone. */
body.hex-workspace-body.inventory-page .page-shell {
  width: min(100%, 1960px) !important;
  max-width: 1960px !important;
  gap: 14px !important;
  padding: 20px clamp(14px, 2vw, 30px) 32px !important;
}
body.hex-workspace-body.inventory-page .hero-card {
  min-height: 74px;
  padding: 14px 18px !important;
  border-left: 3px solid var(--accent) !important;
  background: var(--surface) !important;
}
body.hex-workspace-body.inventory-page .hero-copy h1 { font-size: 1.3rem !important; }
body.hex-workspace-body.inventory-page .dashboard-card,
body.hex-workspace-body.inventory-page .workspace-card { padding: 18px !important; }
body.hex-workspace-body.inventory-page .dashboard-head { align-items: center; }
body.hex-workspace-body.inventory-page .stats-grid { gap: 10px; margin-top: 14px; }
body.hex-workspace-body.inventory-page .stat-card {
  min-height: 74px;
  grid-template-columns: auto 1fr;
  align-items: center;
  column-gap: 12px;
  padding: 12px 14px;
  border-radius: 8px;
  background: var(--surface-soft);
  box-shadow: none;
}
body.hex-workspace-body.inventory-page .stat-card strong { grid-row: 1 / span 2; font-size: 1.35rem; }
body.hex-workspace-body.inventory-page .stat-card span { font-size: .74rem; }
body.hex-workspace-body.inventory-page .workspace-toolbar {
  align-items: center;
  gap: 14px;
  padding: 0 0 14px;
}
body.hex-workspace-body.inventory-page .view-tabs {
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--surface-muted);
}
body.hex-workspace-body.inventory-page .view-tab {
  min-height: 38px;
  padding-inline: 12px;
  border-radius: 6px !important;
  white-space: nowrap;
  font-size: .78rem;
}
body.hex-workspace-body.inventory-page .view-tab.is-active {
  border-color: var(--line) !important;
  background: var(--surface) !important;
  color: var(--text) !important;
  box-shadow: 0 1px 2px rgba(20, 24, 30, .08) !important;
}
body.hex-workspace-body.inventory-page .search-field { min-width: 250px; }
body.hex-workspace-body.inventory-page .inventory-view { padding-top: 16px; }
body.hex-workspace-body.inventory-page .view-head {
  align-items: center;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
}
body.hex-workspace-body.inventory-page .locations-board {
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 330px), 1fr)) !important;
  gap: 14px !important;
  align-items: stretch;
}
body.hex-workspace-body.inventory-page .location-column {
  min-height: 190px;
  border: 1px solid var(--line) !important;
  border-left: 4px solid var(--location-color) !important;
  border-radius: 9px !important;
  background: var(--surface) !important;
  overflow: hidden;
  transition: border-color 140ms ease-in-out, background-color 140ms ease-in-out, transform 140ms ease-in-out;
}
body.hex-workspace-body.inventory-page .location-column:hover { border-color: var(--line-strong) !important; }
body.hex-workspace-body.inventory-page .location-column.is-drop-target {
  border-color: var(--location-color) !important;
  background: color-mix(in srgb, var(--location-color) 5%, var(--surface)) !important;
  outline: 2px dashed var(--location-color);
  outline-offset: -5px;
}
body.hex-workspace-body.inventory-page .location-column > header {
  align-items: flex-start;
  padding: 13px 14px 11px;
  border-bottom: 1px solid var(--line);
  background: var(--surface-soft);
}
body.hex-workspace-body.inventory-page .location-column h3 { font-size: .92rem; font-weight: 680; }
body.hex-workspace-body.inventory-page .location-column header p { margin-top: 6px; font-size: .7rem; }
body.hex-workspace-body.inventory-page .location-dot { width: 8px; height: 8px; margin-right: 6px; }
body.hex-workspace-body.inventory-page .location-items { gap: 8px; padding: 10px; }
body.hex-workspace-body.inventory-page .stock-item {
  padding: 12px;
  border: 1px solid var(--line) !important;
  border-radius: 7px !important;
  background: var(--surface) !important;
  cursor: grab;
  transition: border-color 140ms ease-in-out, background-color 140ms ease-in-out, transform 140ms ease-in-out;
}
body.hex-workspace-body.inventory-page .stock-item:hover {
  border-color: color-mix(in srgb, var(--accent) 40%, var(--line)) !important;
  background: var(--surface-soft) !important;
  transform: translateY(-1px);
}
body.hex-workspace-body.inventory-page .stock-item-top { justify-content: flex-end; min-height: 26px; }
body.hex-workspace-body.inventory-page .stock-item h3 { margin: 3px 0 4px; font-size: .9rem; font-weight: 640; line-height: 1.35; }
body.hex-workspace-body.inventory-page .stock-item > p { margin-top: 3px; font-size: .73rem; line-height: 1.4; }
body.hex-workspace-body.inventory-page .quantity-badge {
  display: inline-flex;
  align-items: baseline;
  gap: 4px;
  min-width: 0;
  padding: 4px 8px;
  border: 1px solid color-mix(in srgb, var(--accent) 22%, var(--line));
  border-radius: 6px;
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-size: .83rem;
  font-weight: 720;
  font-variant-numeric: tabular-nums;
}
body.hex-workspace-body.inventory-page .quantity-badge span { color: var(--muted); font-size: .65rem; font-weight: 560; }
body.hex-workspace-body.inventory-page .stock-actions {
  display: flex !important;
  align-items: center;
  gap: 5px !important;
  margin-top: 10px;
  padding-top: 9px;
  border-top: 1px solid var(--line);
}
body.hex-workspace-body.inventory-page .stock-actions .mini-btn {
  flex: 0 0 32px;
  width: 32px;
  min-height: 32px !important;
  padding: 0 !important;
  border-radius: 6px !important;
  background: var(--surface-muted) !important;
  font-size: .95rem !important;
}
body.hex-workspace-body.inventory-page .stock-actions .text-btn {
  min-height: 32px !important;
  padding: 0 8px !important;
  border: 1px solid var(--line) !important;
  border-radius: 6px !important;
  background: var(--surface) !important;
  color: var(--text) !important;
  font-size: .7rem !important;
  text-decoration: none !important;
}
body.hex-workspace-body.inventory-page .stock-actions [data-prepare-item] {
  margin-left: auto;
  border-color: color-mix(in srgb, var(--accent) 35%, var(--line)) !important;
  background: var(--accent-soft) !important;
  color: var(--accent-strong) !important;
}
body.hex-workspace-body.inventory-page .move-select {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px dashed var(--line);
}
body.hex-workspace-body.inventory-page .move-select select { min-height: 36px !important; }
body.hex-workspace-body.inventory-page .location-column.is-unavailable {
  border-color: color-mix(in srgb, var(--danger) 50%, var(--line)) !important;
  border-left-color: var(--danger) !important;
  background-color: color-mix(in srgb, var(--danger) 4%, var(--surface)) !important;
  background-image: repeating-linear-gradient(-45deg, transparent 0 12px, color-mix(in srgb, var(--danger) 9%, transparent) 12px 14px) !important;
}
body.hex-workspace-body.inventory-page .location-column.is-unavailable > header { background: color-mix(in srgb, var(--danger) 7%, var(--surface)); }
body.hex-workspace-body.inventory-page .location-column.is-unavailable .stock-item { cursor: default; }
body.hex-workspace-body.inventory-page .location-column.is-unavailable .stock-item:hover { transform: none; }
body.hex-workspace-body.inventory-page .add-in-location {
  width: calc(100% - 20px);
  min-height: 38px;
  margin: 0 10px 10px;
  border: 1px dashed var(--line-strong) !important;
  border-radius: 6px !important;
  background: transparent !important;
}
body.hex-workspace-body.inventory-page .empty-drop { min-height: 64px; background: var(--surface-soft); }
body.hex-workspace-body.inventory-page .order-column { border-radius: 9px !important; background: var(--surface-soft) !important; }
body.hex-workspace-body.inventory-page .order-card { border-radius: 8px !important; }

@media (max-width: 760px) {
  body.hex-workspace-body.inventory-page .page-shell { padding: 12px !important; }
  body.hex-workspace-body.inventory-page .dashboard-card,
  body.hex-workspace-body.inventory-page .workspace-card { padding: 13px !important; }
  body.hex-workspace-body.inventory-page .stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  body.hex-workspace-body.inventory-page .stat-card { min-height: 66px; padding: 9px; column-gap: 8px; }
  body.hex-workspace-body.inventory-page .stat-card strong { font-size: 1.15rem; }
  body.hex-workspace-body.inventory-page .workspace-toolbar { align-items: stretch; }
  body.hex-workspace-body.inventory-page .view-tabs { display: flex; width: 100%; overflow-x: auto; flex-wrap: nowrap; }
  body.hex-workspace-body.inventory-page .view-tab { min-height: 42px; flex: 0 0 auto; padding-inline: 10px; }
  body.hex-workspace-body.inventory-page .search-field { min-width: 0; width: 100%; }
  body.hex-workspace-body.inventory-page .locations-board { grid-template-columns: 1fr !important; gap: 10px !important; }
  body.hex-workspace-body.inventory-page .location-column { min-height: 0; }
  body.hex-workspace-body.inventory-page .location-items { gap: 7px; padding: 8px; }
  body.hex-workspace-body.inventory-page .stock-item { padding: 11px; }
  body.hex-workspace-body.inventory-page .stock-actions { display: grid !important; grid-template-columns: 40px 40px minmax(0, 1fr) auto; }
  body.hex-workspace-body.inventory-page .stock-actions .mini-btn { width: 40px; min-height: 40px !important; }
  body.hex-workspace-body.inventory-page .stock-actions .text-btn { min-height: 40px !important; white-space: normal; }
  body.hex-workspace-body.inventory-page .stock-actions [data-prepare-item] { margin-left: 0; }
  body.hex-workspace-body.inventory-page .stock-actions [data-edit-item] { grid-column: 3 / -1; justify-self: end; }
  body.hex-workspace-body.inventory-page .view-head { align-items: stretch; }
}

/* Atelier location accordions and item availability state. */
body.hex-workspace-body.inventory-page .view-tabs .view-tab.is-active {
  border: 1px solid color-mix(in srgb, var(--accent) 58%, var(--line)) !important;
  background: var(--accent-soft) !important;
  color: var(--accent-strong) !important;
  font-weight: 720 !important;
  box-shadow: inset 0 -2px 0 var(--accent) !important;
}
body.hex-workspace-body.inventory-page .location-column { min-height: 0; }
body.hex-workspace-body.inventory-page .location-column.is-collapsed { height: 94px; min-height: 94px; }
body.hex-workspace-body.inventory-page .location-header {
  min-height: 92px;
  align-items: center !important;
  gap: 8px !important;
  padding: 10px 12px !important;
  background: var(--surface-soft) !important;
}
body.hex-workspace-body.inventory-page .location-column.is-collapsed .location-header { height: 92px; min-height: 0; }
body.hex-workspace-body.inventory-page .location-toggle {
  display: flex !important;
  flex: 1 1 auto;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-width: 0;
  min-height: 66px !important;
  padding: 8px !important;
  border: 0 !important;
  border-radius: 7px !important;
  background: transparent !important;
  text-align: left;
  cursor: pointer;
}
body.hex-workspace-body.inventory-page .location-toggle:hover { background: var(--surface) !important; }
body.hex-workspace-body.inventory-page .location-identity { display: flex; align-items: flex-start; gap: 9px; min-width: 0; }
body.hex-workspace-body.inventory-page .location-heading-copy { display: grid; gap: 5px; min-width: 0; }
body.hex-workspace-body.inventory-page .location-name {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow-wrap: anywhere;
  overflow: hidden;
  color: var(--text);
  font-size: 1rem;
  font-weight: 700;
  line-height: 1.25;
}
body.hex-workspace-body.inventory-page .location-summary {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--muted);
  font-size: .69rem;
  font-weight: 560;
  line-height: 1.3;
}
body.hex-workspace-body.inventory-page .location-summary i { padding-inline: 3px; color: var(--line-strong); font-style: normal; }
body.hex-workspace-body.inventory-page .location-chevron {
  flex: 0 0 10px;
  width: 10px;
  height: 10px;
  margin: 0 3px 4px;
  border-right: 1.7px solid var(--muted);
  border-bottom: 1.7px solid var(--muted);
  transform: rotate(45deg);
  transition: transform 140ms ease-in-out;
}
body.hex-workspace-body.inventory-page .location-toggle[aria-expanded="true"] .location-chevron { margin-bottom: -4px; transform: rotate(225deg); }
body.hex-workspace-body.inventory-page .location-content[hidden] { display: none !important; }
body.hex-workspace-body.inventory-page .location-column.is-expanded > .location-header { border-bottom: 1px solid var(--line); }
body.hex-workspace-body.inventory-page .location-dot { flex: 0 0 10px; width: 10px; height: 10px; margin: 4px 0 0; }
body.hex-workspace-body.inventory-page .location-header .location-unavailable-tag { flex: 0 0 auto; margin: 0; }
body.hex-workspace-body.inventory-page .location-edit { flex: 0 0 34px; width: 34px; min-height: 34px !important; }
body.hex-workspace-body.inventory-page .stock-item h3 { font-size: .87rem; font-weight: 620; }
body.hex-workspace-body.inventory-page .stock-item.item-is-unavailable {
  border-color: color-mix(in srgb, var(--danger) 44%, var(--line)) !important;
  border-left: 3px solid var(--danger) !important;
  background: color-mix(in srgb, var(--danger) 4%, var(--surface)) !important;
  cursor: default;
}
body.hex-workspace-body.inventory-page .stock-item.item-is-unavailable:hover { transform: none; }
body.hex-workspace-body.inventory-page .item-unavailable-tag {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  margin-right: auto;
  padding: 3px 7px;
  border: 1px solid color-mix(in srgb, var(--danger) 32%, var(--line));
  border-radius: 5px;
  background: color-mix(in srgb, var(--danger) 9%, var(--surface));
  color: var(--danger);
  font-size: .64rem;
  font-weight: 700;
}
body.hex-workspace-body.inventory-page .stock-item.item-is-unavailable .stock-actions [data-adjust] { opacity: .65; }
body.hex-workspace-body.inventory-page .item-availability-toggle { width: 100%; }
@media (max-width: 760px) {
  body.hex-workspace-body.inventory-page .location-column.is-collapsed { height: 84px; min-height: 84px; }
  body.hex-workspace-body.inventory-page .location-column.is-collapsed .location-header { height: 82px; min-height: 0; }
  body.hex-workspace-body.inventory-page .location-header { min-height: 82px; padding: 8px !important; }
  body.hex-workspace-body.inventory-page .location-toggle { min-height: 62px !important; padding: 6px !important; }
  body.hex-workspace-body.inventory-page .location-name { font-size: .98rem; }
  body.hex-workspace-body.inventory-page .stock-item h3 { font-size: .86rem; }
  body.hex-workspace-body.inventory-page .item-availability-toggle { align-items: flex-start; }
}

/* Navigation reordering feedback: clear affordances for mouse, touch, and keyboard. */
body.hex-workspace-body .workspace-nav-reorder-hint,
body.hex-workspace-body .workspace-nav-empty-hint {
  margin: 0 8px 8px;
  color: #8e959c;
  font-size: .66rem;
  line-height: 1.4;
}
body.hex-workspace-body .workspace-nav-section.is-empty {
  min-height: 76px;
  padding: 0 0 8px;
  border: 1px dashed #43484d;
  border-radius: 7px;
}
body.hex-workspace-body .workspace-nav-section.is-empty .workspace-nav-heading { padding: 9px 9px 3px; }
body.hex-workspace-body .workspace-nav-link[draggable="true"] { cursor: grab; }
body.hex-workspace-body .workspace-nav-link.is-drag-armed,
body.hex-workspace-body .workspace-nav-link.is-dragging {
  border-color: var(--accent) !important;
  background: #30291f !important;
  color: #f3d195 !important;
  user-select: none;
  -webkit-user-select: none;
  cursor: grabbing !important;
}
body.hex-workspace-body .workspace-nav-link.is-dragging { opacity: .56; }
body.hex-workspace-body .workspace-nav-link.is-drop-target {
  box-shadow: inset 0 2px 0 var(--accent), inset 0 -2px 0 var(--accent) !important;
}
body.hex-workspace-body .workspace-nav-section.is-reordering { background: color-mix(in srgb, var(--accent) 3%, transparent); }
body.workspace-sidebar-collapsed .workspace-nav-reorder-hint,
body.workspace-sidebar-collapsed .workspace-nav-empty-hint { display: none !important; }
body.workspace-mobile-layout .workspace-nav-reorder-hint { margin: 0 10px 8px; }

/* Architectural drawing identity: quiet graph paper, never above application content. */
body.hex-workspace-body,
body.home-view-login,
body.home-view-portals,
body.home-view-settings {
  position: relative;
  isolation: isolate;
  background-color: var(--bg, #f3f4f6);
}
body.hex-workspace-body::before,
body.hex-workspace-body::after,
body.home-view-login::before,
body.home-view-login::after,
body.home-view-portals::before,
body.home-view-portals::after,
body.home-view-settings::before,
body.home-view-settings::after {
  content: "" !important;
  display: block !important;
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: -1;
}
body.hex-workspace-body::before,
body.home-view-login::before,
body.home-view-portals::before,
body.home-view-settings::before {
  opacity: .62;
  background-image: var(--hex-grid-lines);
  background-size: 24px 24px;
  mask-image: linear-gradient(135deg, #000 0%, rgba(0,0,0,.72) 62%, rgba(0,0,0,.16) 100%);
}
body.hex-workspace-body::after,
body.home-view-login::after,
body.home-view-portals::after,
body.home-view-settings::after {
  inset: auto 2vw 5vh auto;
  width: min(48vw, 700px);
  height: min(58vh, 520px);
  opacity: .20;
  background-repeat: no-repeat;
  background-position: center;
  background-size: contain;
  background-image: var(--hex-blueprint-art);
  animation: hex-blueprint-draft 24s ease-in-out infinite alternate;
}
html[data-theme='dark'] body.hex-workspace-body::before,
html[data-theme='dark'] body.home-view-login::before,
html[data-theme='dark'] body.home-view-portals::before,
html[data-theme='dark'] body.home-view-settings::before {
  opacity: .7;
  background-image: var(--hex-grid-lines);
  background-size: 24px 24px;
}
html[data-theme='dark'] body.hex-workspace-body::after,
html[data-theme='dark'] body.home-view-login::after,
html[data-theme='dark'] body.home-view-portals::after,
html[data-theme='dark'] body.home-view-settings::after { opacity: .28; filter: brightness(1.32); }
@keyframes hex-blueprint-draft {
  from { transform: translate3d(0, 5px, 0); }
  to { transform: translate3d(-8px, -5px, 0); }
}

/* Short, consistent entrance and navigation feedback. */
body.hex-workspace-body .page-shell,
body.hex-workspace-body .directory-shell,
body.hex-workspace-body .app-shell,
body.hex-workspace-body .invoice-shell,
body.hex-workspace-body .finance-shell,
body.home-view-portals .home-shell,
body.home-view-login .auth-home-card {
  animation: hex-page-enter 180ms ease-out both;
}
body.hex-workspace-body.workspace-navigating > main,
body.hex-workspace-body.workspace-navigating > .app-root {
  opacity: .72;
  transform: translateY(3px);
  transition: opacity 140ms ease, transform 140ms ease;
}
@keyframes hex-page-enter {
  from { opacity: 0; transform: translateY(5px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Account visual preference uses a familiar, touch-friendly switch. */
.visual-preference-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 0;
  border-top: 1px solid var(--line, #dfe2e6);
  cursor: pointer;
}
.visual-preference-copy { display: grid; gap: 4px; }
.visual-preference-copy strong { color: var(--text, #202328); font-size: .9rem; font-weight: 650; }
.visual-preference-copy small { max-width: 540px; color: var(--muted, #626873); font-size: .78rem; line-height: 1.45; }
.visual-preference-row input[type="checkbox"][role="switch"] {
  appearance: none;
  position: relative;
  flex: 0 0 44px;
  width: 44px;
  height: 26px;
  margin: 0;
  border: 1px solid var(--line-strong, #c9cdd3);
  border-radius: 999px;
  background: var(--surface-muted, #f2f4f6);
  cursor: pointer;
  transition: background-color 150ms ease, border-color 150ms ease;
}
.visual-preference-row input[type="checkbox"][role="switch"]::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 2px rgba(0,0,0,.16);
  transition: transform 150ms ease;
}
.visual-preference-row input[type="checkbox"][role="switch"]:checked { border-color: var(--accent, #d39b3d); background: var(--accent, #d39b3d); }
.visual-preference-row input[type="checkbox"][role="switch"]:checked::after { transform: translateX(18px); }
.visual-preference-row input[type="checkbox"][role="switch"]:focus-visible { outline: 3px solid color-mix(in srgb, var(--accent, #d39b3d) 34%, transparent); outline-offset: 2px; }
@media (max-width: 640px) {
  body.hex-workspace-body::after,
  body.home-view-login::after,
  body.home-view-portals::after,
  body.home-view-settings::after { right: -18vw; bottom: 2vh; width: 90vw; height: 38vh; opacity: .14; }
  .visual-preference-row { align-items: flex-start; }
}
@media (prefers-reduced-motion: reduce) {
  body.hex-workspace-body::after,
  body.home-view-login::after,
  body.home-view-portals::after,
  body.home-view-settings::after,
  body.hex-workspace-body .page-shell,
  body.hex-workspace-body .directory-shell,
  body.hex-workspace-body .app-shell,
  body.hex-workspace-body .invoice-shell,
  body.hex-workspace-body .finance-shell,
  body.home-view-portals .home-shell,
  body.home-view-login .auth-home-card { animation: none !important; }
}

/* Blueprint-draft loading mark. */
.hexagone-app-loader {
  overflow: hidden;
  background-color: #f7f7f5;
  background-image: linear-gradient(rgba(168,131,63,.055) 1px, transparent 1px), linear-gradient(90deg, rgba(168,131,63,.055) 1px, transparent 1px);
  background-size: 24px 24px;
}
.hexagone-loader-mark {
  display: grid;
  place-items: center;
  width: 54px;
  height: 54px;
  border: 0;
  border-radius: 0;
  background: transparent;
  animation: none;
}
.hexagone-loader-mark svg { width: 48px; height: 48px; overflow: visible; }
.hexagone-loader-mark path { fill: none; stroke: #c18a31; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.hexagone-loader-mark .plan-draft-outline { stroke-dasharray: 160; stroke-dashoffset: 160; animation: hex-plan-draw 1.5s ease-in-out infinite; }
.hexagone-loader-mark .plan-draft-detail { opacity: .66; stroke-dasharray: 100; stroke-dashoffset: 100; animation: hex-plan-draw 1.5s .16s ease-in-out infinite; }
.hexagone-loader-mark .plan-draft-door { opacity: .8; stroke-dasharray: 20; stroke-dashoffset: 20; animation: hex-plan-draw 1.5s .3s ease-in-out infinite; }
@keyframes hex-plan-draw { 52%, 72% { stroke-dashoffset: 0; } 100% { stroke-dashoffset: 0; opacity: .32; } }
html[data-theme='dark'] .hexagone-app-loader { background-color: #121519; background-image: linear-gradient(rgba(211,155,61,.055) 1px, transparent 1px), linear-gradient(90deg, rgba(211,155,61,.055) 1px, transparent 1px); }
@media (prefers-reduced-motion: reduce) {
  .hexagone-loader-mark path { animation: none !important; stroke-dashoffset: 0 !important; }
}

/* Keep the dark sidebar footer hover treatment identical in light and dark themes. */
body.hex-workspace-body .workspace-sidebar-footer .workspace-footer-action,
body.hex-workspace-body .workspace-sidebar-footer .workspace-sidebar-collapse {
  border-color: transparent !important;
  background: transparent !important;
  color: #b9bec4 !important;
  transition: background-color 140ms ease, border-color 140ms ease, color 140ms ease;
}
body.hex-workspace-body .workspace-sidebar-footer .workspace-footer-action:hover,
body.hex-workspace-body .workspace-sidebar-footer .workspace-footer-action:focus-visible,
body.hex-workspace-body .workspace-sidebar-footer .workspace-sidebar-collapse:hover,
body.hex-workspace-body .workspace-sidebar-footer .workspace-sidebar-collapse:focus-visible {
  border-color: #3b4046 !important;
  background: #25282c !important;
  color: #f3f4f5 !important;
}
body.hex-workspace-body .workspace-sidebar-footer .workspace-footer-action:hover .workspace-action-icon,
body.hex-workspace-body .workspace-sidebar-footer .workspace-footer-action:focus-visible .workspace-action-icon,
body.hex-workspace-body .workspace-sidebar-footer .workspace-sidebar-collapse:hover .workspace-action-icon,
body.hex-workspace-body .workspace-sidebar-footer .workspace-sidebar-collapse:focus-visible .workspace-action-icon {
  color: #e0b15f !important;
  background: transparent !important;
}

/* Shared theme repair: modules inherit the same neutral surfaces and legible controls. */
html[data-theme="dark"] body.hex-workspace-body :is(.topbar, .toolbar, .panel, .card, .table-panel,
  .editor-panel, .editor-card, .modal-card, .summary-grid article, .kpi-grid article,
  .admin-edit-card, .dashboard-card, .workspace-card, .stat-card, .stock-item, .order-card,
  .movement-row, .location-column, .order-column, .assets-location, .audit-item) {
  color: var(--text);
  background-color: var(--surface-strong) !important;
  border-color: var(--line) !important;
}
html[data-theme="dark"] body.hex-workspace-body :is(input, select, textarea) {
  color: var(--text) !important;
  background-color: var(--surface) !important;
  border-color: var(--line-strong) !important;
  color-scheme: dark;
}
html[data-theme="dark"] body.hex-workspace-body :is(th, .table-head, .table-header) {
  color: var(--muted);
  background-color: var(--surface-soft);
  border-color: var(--line);
}
html[data-theme="dark"] body.hex-workspace-body :is(td, .table-cell, .card-description, .muted) {
  border-color: var(--line);
}
body.hex-workspace-body :is(button, a, input, select, textarea) {
  transition-duration: 140ms !important;
}

/* Shared modern finish: soft color fields, crisp accents and restrained glass surfaces. */
html body.hex-workspace-body,
body.home-view-login,
body.home-view-portals,
body.home-view-settings {
  background:
    radial-gradient(ellipse at 9% 0%, var(--bg-layer-1), transparent 34%),
    radial-gradient(ellipse at 92% 8%, var(--bg-layer-2), transparent 32%),
    linear-gradient(155deg, color-mix(in srgb, var(--bg) 97%, white 3%), var(--bg) 58%, color-mix(in srgb, var(--bg) 98%, var(--accent) 2%)) !important;
  background-attachment: fixed !important;
}

html body.hex-workspace-body.hex-workspace-body :is(.topbar, .toolbar, .panel, .card, .table-panel, .editor-panel,
  .editor-card, .modal-card, .summary-grid article, .kpi-grid article, .admin-edit-card,
  .dashboard-card, .workspace-card, .stat-card, .stock-item, .order-card, .movement-row,
  .location-column, .order-column, .assets-location, .audit-item, .list-card, .controls-card,
  .table-wrap, .table-scroll, .planner-toolbar, .gantt-nav, .header-menu-panel, .pdf-controls,
  .dialog-head, .dialog-section, .day-hours-panel, .phase-editor-list, .auth-card) {
  border: 1px solid var(--line) !important;
  border-radius: 15px !important;
  background: color-mix(in srgb, var(--surface-strong) 84%, transparent 16%) !important;
  box-shadow: var(--glass-shadow) !important;
  backdrop-filter: blur(18px) saturate(145%) !important;
  -webkit-backdrop-filter: blur(18px) saturate(145%) !important;
}

/* Keep the left rail legible and grounded while using the same vivid blue selection state. */
html body.hex-workspace-body.hex-workspace-body .workspace-sidebar {
  background: rgba(20, 29, 43, .96) !important;
  border-right: 1px solid rgba(255, 255, 255, .09) !important;
  box-shadow: 8px 0 32px rgba(16, 33, 58, .12) !important;
  backdrop-filter: blur(20px) saturate(130%) !important;
  -webkit-backdrop-filter: blur(20px) saturate(130%) !important;
}
html body.hex-workspace-body.hex-workspace-body .workspace-nav-link.is-active {
  border-color: rgba(96, 165, 250, .26) !important;
  background: linear-gradient(115deg, rgba(37, 99, 235, .24), rgba(14, 165, 233, .13)) !important;
  color: #9bc7ff !important;
}
html body.hex-workspace-body.hex-workspace-body .workspace-nav-link.is-active .workspace-nav-icon { color: #75b6ff !important; }

/* One consistent control language across forms, dialogs and navigation actions. */
html body.hex-workspace-body.hex-workspace-body :is(button, input, select, textarea, .primary-btn, .secondary-btn,
  .mini-btn, .icon-btn, .icon-action, .row-icon-btn, .view-tab, .manage-tab, .view-btn),
body.home-view-login :is(button, input, select, textarea, .primary-btn, .secondary-btn),
body.home-view-portals :is(button, .portal-link) {
  border-radius: 10px !important;
  transition: transform 160ms ease, border-color 160ms ease, background-color 160ms ease,
    box-shadow 160ms ease, color 160ms ease !important;
}
html body.hex-workspace-body.hex-workspace-body :is(input, select, textarea) {
  border-color: var(--line-strong) !important;
  background: color-mix(in srgb, var(--surface) 86%, transparent 14%) !important;
  box-shadow: inset 0 1px 2px rgba(30, 55, 89, .035) !important;
}
html body.hex-workspace-body.hex-workspace-body :is(input, select, textarea):focus-visible {
  border-color: var(--accent) !important;
  outline: 3px solid color-mix(in srgb, var(--accent) 20%, transparent) !important;
  outline-offset: 1px;
}
/* Keep suggestion menus and native option lists opaque over form contents. */
html body.hex-workspace-body.hex-workspace-body :is(.supplier-suggestions, .report-site-suggestions, [role="listbox"]) {
  background: #fff !important;
  color: var(--text) !important;
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
}
html body.hex-workspace-body.hex-workspace-body select option {
  background-color: #fff !important;
  color: #172538 !important;
}
html[data-theme="dark"] body.hex-workspace-body.hex-workspace-body :is(.supplier-suggestions, .report-site-suggestions, [role="listbox"]) { background: #26282c !important; }
html[data-theme="dark"] body.hex-workspace-body.hex-workspace-body select option { background-color: #26282c !important; color: #f0f1f3 !important; }
/* The autocomplete sits inside the first form grid row; lift that stacking context above later sections while open. */
html body.hex-workspace-body.hex-workspace-body .editor-panel > .form-grid:has(.supplier-suggestions:not(.is-hidden)) {
  position: relative !important;
  z-index: 20 !important;
}
html body.hex-workspace-body.hex-workspace-body .supplier-field:has(.supplier-suggestions:not(.is-hidden)) {
  position: relative !important;
  z-index: 21 !important;
}
html body.hex-workspace-body.hex-workspace-body :is(button, .secondary-btn, .mini-btn, .icon-btn, .icon-action, .row-icon-btn) {
  border-color: var(--line-strong) !important;
  background: color-mix(in srgb, var(--surface-strong) 58%, transparent 42%) !important;
  color: var(--text) !important;
}
html body.hex-workspace-body.hex-workspace-body :is(button, .secondary-btn, .mini-btn, .icon-btn, .icon-action, .row-icon-btn):hover:not(:disabled) {
  border-color: color-mix(in srgb, var(--accent) 44%, var(--line-strong)) !important;
  background: color-mix(in srgb, var(--accent) 9%, var(--surface-strong)) !important;
  box-shadow: 0 6px 18px color-mix(in srgb, var(--accent) 10%, transparent) !important;
  transform: translateY(-1px);
}
html body.hex-workspace-body.hex-workspace-body :is(.primary-btn, button.primary-btn) {
  border-color: color-mix(in srgb, var(--accent) 30%, var(--line)) !important;
  background: color-mix(in srgb, var(--accent) 11%, transparent) !important;
  color: var(--accent-strong) !important;
  box-shadow: 0 2px 8px rgba(37, 99, 235, .07) !important;
  font-weight: 650;
}
html body.hex-workspace-body.hex-workspace-body :is(.primary-btn, button.primary-btn):hover:not(:disabled) {
  border-color: color-mix(in srgb, var(--accent) 48%, var(--line)) !important;
  background: color-mix(in srgb, var(--accent) 17%, transparent) !important;
  box-shadow: 0 5px 14px rgba(37, 99, 235, .12) !important;
  transform: translateY(-1px);
}
html body.hex-workspace-body.hex-workspace-body :is(.status-paid, .status-success, .is-positive) { color: #07834f !important; }
html body.hex-workspace-body.hex-workspace-body :is(.status-paid, .status-success) { background: rgba(16, 185, 129, .12) !important; }
html body.hex-workspace-body.hex-workspace-body :is(.status-pending, .status-unpaid, .status-info) { color: #1766c2 !important; background: rgba(37, 99, 235, .1) !important; }
html body.hex-workspace-body.hex-workspace-body :is(.status-partial, .status-overpaid, .status-warning) { color: #b45309 !important; background: rgba(245, 158, 11, .13) !important; }
html body.hex-workspace-body.hex-workspace-body :is(.status-overdue, .status-danger, .is-negative) { color: #c6283b !important; }
html body.hex-workspace-body.hex-workspace-body :is(.status-overdue, .status-danger) { background: rgba(244, 63, 94, .11) !important; }

/* Tables stay quiet and readable; color is reserved for status, focus and interaction. */
html body.hex-workspace-body.hex-workspace-body :is(th, .table-head, .table-header) {
  background: color-mix(in srgb, var(--accent) 5%, var(--surface-muted)) !important;
  color: var(--muted) !important;
  border-color: var(--line) !important;
}
html body.hex-workspace-body.hex-workspace-body :is(td, th) { border-color: var(--line) !important; }
html body.hex-workspace-body.hex-workspace-body tbody tr { transition: background-color 140ms ease; }
html body.hex-workspace-body.hex-workspace-body tbody tr:hover { background: color-mix(in srgb, var(--accent) 5%, transparent) !important; }
html body.hex-workspace-body.hex-workspace-body :is(.view-tab.is-active, .messages-tabs button.is-active, .manage-tab.active, .view-btn.active) {
  border-color: color-mix(in srgb, var(--accent) 34%, var(--line)) !important;
  background: linear-gradient(120deg, color-mix(in srgb, var(--accent) 14%, transparent), color-mix(in srgb, #0ea5e9 8%, transparent)) !important;
  color: var(--accent-strong) !important;
}

/* Atelier primary actions use the same restrained blue glass treatment as other modules. */
html body.hex-workspace-body.hex-workspace-body.inventory-page .primary-btn {
  border: 1px solid color-mix(in srgb, var(--accent) 30%, var(--line)) !important;
  background: color-mix(in srgb, var(--accent) 11%, transparent) !important;
  color: var(--accent-strong) !important;
  box-shadow: 0 2px 8px rgba(37,99,235,.07) !important;
}
html body.hex-workspace-body.hex-workspace-body.inventory-page .primary-btn:hover:not(:disabled) {
  border-color: color-mix(in srgb, var(--accent) 48%, var(--line)) !important;
  background: color-mix(in srgb, var(--accent) 17%, transparent) !important;
  color: var(--accent-strong) !important;
  box-shadow: 0 5px 14px rgba(37,99,235,.12) !important;
}

/* Portal cards share the same glass, glow and saturated accent language as the modules. */
body.home-view-portals :is(.hero-card, .chooser-card, .portal-link),
body.home-view-login .auth-home-card {
  border: 1px solid var(--line) !important;
  border-radius: 17px !important;
  background: color-mix(in srgb, var(--surface-strong) 82%, transparent 18%) !important;
  box-shadow: var(--glass-shadow) !important;
  backdrop-filter: blur(18px) saturate(145%) !important;
  -webkit-backdrop-filter: blur(18px) saturate(145%) !important;
}
body.home-view-portals .portal-link {
  border-left: 3px solid color-mix(in srgb, var(--accent) 78%, #0ea5e9 22%) !important;
}
body.home-view-portals .portal-link:hover {
  border-color: color-mix(in srgb, var(--accent) 32%, var(--line)) !important;
  border-left-color: var(--accent) !important;
  background: linear-gradient(125deg, color-mix(in srgb, var(--accent) 9%, var(--surface-strong)), color-mix(in srgb, #0ea5e9 6%, var(--surface-strong))) !important;
  box-shadow: 0 14px 32px rgba(37, 99, 235, .1) !important;
  transform: translateY(-2px);
}

html[data-theme="dark"] body.hex-workspace-body.hex-workspace-body :is(.topbar, .toolbar, .panel, .card, .table-panel,
  .editor-panel, .editor-card, .modal-card, .summary-grid article, .kpi-grid article, .admin-edit-card,
  .dashboard-card, .workspace-card, .stat-card, .stock-item, .order-card, .movement-row,
  .location-column, .order-column, .assets-location, .audit-item, .list-card, .controls-card,
  .table-wrap, .table-scroll, .planner-toolbar, .gantt-nav, .header-menu-panel, .pdf-controls,
  .dialog-head, .dialog-section, .day-hours-panel, .phase-editor-list, .auth-card) {
  border-color: var(--line) !important;
  background: color-mix(in srgb, var(--surface-strong) 86%, transparent 14%) !important;
  box-shadow: var(--glass-shadow) !important;
}

/* Legacy module headers used fixed white text; keep their copy readable on light glass surfaces. */
html:not([data-theme="dark"]) body.hex-workspace-body.hex-workspace-body :is(
  h1, h2, h3, h4, h5, h6, p, label, small, .muted, .subtitle, .description,
  .help-text, .card-title, .section-title, .page-title, .kpi-label, .stat-label
):not(.workspace-sidebar *) {
  color: var(--text) !important;
}
html:not([data-theme="dark"]) body.hex-workspace-body.hex-workspace-body :is(
  .topbar, .hero-card, .hero, .app-header, .page-header, .section-header
):not(.workspace-sidebar) {
  color: var(--text) !important;
}
html:not([data-theme="dark"]) body:is(.home-view-login, .home-view-portals, .home-view-settings) :is(
  h1, h2, h3, h4, h5, h6, p, label, small, .muted, .subtitle, .description, .help-text
) { color: var(--text) !important; }
html body:is(.home-view-login, .home-view-portals, .home-view-settings) :is(button, input, select, textarea) {
  border-radius: 10px !important;
}
html body:is(.home-view-login, .home-view-portals, .home-view-settings) button:not(.primary-btn) {
  border: 1px solid var(--line-strong) !important;
  background: color-mix(in srgb, var(--surface-strong) 58%, transparent) !important;
  color: var(--text) !important;
  box-shadow: none !important;
}
html body:is(.home-view-login, .home-view-portals, .home-view-settings) .primary-btn {
  border: 1px solid color-mix(in srgb, var(--accent) 30%, var(--line)) !important;
  background: color-mix(in srgb, var(--accent) 11%, transparent) !important;
  color: var(--accent-strong) !important;
  box-shadow: 0 2px 8px rgba(37,99,235,.07) !important;
}

/* Keep the workspace rail dark in both themes, including its controls and mobile menu. */
html body.hex-workspace-body.hex-workspace-body .workspace-sidebar,
html body.hex-workspace-body.hex-workspace-body .workspace-sidebar :is(.workspace-sidebar-head, .workspace-sidebar-footer, .workspace-nav-section) {
  color: #e8edf5 !important;
  background-color: #181a1e !important;
}
html body.hex-workspace-body.hex-workspace-body .workspace-sidebar :is(a, button, .workspace-user, .workspace-theme-toggle, .workspace-action-icon) {
  color: #c5cfdd !important;
  border-color: transparent !important;
  background: transparent !important;
  box-shadow: none !important;
}
html body.hex-workspace-body.hex-workspace-body .workspace-sidebar :is(a, button):hover:not(:disabled),
html body.hex-workspace-body.hex-workspace-body .workspace-sidebar :is(a, button):focus-visible:not(:disabled),
html body.hex-workspace-body.hex-workspace-body .workspace-sidebar-footer .workspace-footer-action:hover:not(:disabled),
html body.hex-workspace-body.hex-workspace-body .workspace-sidebar-footer .workspace-sidebar-collapse:hover:not(:disabled) {
  color: #f6f8fc !important;
  border-color: rgba(255,255,255,.1) !important;
  background: rgba(255,255,255,.075) !important;
  box-shadow: none !important;
  transform: none !important;
}
html body.hex-workspace-body.hex-workspace-body .workspace-sidebar .workspace-nav-link.is-active {
  color: #a9ceff !important;
  border-color: rgba(96,165,250,.25) !important;
  background: linear-gradient(115deg, rgba(37,99,235,.25), rgba(14,165,233,.12)) !important;
}
html body.hex-workspace-body.hex-workspace-body .workspace-sidebar :is(.workspace-user-name, .workspace-nav-heading, .workspace-footer-label) { color: #aeb9c8 !important; }
html body.hex-workspace-body.hex-workspace-body .workspace-sidebar-footer .workspace-footer-action:hover .workspace-action-icon,
html body.hex-workspace-body.hex-workspace-body .workspace-sidebar-footer .workspace-sidebar-collapse:hover .workspace-action-icon {
  color: #f6f8fc !important;
  background: transparent !important;
}
html body.hex-workspace-body.hex-workspace-body .workspace-mobilebar,
html body.hex-workspace-body.hex-workspace-body .workspace-mobilebar :is(button, a) {
  color: #e8edf5 !important;
  border-color: rgba(255,255,255,.09) !important;
  background: #181a1e !important;
}

/* Center shared editors and let tall dialogs scroll inside the viewport. */
html body.hex-workspace-body.hex-workspace-body :is(.editor-overlay, .dialog-overlay):not(.is-hidden) {
  position: fixed !important;
  inset: 0 !important;
  z-index: 700 !important;
  display: grid !important;
  place-items: center !important;
  overflow-x: hidden !important;
  overflow-y: auto !important;
  padding: max(16px, env(safe-area-inset-top)) 16px max(16px, env(safe-area-inset-bottom)) !important;
}
html body.hex-workspace-body.hex-workspace-body :is(.editor-overlay, .dialog-overlay):not(.is-hidden) :is(.editor-panel, .editor-card, .dialog-card, [role='dialog']) {
  width: min(920px, 100%) !important;
  max-width: 100% !important;
  max-height: calc(100dvh - 32px) !important;
  overflow-x: hidden !important;
  overflow-y: auto !important;
  overscroll-behavior: contain;
  box-sizing: border-box !important;
  margin: auto !important;
}

/* The initial loader uses the same restrained color field as the application shell. */
html body .hexagone-app-loader {
  background-color: var(--bg, #f2f6fc) !important;
  background-image: radial-gradient(ellipse at 9% 0%, var(--bg-layer-1), transparent 34%),
    radial-gradient(ellipse at 92% 8%, var(--bg-layer-2), transparent 32%),
    linear-gradient(155deg, color-mix(in srgb, var(--bg) 97%, white 3%), var(--bg) 58%, color-mix(in srgb, var(--bg) 98%, var(--accent) 2%)) !important;
  isolation: isolate;
}
html body .hexagone-app-loader::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  opacity: .62;
  background-image: var(--hex-grid-lines);
  background-size: 24px 24px;
  mask-image: linear-gradient(135deg, #000 0%, rgba(0,0,0,.72) 62%, rgba(0,0,0,.16) 100%);
}
html body .hexagone-app-loader > * { position: relative; z-index: 1; }
html body .hexagone-app-loader::after {
  content: "";
  position: absolute;
  inset: auto 2vw 5vh auto;
  z-index: 0;
  width: min(48vw, 700px);
  height: min(58vh, 520px);
  pointer-events: none;
  opacity: .20;
  background: var(--hex-blueprint-art) center / contain no-repeat;
  animation: hex-blueprint-draft 24s ease-in-out infinite alternate;
}
html[data-theme="dark"] body .hexagone-app-loader {
  background-color: #141517 !important;
  background-image: radial-gradient(ellipse at 9% 0%, var(--bg-layer-1), transparent 34%),
    radial-gradient(ellipse at 92% 8%, var(--bg-layer-2), transparent 32%),
    linear-gradient(155deg, color-mix(in srgb, var(--bg) 97%, white 3%), var(--bg) 58%, color-mix(in srgb, var(--bg) 98%, var(--accent) 2%)) !important;
}
html[data-theme="dark"] body .hexagone-app-loader::before { opacity: .7; background-image: var(--hex-grid-lines); background-size: 24px 24px; }
html[data-theme="dark"] body .hexagone-app-loader::after { opacity: .28; filter: brightness(1.32); }
html body .hexagone-loader-mark path { stroke: #4388ee !important; }
html[data-theme="dark"] body .hexagone-loader-mark path { stroke: #79b6ff !important; }

@media (max-width: 760px), (prefers-reduced-transparency: reduce) {
  html body.hex-workspace-body.hex-workspace-body :is(.topbar, .toolbar, .panel, .card, .table-panel, .editor-panel,
    .editor-card, .modal-card, .summary-grid article, .kpi-grid article, .dashboard-card, .workspace-card),
  body.home-view-portals :is(.hero-card, .chooser-card, .portal-link),
  body.home-view-login .auth-home-card {
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
    background: var(--surface-strong) !important;
  }
}
@media print {
  body.hex-workspace-body { background: #fff !important; }
  html body.hex-workspace-body.hex-workspace-body :is(.topbar, .toolbar, .panel, .card, .table-panel, .editor-panel,
    .editor-card, .modal-card, .summary-grid article, .kpi-grid article, .dashboard-card, .workspace-card) {
    background: #fff !important;
    box-shadow: none !important;
    backdrop-filter: none !important;
  }
}
