/* Company Hub shell. Dashboard cards keep their existing styles and viewport layout. */
:root {
  --hub-side-bg: #203f6a;
  --hub-side-elev: #294d7c;
  --hub-side-fg: #f4f7fb;
  --hub-side-muted: #b8c7da;
  --hub-border: #31547f;
  --hub-active: #345f93;
  --hub-topbar-muted: #c8d5e6;
  --hub-topbar-subtle: #9db0ca;
  /* Resolve the dashboard palette here, before the navy header overrides it. */
  --hub-panel-surface: var(--surface);
  --hub-panel-surface-alt: var(--surface-alt);
  --hub-panel-border: var(--border);
  --hub-panel-text: var(--text);
  --hub-panel-text-sec: var(--text-sec);
  --hub-panel-text-muted: var(--text-muted);
  --hub-panel-accent: var(--workspace-accent);
  --hub-panel-accent-soft: var(--workspace-accent-soft);
}
[data-theme="dark"] {
  --hub-side-bg: var(--surface);
  --hub-side-elev: var(--surface-alt);
  --hub-side-fg: var(--text);
  --hub-side-muted: var(--text-sec);
  --hub-border: var(--border);
  --hub-active: var(--workspace-accent-soft);
  --hub-topbar-muted: var(--text-sec);
  --hub-topbar-subtle: var(--text-muted);
}
.hub-shell { display: grid; grid-template-columns: 224px minmax(0, 1fr); transition: grid-template-columns 180ms cubic-bezier(.16,1,.3,1); }
.hub-sidebar, .hub-topbar { font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; font-size: 14px; line-height: 1.5; }
.hub-shell[data-collapsed="true"] { grid-template-columns: 60px minmax(0, 1fr); }
.hub-shell.hub-shell--no-sidebar { grid-template-columns: minmax(0, 1fr); }
.hub-shell .hub-sidebar { position: relative; inset: auto; width: 100%; height: 100%; max-height: 100dvh; padding: 0; gap: 0; display: flex; flex-direction: column; align-items: stretch; overflow: hidden; background: var(--hub-side-bg); color: var(--hub-side-fg); border-right: 1px solid var(--hub-border); box-shadow: none; transition: none; }
.hub-sidebar-user { display: flex; align-items: center; gap: 10px; height: 56px; padding: 0 16px; border-bottom: 1px solid var(--hub-border); flex: 0 0 auto; }
.hub-sidebar-brand-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; height: 56px; padding: 0 16px; border-bottom: 1px solid var(--hub-border); flex: 0 0 auto; }
.hub-brand-logo, .hub-header-logo { display: block; width: 126px; height: auto; object-fit: contain; flex: 0 0 auto; }
.hub-brand-pin { display: none; width: 24px; height: 24px; }
.hub-sidebar-toggle { display: grid; place-items: center; width: 32px; height: 32px; flex: 0 0 auto; padding: 0; border: 1px solid transparent; border-radius: 8px; background: transparent; color: var(--hub-side-muted); cursor: pointer; }
.hub-avatar { width: 32px; height: 32px; border-radius: 50%; flex-shrink: 0; object-fit: cover; }
.hub-avatar--initials { display: grid; place-items: center; background: linear-gradient(135deg, oklch(.66 .13 30), oklch(.55 .13 350)); color: white; font-size: 12px; font-weight: 700; }
.hub-user-info { min-width: 0; overflow: hidden; line-height: 1.25; white-space: nowrap; }
.hub-user-name { overflow: hidden; color: var(--hub-side-fg); font-size: 13px; font-weight: 600; text-overflow: ellipsis; }
.hub-user-detail { color: var(--hub-side-muted); font-size: 11px; overflow: hidden; text-overflow: ellipsis; }
.hub-sidebar-close { display: none; width: 32px; height: 32px; place-items: center; margin-left: auto; flex-shrink: 0; padding: 0; border: 1px solid transparent; border-radius: 8px; background: transparent; color: var(--hub-side-muted); cursor: pointer; }
.hub-sidebar-nav { display: flex; flex: 1 1 0; min-height: 0; flex-direction: column; gap: 2px; padding: 12px 8px; overflow-x: hidden; overflow-y: auto; }
.hub-sidebar .sidebar-item { position: relative; display: flex; align-items: center; justify-content: flex-start; gap: 10px; width: 100%; min-height: 36px; height: auto; padding: 7px 9px; overflow: hidden; border: 1px solid transparent; border-radius: 8px; background: transparent; color: var(--hub-side-muted); cursor: pointer; font-size: 13px; font-weight: 600; text-align: left; text-decoration: none; white-space: nowrap; flex-shrink: 0; transition: background 120ms ease, color 120ms ease; }
.hub-sidebar .sidebar-item-label, .hub-sidebar .sidebar-item--combined .sidebar-item-label { display: block; flex: 1; width: auto; max-width: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; font-weight: 600; line-height: 20px; text-transform: none; }
.hub-sidebar .sidebar-item > svg, .hub-sidebar .sidebar-item > img { width: 17px; height: 17px; flex: 0 0 18px; stroke-width: 1.9; }
.hub-sidebar .sidebar-item:hover, .hub-sidebar-close:hover, .hub-sidebar-toggle:hover { background: var(--hub-side-elev); color: var(--hub-side-fg); }
.hub-sidebar .sidebar-item--active { background: linear-gradient(var(--hub-active),var(--hub-active)) padding-box, linear-gradient(135deg,#1e3a8a3d,#2563ebb8,#60a5fa61) border-box; color: var(--hub-side-fg); box-shadow: 0 8px 18px #2563eb1f; }
.hub-sidebar .sidebar-item--active::before { content: none; }
[data-theme="dark"] .hub-sidebar .sidebar-item--active { background: linear-gradient(var(--hub-active),var(--hub-active)) padding-box,linear-gradient(135deg,#1e40af8a,#3b82f6e6,#7dd3fc75) border-box; box-shadow: 0 10px 22px #3b82f629; }
.hub-sidebar-foot { display: flex; flex-direction: column; gap: 2px; padding: 10px 8px; border-top: 1px solid var(--hub-border); flex-shrink: 0; }
.hub-sidebar-foot form { margin: 0; }
.hub-shell[data-collapsed="true"] .hub-user-info, .hub-shell[data-collapsed="true"] .sidebar-item-label { display: none; }
.hub-shell[data-collapsed="true"] .hub-sidebar-user { justify-content: center; padding-inline: 8px; }
.hub-shell[data-collapsed="true"] .sidebar-item { gap: 0; justify-content: center; padding: 9px; }
.hub-shell[data-collapsed="true"] .hub-sidebar-brand-row { justify-content: center; padding-inline: 8px; }
.hub-shell[data-collapsed="true"] .hub-brand-logo, .hub-shell[data-collapsed="true"] .hub-sidebar-toggle { display: none; }
.hub-shell[data-collapsed="true"] .hub-brand-pin { display: block; }
.hub-shell[data-collapsed="false"] #sidebar-menu { display: none; }
.hub-shell[data-collapsed="true"] .hub-toggle-chevron { transform: rotate(180deg); transform-origin: 14px 12px; }
.hub-shell > .main { height: 100%; min-width: 0; min-height: 0; margin-left: 0 !important; }
.hub-shell .topbar.hub-topbar { --hub-header-edge-size: 112px; position: relative; z-index: 10; display: grid; grid-template-columns: minmax(var(--hub-header-edge-size), 1fr) minmax(0, auto) minmax(var(--hub-header-edge-size), 1fr); align-items: center; gap: 16px; height: 56px; min-height: 56px; flex: 0 0 56px; min-width: 0; padding: 0 24px; border-bottom: 1px solid var(--hub-border); background: var(--hub-side-bg); }
.hub-shell--no-sidebar .topbar.hub-topbar { --hub-header-edge-size: 126px; }
.hub-header-logo, .hub-topbar > #sidebar-menu { grid-column: 1; grid-row: 1; justify-self: start; }
.hub-topbar .hub-icon-button { display: grid; place-items: center; width: 32px; height: 32px; flex: 0 0 auto; padding: 0; border: 1px solid transparent; border-radius: 8px; background: transparent; color: var(--hub-topbar-muted); cursor: pointer; transition: background 120ms ease,border-color 120ms ease,color 120ms ease; }
.hub-topbar .hub-icon-button:hover { border-color: var(--hub-border); background: var(--hub-side-elev); color: var(--hub-side-fg); }
.hub-dashboard-title { grid-column: 1 / -1; grid-row: 1; justify-self: center; width: max(0px, calc(100% - var(--hub-title-gutter, 224px))); min-width: 0; margin: 0; overflow: hidden; color: var(--hub-side-fg); font: 600 16px/1.4 Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; white-space: nowrap; text-overflow: ellipsis; text-align: center; }
.hub-topbar-actions { grid-column: 3; grid-row: 1; justify-self: end; display: flex; align-items: center; gap: 8px; min-width: 0; }
.hub-topbar-actions form { margin: 0; }
.hub-map-tools { display: flex; align-items: center; gap: 6px; }
.hub-map-tools[hidden] { display: none; }
.hub-map-button { height: 32px; padding: 0 10px; border: 1px solid var(--hub-border); border-radius: 8px; background: transparent; color: var(--hub-topbar-muted); font: 500 12px/1.4 var(--workspace-font); cursor: pointer; white-space: nowrap; }
.hub-map-button:hover, .hub-map-button[aria-expanded="true"] { background: var(--hub-side-elev); color: var(--hub-side-fg); }
.hub-map-button:disabled { opacity: .45; cursor: default; }
.hub-shell .topbar.hub-topbar:has(.hub-map-tools:not([hidden])) { grid-template-columns: auto minmax(0, 1fr) auto; }
.hub-filters { display: flex; align-items: center; }
.hub-filters[hidden], .hub-filter-panel[hidden], .hub-filter-count[hidden] { display: none; }
.hub-shell .topbar.hub-topbar:has(.hub-filters:not([hidden])) { --hub-header-edge-size: 208px; }
.hub-filter-toggle { position: relative; display: flex; align-items: center; justify-content: center; gap: 6px; min-width: 120px; height: 32px; padding: 0 10px; border: 1px solid var(--hub-border); border-radius: 8px; background: transparent; color: var(--hub-topbar-muted); font: 500 12px/1.4 var(--workspace-font); cursor: pointer; }
.hub-filter-toggle:hover, .hub-filter-toggle[aria-expanded="true"], .hub-filter-toggle--active { background: var(--hub-side-elev); color: var(--hub-side-fg); }
.hub-filter-count { display: grid; place-items: center; min-width: 16px; height: 16px; padding: 0 3px; border-radius: 5px; background: var(--hub-active); color: var(--hub-side-fg); font-size: 10px; font-weight: 600; }
.hub-filter-panel { --surface: var(--hub-panel-surface); --surface-alt: var(--hub-panel-surface-alt); --border: var(--hub-panel-border); --text: var(--hub-panel-text); --text-sec: var(--hub-panel-text-sec); --text-muted: var(--hub-panel-text-muted); --workspace-accent: var(--hub-panel-accent); --workspace-accent-soft: var(--hub-panel-accent-soft); position: absolute; top: calc(100% + 8px); right: 24px; width: min(348px, calc(100vw - 20px)); max-height: calc(100dvh - 80px); overflow-y: auto; padding: 18px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); color: var(--text); box-shadow: 0 12px 36px #0f172a26; text-align: left; }
.hub-filter-panel h2 { margin: 0 0 16px; color: var(--text); font: 600 14px/1.4 var(--workspace-font); }
.hub-filter-panel label { display: block; margin: 14px 0 6px; color: var(--text-sec); font: 500 12px/1.4 var(--workspace-font); }
.hub-filter-panel select, .hub-filter-date-field output { display: block; width: 100%; min-width: 0; height: 38px; padding: 0 10px; border: 1px solid var(--border); border-radius: 7px; background: var(--surface-alt); color: var(--text); font: 400 13px/1.4 var(--workspace-font); cursor: pointer; color-scheme: light; }
[data-theme="dark"] .hub-filter-panel select, [data-theme="dark"] .hub-filter-date-field output { color-scheme: dark; }
.hub-filter-panel select:focus-visible, .hub-filter-date-field button:focus-visible { outline: 2px solid var(--workspace-accent); outline-offset: 2px; }
.hub-filter-date-field { display: flex; gap: 6px; }
.hub-filter-date-field output { flex: 1; display: flex; align-items: center; font-size: 12px; cursor: default; }
.hub-filter-date-field button { display: grid; place-items: center; flex: 0 0 32px; padding: 0; border: 1px solid var(--border); border-radius: 7px; background: var(--surface-alt); color: var(--text-sec); cursor: pointer; }
.hub-filter-date-field button:disabled { opacity: .4; cursor: default; }
.hub-filter-date-field button:not(:disabled):hover { color: var(--text); background: var(--workspace-accent-soft); }
.hub-range-calendar { margin-top: 12px; padding: 10px; border: 1px solid var(--border); border-radius: 9px; background: var(--surface-alt); }
.hub-calendar-navigation { display: flex; align-items: center; gap: 5px; margin-bottom: 10px; }
.hub-calendar-navigation select { width: auto; flex: 1; height: 32px; padding-inline: 5px; border: 0; background: transparent; font-size: 12px; }
.hub-calendar-navigation select:last-of-type { flex: 0 1 72px; }
.hub-calendar-navigation button { flex: 0 0 28px; height: 32px; border: 0; border-radius: 6px; background: transparent; color: var(--text); font: 400 23px/1 var(--workspace-font); cursor: pointer; }
.hub-calendar-navigation button:disabled { opacity: .3; cursor: default; }
.hub-calendar-navigation button:not(:disabled):hover { background: var(--workspace-accent-soft); }
.hub-calendar-weekdays, .hub-calendar-days { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); text-align: center; }
.hub-calendar-weekdays { margin-bottom: 5px; color: var(--text-sec); font: 500 10px/1.5 var(--workspace-font); }
.hub-calendar-day { min-width: 0; min-height: 36px; margin-block: 1px; padding: 0; border: 0; border-radius: 6px; background: transparent; color: var(--text); font: 500 12px/1 var(--workspace-font); cursor: pointer; }
.hub-calendar-day:disabled { color: var(--text-muted); opacity: .4; cursor: default; }
.hub-calendar-day:not(:disabled):hover { background: var(--workspace-accent-soft); }
.hub-calendar-day--range { border-radius: 0; background: var(--workspace-accent-soft); }
.hub-calendar-day--endpoint, .hub-calendar-day--endpoint:not(:disabled):hover { border-radius: 6px; background: var(--workspace-accent); color: #fff; }
.hub-calendar-day:focus-visible, .hub-calendar-navigation button:focus-visible { position: relative; outline: 2px solid var(--workspace-accent); outline-offset: 1px; }
.hub-filter-help { margin: 6px 0 0; color: var(--text-sec); font: 400 11px/1.4 var(--workspace-font); }
.hub-filter-history { margin-top: 10px; padding: 6px 10px; border: 1px solid var(--border); border-radius: 7px; background: var(--surface-alt); color: var(--workspace-accent); font: 500 12px/1.4 var(--workspace-font); cursor: pointer; }
.hub-filter-footer { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 18px; }
.hub-filter-footer button { padding: 7px 10px; border: 1px solid transparent; border-radius: 7px; background: transparent; color: var(--workspace-accent); font: 500 12px/1.4 var(--workspace-font); cursor: pointer; }
.hub-filter-footer button:disabled { color: var(--text-muted); cursor: default; }
.hub-filter-footer button:not(:disabled):hover { background: var(--workspace-accent-soft); }
#dashboard-filter-done { border-color: var(--border); background: var(--surface-alt); color: var(--text); }
.hub-sidebar-backdrop { display: none; }
.hub-shell :is(button,a):focus-visible { outline: 2px solid #93c5fd; outline-offset: 2px; }
@media (max-width: 820px) {
  .hub-shell, .hub-shell[data-collapsed="true"] { grid-template-columns: minmax(0,1fr); }
  .hub-shell .hub-sidebar { position: fixed; inset: 0 auto 0 0; z-index: 100; width: min(224px,calc(100vw - 40px)); height: 100dvh; transform: translateX(0); transition: transform 180ms cubic-bezier(.16,1,.3,1); }
  .hub-shell[data-collapsed="true"] .hub-sidebar { transform: translateX(-100%); visibility: hidden; }
  .hub-sidebar-backdrop:not([hidden]) { position: fixed; inset: 0; display: block; width: 100vw; height: 100dvh; z-index: 90; padding: 0; border: 0; background: rgba(15,23,42,.32); }
  .hub-sidebar-close { display: grid; }
  .hub-sidebar-toggle { display: none; }
  .hub-shell[data-collapsed="false"] #sidebar-menu { display: grid; }
  .hub-shell .topbar.hub-topbar { padding-inline: 14px; gap: 10px; }
  .hub-filter-panel { right: 14px; }
}
@media (max-width: 560px) {
  .hub-shell .topbar.hub-topbar { --hub-header-edge-size: 96px; }
  .hub-shell .topbar.hub-topbar:has(.hub-topbar-actions form) { --hub-header-edge-size: 112px; }
  .hub-header-logo { width: 96px; }
  .hub-dashboard-title { font-size: 14px; }
  .hub-shell .topbar.hub-topbar:has(.hub-filters:not([hidden])) { --hub-header-edge-size: 112px; }
  .hub-shell .topbar.hub-topbar:has(.hub-filters:not([hidden])):has(.hub-topbar-actions form) { --hub-header-edge-size: 152px; }
  .hub-filter-toggle { width: 32px; min-width: 32px; padding: 0; }
  .hub-filter-label, .hub-filter-chevron { display: none; }
  .hub-filter-count { position: absolute; top: -4px; right: -4px; }
}
@media (max-width: 420px) {
  .hub-shell .topbar.hub-topbar { padding-inline: 10px; gap: 8px; }
  .hub-shell .topbar.hub-topbar:has(.hub-topbar-actions form) { --hub-header-edge-size: 100px; }
  .hub-topbar-actions { gap: 2px; }
  .hub-shell .topbar.hub-topbar:has(.hub-filters:not([hidden])) { --hub-header-edge-size: 100px; }
  .hub-shell .topbar.hub-topbar:has(.hub-filters:not([hidden])):has(.hub-topbar-actions form) { --hub-header-edge-size: 134px; }
  .hub-filter-panel { right: 10px; }
}
@media (prefers-reduced-motion: reduce) {
  .hub-shell, .hub-shell *, .hub-shell *::before, .hub-shell *::after { transition: none !important; animation: none !important; }
}
/* Make navigation and filters comfortable to tap on in-car touchscreens. */
@media (pointer: coarse) and (min-width: 600px) {
  .hub-topbar .hub-icon-button { width: 44px; height: 44px; flex-basis: 44px; }
  .hub-filter-toggle { height: 44px; min-width: 44px; }
  .hub-filter-panel select, .hub-filter-date-field output, .hub-filter-footer button { min-height: 44px; }
  .hub-filter-date-field button { flex-basis: 44px; }
  .hub-filter-label, .hub-filter-chevron { display: none; }
  .hub-shell .topbar.hub-topbar:has(.hub-filters:not([hidden])) { --hub-header-edge-size: 148px; }
  .hub-shell .topbar.hub-topbar:has(.hub-filters:not([hidden])):has(.hub-topbar-actions form) { --hub-header-edge-size: 200px; }
}

/* Date ranges share the header's action area with filters. */
.hub-topbar .chart-range-control { --range-highlight: var(--hub-side-elev); --range-shadow: inset 0 0 0 1px var(--hub-border); background: var(--hub-side-bg); border-color: var(--hub-border); }
.hub-topbar .chart-range-control button { color: var(--hub-topbar-muted); }
.hub-topbar .chart-range-control button[aria-pressed="false"]:hover { background: var(--hub-side-elev); color: var(--hub-side-fg); }
.hub-topbar .chart-range-control button[aria-pressed="true"] { background: transparent; color: var(--hub-side-fg); }
.hub-shell .topbar.hub-topbar:has(.chart-range-control:not([hidden])) { grid-template-columns: auto minmax(0, 1fr) auto; }
.hub-shell .topbar.hub-topbar.hub-topbar--stacked-controls { height: auto; min-height: 88px; flex-basis: auto; padding-block: 6px; row-gap: 4px; }
.hub-topbar.hub-topbar--stacked-controls .hub-topbar-actions { grid-column: 1 / -1; grid-row: 2; justify-self: end; }
@media (max-width: 760px) {
  .hub-shell .topbar.hub-topbar:has(.hub-map-tools:not([hidden])) { height: auto; min-height: 96px; flex-basis: auto; padding-block: 6px; row-gap: 4px; }
  .hub-topbar:has(.hub-map-tools:not([hidden])) .hub-topbar-actions { grid-column: 1 / -1; grid-row: 2; justify-self: end; }
  .hub-map-button { min-height: 40px; }
  .hub-shell .topbar.hub-topbar:has(.chart-range-control:not([hidden])) { height: auto; min-height: 88px; flex-basis: auto; padding-block: 8px; row-gap: 6px; }
  .hub-topbar:has(.chart-range-control:not([hidden])) .hub-topbar-actions { grid-column: 1 / -1; grid-row: 2; justify-self: end; }
  .chart-range-control button { padding: 5px 9px; }
}
