/* Final role workspace layout: user delivery, agent business, admin operations. */

#accountSection.account-layout {
  --layout-bg: #f5f7fb;
  --layout-ink: #121826;
  --layout-muted: #667085;
  --layout-line: #d8dde8;
  --layout-blue: #002fa7;
  --layout-red: #e4002b;
  --layout-green: #067647;
  --layout-cyan: #0891b2;
  background:
    linear-gradient(90deg, rgba(0, 47, 167, 0.035) 0 1px, transparent 1px 25%),
    linear-gradient(180deg, #ffffff 0, var(--layout-bg) 360px);
  color: var(--layout-ink);
}

#accountSection[data-role="user"] .account-header {
  grid-template-columns: minmax(0, 1fr) minmax(300px, 520px);
  align-items: start;
  padding: clamp(24px, 3.4vw, 42px) clamp(22px, 4.5vw, 56px) 26px;
  background:
    radial-gradient(circle at 8% 0%, rgba(0, 47, 167, 0.08), transparent 30%),
    #ffffff;
}

#accountSection[data-role="user"] .account-header h2 {
  max-width: 760px;
  margin: 0 0 12px;
  font-size: clamp(28px, 3.5vw, 48px);
  line-height: 1.08;
  letter-spacing: 0;
}

#accountSection[data-role="user"] .account-header p {
  max-width: 820px;
  line-height: 1.75;
}

#accountSection .account-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  justify-content: stretch;
  gap: 10px;
  padding: 14px;
  border: 1px solid var(--layout-line);
  background: rgba(255, 255, 255, 0.86);
  box-shadow: 0 18px 44px rgba(18, 28, 45, 0.08);
}

#accountSection .account-actions .button {
  justify-content: center;
  width: 100%;
  min-height: 42px;
  white-space: nowrap;
}

#accountSection .account-actions #logoutButton,
#accountSection .account-actions #detailConsoleButton {
  grid-column: span 2;
}

#accountSection .account-identity {
  gap: 10px;
  margin-top: 20px;
}

#accountSection .identity-chip {
  min-height: 34px;
  border-color: rgba(0, 47, 167, 0.16);
  background: rgba(0, 47, 167, 0.045);
}

#accountSection .identity-chip strong {
  color: var(--layout-blue);
}

#userWorkbench .status-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1px;
  padding: 1px;
  border: 0;
  background: var(--layout-line);
}

#userWorkbench .status-grid .metric-card {
  position: relative;
  min-height: 156px;
  padding: 22px;
  border: 0;
  background: #ffffff;
  overflow: hidden;
}

#userWorkbench .status-grid .metric-card::after {
  content: "";
  position: absolute;
  right: -34px;
  bottom: -44px;
  width: 120px;
  height: 120px;
  border-radius: 999px;
  background: rgba(0, 47, 167, 0.06);
}

#userWorkbench .status-grid .metric-card:nth-child(2)::after,
#userWorkbench .status-grid .metric-card:nth-child(4)::after {
  background: rgba(228, 0, 43, 0.055);
}

#userWorkbench .status-grid .metric-card span,
#userWorkbench .status-grid .metric-card strong,
#userWorkbench .status-grid .metric-card p {
  position: relative;
  z-index: 1;
}

#userWorkbench .status-grid .metric-card span {
  margin-bottom: 18px;
  color: var(--layout-muted);
  font-size: 12px;
  font-weight: 800;
}

#userWorkbench .status-grid .metric-card strong {
  margin-bottom: 10px;
  color: var(--layout-ink);
  font-size: clamp(24px, 3vw, 40px);
  overflow-wrap: anywhere;
}

#userWorkbench .status-grid .metric-card p {
  color: var(--layout-muted);
  line-height: 1.65;
}

#userWorkbench {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  gap: 0;
  min-height: 720px;
  border-top: 1px solid var(--layout-line);
  background: var(--layout-line);
}

#userWorkbench[hidden],
#userWorkspace[hidden],
[data-user-panel][hidden] {
  display: none !important;
}

.user-side-nav {
  position: sticky;
  top: 0;
  align-self: start;
  min-height: 720px;
  padding: 22px 16px;
  background: #ffffff;
  border-right: 1px solid var(--layout-line);
}

.user-side-profile {
  padding: 12px 10px 18px;
  border-bottom: 1px solid var(--layout-line);
}

.user-side-profile span,
.user-side-note strong {
  display: block;
  color: var(--layout-cyan);
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0;
}

.user-side-profile strong {
  display: block;
  margin-top: 8px;
  color: var(--layout-ink);
  font-size: 22px;
  line-height: 1.15;
}

.user-side-profile p,
.user-side-note p {
  margin: 8px 0 0;
  color: var(--layout-muted);
  font-size: 13px;
  line-height: 1.65;
}

.user-menu {
  display: grid;
  gap: 6px;
  margin-top: 18px;
}

.user-menu a {
  display: grid;
  gap: 3px;
  padding: 12px 12px;
  border: 1px solid transparent;
  color: var(--layout-muted);
  text-decoration: none;
  transition: background 180ms ease, border-color 180ms ease, color 180ms ease;
}

.user-menu a:hover,
.user-menu a.active {
  border-color: rgba(8, 145, 178, 0.26);
  background: #ecfeff;
  color: var(--layout-ink);
}

.user-menu a span {
  color: var(--layout-cyan);
  font-size: 11px;
  font-weight: 900;
}

.user-menu a strong {
  font-size: 14px;
  line-height: 1.3;
}

.user-side-note {
  margin-top: 22px;
  padding: 14px 12px;
  border: 1px solid rgba(8, 145, 178, 0.22);
  background: #f0fdfa;
}

.user-detail-pane {
  min-width: 0;
  background: var(--layout-bg);
}

#userWorkspace {
  display: block;
}

#userWorkspace .license-flow-panel,
#userWorkspace .delivery-actions-panel,
#userWorkspace .work-panel,
#userWorkspace .records-panel,
#userWorkspace .device-section,
#agentSection .role-panel,
#adminSection .role-panel,
#agentSection .records-panel,
#adminSection .records-panel {
  background: rgba(255, 255, 255, 0.94);
}

#userWorkspace > .work-grid,
#userWorkspace > .records-grid {
  display: contents;
}

#userWorkspace .user-panel {
  display: none;
}

#userWorkspace .user-panel.active {
  display: block;
}

#userWorkspace .user-overview-panel {
  background: var(--layout-bg);
}

#userWorkspace .license-flow-panel {
  padding: clamp(30px, 4vw, 48px) clamp(22px, 4.5vw, 56px);
  background:
    linear-gradient(90deg, rgba(0, 47, 167, 0.07), transparent 48%),
    #ffffff;
}

#userWorkspace .license-flow {
  grid-template-columns: repeat(5, minmax(150px, 1fr));
  overflow-x: auto;
}

#userWorkspace .license-step {
  min-height: 158px;
}

#userWorkspace .delivery-actions-panel {
  padding: clamp(30px, 4vw, 48px) clamp(22px, 4.5vw, 56px);
  border-bottom: 1px solid var(--layout-line);
}

#userWorkspace .delivery-action-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1px;
  margin-top: 24px;
  border: 1px solid var(--layout-line);
  background: var(--layout-line);
}

#userWorkspace .delivery-action-card {
  position: relative;
  display: grid;
  grid-template-rows: auto 1fr auto;
  min-height: 210px;
  padding: 20px;
  background: #ffffff;
  transition: background 180ms ease, box-shadow 180ms ease;
}

#userWorkspace .delivery-action-card:hover {
  background: #fbfcff;
  box-shadow: inset 0 0 0 2px rgba(0, 47, 167, 0.18);
}

#userWorkspace .action-index {
  color: var(--layout-blue);
  font-size: 28px;
  font-weight: 900;
  line-height: 1;
}

#userWorkspace .delivery-action-card h4 {
  margin: 24px 0 10px;
  font-size: 20px;
  line-height: 1.2;
}

#userWorkspace .delivery-action-card p {
  margin: 0;
  color: var(--layout-muted);
  font-size: 13px;
  line-height: 1.7;
}

#userWorkspace .delivery-action-card strong {
  margin-top: 20px;
  color: var(--layout-ink);
  font-size: 13px;
  overflow-wrap: anywhere;
}

#userWorkspace .work-grid,
#userWorkspace .records-grid {
  gap: 1px;
  border: 0;
  background: var(--layout-line);
}

#userWorkspace .work-panel,
#userWorkspace .records-panel,
#userWorkspace .device-section {
  border: 0;
  min-height: 720px;
  padding: clamp(28px, 4vw, 46px) clamp(22px, 4.5vw, 56px);
}

#userWorkspace .help-center-panel {
  min-height: 720px;
  padding: clamp(28px, 4vw, 46px) clamp(22px, 4.5vw, 56px);
  border: 0;
  background: rgba(255, 255, 255, 0.94);
}

#userWorkspace .panel-heading h3,
#agentSection .panel-heading h3,
#adminSection .panel-heading h3 {
  font-size: clamp(24px, 2.6vw, 34px);
}

#userWorkspace .panel-heading p,
#agentSection .panel-heading p,
#adminSection .panel-heading p {
  max-width: 820px;
}

#agentSection.role-workspace,
#adminSection.role-workspace {
  padding: 0;
  background: var(--layout-bg);
}

#agentSection .role-grid,
#adminSection .role-grid {
  grid-template-columns: minmax(0, 1.45fr) minmax(320px, 0.8fr);
  gap: 1px;
  border: 0;
  background: var(--layout-line);
}

#agentSection .role-panel,
#adminSection .role-panel,
#agentSection .records-panel,
#adminSection .records-panel {
  border: 0;
  padding: clamp(28px, 4vw, 46px) clamp(22px, 4vw, 48px);
}

#agentSection .status-grid.compact,
#adminSection .status-grid.compact {
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 1px;
  border: 1px solid var(--layout-line);
  background: var(--layout-line);
}

#agentSection .status-grid.compact .metric-card,
#adminSection .status-grid.compact .metric-card {
  position: relative;
  min-height: 126px;
  border: 0;
  padding: 18px 18px 18px 58px;
}

#agentSection .status-grid.compact .metric-icon,
#adminSection .status-grid.compact .metric-icon {
  position: absolute;
  left: 18px;
  top: 18px;
  display: inline-grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border: 1px solid rgba(0, 47, 167, 0.22);
  background: #f6f8ff;
  color: var(--layout-blue);
}

#agentSection .status-grid.compact .metric-icon svg,
#adminSection .status-grid.compact .metric-icon svg {
  width: 19px;
  height: 19px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
}

#agentSection .status-grid.compact .metric-card[data-metric-icon="activation"] .metric-icon,
#adminSection .status-grid.compact .metric-card[data-metric-icon="activation"] .metric-icon {
  border-color: rgba(255, 79, 0, 0.28);
  background: #fff7ed;
  color: #ff4f00;
}

#agentSection .status-grid.compact .metric-card[data-metric-icon="online"] .metric-icon,
#adminSection .status-grid.compact .metric-card[data-metric-icon="online"] .metric-icon,
#agentSection .status-grid.compact .metric-card[data-metric-icon="members"] .metric-icon,
#adminSection .status-grid.compact .metric-card[data-metric-icon="members"] .metric-icon {
  border-color: rgba(6, 118, 71, 0.24);
  background: #f0fdf4;
  color: var(--layout-green);
}

#agentSection .status-grid.compact .metric-card span:not(.metric-icon),
#adminSection .status-grid.compact .metric-card span:not(.metric-icon) {
  margin: 2px 0 16px;
  line-height: 1.3;
}

#agentSection .status-grid.compact .metric-card strong,
#adminSection .status-grid.compact .metric-card strong {
  font-size: clamp(22px, 2vw, 30px);
  line-height: 1.08;
  white-space: nowrap;
  word-break: keep-all;
  overflow-wrap: normal;
}

#agentSection .status-grid.compact .metric-card p,
#adminSection .status-grid.compact .metric-card p {
  line-height: 1.5;
}

#agentSection .records-grid,
#adminSection .records-grid {
  gap: 1px;
  border: 0;
  background: var(--layout-line);
}

#agentSection .record-list,
#adminSection .record-list {
  margin-top: 20px;
}

@media (max-width: 1160px) {
  #accountSection .account-header,
  #agentSection .role-grid,
  #adminSection .role-grid {
    grid-template-columns: 1fr;
  }

  #userWorkbench {
    grid-template-columns: 218px minmax(0, 1fr);
  }

  #accountSection .account-actions {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  #accountSection .account-actions #logoutButton,
  #accountSection .account-actions #detailConsoleButton {
    grid-column: auto;
  }

  #userWorkspace .delivery-action-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 760px) {
  #accountSection .account-header {
    padding: 24px 18px;
  }

  #accountSection .account-actions,
  #userWorkbench .status-grid,
  #userWorkspace .delivery-action-grid,
  #agentSection .status-grid.compact,
  #adminSection .status-grid.compact {
    grid-template-columns: 1fr;
  }

  #userWorkbench {
    grid-template-columns: 1fr;
  }

  .user-side-nav {
    position: relative;
    top: auto;
    min-height: auto;
    padding: 14px;
    border-right: 0;
    border-bottom: 1px solid var(--layout-line);
  }

  .user-side-profile,
  .user-side-note {
    display: none;
  }

  .user-menu {
    display: flex;
    gap: 8px;
    margin-top: 0;
    overflow-x: auto;
    padding-bottom: 4px;
  }

  .user-menu a {
    min-width: 128px;
    flex: 0 0 auto;
  }

  #accountSection .account-actions #logoutButton,
  #accountSection .account-actions #detailConsoleButton {
    grid-column: auto;
  }

  #userWorkspace .license-flow {
    grid-template-columns: 1fr;
    overflow-x: visible;
  }

  #userWorkspace .work-panel,
  #userWorkspace .records-panel,
  #userWorkspace .device-section,
  #userWorkspace .help-center-panel {
    min-height: auto;
  }
}

@media (prefers-reduced-motion: reduce) {
  .user-menu a {
    transition: none;
  }
}
