/* GIOP shell styling on top of the shared AXIOM theme tokens. */
:root {
  /* Dynamics 365 / modern Microsoft typography on Windows 11, with the
     classic Microsoft UI face as the cross-platform fallback. */
  --axiom-font-family: "Segoe UI Variable Text", "Segoe UI Variable", "Segoe UI",
    system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
}

.giop-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background-color: var(--axiom-canvas);
  font-family: var(--axiom-font-family);
}

.giop-topbar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-height: var(--axiom-topbar-height);
  padding: 0 1rem;
  background-color: var(--axiom-navy-topbar);
  border-bottom: 1px solid var(--axiom-navy-topbar-border);
  color: #ffffff;
}

.giop-topbar-logo {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.75rem;
  height: 1.75rem;
  border-radius: 0.125rem;
  background-color: var(--axiom-primary);
  font-size: 0.75rem;
  font-weight: 700;
}

.giop-topbar-title {
  font-weight: 600;
  letter-spacing: 0.02em;
}

.giop-topbar-nav {
  margin-left: auto;
  display: flex;
  gap: 1rem;
}

.giop-topbar-nav a {
  color: #ddebff;
  text-decoration: none;
  font-size: 0.875rem;
  min-height: var(--axiom-min-nav-height);
  display: inline-flex;
  align-items: center;
}

.giop-topbar-nav a:hover,
.giop-topbar-nav a.active {
  color: #ffffff;
}

.giop-main {
  flex: 1;
  padding: 1.5rem;
  max-width: 72rem;
  width: 100%;
  margin: 0 auto;
  box-sizing: border-box;
}

.giop-card {
  background-color: var(--axiom-surface);
  border: 1px solid var(--axiom-border);
  border-radius: 0.5rem;
  padding: 1.25rem;
  margin-top: 1rem;
}

.giop-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

.giop-table th,
.giop-table td {
  text-align: left;
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid var(--axiom-border);
}

.giop-table th {
  color: var(--axiom-text-secondary);
  font-weight: 600;
  background-color: var(--axiom-command-bar);
}

.giop-error {
  color: var(--axiom-danger);
  font-size: 0.875rem;
  margin-top: 0.5rem;
}

.giop-form {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  max-width: 22rem;
}

.giop-form label {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--axiom-text-secondary);
}

.giop-form input {
  min-height: 2.25rem;
  padding: 0 0.625rem;
  border: 1px solid var(--axiom-border);
  border-radius: 0.375rem;
  font-family: inherit;
}

.giop-form button {
  min-height: var(--axiom-min-button-height);
  border: none;
  border-radius: 0.375rem;
  background-color: var(--axiom-primary);
  color: #ffffff;
  font-weight: 600;
  cursor: pointer;
}

.giop-form button:hover {
  background-color: var(--axiom-primary-dark);
}

/* ---- Portal shell (React GIOP reference parity, Phase B2) ---- */
/* All colors come from Axiom.UI.Shared tokens (var(--axiom-*)). */

.portal-shell {
  min-height: 100vh;
  background-color: var(--axiom-canvas);
  font-family: var(--axiom-font-family);
}

/* Top bar: navy, 44px, white/soft-blue text. */
.portal-topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  height: var(--axiom-topbar-height);
  background-color: var(--axiom-navy-topbar);
  border-bottom: 1px solid var(--axiom-navy-topbar-border);
  color: #ddebff;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.2);
  padding-right: 0.75rem;
}

.portal-logo-block {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2.75rem;
  height: 100%;
  border-right: 1px solid rgba(255, 255, 255, 0.3);
  flex-shrink: 0;
}

.portal-logo {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.75rem;
  height: 1.75rem;
  border-radius: 0.125rem;
  border: 1px solid rgba(255, 255, 255, 0.25);
  background-color: #ffffff;
  color: var(--axiom-navy-topbar);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.portal-product-block {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  height: 100%;
  padding: 0 1rem 0 0.5rem;
  border-right: 1px solid rgba(255, 255, 255, 0.3);
  flex-shrink: 0;
}

.portal-product-title {
  font-size: 15px;
  font-weight: 600;
  line-height: 1;
  color: #ffffff;
  white-space: nowrap;
}

.portal-breadcrumb {
  display: none;
  align-items: center;
  gap: 0.5rem;
  padding: 0 1rem;
  font-size: 13px;
  font-weight: 600;
  overflow: hidden;
  white-space: nowrap;
}

@media (min-width: 640px) {
  .portal-breadcrumb { display: flex; }
}

.portal-crumb {
  color: #ddebff;
  text-decoration: none;
}

.portal-crumb:hover { opacity: 0.9; }
.portal-crumb.active { color: #ffffff; }

.portal-crumb-divider { color: #7ea6d9; }

.portal-topbar-spacer { flex: 1; }

.portal-search {
  display: none;
  align-items: center;
  gap: 0.5rem;
  height: 1.75rem;
  width: 280px;
  padding: 0 0.5rem;
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 0.125rem;
  background-color: rgba(255, 255, 255, 0.1);
  font-size: 13px;
  color: #ddebff;
}

@media (min-width: 1280px) {
  .portal-search { display: flex; }
}

.portal-search:focus-within { border-color: #7ea6d9; }

.portal-search input {
  flex: 1;
  border: none;
  background: none;
  outline: none;
  color: #ffffff;
  font-size: 13px;
  font-family: var(--axiom-font-family);
}

.portal-search input::placeholder { color: #bfd8ff; }

.portal-topbar-iconbtn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  margin-left: 0.25rem;
  border: none;
  border-radius: 0.125rem;
  background: none;
  color: #ddebff;
  font-size: 0.9375rem;
  cursor: pointer;
}

.portal-topbar-iconbtn:hover { background-color: rgba(255, 255, 255, 0.1); }

.portal-hamburger { margin-left: 0; }

.portal-topbar-divider {
  width: 1px;
  height: 1.75rem;
  margin: 0 0.5rem;
  background-color: rgba(255, 255, 255, 0.3);
}

/* User area + dropdown. */
.portal-user-area { position: relative; }

.portal-user-trigger {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  height: 2rem;
  padding: 0 0.375rem;
  border: none;
  border-radius: 0.125rem;
  background: none;
  cursor: pointer;
}

.portal-user-trigger:hover { background-color: rgba(255, 255, 255, 0.1); }

.portal-avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.5rem;
  height: 1.5rem;
  border-radius: 9999px;
  background-color: var(--axiom-primary);
  color: #ffffff;
  font-size: 11px;
  font-weight: 600;
}

.portal-user-name {
  display: none;
  font-size: 12px;
  font-weight: 600;
  color: #ffffff;
}

@media (min-width: 1024px) {
  .portal-user-name { display: inline; }
}

.portal-user-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 0.5rem);
  z-index: 60;
  width: 16rem;
  padding: 0.5rem 0;
  background-color: var(--axiom-surface);
  border: 1px solid var(--axiom-border);
  border-radius: 0.125rem;
  box-shadow: 0 20px 25px -5px rgba(15, 23, 42, 0.15), 0 8px 10px -6px rgba(15, 23, 42, 0.1);
  color: var(--axiom-text-secondary);
  font-size: 0.875rem;
}

.portal-user-menu-header {
  padding: 0.5rem 1rem 0.75rem;
  border-bottom: 1px solid var(--axiom-border);
}

.portal-user-menu-name {
  font-weight: 600;
  color: var(--axiom-text-primary);
}

.portal-user-menu-role { font-size: 0.75rem; }

.portal-user-menu-item {
  display: block;
  width: 100%;
  padding: 0.5rem 1rem;
  border: none;
  background: none;
  text-align: left;
  font-size: 0.875rem;
  font-family: var(--axiom-font-family);
  color: var(--axiom-text-secondary);
  cursor: pointer;
}

.portal-user-menu-item:hover:not(:disabled) { background-color: var(--axiom-command-bar); }
.portal-user-menu-item:disabled { opacity: 0.5; cursor: default; }
.portal-user-menu-item.danger { color: var(--axiom-danger); }
.portal-user-menu-item.danger:hover { background-color: #fef2f2; }

.portal-user-menu-separator {
  margin: 0.25rem 0;
  border-top: 1px solid var(--axiom-border);
}

/* Body: sidebar with a SMOOTH width transition; main gets the rest. */
.portal-body {
  --portal-sidebar-width: var(--axiom-sidebar-expanded-width);
  display: flex;
  min-height: calc(100vh - var(--axiom-topbar-height));
}

.portal-body.sidebar-collapsed {
  --portal-sidebar-width: var(--axiom-sidebar-collapsed-width);
}

.portal-sidebar {
  position: sticky;
  top: var(--axiom-topbar-height);
  align-self: flex-start;
  display: flex;
  flex-direction: column;
  width: var(--portal-sidebar-width);
  height: calc(100vh - var(--axiom-topbar-height));
  background-color: var(--axiom-command-bar);
  border-right: 1px solid var(--axiom-border);
  box-shadow: 1px 0 3px rgba(15, 23, 42, 0.08);
  overflow-x: hidden;
  overflow-y: auto;
  flex-shrink: 0;
  transition: width var(--axiom-sidebar-transition) ease-in-out;
}

.portal-sidebar-nav {
  flex: 1;
  min-height: 0;
  padding: 0.75rem 0.5rem;
}

.portal-nav-group { margin-bottom: 1rem; }

.portal-nav-group-label {
  margin: 0 0 0.25rem;
  padding: 0 0.5rem;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #64748b;
  white-space: nowrap;
  opacity: 1;
  transition: opacity 200ms ease;
}

.sidebar-collapsed .portal-nav-group-label { opacity: 0; }

.portal-nav-item {
  position: relative;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  height: var(--axiom-sidebar-item-height);
  padding: 0 0.75rem;
  border-radius: 0.125rem;
  font-size: 0.875rem;
  font-weight: 500;
  color: #334155;
  text-decoration: none;
  white-space: nowrap;
  transition: background-color 120ms ease, color 120ms ease;
  margin-bottom: 0.25rem;
}

.portal-nav-item:hover:not(.disabled) {
  background-color: var(--axiom-surface);
  color: var(--axiom-text-primary);
}

.portal-nav-item.active {
  background-color: var(--axiom-surface);
  color: var(--axiom-text-primary);
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.08);
}

.portal-nav-item.active::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0.375rem;
  width: 4px;
  height: 1.5rem;
  background-color: var(--axiom-primary);
}

.portal-nav-item.disabled {
  color: #94a3b8;
  cursor: default;
}

.portal-nav-icon {
  display: inline-flex;
  width: var(--axiom-sidebar-icon-size);
  justify-content: center;
  color: #64748b;
  flex-shrink: 0;
}

.portal-nav-item.active .portal-nav-icon { color: var(--axiom-primary); }

.portal-nav-text {
  overflow: hidden;
  opacity: 1;
  /* Collapses to zero width, not just transparent: a hidden label that still
     claims flex width would push the icon off the rail's centre. */
  max-width: 12rem;
  transition: opacity 200ms ease, max-width var(--axiom-sidebar-transition) ease-in-out;
}

.sidebar-collapsed .portal-nav-text {
  opacity: 0;
  max-width: 0;
}

.sidebar-collapsed .portal-nav-item { justify-content: center; padding: 0; gap: 0; }
.sidebar-collapsed .portal-site-selector { display: none; }

.portal-sidebar-footer {
  border-top: 1px solid var(--axiom-border);
  padding: 0.5rem;
}

.portal-main {
  flex: 1;
  min-width: 0;
  padding: 1rem 1.25rem;
}

/* ---- Dashboard ---- */
.portal-kpi-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

@media (min-width: 640px) { .portal-kpi-grid { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 1024px) { .portal-kpi-grid { grid-template-columns: repeat(3, 1fr); } }
@media (min-width: 1280px) { .portal-kpi-grid { grid-template-columns: repeat(6, 1fr); } }

/* Map hero: dark canvas, overlay chrome, fullscreen. */
.portal-map-hero {
  position: relative;
  min-height: 420px;
  margin-bottom: 0.75rem;
  background-color: #141416;
  border: 1px solid var(--axiom-border);
  border-radius: 0.125rem;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.08);
  overflow: hidden;
  transition: min-height 300ms ease-in-out;
}

.portal-map-hero.expanded {
  position: fixed;
  inset: var(--axiom-topbar-height) 0 0 0;
  z-index: 40;
  margin: 0;
  border-radius: 0;
  min-height: 0;
}

.portal-map-title {
  pointer-events: none;
  position: absolute;
  left: 0.75rem;
  top: 0.75rem;
  z-index: 10;
  padding: 0.25rem 0.75rem;
  border-radius: 0.125rem;
  background-color: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(4px);
  color: #ffffff;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.portal-map-legend {
  position: absolute;
  right: 0.75rem;
  top: 0.75rem;
  z-index: 10;
  display: none;
  align-items: center;
  gap: 0.75rem;
  padding: 0.25rem 0.75rem;
  border-radius: 0.125rem;
  background-color: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(4px);
  color: #ffffff;
  font-size: 11px;
  font-weight: 600;
}

@media (min-width: 640px) { .portal-map-legend { display: flex; } }

.portal-map-legend .dot {
  display: inline-block;
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 9999px;
  margin-right: 0.25rem;
}

.portal-map-placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  color: rgba(255, 255, 255, 0.8);
  font-size: 0.875rem;
  font-weight: 600;
  background:
    radial-gradient(ellipse at 30% 40%, rgba(0, 91, 187, 0.25), transparent 55%),
    radial-gradient(ellipse at 70% 65%, rgba(22, 163, 74, 0.12), transparent 50%),
    #141416;
}

.portal-map-placeholder small {
  font-weight: 400;
  color: rgba(255, 255, 255, 0.55);
}

.portal-map-fullscreen {
  position: absolute;
  right: 0.75rem;
  bottom: 0.75rem;
  z-index: 50;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.25rem;
  height: 2.25rem;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 0.125rem;
  background-color: rgba(0, 0, 0, 0.65);
  color: #ffffff;
  cursor: pointer;
}

.portal-map-fullscreen:hover { background-color: rgba(0, 0, 0, 0.85); }

/* Row 3. */
.portal-chart-row {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.75rem;
}

@media (min-width: 1024px) { .portal-chart-row { grid-template-columns: repeat(3, 1fr); } }

.portal-panel {
  padding: 0;
  background-color: var(--axiom-surface);
  border: 1px solid var(--axiom-border);
  border-radius: 0.125rem;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.08);
  transition: box-shadow 150ms ease;
}

.portal-panel:hover { box-shadow: 0 4px 10px rgba(15, 23, 42, 0.16); }

.portal-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid var(--axiom-border);
}

.portal-panel-title {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
  color: var(--axiom-text-primary);
}

.portal-panel-subtitle {
  margin: 0.125rem 0 0;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--axiom-text-secondary);
}

.portal-panel-body { padding: 0.75rem; }

/* Dossier content (inside the shared overlay). */
.portal-dossier-tabs {
  display: flex;
  gap: 0.25rem;
  border-bottom: 1px solid var(--axiom-border);
  margin-bottom: 0.5rem;
  overflow-x: auto;
  /* React reference hides the tab strip scrollbar (.no-scrollbar). */
  scrollbar-width: none;
}

.portal-dossier-tabs::-webkit-scrollbar {
  display: none;
}

.portal-dossier-tab {
  padding: 0 0.75rem 0.5rem;
  border: none;
  background: none;
  font-size: 0.875rem;
  font-weight: 500;
  font-family: var(--axiom-font-family);
  color: var(--axiom-text-secondary);
  cursor: pointer;
  white-space: nowrap;
}

.portal-dossier-tab.active {
  color: var(--axiom-primary);
  font-weight: 600;
  box-shadow: inset 0 -2px 0 var(--axiom-primary);
}

.portal-dossier-section h4 {
  margin: 0.5rem 0 0.25rem;
  padding: 0.375rem 0.5rem;
  background-color: rgba(248, 250, 252, 0.8);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: #64748b;
}

.portal-dossier-row {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.375rem 0.5rem;
  border-bottom: 1px solid rgba(226, 232, 240, 0.6);
  font-size: 0.8125rem;
}

.portal-dossier-row span:first-child { color: var(--axiom-text-secondary); }
.portal-dossier-row span:last-child { font-weight: 600; word-break: break-all; text-align: right; }

.portal-finding-card {
  border: 1px solid var(--axiom-border);
  border-radius: 0.5rem;
  background-color: rgba(248, 250, 252, 0.5);
  padding: 0.75rem;
  margin-bottom: 0.5rem;
  cursor: pointer;
}

.portal-finding-card:hover { background-color: var(--axiom-surface); }
.portal-finding-card.selected { border-color: var(--axiom-primary); }

.portal-finding-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.portal-finding-description,
.portal-finding-action {
  margin: 0.375rem 0 0;
  font-size: 0.8125rem;
  color: var(--axiom-text-secondary);
}

.portal-ai-tag {
  font-size: 0.6875rem;
  font-weight: 600;
  color: var(--axiom-primary);
  background-color: var(--axiom-accent-light);
  border-radius: 9999px;
  padding: 0.125rem 0.5rem;
}

.portal-report-row {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--axiom-border);
}

.portal-report-name { flex: 1; min-width: 0; }

.portal-report-title {
  font-size: 0.8125rem;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.portal-report-meta {
  font-size: 0.6875rem;
  color: var(--axiom-text-secondary);
}

.portal-empty { color: var(--axiom-text-secondary); }
.portal-error { color: var(--axiom-danger); font-size: 0.8125rem; }
.portal-mono { font-family: ui-monospace, monospace; font-size: 0.75rem; color: var(--axiom-text-secondary); }
.portal-count-alert { color: var(--axiom-danger); font-weight: 700; }

/* Site selector card in the sidebar. */
.portal-site-selector {
  padding: 0.5rem;
  margin: 0 0 1rem;
  border: 1px solid var(--axiom-border);
  border-radius: 0.125rem;
  background-color: var(--axiom-surface);
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.08);
}

.portal-site-selector-client {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #64748b;
  margin-bottom: 0.375rem;
}

.portal-site-selector-meta,
.portal-site-selector-empty {
  margin-top: 0.375rem;
  font-size: 0.75rem;
  color: var(--axiom-text-secondary);
}

/* Lightweight modal for action-bar dialogs. */
.portal-modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 70;
  background-color: rgba(15, 23, 42, 0.35);
}

.portal-modal {
  position: fixed;
  left: 50%;
  top: 20%;
  transform: translateX(-50%);
  z-index: 71;
  width: min(26rem, calc(100vw - 2rem));
  display: flex;
  flex-direction: column;
  gap: 0.625rem;
  padding: 1rem;
  background-color: var(--axiom-surface);
  border: 1px solid var(--axiom-border);
  border-radius: 0.25rem;
  box-shadow: 0 20px 25px -5px rgba(15, 23, 42, 0.2);
}

.portal-modal-actions {
  display: flex;
  gap: 0.5rem;
  justify-content: flex-end;
  margin-top: 0.25rem;
}

.giop-detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(13rem, 1fr));
  gap: 0.875rem 1.5rem;
  margin: 0;
}

.giop-detail-field dt {
  color: var(--axiom-text-secondary);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 0.125rem;
}

.giop-detail-field dd {
  margin: 0;
  font-size: 0.875rem;
}

.giop-detail-caption {
  color: var(--axiom-text-secondary);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin: 0 0 0.25rem;
}

.giop-context-warning {
  border-left: 3px solid var(--axiom-accent);
}

.giop-history-cell {
  background-color: var(--axiom-canvas);
}

.giop-history-note {
  color: var(--axiom-text-secondary);
  font-size: 0.8125rem;
}

.giop-asset-search {
  margin-bottom: 0.875rem;
  max-width: 22rem;
}

.giop-tree {
  list-style: none;
  margin: 0;
  padding-left: 1rem;
  border-left: 1px solid var(--axiom-border);
}

.giop-tree-root {
  padding-left: 0;
  border-left: none;
}

.giop-tree-node {
  margin: 0.25rem 0;
}

.giop-tree-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.875rem;
  padding: 0.25rem 0;
}

.giop-tree-code {
  font-weight: 600;
  min-width: 6rem;
}

.giop-tree-meta {
  color: var(--axiom-text-secondary);
  font-size: 0.8125rem;
}
