/* ==========================================================================
   RCH Office v1 — pre-v0.19 shell consolidation
   Final cascade layer for Office. No additional hotfix stylesheet is needed.
   ========================================================================== */

:root {
  --office-sidebar-width: 16rem;
  --office-topbar-min: 6.25rem;
  --office-canvas: #edf3fa;
  --office-sidebar-bg:
    radial-gradient(circle at 25% 0%, rgba(26, 119, 255, 0.23), transparent 22rem),
    linear-gradient(180deg, #082a55, #061b38 58%, #04162e);
  --office-panel-border: #dbe5f1;
  --office-content-max: 110rem;
}

html,
body.rch-office-v1 {
  min-height: 100%;
  background:
    radial-gradient(circle at 15% 0%, rgba(48, 126, 255, 0.09), transparent 30rem),
    var(--office-canvas);
}

body.rch-office-v1 {
  overflow-x: hidden;
}

/* --------------------------------------------------------------------------
   Access gate
   -------------------------------------------------------------------------- */

body.rch-office-v1 .access-gate {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: var(--rch-space-5);
  background:
    radial-gradient(circle at 18% 10%, rgba(20, 124, 255, 0.18), transparent 30rem),
    radial-gradient(circle at 88% 90%, rgba(113, 78, 234, 0.13), transparent 28rem),
    linear-gradient(135deg, #eef5ff, #f7f9fd 55%, #f3f0ff);
}

body.rch-office-v1 .gate-card {
  width: min(100%, 30rem);
  padding: clamp(1.75rem, 4vw, 2.5rem);
  border: 1px solid rgba(203, 217, 235, 0.92);
  border-radius: var(--rch-radius-hero);
  background: rgba(255, 255, 255, 0.96);
  box-shadow: var(--rch-shadow-lg);
  backdrop-filter: blur(14px);
}

body.rch-office-v1 .gate-brand-logo {
  width: 4.8rem;
  height: 4.8rem;
  margin-bottom: var(--rch-space-4);
  border-radius: var(--rch-radius-card);
  box-shadow: 0 0.9rem 2.2rem rgba(20, 124, 255, 0.22);
}

body.rch-office-v1 .gate-card .eyebrow {
  margin: 0 0 var(--rch-space-1);
  color: var(--rch-primary-600);
  font-size: var(--rch-text-micro);
  font-weight: 900;
  letter-spacing: 0.14em;
}

body.rch-office-v1 .gate-card h1 {
  margin: 0;
  color: var(--rch-neutral-900);
  font-size: clamp(2rem, 5vw, 2.6rem);
  line-height: 1;
  letter-spacing: -0.045em;
}

body.rch-office-v1 .gate-message {
  margin: var(--rch-space-3) 0 var(--rch-space-5);
  color: var(--rch-neutral-500);
}

body.rch-office-v1 .gate-login,
body.rch-office-v1 .gate-denied {
  display: grid;
  gap: var(--rch-space-3);
}

body.rch-office-v1 .gate-status {
  margin: var(--rch-space-4) 0 0;
  color: var(--rch-neutral-500);
  font-size: var(--rch-text-small);
}

/* --------------------------------------------------------------------------
   Main shell
   -------------------------------------------------------------------------- */

body.rch-office-v1 .office-shell {
  min-height: 100dvh;
  display: grid;
  grid-template-columns: var(--office-sidebar-width) minmax(0, 1fr);
  background: transparent;
}

body.rch-office-v1 .office-sidebar {
  position: sticky;
  z-index: var(--rch-z-sticky);
  top: 0;
  height: 100dvh;
  min-width: 0;
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr) auto;
  gap: var(--rch-space-3);
  padding: var(--rch-space-4) var(--rch-space-3);
  overflow: hidden;
  color: #dce9f8;
  background: var(--office-sidebar-bg);
  box-shadow: 0.7rem 0 2rem rgba(5, 24, 51, 0.14);
}

body.rch-office-v1 .office-brand {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: var(--rch-space-3);
  padding: var(--rch-space-2);
  color: var(--rch-white);
  text-decoration: none;
}

body.rch-office-v1 .office-brand-logo {
  width: 3rem;
  height: 3rem;
  flex: 0 0 auto;
  border-radius: var(--rch-radius-small);
  box-shadow: 0 0.6rem 1.5rem rgba(0, 108, 255, 0.28);
}

body.rch-office-v1 .office-brand span {
  min-width: 0;
  display: grid;
  gap: 0.12rem;
}

body.rch-office-v1 .office-brand strong {
  font-size: 1.05rem;
  line-height: 1.05;
}

body.rch-office-v1 .office-brand small {
  overflow: hidden;
  color: #a9bdd6;
  font-size: var(--rch-text-micro);
  text-overflow: ellipsis;
  white-space: nowrap;
}

body.rch-office-v1 .sidebar-scroll-controls {
  display: grid;
  grid-template-columns: 2.5rem minmax(0, 1fr) 2.5rem;
  align-items: center;
  gap: var(--rch-space-2);
}

body.rch-office-v1 .sidebar-scroll-btn {
  width: 2.5rem;
  height: 2.5rem;
  display: grid;
  place-items: center;
  border: 1px solid rgba(139, 177, 222, 0.18);
  border-radius: var(--rch-radius-control);
  color: #c7d8ed;
  background: rgba(255, 255, 255, 0.05);
}

body.rch-office-v1 .sidebar-scroll-label {
  color: #8ea9c9;
  font-size: var(--rch-text-micro);
  font-weight: 850;
  letter-spacing: 0.11em;
  text-align: center;
  text-transform: uppercase;
}

body.rch-office-v1 .office-sidebar-scroll {
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: #6685a9 transparent;
}

body.rch-office-v1 .office-nav {
  display: grid;
  gap: var(--rch-space-1);
}

body.rch-office-v1 .nav-item {
  min-width: 0;
  min-height: 2.85rem;
  display: grid;
  grid-template-columns: 1.55rem minmax(0, 1fr) auto;
  align-items: center;
  gap: var(--rch-space-2);
  padding: 0 var(--rch-space-3);
  border: 1px solid transparent;
  border-radius: var(--rch-radius-small);
  color: #aec1da;
  background: transparent;
  font-size: var(--rch-text-small);
  font-weight: 760;
  text-align: left;
  text-decoration: none;
}

body.rch-office-v1 .nav-item > span:first-child {
  width: 1.55rem;
  display: grid;
  place-items: center;
  font-size: 0.95rem;
}

body.rch-office-v1 .nav-item > span:nth-child(2) {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

body.rch-office-v1 .nav-item b {
  min-width: 1.55rem;
  min-height: 1.55rem;
  display: inline-grid;
  place-items: center;
  padding: 0 var(--rch-space-1);
  border-radius: var(--rch-radius-pill);
  color: #cbd9eb;
  background: rgba(255, 255, 255, 0.08);
  font-size: 0.62rem;
}

body.rch-office-v1 .nav-item:hover {
  color: var(--rch-white);
  border-color: rgba(141, 182, 231, 0.13);
  background: rgba(255, 255, 255, 0.055);
}

body.rch-office-v1 .nav-item.active {
  color: var(--rch-white);
  border-color: rgba(69, 145, 255, 0.38);
  background: linear-gradient(90deg, rgba(20, 124, 255, 0.28), rgba(75, 86, 203, 0.13));
  box-shadow: inset 0.22rem 0 0 #2387ff;
}

body.rch-office-v1 .nav-roadmap {
  margin-top: var(--rch-space-5);
  padding: var(--rch-space-3);
  border: 1px solid rgba(139, 177, 222, 0.12);
  border-radius: var(--rch-radius-card);
  background: rgba(255, 255, 255, 0.035);
}

body.rch-office-v1 .nav-roadmap > p {
  margin: 0 0 var(--rch-space-2);
  color: #7693b6;
  font-size: 0.58rem;
  font-weight: 900;
  letter-spacing: 0.12em;
}

body.rch-office-v1 .nav-roadmap div {
  display: grid;
  gap: 0.1rem;
  padding: var(--rch-space-2) 0;
  border-top: 1px solid rgba(139, 177, 222, 0.08);
}

body.rch-office-v1 .nav-roadmap span {
  color: #b8c9dd;
  font-size: 0.72rem;
  font-weight: 730;
}

body.rch-office-v1 .nav-roadmap small {
  color: #6f89a9;
  font-size: 0.62rem;
}

body.rch-office-v1 .sidebar-footer {
  display: grid;
  gap: var(--rch-space-2);
  padding-top: var(--rch-space-3);
  border-top: 1px solid rgba(139, 177, 222, 0.13);
}

body.rch-office-v1 .sidebar-footer .btn {
  min-height: 2.55rem;
  color: #dce8f6;
  border-color: rgba(149, 184, 225, 0.22);
  background: rgba(255, 255, 255, 0.05);
  box-shadow: none;
}

body.rch-office-v1 .sidebar-footer .btn:hover {
  color: var(--rch-white);
  background: rgba(255, 255, 255, 0.09);
}

body.rch-office-v1 .office-main {
  min-width: 0;
  background: transparent;
}

/* --------------------------------------------------------------------------
   Topbar
   -------------------------------------------------------------------------- */

body.rch-office-v1 .office-topbar {
  position: sticky;
  z-index: calc(var(--rch-z-sticky) - 20);
  top: 0;
  min-height: var(--office-topbar-min);
  display: grid;
  grid-template-columns: minmax(15rem, 0.68fr) minmax(0, 1.32fr);
  align-items: center;
  gap: var(--rch-space-5);
  padding: var(--rch-space-3) var(--rch-space-5);
  border-bottom: 1px solid var(--rch-neutral-200);
  background: rgba(255, 255, 255, 0.94);
  box-shadow: 0 0.45rem 1.5rem rgba(35, 63, 98, 0.07);
  backdrop-filter: blur(14px);
}

body.rch-office-v1 .office-topbar > div:first-child {
  min-width: 0;
}

body.rch-office-v1 .office-topbar .eyebrow {
  margin: 0 0 0.15rem;
  color: var(--rch-primary-600);
  font-size: 0.58rem;
  font-weight: 900;
  letter-spacing: 0.14em;
}

body.rch-office-v1 .office-topbar h1 {
  max-width: 100%;
  margin: 0;
  overflow: hidden;
  color: var(--rch-neutral-900);
  font-size: clamp(1.45rem, 2vw, 2rem);
  line-height: 1.06;
  letter-spacing: -0.04em;
  text-overflow: ellipsis;
  white-space: nowrap;
}

body.rch-office-v1 .page-subtitle {
  max-width: 42rem;
  margin: 0.25rem 0 0;
  overflow: hidden;
  color: var(--rch-neutral-500);
  font-size: 0.77rem;
  line-height: 1.25;
  text-overflow: ellipsis;
  white-space: nowrap;
}

body.rch-office-v1 .topbar-actions {
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--rch-space-2);
}

body.rch-office-v1 .scope-control {
  min-width: 13rem;
  max-width: 19rem;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: var(--rch-space-2);
  min-height: 2.65rem;
  padding: 0 var(--rch-space-2) 0 var(--rch-space-3);
  border: 1px solid var(--rch-neutral-200);
  border-radius: var(--rch-radius-pill);
  background: var(--rch-white);
  box-shadow: var(--rch-shadow-xs);
}

body.rch-office-v1 .scope-control span {
  color: var(--rch-neutral-500);
  font-size: 0.62rem;
  font-weight: 850;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

body.rch-office-v1 .scope-control select {
  min-height: 2.2rem;
  padding-inline: var(--rch-space-2);
  border: 0;
  background: transparent;
  box-shadow: none;
  font-size: 0.78rem;
  font-weight: 780;
}

body.rch-office-v1 .status-chip,
body.rch-office-v1 .user-chip {
  min-height: 2.25rem;
  display: inline-flex;
  align-items: center;
  padding: 0 var(--rch-space-3);
  border: 1px solid var(--rch-neutral-200);
  border-radius: var(--rch-radius-pill);
  color: var(--rch-neutral-700);
  background: var(--rch-white);
  font-size: 0.65rem;
  font-weight: 800;
  white-space: nowrap;
}

body.rch-office-v1 .status-chip.online {
  color: #087a4e;
  border-color: #b9ebd5;
  background: #ecfbf4;
}

body.rch-office-v1 .user-chip {
  color: #145bc2;
  border-color: #c9def9;
  background: #f0f6ff;
}

body.rch-office-v1 .topbar-actions .btn {
  flex: 0 0 auto;
  min-height: 2.55rem;
  font-size: 0.68rem;
}

body.rch-office-v1 .mobile-menu-toggle {
  display: none;
}

/* --------------------------------------------------------------------------
   Content and common view blocks
   -------------------------------------------------------------------------- */

body.rch-office-v1 .office-content {
  width: min(100%, var(--office-content-max));
  margin: 0 auto;
  padding: var(--rch-space-5) var(--rch-space-5) var(--rch-space-12);
}

body.rch-office-v1 .office-view {
  display: none;
  min-width: 0;
}

body.rch-office-v1 .office-view.active {
  display: block;
}

body.rch-office-v1 .scope-banner {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: var(--rch-space-3);
  margin-bottom: var(--rch-space-4);
  padding: var(--rch-space-3) var(--rch-space-4);
  border: 1px solid #cfe0f5;
  border-radius: var(--rch-radius-card);
  background: linear-gradient(135deg, #f0f6ff, #fbfdff);
}

body.rch-office-v1 .scope-banner strong {
  flex: 0 0 auto;
  color: var(--rch-primary-700);
  font-size: 0.75rem;
}

body.rch-office-v1 .scope-banner span {
  min-width: 0;
  overflow: hidden;
  color: var(--rch-neutral-500);
  font-size: 0.72rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* KPI */
body.rch-office-v1 .kpi-grid {
  min-width: 0;
  display: grid;
  grid-template-columns: repeat(6, minmax(8rem, 1fr));
  gap: var(--rch-space-3);
}

body.rch-office-v1 .kpi-card {
  position: relative;
  min-width: 0;
  min-height: 7rem;
  display: grid;
  align-content: center;
  padding: var(--rch-space-4);
  overflow: hidden;
  border: 1px solid var(--rch-neutral-200);
  border-radius: var(--rch-radius-card);
  background: var(--rch-white);
  box-shadow: var(--rch-shadow-sm);
}

body.rch-office-v1 .kpi-card::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 0.25rem;
  background: var(--accent, var(--rch-primary-600));
}

body.rch-office-v1 .kpi-card::after {
  content: "";
  position: absolute;
  top: -2.2rem;
  right: -2rem;
  width: 6.8rem;
  height: 6.8rem;
  border-radius: 50%;
  background: var(--soft, var(--rch-primary-100));
  opacity: 0.88;
}

body.rch-office-v1 .kpi-card small,
body.rch-office-v1 .kpi-card strong,
body.rch-office-v1 .kpi-card span {
  position: relative;
  z-index: 1;
  min-width: 0;
}

body.rch-office-v1 .kpi-card small {
  overflow: hidden;
  color: var(--rch-neutral-500);
  font-size: 0.58rem;
  font-weight: 900;
  letter-spacing: 0.065em;
  text-overflow: ellipsis;
  text-transform: uppercase;
  white-space: nowrap;
}

body.rch-office-v1 .kpi-card strong {
  display: block;
  margin: var(--rch-space-2) 0 var(--rch-space-1);
  color: var(--rch-neutral-900);
  font-size: clamp(1.9rem, 2.5vw, 2.45rem);
  line-height: 0.95;
  letter-spacing: -0.05em;
}

body.rch-office-v1 .kpi-card span {
  overflow: hidden;
  color: #8391a5;
  font-size: 0.68rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Panels */
body.rch-office-v1 .overview-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--rch-space-4);
  margin-top: var(--rch-space-4);
}

body.rch-office-v1 .panel {
  min-width: 0;
  border: 1px solid var(--rch-neutral-200);
  border-radius: var(--rch-radius-panel);
  background: var(--rch-white);
  box-shadow: var(--rch-shadow-sm);
}

body.rch-office-v1 .panel-heading {
  min-width: 0;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--rch-space-4);
  padding: var(--rch-space-4) var(--rch-space-5) var(--rch-space-3);
}

body.rch-office-v1 .panel-heading > div {
  min-width: 0;
}

body.rch-office-v1 .panel-heading .eyebrow,
body.rch-office-v1 .section-intro .eyebrow {
  margin: 0 0 var(--rch-space-1);
  color: var(--rch-primary-600);
  font-size: 0.56rem;
  font-weight: 900;
  letter-spacing: 0.12em;
}

body.rch-office-v1 .panel-heading h2,
body.rch-office-v1 .section-intro h2 {
  margin: 0;
  color: var(--rch-neutral-900);
  font-size: 1.08rem;
  line-height: 1.2;
  letter-spacing: -0.025em;
}

body.rch-office-v1 .section-intro {
  min-width: 0;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--rch-space-5);
  margin-bottom: var(--rch-space-4);
  padding: var(--rch-space-5);
}

body.rch-office-v1 .section-intro > div:first-child {
  min-width: 0;
}

body.rch-office-v1 .section-intro p:last-child {
  max-width: 58rem;
  margin: var(--rch-space-2) 0 0;
  color: var(--rch-neutral-500);
  font-size: 0.78rem;
  line-height: 1.45;
}

body.rch-office-v1 .toolbar-actions {
  flex: 0 0 auto;
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: var(--rch-space-2);
}

/* Toolbars and filters */
body.rch-office-v1 .table-toolbar {
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--rch-space-3);
  padding: var(--rch-space-3);
}

body.rch-office-v1 .toolbar-main {
  min-width: 0;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(10rem, 1fr));
  gap: var(--rch-space-2);
  flex: 1 1 auto;
}

body.rch-office-v1 .toolbar-main > *,
body.rch-office-v1 .table-toolbar input,
body.rch-office-v1 .table-toolbar select {
  min-width: 0;
  min-height: 2.65rem;
}

body.rch-office-v1 .table-meta {
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--rch-space-4);
  padding: var(--rch-space-3) var(--rch-space-4);
  border-top: 1px solid var(--rch-neutral-200);
  border-bottom: 1px solid var(--rch-neutral-200);
  color: var(--rch-neutral-500);
  font-size: 0.68rem;
}

body.rch-office-v1 .table-meta strong {
  color: var(--rch-neutral-700);
}

/* Tables */
body.rch-office-v1 .table-panel {
  overflow: hidden;
}

body.rch-office-v1 .table-scroll {
  max-width: 100%;
  overflow: auto;
  scrollbar-gutter: stable;
  scrollbar-width: thin;
  scrollbar-color: #aabbd0 transparent;
}

body.rch-office-v1 .data-table {
  width: 100%;
  min-width: 62rem;
  border-collapse: separate;
  border-spacing: 0;
  color: var(--rch-neutral-700);
}

body.rch-office-v1 .data-table th {
  position: sticky;
  z-index: 1;
  top: 0;
  padding: 0.8rem 0.75rem;
  border-bottom: 1px solid var(--rch-neutral-200);
  color: var(--rch-neutral-500);
  background: #f7f9fc;
  font-size: 0.58rem;
  font-weight: 900;
  letter-spacing: 0.065em;
  text-align: left;
  text-transform: uppercase;
  white-space: nowrap;
}

body.rch-office-v1 .data-table td {
  padding: 0.78rem 0.75rem;
  border-bottom: 1px solid #edf1f6;
  color: var(--rch-neutral-700);
  font-size: 0.72rem;
  line-height: 1.35;
  vertical-align: middle;
}

body.rch-office-v1 .data-table tbody tr:hover td {
  background: #f7fbff;
}

body.rch-office-v1 .data-table tbody tr.selected td {
  background: #edf6ff;
}

/* Drawers */
body.rch-office-v1 .drawer {
  position: fixed;
  z-index: var(--rch-z-drawer);
  inset: 0;
  visibility: hidden;
  pointer-events: none;
}

body.rch-office-v1 .drawer.open {
  visibility: visible;
  pointer-events: auto;
}

body.rch-office-v1 .drawer-backdrop {
  position: absolute;
  inset: 0;
  opacity: 0;
  background: rgba(4, 17, 37, 0.58);
  backdrop-filter: blur(6px);
  transition: opacity 180ms ease;
}

body.rch-office-v1 .drawer.open .drawer-backdrop {
  opacity: 1;
}

body.rch-office-v1 .drawer-panel {
  position: absolute;
  top: 0;
  right: 0;
  width: min(100%, 39rem);
  height: 100dvh;
  overflow-y: auto;
  padding: var(--rch-space-5);
  background: var(--rch-white);
  box-shadow: -1.4rem 0 4.5rem rgba(4, 17, 37, 0.25);
  transform: translateX(102%);
  transition: transform 210ms ease;
  scrollbar-gutter: stable;
}

body.rch-office-v1 .drawer-panel-wide {
  width: min(100%, 52rem);
}

body.rch-office-v1 .drawer-panel-xwide {
  width: min(100%, 68rem);
}

body.rch-office-v1 .drawer.open .drawer-panel {
  transform: translateX(0);
}

body.rch-office-v1 .drawer-header {
  position: sticky;
  z-index: 2;
  top: calc(-1 * var(--rch-space-5));
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--rch-space-4);
  margin: calc(-1 * var(--rch-space-5)) calc(-1 * var(--rch-space-5)) 0;
  padding: var(--rch-space-5);
  border-bottom: 1px solid var(--rch-neutral-200);
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(12px);
}

body.rch-office-v1 .drawer-form {
  display: grid;
  gap: var(--rch-space-4);
  padding-top: var(--rch-space-5);
}

body.rch-office-v1 .drawer-form label {
  display: grid;
  gap: var(--rch-space-2);
}

body.rch-office-v1 .drawer-actions {
  position: sticky;
  bottom: calc(-1 * var(--rch-space-5));
  display: flex;
  justify-content: flex-end;
  gap: var(--rch-space-2);
  margin: var(--rch-space-4) calc(-1 * var(--rch-space-5)) calc(-1 * var(--rch-space-5));
  padding: var(--rch-space-4) var(--rch-space-5);
  border-top: 1px solid var(--rch-neutral-200);
  background: rgba(255, 255, 255, 0.97);
  backdrop-filter: blur(12px);
}

/* Toast */
body.rch-office-v1 .toast-host {
  position: fixed;
  z-index: var(--rch-z-toast);
  top: var(--rch-space-4);
  right: var(--rch-space-4);
  width: min(24rem, calc(100vw - 2rem));
  display: grid;
  gap: var(--rch-space-2);
}

body.rch-office-v1 .toast {
  padding: var(--rch-space-3) var(--rch-space-4);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: var(--rch-radius-small);
  color: var(--rch-white);
  background: var(--rch-brand-900);
  box-shadow: var(--rch-shadow-lg);
  font-size: var(--rch-text-small);
}

body.rch-office-v1 .toast.success { background: #087a51; }
body.rch-office-v1 .toast.error { background: #bd2b22; }
body.rch-office-v1 .toast.warning { background: #a85b08; }

/* Mobile helpers */
body.rch-office-v1 .office-sidebar-backdrop {
  position: fixed;
  z-index: calc(var(--rch-z-drawer-backdrop) - 10);
  inset: 0;
  background: rgba(4, 17, 37, 0.58);
  backdrop-filter: blur(4px);
}

body.rch-office-v1 .mobile-timer-fab {
  display: none;
}

/* --------------------------------------------------------------------------
   Responsive
   -------------------------------------------------------------------------- */

@media (max-width: 95rem) and (min-width: 64.01rem) {
  :root {
    --office-sidebar-width: 15rem;
  }

  body.rch-office-v1 .office-topbar {
    grid-template-columns: minmax(13rem, 0.6fr) minmax(0, 1.4fr);
    padding-inline: var(--rch-space-4);
  }

  body.rch-office-v1 .page-subtitle {
    display: none;
  }

  body.rch-office-v1 .topbar-actions .status-chip,
  body.rch-office-v1 .topbar-actions .user-chip {
    display: none;
  }

  body.rch-office-v1 .topbar-actions .btn:not(.office-timer-link):not(.office-territory-link) {
    width: 2.55rem;
    min-width: 2.55rem;
    padding-inline: 0;
    overflow: hidden;
    font-size: 0;
  }

  body.rch-office-v1 .topbar-actions .btn:not(.office-timer-link):not(.office-territory-link)::first-letter {
    font-size: 0.9rem;
  }

  body.rch-office-v1 .kpi-grid {
    grid-template-columns: repeat(3, minmax(8rem, 1fr));
  }
}

@media (max-width: 64rem) {
  body.rch-office-v1 .office-shell {
    grid-template-columns: 1fr;
  }

  body.rch-office-v1 .office-sidebar {
    position: fixed;
    z-index: var(--rch-z-drawer);
    top: 0;
    left: 0;
    width: min(19rem, 88vw);
    height: 100dvh;
    transform: translateX(-103%);
    transition: transform 190ms ease;
  }

  body.rch-office-v1 .office-sidebar.open {
    transform: translateX(0);
  }

  body.rch-office-v1 .office-topbar {
    grid-template-columns: minmax(0, 1fr);
    gap: var(--rch-space-3);
    padding: var(--rch-space-3) var(--rch-space-4);
  }

  body.rch-office-v1 .topbar-actions {
    justify-content: flex-start;
    overflow-x: auto;
    padding-bottom: 0.15rem;
    scrollbar-width: none;
  }

  body.rch-office-v1 .topbar-actions::-webkit-scrollbar {
    display: none;
  }

  body.rch-office-v1 .mobile-menu-toggle {
    display: inline-flex;
    order: -1;
  }

  body.rch-office-v1 .scope-control {
    min-width: 12rem;
  }

  body.rch-office-v1 .office-content {
    padding: var(--rch-space-4);
  }

  body.rch-office-v1 .overview-grid {
    grid-template-columns: 1fr;
  }

  body.rch-office-v1 .section-intro {
    display: grid;
  }

  body.rch-office-v1 .toolbar-actions {
    justify-content: flex-start;
  }

  body.rch-office-v1 .mobile-timer-fab {
    position: fixed;
    z-index: var(--rch-z-sticky);
    right: var(--rch-space-4);
    bottom: calc(var(--rch-space-4) + var(--rch-safe-bottom));
    width: 3.3rem;
    height: 3.3rem;
    display: grid;
    place-items: center;
    border-radius: 50%;
    color: var(--rch-white);
    background: linear-gradient(135deg, var(--rch-primary-600), var(--rch-primary-700));
    box-shadow: 0 1rem 2.2rem rgba(20, 124, 255, 0.28);
    text-decoration: none;
  }
}

@media (max-width: 47.99rem) {
  body.rch-office-v1 .office-topbar h1 {
    white-space: normal;
  }

  body.rch-office-v1 .topbar-actions {
    display: grid;
    grid-template-columns: minmax(0, 1fr) repeat(2, auto);
  }

  body.rch-office-v1 .scope-control {
    grid-column: 1 / -1;
    max-width: none;
  }

  body.rch-office-v1 .status-chip,
  body.rch-office-v1 .user-chip,
  body.rch-office-v1 .office-territory-link,
  body.rch-office-v1 #refreshBtn {
    display: none;
  }

  body.rch-office-v1 .office-content {
    padding: var(--rch-space-3);
  }

  body.rch-office-v1 .scope-banner {
    display: grid;
  }

  body.rch-office-v1 .scope-banner span {
    white-space: normal;
  }

  body.rch-office-v1 .kpi-grid,
  body.rch-office-v1 .rch-compact-kpis {
    display: flex;
    gap: var(--rch-space-2);
    overflow-x: auto;
    scrollbar-width: none;
  }

  body.rch-office-v1 .kpi-grid::-webkit-scrollbar,
  body.rch-office-v1 .rch-compact-kpis::-webkit-scrollbar {
    display: none;
  }

  body.rch-office-v1 .kpi-card {
    flex: 0 0 9.4rem;
    min-height: 6.3rem;
  }

  body.rch-office-v1 .panel-heading,
  body.rch-office-v1 .section-intro {
    padding: var(--rch-space-4);
  }

  body.rch-office-v1 .table-toolbar {
    align-items: stretch;
  }

  body.rch-office-v1 .toolbar-main {
    grid-template-columns: 1fr;
  }

  body.rch-office-v1 .table-meta {
    align-items: flex-start;
    display: grid;
  }

  body.rch-office-v1 .drawer-panel,
  body.rch-office-v1 .drawer-panel-wide,
  body.rch-office-v1 .drawer-panel-xwide {
    width: 100%;
    padding:
      calc(var(--rch-space-5) + var(--rch-safe-top))
      var(--rch-space-4)
      calc(var(--rch-space-5) + var(--rch-safe-bottom));
  }

  body.rch-office-v1 .drawer-header {
    top: calc(-1 * (var(--rch-space-5) + var(--rch-safe-top)));
    margin:
      calc(-1 * (var(--rch-space-5) + var(--rch-safe-top)))
      calc(-1 * var(--rch-space-4))
      0;
    padding:
      calc(var(--rch-space-5) + var(--rch-safe-top))
      var(--rch-space-4)
      var(--rch-space-4);
  }

  body.rch-office-v1 .drawer-actions {
    bottom: calc(-1 * (var(--rch-space-5) + var(--rch-safe-bottom)));
    margin:
      var(--rch-space-4)
      calc(-1 * var(--rch-space-4))
      calc(-1 * (var(--rch-space-5) + var(--rch-safe-bottom)));
    padding:
      var(--rch-space-4)
      var(--rch-space-4)
      calc(var(--rch-space-4) + var(--rch-safe-bottom));
  }
}

/* ==========================================================================
   Fase 3.1 — Office critical views
   Inbox RCH, Task Team e Report Accertatori.
   Queste regole fanno parte del foglio consolidato rch-office-v1.css.
   ========================================================================== */

/* --------------------------------------------------------------------------
   Palette KPI Office
   -------------------------------------------------------------------------- */

body.rch-office-v1 .kpi-card.blue {
  --accent: var(--rch-info-600);
  --soft: #eaf3ff;
}

body.rch-office-v1 .kpi-card.indigo {
  --accent: #5368e8;
  --soft: #eef0ff;
}

body.rch-office-v1 .kpi-card.violet {
  --accent: var(--rch-violet-600);
  --soft: #f1edff;
}

body.rch-office-v1 .kpi-card.green {
  --accent: var(--rch-success-600);
  --soft: #e8f9f2;
}

body.rch-office-v1 .kpi-card.teal {
  --accent: #0a9c9a;
  --soft: #e7f8f7;
}

body.rch-office-v1 .kpi-card.magenta {
  --accent: var(--rch-magenta-600);
  --soft: #fff0ff;
}

body.rch-office-v1 .kpi-card.red {
  --accent: var(--rch-danger-600);
  --soft: #fff0f0;
}

body.rch-office-v1 .kpi-card.orange {
  --accent: #dd8508;
  --soft: #fff6e7;
}

/* --------------------------------------------------------------------------
   Shared critical-view primitives
   -------------------------------------------------------------------------- */

body.rch-office-v1 #view-inbox,
body.rch-office-v1 #view-tasks,
body.rch-office-v1 #view-fieldwork {
  --critical-view-gap: var(--rch-space-4);
}

body.rch-office-v1 #view-inbox > *,
body.rch-office-v1 #view-tasks > *,
body.rch-office-v1 #view-fieldwork > * {
  margin-bottom: var(--critical-view-gap);
}

body.rch-office-v1 #view-inbox > *:last-child,
body.rch-office-v1 #view-tasks > *:last-child,
body.rch-office-v1 #view-fieldwork > *:last-child {
  margin-bottom: 0;
}

body.rch-office-v1 #view-inbox .section-intro,
body.rch-office-v1 #view-tasks .section-intro,
body.rch-office-v1 #view-fieldwork .section-intro {
  position: relative;
  overflow: hidden;
  isolation: isolate;
}

body.rch-office-v1 #view-inbox .section-intro::after,
body.rch-office-v1 #view-tasks .section-intro::after,
body.rch-office-v1 #view-fieldwork .section-intro::after {
  content: "";
  position: absolute;
  z-index: -1;
  top: -5rem;
  right: -4rem;
  width: 15rem;
  height: 15rem;
  border-radius: 50%;
  opacity: 0.55;
}

body.rch-office-v1 #view-inbox .section-intro h2,
body.rch-office-v1 #view-tasks .section-intro h2,
body.rch-office-v1 #view-fieldwork .section-intro h2 {
  font-size: clamp(1.25rem, 1.8vw, 1.6rem);
}

body.rch-office-v1 #view-inbox .section-intro p:last-child,
body.rch-office-v1 #view-tasks .section-intro p:last-child,
body.rch-office-v1 #view-fieldwork .section-intro p:last-child {
  max-width: 55rem;
}

body.rch-office-v1 #view-inbox .rch-compact-kpis,
body.rch-office-v1 #view-tasks .rch-compact-kpis {
  grid-template-columns: repeat(4, minmax(9rem, 1fr));
}

body.rch-office-v1 #view-inbox .rch-compact-kpis .kpi-card,
body.rch-office-v1 #view-tasks .rch-compact-kpis .kpi-card {
  min-height: 6.5rem;
}

body.rch-office-v1 #view-inbox .rch-compact-kpis .kpi-card strong,
body.rch-office-v1 #view-tasks .rch-compact-kpis .kpi-card strong {
  font-size: clamp(1.85rem, 2.4vw, 2.3rem);
}

body.rch-office-v1 #view-inbox .compact-toolbar,
body.rch-office-v1 #view-tasks .compact-toolbar {
  align-items: stretch;
  border-bottom: 1px solid var(--rch-neutral-200);
  border-radius: 0;
  box-shadow: none;
}

body.rch-office-v1 #view-inbox .compact-toolbar .toolbar-main,
body.rch-office-v1 #view-tasks .compact-toolbar .toolbar-main {
  width: 100%;
}

body.rch-office-v1 .cell-title {
  display: block;
  max-width: 24rem;
  overflow: hidden;
  color: var(--rch-neutral-900);
  font-size: 0.75rem;
  font-weight: 820;
  line-height: 1.3;
  text-overflow: ellipsis;
  white-space: nowrap;
}

body.rch-office-v1 .cell-subtitle {
  display: block;
  max-width: 24rem;
  overflow: hidden;
  margin-top: 0.18rem;
  color: var(--rch-neutral-500);
  font-size: 0.66rem;
  line-height: 1.35;
  text-overflow: ellipsis;
  white-space: nowrap;
}

body.rch-office-v1 .link-button {
  min-height: 2rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 var(--rch-space-3);
  border: 1px solid #cfe0f5;
  border-radius: var(--rch-radius-control);
  color: var(--rch-primary-700);
  background: #f3f8ff;
  font-size: 0.68rem;
  font-weight: 820;
  text-decoration: none;
}

body.rch-office-v1 .link-button:hover {
  color: var(--rch-white);
  border-color: var(--rch-primary-600);
  background: var(--rch-primary-600);
}

body.rch-office-v1 .empty-state {
  min-height: 10rem;
  display: grid;
  place-items: center;
  padding: var(--rch-space-6);
  color: var(--rch-neutral-500);
  border: 1px dashed var(--rch-neutral-300);
  border-radius: var(--rch-radius-card);
  background:
    radial-gradient(circle at 50% 0, rgba(20, 124, 255, 0.08), transparent 9rem),
    var(--rch-neutral-50);
  font-size: 0.78rem;
  font-weight: 680;
  text-align: center;
}

body.rch-office-v1 .badge {
  min-height: 1.65rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 var(--rch-space-2);
  border: 1px solid transparent;
  border-radius: var(--rch-radius-pill);
  color: var(--rch-neutral-700);
  background: var(--rch-neutral-100);
  font-size: 0.62rem;
  font-weight: 820;
  line-height: 1;
  white-space: nowrap;
}

body.rch-office-v1 .badge.blue,
body.rch-office-v1 .badge.info {
  color: #145bc2;
  border-color: #c9def9;
  background: #edf5ff;
}

body.rch-office-v1 .badge.green,
body.rch-office-v1 .badge.success {
  color: #087a4e;
  border-color: #b9ebd5;
  background: #ecfbf4;
}

body.rch-office-v1 .badge.warning,
body.rch-office-v1 .badge.orange {
  color: #9b6100;
  border-color: #f1d59d;
  background: #fff8e9;
}

body.rch-office-v1 .badge.purple,
body.rch-office-v1 .badge.violet,
body.rch-office-v1 .badge.indigo {
  color: #5c40ba;
  border-color: #d8cdf9;
  background: #f5f1ff;
}

body.rch-office-v1 .badge.alert,
body.rch-office-v1 .badge.danger,
body.rch-office-v1 .badge.red {
  color: #b22e33;
  border-color: #f1c2c5;
  background: #fff2f2;
}

body.rch-office-v1 .badge.neutral {
  color: var(--rch-neutral-700);
  border-color: var(--rch-neutral-200);
  background: var(--rch-neutral-50);
}

/* --------------------------------------------------------------------------
   Inbox RCH
   -------------------------------------------------------------------------- */

body.rch-office-v1 #view-inbox .rch-inbox-hero {
  min-height: 10rem;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(16rem, 21rem);
  align-items: center;
  background:
    linear-gradient(135deg, rgba(239, 246, 255, 0.98), rgba(255, 255, 255, 0.98));
}

body.rch-office-v1 #view-inbox .rch-inbox-hero::after {
  background: rgba(113, 78, 234, 0.12);
}

body.rch-office-v1 #view-inbox .rch-inbox-hero .toolbar-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-self: stretch;
  align-content: center;
}

body.rch-office-v1 #view-inbox .rch-inbox-hero .toolbar-actions .btn {
  min-height: 2.85rem;
  white-space: normal;
  text-align: center;
}

body.rch-office-v1 #view-inbox .rch-inbox-hero #createInboxBtn {
  grid-column: 1 / -1;
  min-height: 3.15rem;
}

body.rch-office-v1 #view-inbox .table-panel {
  overflow: hidden;
}

body.rch-office-v1 #view-inbox .toolbar-main {
  grid-template-columns:
    minmax(15rem, 1.5fr)
    repeat(5, minmax(9.5rem, 1fr));
}

body.rch-office-v1 #view-inbox .rch-compact-table {
  min-width: 68rem;
}

body.rch-office-v1 #view-inbox .rch-compact-table th:first-child,
body.rch-office-v1 #view-inbox .rch-compact-table td:first-child {
  width: 7rem;
}

body.rch-office-v1 #view-inbox .rch-compact-table th:last-child,
body.rch-office-v1 #view-inbox .rch-compact-table td:last-child {
  width: 5rem;
  text-align: right;
}

/* --------------------------------------------------------------------------
   Task Team
   -------------------------------------------------------------------------- */

body.rch-office-v1 #view-tasks .rch-tasks-hero {
  min-height: 8.75rem;
  background:
    linear-gradient(135deg, rgba(245, 241, 255, 0.98), rgba(255, 255, 255, 0.98));
}

body.rch-office-v1 #view-tasks .rch-tasks-hero::after {
  background: rgba(217, 65, 232, 0.10);
}

body.rch-office-v1 #view-tasks .toolbar-main {
  grid-template-columns: minmax(16rem, 1.6fr) repeat(3, minmax(10rem, 1fr));
}

body.rch-office-v1 #view-tasks #taskResultLabel {
  flex: 0 0 auto;
  align-self: center;
  min-height: 2.2rem;
  display: inline-flex;
  align-items: center;
  padding: 0 var(--rch-space-3);
  border: 1px solid var(--rch-neutral-200);
  border-radius: var(--rch-radius-pill);
  color: var(--rch-neutral-700);
  background: var(--rch-neutral-50);
  font-size: 0.68rem;
  font-weight: 820;
  white-space: nowrap;
}

body.rch-office-v1 #view-tasks .data-table {
  min-width: 72rem;
}

body.rch-office-v1 #view-tasks .data-table select {
  min-width: 10rem;
  min-height: 2.2rem;
  padding-inline: var(--rch-space-2);
  font-size: 0.68rem;
}

body.rch-office-v1 #view-tasks .data-table .btn.compact {
  min-height: 2.2rem;
  padding-inline: var(--rch-space-3);
}

body.rch-office-v1 #view-tasks .row-alert td {
  background: #fff7f7;
  border-bottom-color: #f4d0d2;
}

body.rch-office-v1 #view-tasks .row-alert td:first-child {
  box-shadow: inset 0.22rem 0 0 var(--rch-danger-600);
}

body.rch-office-v1 #view-tasks .text-alert {
  color: var(--rch-danger-600);
  font-weight: 850;
}

/* --------------------------------------------------------------------------
   Report Accertatori
   -------------------------------------------------------------------------- */

body.rch-office-v1 #view-fieldwork .fieldwork-hero {
  min-height: 10rem;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  background:
    linear-gradient(135deg, rgba(236, 251, 244, 0.95), rgba(255, 255, 255, 0.98));
}

body.rch-office-v1 #view-fieldwork .fieldwork-hero::after {
  background: rgba(16, 169, 107, 0.10);
}

body.rch-office-v1 #view-fieldwork .fieldwork-hero-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
}

body.rch-office-v1 #view-fieldwork .timer-open-cta {
  min-height: 3rem;
}

body.rch-office-v1 #view-fieldwork > .kpi-grid {
  grid-template-columns: repeat(4, minmax(9rem, 1fr));
}

body.rch-office-v1 #view-fieldwork > .kpi-grid .kpi-card {
  min-height: 6.8rem;
}

body.rch-office-v1 #view-fieldwork > .table-toolbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  align-items: stretch;
}

body.rch-office-v1 #view-fieldwork > .table-toolbar .toolbar-main {
  grid-template-columns:
    minmax(16rem, 1.6fr)
    repeat(5, minmax(9rem, 1fr));
}

body.rch-office-v1 #view-fieldwork > .table-toolbar .toolbar-actions {
  justify-content: flex-start;
  padding-top: var(--rch-space-3);
  border-top: 1px solid var(--rch-neutral-200);
}

body.rch-office-v1 #view-fieldwork .workload-list {
  display: grid;
  gap: var(--rch-space-3);
  padding: 0 var(--rch-space-5) var(--rch-space-5);
}

body.rch-office-v1 #view-fieldwork .workload-item,
body.rch-office-v1 #view-fieldwork .progress-item {
  min-width: 0;
  padding: var(--rch-space-3) var(--rch-space-4);
  border: 1px solid var(--rch-neutral-200);
  border-radius: var(--rch-radius-card);
  background: linear-gradient(180deg, #fbfdff, #f7faff);
}

body.rch-office-v1 #view-fieldwork .progress-bar {
  height: 0.65rem;
  overflow: hidden;
  border-radius: var(--rch-radius-pill);
  background: var(--rch-neutral-100);
}

body.rch-office-v1 #view-fieldwork .progress-bar i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--rch-primary-600), var(--rch-success-600));
}

body.rch-office-v1 #view-fieldwork .data-table {
  min-width: 70rem;
}

/* --------------------------------------------------------------------------
   Responsive critical views
   -------------------------------------------------------------------------- */

@media (max-width: 90rem) and (min-width: 64.01rem) {
  body.rch-office-v1 #view-inbox .toolbar-main {
    grid-template-columns: minmax(14rem, 1.5fr) repeat(3, minmax(9rem, 1fr));
  }

  body.rch-office-v1 #view-fieldwork > .table-toolbar .toolbar-main {
    grid-template-columns: minmax(15rem, 1.5fr) repeat(3, minmax(9rem, 1fr));
  }

  body.rch-office-v1 #view-fieldwork > .kpi-grid {
    grid-template-columns: repeat(4, minmax(8rem, 1fr));
  }
}

@media (max-width: 64rem) {
  body.rch-office-v1 #view-inbox .rch-inbox-hero,
  body.rch-office-v1 #view-fieldwork .fieldwork-hero {
    grid-template-columns: 1fr;
  }

  body.rch-office-v1 #view-inbox .rch-inbox-hero .toolbar-actions,
  body.rch-office-v1 #view-fieldwork .fieldwork-hero-actions {
    justify-content: flex-start;
  }

  body.rch-office-v1 #view-inbox .toolbar-main,
  body.rch-office-v1 #view-tasks .toolbar-main,
  body.rch-office-v1 #view-fieldwork > .table-toolbar .toolbar-main {
    grid-template-columns: repeat(2, minmax(10rem, 1fr));
  }

  body.rch-office-v1 #view-fieldwork > .kpi-grid {
    grid-template-columns: repeat(2, minmax(9rem, 1fr));
  }
}

@media (max-width: 47.99rem) {
  body.rch-office-v1 #view-inbox,
  body.rch-office-v1 #view-tasks,
  body.rch-office-v1 #view-fieldwork {
    --critical-view-gap: var(--rch-space-3);
  }

  body.rch-office-v1 #view-inbox .section-intro,
  body.rch-office-v1 #view-tasks .section-intro,
  body.rch-office-v1 #view-fieldwork .section-intro {
    padding: var(--rch-space-4);
  }

  body.rch-office-v1 #view-inbox .rch-inbox-hero .toolbar-actions {
    grid-template-columns: 1fr;
    width: 100%;
  }

  body.rch-office-v1 #view-inbox .rch-inbox-hero #createInboxBtn {
    grid-column: auto;
  }

  body.rch-office-v1 #view-inbox .rch-inbox-hero .toolbar-actions .btn,
  body.rch-office-v1 #view-fieldwork .fieldwork-hero-actions .btn {
    width: 100%;
  }

  body.rch-office-v1 #view-inbox .toolbar-main,
  body.rch-office-v1 #view-tasks .toolbar-main,
  body.rch-office-v1 #view-fieldwork > .table-toolbar .toolbar-main {
    grid-template-columns: 1fr;
  }

  body.rch-office-v1 #view-tasks .compact-toolbar {
    display: grid;
  }

  body.rch-office-v1 #view-tasks #taskResultLabel {
    justify-self: start;
  }

  body.rch-office-v1 #view-fieldwork > .table-toolbar .toolbar-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  body.rch-office-v1 #view-fieldwork > .table-toolbar .toolbar-actions .btn {
    width: 100%;
    white-space: normal;
  }

  body.rch-office-v1 #view-fieldwork > .kpi-grid {
    display: flex;
    overflow-x: auto;
  }

  body.rch-office-v1 #view-fieldwork > .kpi-grid .kpi-card {
    flex: 0 0 9.5rem;
  }
}

/* ==========================================================================
   Fase 3.2 — Office operational views
   Panoramica, Attività, Calendario, Segnalazioni, Permessi,
   Assegnazioni, Eventi e Audit.
   ========================================================================== */

/* --------------------------------------------------------------------------
   Panoramica
   -------------------------------------------------------------------------- */

body.rch-office-v1 #view-overview .overview-grid {
  grid-template-columns: repeat(12, minmax(0, 1fr));
  align-items: start;
}

body.rch-office-v1 #view-overview .overview-grid > .panel:nth-child(1),
body.rch-office-v1 #view-overview .overview-grid > .panel:nth-child(2),
body.rch-office-v1 #view-overview .overview-grid > .panel:nth-child(3) {
  grid-column: span 6;
}

body.rch-office-v1 #view-overview .overview-grid > .panel:nth-child(4),
body.rch-office-v1 #view-overview .overview-grid > .panel:nth-child(5) {
  grid-column: span 6;
}

body.rch-office-v1 #view-overview .priority-list,
body.rch-office-v1 #view-overview .progress-list,
body.rch-office-v1 #view-overview .workload-list,
body.rch-office-v1 #view-overview .quality-grid {
  display: grid;
  gap: var(--rch-space-3);
  padding: 0 var(--rch-space-5) var(--rch-space-5);
}

body.rch-office-v1 #view-overview .priority-row {
  min-width: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: var(--rch-space-3);
  padding: var(--rch-space-3) var(--rch-space-4);
  border: 1px solid var(--rch-neutral-200);
  border-left: 0.22rem solid var(--rch-primary-600);
  border-radius: var(--rch-radius-card);
  background: linear-gradient(180deg, #fbfdff, #f7faff);
  transition:
    border-color 140ms ease,
    background 140ms ease,
    transform 140ms ease;
}

body.rch-office-v1 #view-overview .priority-row:hover {
  border-color: #b8d5fb;
  background: #f2f8ff;
  transform: translateY(-1px);
}

body.rch-office-v1 #view-overview .priority-row > div {
  min-width: 0;
}

body.rch-office-v1 #view-overview .priority-row strong {
  display: block;
  overflow: hidden;
  color: var(--rch-neutral-900);
  font-size: 0.78rem;
  font-weight: 850;
  text-overflow: ellipsis;
  white-space: nowrap;
}

body.rch-office-v1 #view-overview .priority-row span {
  display: block;
  overflow: hidden;
  margin-top: 0.2rem;
  color: var(--rch-neutral-500);
  font-size: 0.67rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

body.rch-office-v1 #view-overview .progress-row {
  display: grid;
  grid-template-columns: minmax(9rem, 1fr) minmax(10rem, 1.4fr) auto;
  align-items: center;
  gap: var(--rch-space-3);
}

body.rch-office-v1 #view-overview .progress-label {
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--rch-space-2);
  color: var(--rch-neutral-700);
  font-size: 0.72rem;
  font-weight: 760;
}

body.rch-office-v1 #view-overview .progress-label span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

body.rch-office-v1 #view-overview .progress-label strong {
  flex: 0 0 auto;
  color: var(--rch-neutral-900);
}

body.rch-office-v1 #view-overview .progress-track,
body.rch-office-v1 #view-overview .workload-row .progress-track {
  height: 0.65rem;
  overflow: hidden;
  border-radius: var(--rch-radius-pill);
  background: var(--rch-neutral-100);
  box-shadow: inset 0 1px 2px rgba(18, 46, 78, 0.07);
}

body.rch-office-v1 #view-overview .progress-track i,
body.rch-office-v1 #view-overview .workload-row .progress-track i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--rch-primary-600), var(--rch-violet-600));
}

body.rch-office-v1 #view-overview .workload-row {
  display: grid;
  gap: var(--rch-space-2);
  padding: var(--rch-space-3) var(--rch-space-4);
  border: 1px solid var(--rch-neutral-200);
  border-radius: var(--rch-radius-card);
  background: var(--rch-neutral-25);
}

body.rch-office-v1 #view-overview .workload-head {
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--rch-space-3);
}

body.rch-office-v1 #view-overview .workload-head strong {
  min-width: 0;
  overflow: hidden;
  color: var(--rch-neutral-900);
  font-size: 0.76rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

body.rch-office-v1 #view-overview .workload-head span {
  flex: 0 0 auto;
  color: var(--rch-primary-700);
  font-size: 0.68rem;
  font-weight: 850;
}

body.rch-office-v1 #view-overview .quality-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

body.rch-office-v1 #view-overview .quality-card {
  min-width: 0;
  min-height: 6.2rem;
  display: grid;
  align-content: center;
  padding: var(--rch-space-4);
  border: 1px solid var(--rch-neutral-200);
  border-radius: var(--rch-radius-card);
  background:
    radial-gradient(circle at 100% 0, rgba(20, 124, 255, 0.08), transparent 4.5rem),
    var(--rch-neutral-25);
}

body.rch-office-v1 #view-overview .quality-card strong {
  color: var(--rch-neutral-900);
  font-size: 1.7rem;
  font-weight: 900;
  line-height: 1;
}

body.rch-office-v1 #view-overview .quality-card span {
  margin-top: var(--rch-space-2);
  color: var(--rch-neutral-500);
  font-size: 0.68rem;
  line-height: 1.35;
}

/* --------------------------------------------------------------------------
   Attività
   -------------------------------------------------------------------------- */

body.rch-office-v1 #view-activities .table-toolbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
}

body.rch-office-v1 #view-activities .toolbar-main {
  grid-template-columns:
    minmax(16rem, 1.6fr)
    repeat(4, minmax(10rem, 1fr));
}

body.rch-office-v1 #view-activities .bulk-bar {
  position: sticky;
  z-index: 20;
  top: calc(var(--office-topbar-min) + var(--rch-space-2));
  display: grid;
  grid-template-columns:
    auto
    repeat(3, minmax(10rem, 1fr))
    auto
    auto;
  align-items: center;
  gap: var(--rch-space-2);
  margin: var(--rch-space-3) 0;
  padding: var(--rch-space-3);
  border: 1px solid #b9d5f8;
  border-radius: var(--rch-radius-card);
  background: rgba(239, 246, 255, 0.97);
  box-shadow: var(--rch-shadow-md);
  backdrop-filter: blur(10px);
}

body.rch-office-v1 #view-activities .bulk-bar strong {
  color: var(--rch-primary-700);
  font-size: 0.72rem;
  white-space: nowrap;
}

body.rch-office-v1 #view-activities .check-cell {
  width: 3.2rem;
  text-align: center;
}

body.rch-office-v1 #view-activities .check-cell input,
body.rch-office-v1 #view-activities .row-checkbox {
  width: 1rem;
  height: 1rem;
  accent-color: var(--rch-primary-600);
}

body.rch-office-v1 #view-activities .pagination {
  display: flex;
  justify-content: flex-end;
  gap: var(--rch-space-2);
  padding: var(--rch-space-3) var(--rch-space-4);
  border-top: 1px solid var(--rch-neutral-200);
  background: var(--rch-neutral-25);
}

/* --------------------------------------------------------------------------
   Shared operational modules
   -------------------------------------------------------------------------- */

body.rch-office-v1 #view-calendar .section-intro,
body.rch-office-v1 #view-signals .section-intro,
body.rch-office-v1 #view-permits .section-intro,
body.rch-office-v1 #view-events .section-intro,
body.rch-office-v1 #view-assignments .section-intro {
  position: relative;
  min-height: 8.5rem;
  align-items: center;
  overflow: hidden;
  isolation: isolate;
}

body.rch-office-v1 #view-calendar .section-intro::after,
body.rch-office-v1 #view-signals .section-intro::after,
body.rch-office-v1 #view-permits .section-intro::after,
body.rch-office-v1 #view-events .section-intro::after,
body.rch-office-v1 #view-assignments .section-intro::after {
  content: "";
  position: absolute;
  z-index: -1;
  top: -5rem;
  right: -4rem;
  width: 15rem;
  height: 15rem;
  border-radius: 50%;
}

body.rch-office-v1 #view-calendar .section-intro {
  background: linear-gradient(135deg, #f0f6ff, #ffffff);
}

body.rch-office-v1 #view-calendar .section-intro::after {
  background: rgba(20, 124, 255, 0.09);
}

body.rch-office-v1 #view-signals .section-intro {
  background: linear-gradient(135deg, #fff8ef, #ffffff);
}

body.rch-office-v1 #view-signals .section-intro::after {
  background: rgba(221, 133, 8, 0.10);
}

body.rch-office-v1 #view-permits .section-intro {
  background: linear-gradient(135deg, #f5f1ff, #ffffff);
}

body.rch-office-v1 #view-permits .section-intro::after {
  background: rgba(113, 78, 234, 0.10);
}

body.rch-office-v1 #view-events .section-intro {
  background: linear-gradient(135deg, #ecfbf4, #ffffff);
}

body.rch-office-v1 #view-events .section-intro::after {
  background: rgba(16, 169, 107, 0.10);
}

body.rch-office-v1 #view-assignments .section-intro {
  background: linear-gradient(135deg, #f1f4ff, #ffffff);
}

body.rch-office-v1 #view-assignments .section-intro::after {
  background: rgba(83, 104, 232, 0.10);
}

body.rch-office-v1 #view-calendar .table-toolbar,
body.rch-office-v1 #view-signals .table-toolbar,
body.rch-office-v1 #view-permits .table-toolbar,
body.rch-office-v1 #view-events .table-toolbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  align-items: stretch;
}

body.rch-office-v1 #view-calendar .table-toolbar .toolbar-main,
body.rch-office-v1 #view-signals .table-toolbar .toolbar-main,
body.rch-office-v1 #view-permits .table-toolbar .toolbar-main,
body.rch-office-v1 #view-events .table-toolbar .toolbar-main {
  grid-template-columns:
    minmax(16rem, 1.5fr)
    repeat(4, minmax(9.5rem, 1fr))
    repeat(2, minmax(9rem, 0.85fr));
}

body.rch-office-v1 #view-calendar .table-toolbar .toolbar-actions,
body.rch-office-v1 #view-signals .table-toolbar .toolbar-actions,
body.rch-office-v1 #view-permits .table-toolbar .toolbar-actions,
body.rch-office-v1 #view-events .table-toolbar .toolbar-actions {
  justify-content: flex-start;
  padding-top: var(--rch-space-3);
  border-top: 1px solid var(--rch-neutral-200);
}

/* --------------------------------------------------------------------------
   Calendario mensile
   -------------------------------------------------------------------------- */

body.rch-office-v1 #view-calendar .calendar-month-scroll {
  max-width: 100%;
  overflow-x: auto;
  padding: 0 var(--rch-space-5) var(--rch-space-5);
  scrollbar-width: thin;
  scrollbar-color: #aabbd0 transparent;
}

body.rch-office-v1 #view-calendar .calendar-month-grid {
  min-width: 58rem;
  display: grid;
  grid-template-columns: repeat(7, minmax(7rem, 1fr));
  gap: var(--rch-space-2);
}

body.rch-office-v1 #view-calendar .calendar-day,
body.rch-office-v1 #view-calendar .calendar-day.empty {
  position: relative;
  min-height: 8.5rem;
  display: grid;
  align-content: start;
  gap: var(--rch-space-2);
  padding: var(--rch-space-3);
  overflow: hidden;
  border: 1px solid var(--rch-neutral-200);
  border-radius: var(--rch-radius-card);
  background: var(--rch-white);
}

body.rch-office-v1 #view-calendar .calendar-day.empty {
  background: #f5f7fa;
  opacity: 0.66;
}

body.rch-office-v1 #view-calendar .calendar-day:hover {
  border-color: #a9cdfb;
  box-shadow: var(--rch-shadow-sm);
}

body.rch-office-v1 #view-calendar .calendar-day.today {
  border-color: var(--rch-primary-600);
  box-shadow: inset 0 0 0 1px var(--rch-primary-600);
}

body.rch-office-v1 #view-calendar .calendar-day.has-availability::after {
  content: "";
  position: absolute;
  top: var(--rch-space-2);
  right: var(--rch-space-2);
  width: 0.55rem;
  height: 0.55rem;
  border-radius: 50%;
  background: var(--rch-success-600);
  box-shadow: 0 0 0 0.25rem rgba(16, 169, 107, 0.12);
}

body.rch-office-v1 #view-calendar .calendar-day-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--rch-space-2);
}

body.rch-office-v1 #view-calendar .calendar-day-number {
  width: 1.9rem;
  height: 1.9rem;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: var(--rch-neutral-900);
  font-size: 0.72rem;
  font-weight: 900;
}

body.rch-office-v1 #view-calendar .calendar-day.today .calendar-day-number {
  color: var(--rch-white);
  background: var(--rch-primary-600);
}

body.rch-office-v1 #view-calendar .calendar-day-count {
  color: var(--rch-neutral-500);
  font-size: 0.62rem;
  font-weight: 780;
}

body.rch-office-v1 #view-calendar .calendar-entry-chip {
  min-width: 0;
  min-height: 1.8rem;
  display: flex;
  align-items: center;
  padding: 0 var(--rch-space-2);
  overflow: hidden;
  border: 1px solid #cfe0f5;
  border-radius: var(--rch-radius-control);
  color: #245484;
  background: #edf5ff;
  font-size: 0.62rem;
  font-weight: 750;
  text-overflow: ellipsis;
  white-space: nowrap;
}

body.rch-office-v1 #view-calendar .calendar-entry-chip.purple {
  color: #5b41ba;
  border-color: #d8cdf9;
  background: #f5f1ff;
}

body.rch-office-v1 #view-calendar .calendar-entry-chip.warning {
  color: #986000;
  border-color: #f0d69f;
  background: #fff8e9;
}

body.rch-office-v1 #view-calendar .calendar-entry-chip.alert {
  color: #b22e33;
  border-color: #f1c2c5;
  background: #fff2f2;
}

body.rch-office-v1 #view-calendar .calendar-entry-more {
  color: var(--rch-primary-700);
  font-size: 0.62rem;
  font-weight: 850;
}

/* --------------------------------------------------------------------------
   Signals, permits and events tables
   -------------------------------------------------------------------------- */

body.rch-office-v1 #view-signals .data-table,
body.rch-office-v1 #view-permits .data-table,
body.rch-office-v1 #view-events .data-table {
  min-width: 70rem;
}

body.rch-office-v1 #view-signals .data-table td:first-child,
body.rch-office-v1 #view-permits .data-table td:first-child,
body.rch-office-v1 #view-events .data-table td:first-child {
  min-width: 16rem;
}

/* --------------------------------------------------------------------------
   Assegnazioni
   -------------------------------------------------------------------------- */

body.rch-office-v1 #view-assignments .assignment-cards {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--rch-space-4);
}

body.rch-office-v1 #view-assignments .assignment-card {
  min-width: 0;
  display: grid;
  align-content: start;
  padding: var(--rch-space-5);
  border: 1px solid var(--rch-neutral-200);
  border-top: 0.25rem solid var(--rch-violet-600);
  border-radius: var(--rch-radius-panel);
  background:
    radial-gradient(circle at 100% 0, rgba(113, 78, 234, 0.08), transparent 6rem),
    var(--rch-white);
  box-shadow: var(--rch-shadow-sm);
}

body.rch-office-v1 #view-assignments .assignment-card h3 {
  margin: 0;
  overflow: hidden;
  color: var(--rch-neutral-900);
  font-size: 0.95rem;
  font-weight: 880;
  text-overflow: ellipsis;
  white-space: nowrap;
}

body.rch-office-v1 #view-assignments .assignment-card p {
  min-height: 2.8rem;
  margin: var(--rch-space-2) 0 var(--rch-space-4);
  color: var(--rch-neutral-500);
  font-size: 0.72rem;
  line-height: 1.4;
}

body.rch-office-v1 #view-assignments .assignment-card .form-line {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: var(--rch-space-2);
}

body.rch-office-v1 #view-assignments .assignment-card .form-line select {
  min-width: 0;
}

/* --------------------------------------------------------------------------
   Audit
   -------------------------------------------------------------------------- */

body.rch-office-v1 #view-audit .table-panel {
  overflow: hidden;
}

body.rch-office-v1 #view-audit .audit-heading {
  min-height: 6rem;
  align-items: center;
  background:
    radial-gradient(circle at 100% 0, rgba(113, 78, 234, 0.08), transparent 10rem),
    linear-gradient(135deg, #f7f4ff, #ffffff);
}

body.rch-office-v1 #view-audit .audit-heading > span {
  flex: 0 0 auto;
  color: var(--rch-neutral-500);
  font-size: 0.68rem;
  font-weight: 720;
}

body.rch-office-v1 #view-audit .audit-toolbar {
  display: grid;
  grid-template-columns: minmax(16rem, 1.6fr) repeat(3, minmax(10rem, 1fr)) auto;
  gap: var(--rch-space-2);
  align-items: center;
  padding: var(--rch-space-3);
  border-top: 1px solid var(--rch-neutral-200);
  border-bottom: 1px solid var(--rch-neutral-200);
  background: var(--rch-neutral-25);
}

body.rch-office-v1 #view-audit .audit-toolbar strong {
  min-height: 2.2rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 var(--rch-space-3);
  border: 1px solid var(--rch-neutral-200);
  border-radius: var(--rch-radius-pill);
  color: var(--rch-neutral-700);
  background: var(--rch-white);
  font-size: 0.68rem;
  white-space: nowrap;
}

body.rch-office-v1 #view-audit .audit-table {
  min-width: 72rem;
}

body.rch-office-v1 #view-audit .audit-table td:nth-child(3),
body.rch-office-v1 #view-audit .audit-table td:nth-child(4) {
  max-width: 28rem;
  white-space: normal;
}

/* --------------------------------------------------------------------------
   Responsive operational views
   -------------------------------------------------------------------------- */

@media (max-width: 90rem) and (min-width: 64.01rem) {
  body.rch-office-v1 #view-overview .overview-grid > .panel {
    grid-column: span 6;
  }

  body.rch-office-v1 #view-calendar .table-toolbar .toolbar-main,
  body.rch-office-v1 #view-signals .table-toolbar .toolbar-main,
  body.rch-office-v1 #view-permits .table-toolbar .toolbar-main,
  body.rch-office-v1 #view-events .table-toolbar .toolbar-main {
    grid-template-columns: minmax(15rem, 1.4fr) repeat(3, minmax(9rem, 1fr));
  }

  body.rch-office-v1 #view-assignments .assignment-cards {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 64rem) {
  body.rch-office-v1 #view-overview .overview-grid {
    grid-template-columns: 1fr;
  }

  body.rch-office-v1 #view-overview .overview-grid > .panel {
    grid-column: auto;
  }

  body.rch-office-v1 #view-activities .table-toolbar {
    grid-template-columns: 1fr;
  }

  body.rch-office-v1 #view-activities .toolbar-main,
  body.rch-office-v1 #view-calendar .table-toolbar .toolbar-main,
  body.rch-office-v1 #view-signals .table-toolbar .toolbar-main,
  body.rch-office-v1 #view-permits .table-toolbar .toolbar-main,
  body.rch-office-v1 #view-events .table-toolbar .toolbar-main {
    grid-template-columns: repeat(2, minmax(10rem, 1fr));
  }

  body.rch-office-v1 #view-activities .toolbar-actions {
    justify-content: flex-start;
  }

  body.rch-office-v1 #view-activities .bulk-bar {
    position: static;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  body.rch-office-v1 #view-audit .audit-toolbar {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  body.rch-office-v1 #view-audit .audit-toolbar strong {
    justify-self: start;
  }
}

@media (max-width: 47.99rem) {
  body.rch-office-v1 #view-overview .progress-row {
    grid-template-columns: 1fr;
    gap: var(--rch-space-2);
  }

  body.rch-office-v1 #view-overview .quality-grid {
    grid-template-columns: 1fr;
  }

  body.rch-office-v1 #view-activities .toolbar-main,
  body.rch-office-v1 #view-calendar .table-toolbar .toolbar-main,
  body.rch-office-v1 #view-signals .table-toolbar .toolbar-main,
  body.rch-office-v1 #view-permits .table-toolbar .toolbar-main,
  body.rch-office-v1 #view-events .table-toolbar .toolbar-main {
    grid-template-columns: 1fr;
  }

  body.rch-office-v1 #view-activities .toolbar-actions,
  body.rch-office-v1 #view-calendar .table-toolbar .toolbar-actions,
  body.rch-office-v1 #view-signals .table-toolbar .toolbar-actions,
  body.rch-office-v1 #view-permits .table-toolbar .toolbar-actions,
  body.rch-office-v1 #view-events .table-toolbar .toolbar-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  body.rch-office-v1 #view-activities .toolbar-actions .btn,
  body.rch-office-v1 #view-calendar .table-toolbar .toolbar-actions .btn,
  body.rch-office-v1 #view-signals .table-toolbar .toolbar-actions .btn,
  body.rch-office-v1 #view-permits .table-toolbar .toolbar-actions .btn,
  body.rch-office-v1 #view-events .table-toolbar .toolbar-actions .btn {
    width: 100%;
    white-space: normal;
  }

  body.rch-office-v1 #view-activities .bulk-bar {
    grid-template-columns: 1fr;
  }

  body.rch-office-v1 #view-assignments .assignment-cards {
    grid-template-columns: 1fr;
  }

  body.rch-office-v1 #view-audit .audit-heading {
    display: grid;
  }

  body.rch-office-v1 #view-audit .audit-toolbar {
    grid-template-columns: 1fr;
  }

  body.rch-office-v1 #view-calendar .calendar-month-scroll {
    margin-inline: calc(-1 * var(--rch-space-4));
    padding-inline: var(--rch-space-4);
  }
}

/* ==========================================================================
   Fase 3.2.1 — Office stabilization
   - access gate realmente esclusivo
   - Inbox actions leggibili
   - calendario compatto e ordinato
   - Panoramica bilanciata
   ========================================================================== */

/* --------------------------------------------------------------------------
   Hidden state: gate e applicazione non possono essere visibili insieme.
   -------------------------------------------------------------------------- */

body.rch-office-v1 [hidden],
body.rch-office-v1 #accessGate[hidden],
body.rch-office-v1 #officeApp[hidden],
body.rch-office-v1 #gateLogin[hidden],
body.rch-office-v1 #gateDenied[hidden],
body.rch-office-v1 #mobileSidebarBackdrop[hidden],
body.rch-office-v1 .drawer[hidden] {
  display: none;
}

body.rch-office-v1 #accessGate:not([hidden]) {
  display: grid;
}

body.rch-office-v1 #officeApp:not([hidden]) {
  display: grid;
}

/* --------------------------------------------------------------------------
   Inbox RCH: azioni sempre leggibili sul nuovo hero chiaro.
   -------------------------------------------------------------------------- */

body.rch-office-v1 #view-inbox .rch-inbox-hero .toolbar-actions {
  position: relative;
  z-index: 2;
  width: 100%;
  opacity: 1;
}

body.rch-office-v1 #view-inbox .rch-inbox-hero .toolbar-actions .btn {
  opacity: 1;
  visibility: visible;
  filter: none;
}

body.rch-office-v1 #view-inbox .rch-inbox-hero #createInboxBtn {
  color: var(--rch-white);
  border-color: var(--rch-primary-600);
  background: linear-gradient(135deg, #2387ff, var(--rch-primary-700));
  box-shadow: 0 0.8rem 1.8rem rgba(20, 124, 255, 0.20);
}

body.rch-office-v1 #view-inbox .rch-inbox-hero .btn.secondary {
  color: var(--rch-neutral-700);
  border-color: #cad8e8;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: var(--rch-shadow-xs);
}

body.rch-office-v1 #view-inbox .rch-inbox-hero .btn.secondary:hover {
  color: var(--rch-primary-700);
  border-color: #9fc5f8;
  background: #f4f9ff;
}

/* --------------------------------------------------------------------------
   Panoramica: nessuna colonna vuota e diagnostica a tutta larghezza.
   -------------------------------------------------------------------------- */

body.rch-office-v1 #view-overview .overview-grid {
  grid-template-columns: repeat(12, minmax(0, 1fr));
  grid-template-areas:
    "priority priority priority priority priority priority priority progress progress progress progress progress"
    "workload workload workload workload workload quality quality quality quality quality quality quality"
    "system system system system system system system system system system system system";
  align-items: stretch;
}

body.rch-office-v1 #view-overview .overview-grid > .panel:nth-child(1) {
  grid-area: priority;
}

body.rch-office-v1 #view-overview .overview-grid > .panel:nth-child(2) {
  grid-area: progress;
}

body.rch-office-v1 #view-overview .overview-grid > .panel:nth-child(3) {
  grid-area: workload;
}

body.rch-office-v1 #view-overview .overview-grid > .panel:nth-child(4) {
  grid-area: quality;
}

body.rch-office-v1 #view-overview .overview-grid > .panel:nth-child(5) {
  grid-area: system;
}

body.rch-office-v1 #view-overview .overview-grid > .panel {
  min-width: 0;
  height: 100%;
  align-self: stretch;
}

body.rch-office-v1 #view-overview #qualitySummary {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

body.rch-office-v1 #view-overview #systemStatusSummary {
  grid-template-columns: repeat(6, minmax(0, 1fr));
}

body.rch-office-v1 #view-overview #systemStatusSummary .quality-card {
  min-height: 6.4rem;
}

body.rch-office-v1 #view-overview .priority-list,
body.rch-office-v1 #view-overview .progress-list,
body.rch-office-v1 #view-overview .workload-list {
  height: 100%;
  align-content: start;
}

/* --------------------------------------------------------------------------
   Calendario: ripristino di una vista mensile compatta e leggibile.
   -------------------------------------------------------------------------- */

body.rch-office-v1 #view-calendar > .panel:has(#calendarMonthGrid) {
  overflow: hidden;
}

body.rch-office-v1 #view-calendar > .panel:has(#calendarMonthGrid) .panel-heading {
  align-items: center;
  padding-bottom: var(--rch-space-4);
  border-bottom: 1px solid var(--rch-neutral-200);
}

body.rch-office-v1 #view-calendar .calendar-month-scroll {
  max-width: 100%;
  overflow-x: auto;
  padding: var(--rch-space-4);
  background:
    linear-gradient(180deg, #fbfdff, #f7faff);
  scrollbar-gutter: stable;
  scrollbar-width: thin;
  scrollbar-color: #aabbd0 transparent;
}

body.rch-office-v1 #view-calendar .calendar-month-grid {
  min-width: 56rem;
  display: grid;
  grid-template-columns: repeat(7, minmax(7rem, 1fr));
  gap: 0.55rem;
}

body.rch-office-v1 #view-calendar .calendar-month-grid > .calendar-day-head {
  min-height: 2rem;
  display: flex;
  align-items: center;
  padding: 0 var(--rch-space-2);
  color: var(--rch-neutral-500);
  font-size: 0.65rem;
  font-weight: 900;
  letter-spacing: 0.075em;
  text-transform: uppercase;
}

body.rch-office-v1 #view-calendar .calendar-day,
body.rch-office-v1 #view-calendar .calendar-day.empty {
  min-width: 0;
  min-height: 7rem;
  display: block;
  padding: 0.7rem;
  overflow: hidden;
  border: 1px solid #dbe5f1;
  border-radius: 1rem;
  color: var(--rch-neutral-700);
  background: var(--rch-white);
  box-shadow: none;
  text-align: left;
  appearance: none;
}

body.rch-office-v1 #view-calendar .calendar-day.empty {
  background:
    repeating-linear-gradient(
      135deg,
      #f5f7fa,
      #f5f7fa 0.5rem,
      #f8fafc 0.5rem,
      #f8fafc 1rem
    );
  opacity: 0.72;
}

body.rch-office-v1 #view-calendar .calendar-day:not(.empty):hover {
  border-color: #a7cafa;
  background: #fbfdff;
  box-shadow: 0 0.55rem 1.4rem rgba(23, 70, 120, 0.09);
  transform: translateY(-1px);
}

body.rch-office-v1 #view-calendar .calendar-day.today {
  border-color: var(--rch-primary-600);
  background: linear-gradient(180deg, #f0f6ff, #ffffff);
  box-shadow: inset 0 0 0 1px var(--rch-primary-600);
}

body.rch-office-v1 #view-calendar .calendar-day.has-availability {
  border-color: #b9e8d3;
  background: linear-gradient(180deg, #f3fcf7, #ffffff 58%);
}

body.rch-office-v1 #view-calendar .calendar-day.has-availability::after {
  display: none;
}

body.rch-office-v1 #view-calendar .calendar-day-number {
  width: 100%;
  height: auto;
  min-height: 1.6rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--rch-space-2);
  margin: 0;
  padding: 0;
  border-radius: 0;
  color: var(--rch-neutral-900);
  background: transparent;
  font-size: 0.76rem;
  font-weight: 900;
  line-height: 1;
}

body.rch-office-v1 #view-calendar .calendar-day.today .calendar-day-number {
  color: var(--rch-primary-700);
  background: transparent;
}

body.rch-office-v1 #view-calendar .calendar-day-number .badge {
  min-height: 1.45rem;
  padding: 0 0.45rem;
  font-size: 0.55rem;
}

body.rch-office-v1 #view-calendar .calendar-day-count {
  display: block;
  margin: 0.2rem 0 0.45rem;
  color: var(--rch-neutral-500);
  font-size: 0.61rem;
  font-weight: 730;
}

body.rch-office-v1 #view-calendar .calendar-entry-chip {
  min-width: 0;
  min-height: 1.7rem;
  display: flex;
  align-items: center;
  margin-top: 0.32rem;
  padding: 0 0.52rem;
  overflow: hidden;
  border: 1px solid #d4e2f3;
  border-radius: 0.65rem;
  color: #245484;
  background: #edf5ff;
  font-size: 0.59rem;
  font-weight: 760;
  line-height: 1.15;
  text-overflow: ellipsis;
  white-space: nowrap;
}

body.rch-office-v1 #view-calendar .calendar-entry-chip.purple {
  color: #5a3db8;
  border-color: #d9cff8;
  background: #f4f0ff;
}

body.rch-office-v1 #view-calendar .calendar-entry-chip.success,
body.rch-office-v1 #view-calendar .calendar-entry-chip.availability-chip {
  color: #08784d;
  border-color: #b8e8d1;
  background: #ecfaf3;
}

body.rch-office-v1 #view-calendar .calendar-entry-chip.high,
body.rch-office-v1 #view-calendar .calendar-entry-chip.alert {
  color: #ad3035;
  border-color: #f0c4c7;
  background: #fff2f2;
}

body.rch-office-v1 #view-calendar .calendar-entry-chip.medium {
  color: #956000;
  border-color: #eed39e;
  background: #fff8e8;
}

body.rch-office-v1 #view-calendar .calendar-entry-more {
  display: block;
  margin-top: 0.4rem;
  color: var(--rch-primary-700);
  font-size: 0.58rem;
  font-weight: 850;
}

body.rch-office-v1 #view-calendar .calendar-month-scroll + * {
  border-top: 1px solid var(--rch-neutral-200);
}

/* --------------------------------------------------------------------------
   Responsive corrections.
   -------------------------------------------------------------------------- */

@media (max-width: 80rem) and (min-width: 64.01rem) {
  body.rch-office-v1 #view-overview .overview-grid {
    grid-template-areas:
      "priority priority priority priority priority priority progress progress progress progress progress progress"
      "workload workload workload workload workload workload quality quality quality quality quality quality"
      "system system system system system system system system system system system system";
  }

  body.rch-office-v1 #view-overview #qualitySummary {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  body.rch-office-v1 #view-overview #systemStatusSummary {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 64rem) {
  body.rch-office-v1 #view-overview .overview-grid {
    grid-template-columns: 1fr;
    grid-template-areas:
      "priority"
      "progress"
      "workload"
      "quality"
      "system";
  }

  body.rch-office-v1 #view-overview #qualitySummary,
  body.rch-office-v1 #view-overview #systemStatusSummary {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  body.rch-office-v1 #view-calendar .calendar-month-grid {
    min-width: 52rem;
  }
}

@media (max-width: 47.99rem) {
  body.rch-office-v1 #view-overview #qualitySummary,
  body.rch-office-v1 #view-overview #systemStatusSummary {
    grid-template-columns: 1fr;
  }

  body.rch-office-v1 #view-calendar .calendar-month-scroll {
    margin-inline: 0;
    padding: var(--rch-space-3);
  }

  body.rch-office-v1 #view-calendar .calendar-month-grid {
    min-width: 49rem;
    gap: 0.4rem;
  }

  body.rch-office-v1 #view-calendar .calendar-day,
  body.rch-office-v1 #view-calendar .calendar-day.empty {
    min-height: 6.6rem;
    padding: 0.6rem;
  }
}

/* ==========================================================================
   Fase 4.0.1 - Refresh button visibility
   ========================================================================== */

body.rch-office-v1 #refreshBtn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.42rem;
}

body.rch-office-v1 #refreshBtn .refresh-icon {
  flex: 0 0 auto;
  display: inline-grid;
  place-items: center;
  font-size: 1rem;
  font-weight: 900;
  line-height: 1;
}

body.rch-office-v1 #refreshBtn .refresh-label {
  display: inline;
  font-size: 0.68rem;
  font-weight: 820;
  line-height: 1;
}

@media (max-width: 95rem) and (min-width: 48rem) {
  body.rch-office-v1 .topbar-actions #refreshBtn {
    width: 2.55rem;
    min-width: 2.55rem;
    padding-inline: 0;
    overflow: visible;
    font-size: inherit;
  }

  body.rch-office-v1 #refreshBtn .refresh-label {
    display: none;
  }
}

@media (max-width: 47.99rem) {
  body.rch-office-v1 #refreshBtn {
    display: none;
  }
}

/* ==========================================================================
   Fase 4.0.2 - Refresh button compact
   ========================================================================== */

body.rch-office-v1 .topbar-actions #refreshBtn.refresh-button {
  width: 2.75rem;
  min-width: 2.75rem;
  max-width: 2.75rem;
  height: 2.75rem;
  min-height: 2.75rem;
  flex: 0 0 2.75rem;
  display: inline-grid;
  place-items: center;
  gap: 0;
  padding: 0;
  overflow: hidden;
  border: 1px solid #cddbeb;
  border-radius: 0.9rem;
  color: #445269;
  background: #ffffff;
  box-shadow: 0 0.35rem 1rem rgba(32, 61, 96, 0.06);
  font-size: 0;
  line-height: 1;
  white-space: nowrap;
}

body.rch-office-v1 #refreshBtn .refresh-icon-svg {
  width: 1.12rem;
  height: 1.12rem;
  display: block;
  overflow: visible;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: transform 180ms ease;
}

body.rch-office-v1 .topbar-actions #refreshBtn.refresh-button:hover {
  color: var(--rch-primary-700);
  border-color: #9fc5f8;
  background: #f4f9ff;
  box-shadow: 0 0.55rem 1.3rem rgba(20, 124, 255, 0.11);
}

body.rch-office-v1 #refreshBtn:hover .refresh-icon-svg {
  transform: rotate(28deg);
}

body.rch-office-v1 .topbar-actions #refreshBtn.refresh-button:active {
  transform: translateY(1px);
  box-shadow: 0 0.2rem 0.6rem rgba(32, 61, 96, 0.08);
}

body.rch-office-v1 .topbar-actions #refreshBtn.refresh-button:focus-visible {
  outline: 3px solid rgba(20, 124, 255, 0.20);
  outline-offset: 2px;
}

@media (max-width: 47.99rem) {
  body.rch-office-v1 .topbar-actions #refreshBtn.refresh-button {
    display: none;
  }
}

/* ==========================================================================
   Fase 5.0 - Refresh definitive
   ========================================================================== */

body.rch-office-v1 .topbar-actions #refreshBtn.refresh-button {
  width: 2.75rem;
  min-width: 2.75rem;
  max-width: 2.75rem;
  height: 2.75rem;
  min-height: 2.75rem;
  flex: 0 0 2.75rem;
  display: inline-grid;
  place-items: center;
  padding: 0;
  overflow: hidden;
  border: 1px solid #cddbeb;
  border-radius: 0.9rem;
  color: #3f4d63;
  background: #ffffff;
  box-shadow: 0 0.35rem 1rem rgba(32, 61, 96, 0.07);
  font-size: 0;
  line-height: 1;
  appearance: none;
}

body.rch-office-v1 #refreshBtn .refresh-glyph {
  width: 1.4rem;
  height: 1.4rem;
  display: grid;
  place-items: center;
  color: #3f4d63;
  font-family: "Segoe UI Symbol", "Arial Unicode MS", system-ui, sans-serif;
  font-size: 1.28rem;
  font-weight: 800;
  line-height: 1;
  transform: translateY(-0.02rem);
  transition:
    color 160ms ease,
    transform 180ms ease;
}

body.rch-office-v1 .topbar-actions #refreshBtn.refresh-button:hover {
  color: var(--rch-primary-700);
  border-color: #9fc5f8;
  background: #f4f9ff;
  box-shadow: 0 0.55rem 1.3rem rgba(20, 124, 255, 0.12);
}

body.rch-office-v1 #refreshBtn:hover .refresh-glyph {
  color: var(--rch-primary-700);
  transform: rotate(28deg);
}

body.rch-office-v1 .topbar-actions #refreshBtn.refresh-button:active {
  transform: translateY(1px);
}

body.rch-office-v1 .topbar-actions #refreshBtn.refresh-button:focus-visible {
  outline: 3px solid rgba(20, 124, 255, 0.20);
  outline-offset: 2px;
}

@media (max-width: 47.99rem) {
  body.rch-office-v1 .topbar-actions #refreshBtn.refresh-button {
    display: none;
  }
}

/* ==========================================================================
   Fase 6.1 - Office mobile stabilization
   ========================================================================== */

body.rch-office-v1 .panel-heading {
  gap: 0.55rem;
}

body.rch-office-v1 .panel-heading .eyebrow {
  display: block;
  margin-bottom: 0.45rem;
}

body.rch-office-v1 #view-overview .priority-list {
  gap: 0.85rem;
}

body.rch-office-v1 #view-overview .priority-row {
  min-height: 5.25rem;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  column-gap: 1rem;
  padding: 1rem 1.25rem;
}

body.rch-office-v1 #view-overview .priority-row > div {
  min-width: 0;
  display: grid;
  gap: 0.45rem;
}

body.rch-office-v1 #view-overview .priority-row strong {
  line-height: 1.25;
}

body.rch-office-v1 #view-overview .priority-row span:not(.badge) {
  line-height: 1.4;
}

body.rch-office-v1 #view-overview .progress-list {
  gap: 1rem;
}

body.rch-office-v1 #view-overview .progress-row {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.5rem;
  padding: 0.15rem 0;
}

body.rch-office-v1 #view-overview .progress-label {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.35rem;
}

body.rch-office-v1 #view-overview .area-progress-name {
  display: block;
  min-width: 0;
  overflow: visible;
  color: var(--rch-neutral-900);
  font-size: 0.79rem;
  font-weight: 800;
  line-height: 1.3;
  text-overflow: clip;
  white-space: normal;
}

body.rch-office-v1 #view-overview .area-progress-metrics {
  display: grid;
  grid-template-columns: minmax(7rem, auto) 4rem;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  color: var(--rch-neutral-500);
  font-size: 0.7rem;
  font-variant-numeric: tabular-nums;
}

body.rch-office-v1 #view-overview .area-progress-count {
  white-space: nowrap;
}

body.rch-office-v1 #view-overview .area-progress-percent {
  text-align: right;
  font-weight: 800;
  white-space: nowrap;
}

body.rch-office-v1 #view-overview .progress-track {
  width: 100%;
  height: 0.56rem;
}

body.rch-office-v1 #refreshBtn {
  display: inline-grid;
  place-items: center;
  width: 2.7rem;
  min-width: 2.7rem;
  height: 2.7rem;
  padding: 0;
  overflow: visible;
  font-size: 0;
}

body.rch-office-v1 #refreshBtn > * {
  display: none !important;
}

body.rch-office-v1 #refreshBtn::before {
  content: "";
  width: 1.05rem;
  height: 1.05rem;
  border: 0.15rem solid currentColor;
  border-left-color: transparent;
  border-radius: 50%;
  transform: rotate(-38deg);
}

body.rch-office-v1 #refreshBtn::after {
  content: "";
  position: absolute;
  width: 0;
  height: 0;
  margin: -0.72rem 0 0 0.72rem;
  border-top: 0.25rem solid transparent;
  border-bottom: 0.25rem solid transparent;
  border-left: 0.38rem solid currentColor;
  transform: rotate(18deg);
}

body.rch-office-v1 #refreshBtn {
  position: relative;
}

@media (max-width: 64rem) {
  body.rch-office-v1.sidebar-open {
    overflow: hidden;
  }

  body.rch-office-v1.sidebar-open .office-sidebar {
    z-index: 10020 !important;
    transform: translateX(0) !important;
    visibility: visible !important;
    opacity: 1 !important;
    pointer-events: auto !important;
  }

  body.rch-office-v1 .office-sidebar-backdrop:not([hidden]),
  body.rch-office-v1.sidebar-open .office-sidebar-backdrop {
    position: fixed;
    z-index: 10010 !important;
    inset: 0;
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
    pointer-events: auto !important;
    background: rgba(5, 18, 38, 0.52);
    backdrop-filter: blur(5px);
  }

  body.rch-office-v1 .office-sidebar {
    box-shadow: 1.25rem 0 3rem rgba(5, 18, 38, 0.32);
  }
}

@media (max-width: 42rem) {
  body.rch-office-v1 #view-overview .priority-row {
    min-height: 0;
    padding: 0.9rem;
  }

  body.rch-office-v1 #view-overview .area-progress-metrics {
    grid-template-columns: minmax(0, 1fr) auto;
  }
}
