/* Build 5 Workstream 4.0 — shared canonical conformance repairs.
   Keep this file last in the GCC v2 cascade so launch-level repairs can be
   verified before older compatibility layers are consolidated. */

body.gcc-v2 :where(a, button, input, select, textarea, summary, [tabindex]):focus-visible {
  outline: 3px solid var(--gcc-orange);
  outline-offset: 3px;
}

body.gcc-v2 .gcc-button.accent,
body.gcc-v2 button.gcc-button.accent {
  background: var(--gcc-green);
  color: #fff;
  box-shadow: 0 12px 26px rgba(11, 92, 59, .18);
}
body.gcc-v2 .gcc-button.accent:hover,
body.gcc-v2 button.gcc-button.accent:hover { background: var(--gcc-green-2); }

body.gcc-v2 .gcc-page-head {
  position: relative;
  overflow: hidden;
  padding: 22px 24px;
  border: 1px solid var(--gcc-line);
  border-radius: 22px;
  background: rgba(255,255,255,.97);
  box-shadow: 0 14px 38px rgba(20,42,29,.075);
}
body.gcc-v2 .gcc-page-head::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 4px;
  background: linear-gradient(var(--gcc-green), var(--gcc-orange));
}
body.gcc-v2 .gcc-page-head .gcc-subtitle { font-size: 13px !important; }
body.gcc-v2 .gcc-card.hero { padding: 20px; border-radius: 18px; box-shadow: var(--gcc-shadow-soft); }
body.gcc-v2 .gcc-metrics { display: grid; grid-template-columns: repeat(4,minmax(0,1fr)); gap: 10px; }
body.gcc-v2 .gcc-metric {
  position: relative;
  min-height: 102px;
  padding: 15px;
  overflow: hidden;
  border: 1px solid var(--gcc-line);
  border-radius: 16px;
  background: #fff;
  box-shadow: var(--gcc-shadow-soft);
}
body.gcc-v2 .gcc-metric::after { content: ""; position: absolute; inset: auto 0 0; height: 3px; background: var(--gcc-green); }
body.gcc-v2 .gcc-metric > strong { display: block; margin-top: 3px; font-size: 30px; line-height: 1; letter-spacing: -.05em; }
body.gcc-v2 .gcc-metric > span { display: block; margin-top: 8px; color: var(--gcc-muted); font-size: 10px; font-weight: 900; letter-spacing: .07em; text-transform: uppercase; }

/* Route Planner is an operational workspace, not a dashboard. Its date selector
   and route facts stay in one compact utility strip on desktop rather than
   inheriting the launch-dashboard metric-card height above. */
@media (min-width: 1101px) {
  body.gcc-v2 .route-planner-command.gcc-card.hero {
    padding: 6px 8px;
    border-radius: 12px;
    box-shadow: var(--gcc-shadow-soft);
  }
  body.gcc-v2 .route-summary-metrics { gap: 6px; }
  body.gcc-v2 .route-summary-metrics .gcc-metric {
    display: flex;
    min-height: 44px;
    padding: 5px 9px;
    flex-direction: column;
    justify-content: center;
    border-radius: 10px;
    box-shadow: none;
  }
  body.gcc-v2 .route-summary-metrics .gcc-metric::after { height: 2px; }
  body.gcc-v2 .route-summary-metrics .gcc-metric > strong {
    margin-top: 0;
    font-size: 16px;
    line-height: 1;
    letter-spacing: -.035em;
  }
  body.gcc-v2 .route-summary-metrics .gcc-metric > span {
    margin-top: 3px;
    font-size: 7px;
    line-height: 1;
    letter-spacing: .055em;
  }

  /* Inspector Command Center is the field-execution companion to Route Planner.
     On desktop, working-route visibility outranks dashboard-card presence. */
  body.gcc-v2 .inspector-command-head {
    align-items: center;
    margin-bottom: 8px;
    padding: 10px 16px;
    border-radius: 14px;
    box-shadow: var(--gcc-shadow-soft);
  }
  body.gcc-v2 .inspector-command-head .gcc-kicker { font-size: 9px; line-height: 1.1; }
  body.gcc-v2 .inspector-command-head .gcc-title {
    margin: 2px 0 0;
    font-size: 24px;
    line-height: 1.05;
    letter-spacing: -.045em;
  }
  body.gcc-v2 .inspector-command-head .gcc-subtitle { display: none; }
  body.gcc-v2 .inspector-command-head .gcc-head-actions { gap: 6px; }
  body.gcc-v2 .inspector-command-head .gcc-button {
    min-height: 32px;
    padding: 6px 11px;
    font-size: 11px;
  }

  body.gcc-v2 .field-command-card.inspector-command-summary {
    display: grid;
    grid-template-columns: minmax(330px, 410px) minmax(0, 1fr);
    gap: 8px;
    align-items: end;
    margin-bottom: 8px;
    padding: 6px 8px;
    border-radius: 12px;
    box-shadow: var(--gcc-shadow-soft);
  }
  body.gcc-v2 .inspector-command-summary > .compact-head {
    align-items: end;
    gap: 6px;
    margin-bottom: 0;
    flex-wrap: nowrap;
  }
  body.gcc-v2 .inspector-command-summary .date-command-row {
    display: grid;
    grid-template-columns: minmax(170px, 1fr) auto;
    gap: 6px;
    align-items: end;
    margin: 0;
    flex: 1;
  }
  body.gcc-v2 .inspector-command-summary .date-command-row .gcc-field { margin: 0; }
  body.gcc-v2 .inspector-command-summary .date-command-row .gcc-field label {
    margin-bottom: 2px;
    font-size: 8px;
  }
  body.gcc-v2 .inspector-command-summary .date-command-row input {
    min-height: 32px;
    height: 32px;
    padding: 5px 8px;
    border-radius: 9px;
    font-size: 11px;
  }
  body.gcc-v2 .inspector-command-summary .date-command-row > .gcc-button,
  body.gcc-v2 .inspector-command-summary > .compact-head > .gcc-button {
    min-height: 32px;
    height: 32px;
    padding: 5px 9px;
    font-size: 10px;
    white-space: nowrap;
  }
  body.gcc-v2 .inspector-command-metrics {
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 5px;
  }
  body.gcc-v2 .inspector-command-metrics .gcc-metric {
    display: flex;
    min-height: 42px;
    padding: 4px 7px;
    flex-direction: column;
    justify-content: center;
    border-radius: 9px;
    box-shadow: none;
  }
  body.gcc-v2 .inspector-command-metrics .gcc-metric::after { height: 2px; }
  body.gcc-v2 .inspector-command-metrics .gcc-metric > strong {
    margin-top: 0;
    font-size: 15px;
    line-height: 1;
    letter-spacing: -.03em;
  }
  body.gcc-v2 .inspector-command-metrics .gcc-metric > span {
    margin-top: 2px;
    font-size: 6.5px;
    line-height: 1;
    letter-spacing: .045em;
  }

  body.gcc-v2 .inspector-day-route-card.gcc-card.hero {
    padding: 8px 10px;
    border-radius: 12px;
    box-shadow: var(--gcc-shadow-soft);
  }
  body.gcc-v2 .inspector-day-route-head {
    align-items: center;
    margin-bottom: 5px;
  }
  body.gcc-v2 .inspector-day-route-head .gcc-kicker { font-size: 8px; }
  body.gcc-v2 .inspector-day-route-head h2 {
    margin: 1px 0 0;
    font-size: 15px;
    line-height: 1.08;
  }
  body.gcc-v2 .inspector-day-route-head .gcc-subtitle { display: none; }
  body.gcc-v2 .inspector-day-route-head > .gcc-pill {
    padding: 3px 7px;
    font-size: 9px;
  }
  body.gcc-v2 .inspector-command-stop-list { gap: 4px; }
  body.gcc-v2 .inspector-command-stop {
    grid-template-columns: 28px minmax(0, 1fr) auto;
    gap: 7px;
    min-height: 50px;
    padding: 5px 7px;
    border-radius: 9px;
  }
  body.gcc-v2 .inspector-command-stop .gcc-compact-stop-index {
    width: 24px;
    height: 24px;
    font-size: 11px;
  }
  body.gcc-v2 .inspector-command-stop .gcc-compact-stop-mainline { gap: 5px; }
  body.gcc-v2 .inspector-command-stop .gcc-compact-stop-mainline strong {
    font-size: 12px;
    line-height: 1.1;
  }
  body.gcc-v2 .inspector-command-stop .gcc-compact-stop-mainline > span:not(.gcc-pill) {
    font-size: 10px;
    line-height: 1.1;
  }
  body.gcc-v2 .inspector-command-stop .gcc-compact-stop-mainline .gcc-pill,
  body.gcc-v2 .inspector-command-stop .gcc-compact-stop-actions > .gcc-pill {
    padding: 3px 6px;
    font-size: 9px;
  }
  body.gcc-v2 .inspector-command-stop .gcc-compact-stop-subline {
    gap: 8px;
    margin-top: 2px;
    font-size: 9.5px;
    line-height: 1.15;
  }
  body.gcc-v2 .inspector-command-stop .gcc-compact-stop-actions {
    gap: 4px;
    flex-wrap: nowrap;
  }
  body.gcc-v2 .inspector-command-stop .gcc-compact-eta-form { gap: 3px; }
  body.gcc-v2 .inspector-command-stop .gcc-compact-eta-form input[type="date"],
  body.gcc-v2 .inspector-command-stop .gcc-compact-eta-form select {
    min-height: 30px;
    height: 30px;
    padding: 4px 6px;
    border-radius: 8px;
    font-size: 10px;
  }
  body.gcc-v2 .inspector-command-stop .gcc-compact-eta-form input[type="date"] { max-width: 112px; }
  body.gcc-v2 .inspector-command-stop .gcc-compact-eta-form select { max-width: 98px; }
  body.gcc-v2 .inspector-command-stop .gcc-button.small {
    min-height: 30px;
    padding: 4px 7px;
    font-size: 10px;
  }
}

body.gcc-v2 .gcc-list { overflow: hidden; border: 1px solid var(--gcc-line); border-radius: 14px; background: #fff; }
body.gcc-v2 .gcc-list > .gcc-row {
  min-height: 58px;
  margin: 0;
  border: 0;
  border-bottom: 1px solid var(--gcc-line);
  border-radius: 0;
  background: #fff;
  box-shadow: none;
  transition: background .14s ease, box-shadow .14s ease, transform .14s ease;
}
body.gcc-v2 .gcc-list > .gcc-row:last-child { border-bottom: 0; }
body.gcc-v2 .gcc-list > .gcc-row:hover { background: #fbfdfb; box-shadow: inset 3px 0 0 var(--gcc-green); transform: translateY(-1px); }
body.gcc-v2 .gcc-empty { border-radius: 14px; box-shadow: none; }

.gcc-canonical-workspace { display: grid; gap: 16px; }
.gcc-canonical-hero {
  position: relative;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 24px;
  padding: 24px;
  overflow: hidden;
  border: 1px solid var(--gcc-line);
  border-radius: 22px;
  background: rgba(255,255,255,.97);
  box-shadow: 0 14px 38px rgba(20,42,29,.075);
}
.gcc-canonical-hero::before { content: ""; position: absolute; inset: 0 auto 0 0; width: 4px; background: linear-gradient(var(--gcc-green), var(--gcc-orange)); }
.gcc-canonical-hero h1 { margin: 4px 0 6px; color: var(--gcc-ink); font-size: clamp(32px,4vw,48px); line-height: .98; letter-spacing: -.055em; }
.gcc-canonical-hero p { max-width: 850px; margin: 0; color: var(--gcc-muted); font-size: 13px; }
.gcc-canonical-hero-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 9px; }
.gcc-canonical-section { padding: 18px; border: 1px solid var(--gcc-line); border-radius: 18px; background: rgba(255,255,255,.97); box-shadow: var(--gcc-shadow-soft); }
.gcc-canonical-section-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 14px; margin-bottom: 14px; }
.gcc-canonical-section-head h2 { margin: 2px 0 0; font-size: 21px; letter-spacing: -.03em; }
.gcc-canonical-section-head p { margin: 5px 0 0; color: var(--gcc-muted); font-size: 12px; }
.gcc-canonical-split { display: grid; grid-template-columns: minmax(0,1.55fr) minmax(320px,.72fr); gap: 14px; align-items: start; }
.gcc-canonical-stack { display: grid; gap: 14px; }
.gcc-canonical-toolbar { display: flex; align-items: flex-end; gap: 9px; flex-wrap: wrap; margin-bottom: 14px; }
.gcc-canonical-toolbar .gcc-field { min-width: 160px; }
.gcc-canonical-toolbar .gcc-field.grow { flex: 1; min-width: 260px; }
.gcc-canonical-toolbar input, .gcc-canonical-toolbar select { min-height: 40px; }
.gcc-canonical-intelligence { display: grid; grid-template-columns: repeat(4,minmax(0,1fr)); gap: 10px; }
.gcc-canonical-intelligence > article { position: relative; min-height: 100px; padding: 15px; overflow: hidden; border: 1px solid var(--gcc-line); border-radius: 16px; background: #fff; box-shadow: var(--gcc-shadow-soft); }
.gcc-canonical-intelligence > article::after { content:""; position:absolute; inset:auto 0 0; height:3px; background:var(--gcc-green); }
.gcc-canonical-intelligence > article.attention::after { background: var(--gcc-orange); }
.gcc-canonical-intelligence > article.danger::after { background: var(--gcc-red); }
.gcc-canonical-intelligence span { display:block; color:var(--gcc-muted); font-size:9px; font-weight:950; letter-spacing:.09em; text-transform:uppercase; }
.gcc-canonical-intelligence strong { display:block; margin-top:7px; font-size:29px; line-height:1; letter-spacing:-.05em; }
.gcc-canonical-intelligence small { display:block; margin-top:7px; color:var(--gcc-muted); font-size:10px; }

/* Only explicitly upgraded legacy tables use card conversion. Each cell must
   provide data-label so no column meaning is lost at mobile width. */
@media (max-width: 767px) {
  body.gcc-v2 .gcc-table-wrap:has(.gcc-responsive-table) { overflow: visible; border: 0; }
  body.gcc-v2 .gcc-data-table.gcc-responsive-table { min-width: 0 !important; }
  body.gcc-v2 .gcc-data-table.gcc-responsive-table thead { display: none; }
  body.gcc-v2 .gcc-data-table.gcc-responsive-table,
  body.gcc-v2 .gcc-data-table.gcc-responsive-table tbody,
  body.gcc-v2 .gcc-data-table.gcc-responsive-table tr,
  body.gcc-v2 .gcc-data-table.gcc-responsive-table td { display: block; width: 100%; }
  body.gcc-v2 .gcc-data-table.gcc-responsive-table tr { margin-bottom: 10px; overflow: hidden; border: 1px solid var(--gcc-line); border-radius: 14px; background: #fff; }
  body.gcc-v2 .gcc-data-table.gcc-responsive-table td { display: grid; grid-template-columns: 96px minmax(0,1fr); gap: 10px; padding: 9px 12px; border-bottom: 1px solid var(--gcc-line); }
  body.gcc-v2 .gcc-data-table.gcc-responsive-table td::before { content: attr(data-label); color: var(--gcc-muted); font-size: 8px; font-weight: 950; letter-spacing: .06em; text-transform: uppercase; }
  body.gcc-v2 .gcc-data-table.gcc-responsive-table td:last-child { border-bottom: 0; }
  body.gcc-v2 .gcc-data-table.gcc-responsive-table .gcc-table-actions { display: flex; flex-wrap: wrap; gap: 8px; }
  body.gcc-v2 .gcc-data-table.gcc-responsive-table .gcc-table-actions::before { flex-basis: 86px; }
}

.gcc-mobile-shellbar { display: none; }

@media (min-width: 768px) and (max-width: 1023px) {
  .gcc-shell { display: flex; }
  .gcc-sidebar { position: sticky; top: 0; width: 224px; min-height: 100vh; align-self: flex-start; flex-direction: column; align-items: stretch; overflow: visible; padding: 16px 12px; }
  .gcc-brand { min-width: 0; border-bottom: 1px solid var(--gcc-line); padding: 0 0 14px; }
  .gcc-brand-text span { display: none; }
  .gcc-nav { display: grid; min-width: 0; gap: 5px; }
  .gcc-nav-label, .gcc-user { display: block; }
  .gcc-nav a { min-height: 44px; padding: 9px 11px; white-space: normal; }
  .gcc-canonical-split { grid-template-columns: 1fr; }
  .gcc-canonical-intelligence, body.gcc-v2 .gcc-metrics { grid-template-columns: repeat(2,minmax(0,1fr)); }
}

@media (max-width: 767px) {
  .gcc-mobile-shellbar { position: sticky; top: 0; z-index: 900; display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 64px; padding: 9px 12px; border-bottom: 1px solid var(--gcc-line); background: rgba(255, 255, 255, .96); box-shadow: 0 8px 24px rgba(15, 35, 24, .07); backdrop-filter: blur(16px); }
  .gcc-mobile-brand { min-width: 0; display: flex; align-items: center; gap: 9px; }
  .gcc-mobile-brand img { width: 38px; height: 38px; flex: 0 0 auto; object-fit: contain; }
  .gcc-mobile-brand span { min-width: 0; display: grid; gap: 1px; }
  .gcc-mobile-brand strong { overflow: hidden; color: var(--gcc-ink); font-size: 12px; line-height: 1.15; text-overflow: ellipsis; white-space: nowrap; }
  .gcc-mobile-brand small { color: var(--gcc-muted); font-size: 10px; }
  .gcc-mobile-menu-button { min-width: 76px; min-height: 44px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 8px 12px; border: 1px solid var(--gcc-line-strong); border-radius: 999px; background: #fff; color: var(--gcc-green); font: inherit; font-size: 12px; font-weight: 900; cursor: pointer; }
  .gcc-mobile-menu-icon { width: 18px; display: grid; gap: 3px; }
  .gcc-mobile-menu-icon i { display: block; width: 18px; height: 2px; border-radius: 2px; background: currentColor; }
  .gcc-sidebar { display: none !important; }
  .gcc-shell { display: block; min-height: calc(100vh - 64px); }
  .gcc-main { width: 100%; }
  .gcc-drawer-nav { display: grid !important; min-width: 0 !important; gap: 10px; }
  .gcc-drawer-nav .gcc-nav-group { display: grid; gap: 5px; }
  .gcc-drawer-nav .gcc-nav-label { display: block !important; padding: 8px 10px 2px; }
  .gcc-drawer-nav a { min-height: 48px; padding: 11px 13px; border-radius: 14px; }
  .gcc-mobile-nav-drawer .gcc-drawer-body { padding: 10px 12px 22px; }
  .gcc-canonical-hero { display: grid; gap: 16px; padding: 20px; }
  .gcc-canonical-hero-actions { justify-content: flex-start; }
  .gcc-canonical-split, .gcc-canonical-intelligence, body.gcc-v2 .gcc-metrics { grid-template-columns: 1fr; }
  .gcc-canonical-toolbar { display: grid; grid-template-columns: 1fr; }
  .gcc-canonical-toolbar .gcc-field, .gcc-canonical-toolbar .gcc-field.grow { min-width: 0; }
  body.gcc-v2 .gcc-page-head { padding: 19px; }
}

@media (prefers-reduced-motion: reduce) {
  html:focus-within { scroll-behavior: auto; }
  body.gcc-v2 *, body.gcc-v2 *::before, body.gcc-v2 *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; scroll-behavior: auto !important; transition-duration: .01ms !important; }
}
