.v3-shell {
  --v3-shell-max: 1240px;
  --v3-shell-pad-x: clamp(14px, 2.4vw, 28px);
  --v3-shell-pad-y: clamp(14px, 1.9vw, 24px);
  --v3-shell-gap: clamp(0.72rem, 1.45vw, 1.05rem);
  --v3-card-pad: clamp(0.82rem, 1.28vw, 1.08rem);
  --v3-left-column: clamp(350px, 29vw, 388px);
  --v3-topbar-pad-top: clamp(0.3rem, 0.48vw, 0.42rem);
  --v3-topbar-pad-bottom: clamp(0.34rem, 0.56vw, 0.48rem);
  --v3-topbar-block-size: calc(44px + var(--v3-topbar-pad-top) + var(--v3-topbar-pad-bottom));
  --v3-topbar-clearance: clamp(0.58rem, 0.9vw, 0.78rem);
  --v3-shell-content-offset: calc(var(--v3-topbar-block-size) + var(--v3-topbar-clearance));
  --v3-card-border: var(--v3-theme-divider);
  --v3-card-shadow: 0 8px 22px var(--v3-theme-card-shadow-color);
  width: 100%;
  max-width: var(--v3-shell-max);
  margin: 0 auto;
  padding: var(--v3-shell-pad-y) var(--v3-shell-pad-x) var(--v3-space-6);
}

.v3-topbar {
  position: sticky;
  top: 0;
  z-index: 70;
  width: auto;
  display: flex;
  flex-direction: row;
  gap: var(--v3-space-2);
  align-items: center;
  justify-content: space-between;
  margin: calc(var(--v3-shell-pad-y) * -1) calc(var(--v3-shell-pad-x) * -1) var(--v3-topbar-clearance);
  padding:
    var(--v3-topbar-pad-top)
    var(--v3-shell-pad-x)
    var(--v3-topbar-pad-bottom);
  background: var(--v3-theme-bg);
  box-shadow:
    0 0 0 100vmax var(--v3-theme-bg),
    0 16px 30px -28px var(--v3-theme-shadow-strong);
  clip-path: inset(0 -100vmax 0);
}

.v3-brand {
  display: flex;
  gap: var(--v3-space-2);
  align-items: center;
}

.v3-logo-home-btn {
  display: block;
  margin: 0;
  padding: 0;
  border: 0;
  background: none;
  cursor: default;
}

.v3-logo-home-btn img {
  display: block;
  max-width: min(220px, 48vw);
  max-height: 44px;
  width: auto;
  object-fit: contain;
}

.v3-theme-logo.v3-theme-logo--dark {
  display: none;
}

:root[data-v3-theme="dark"] .v3-theme-logo--light {
  display: none;
}

:root[data-v3-theme="dark"] .v3-theme-logo--dark {
  display: block;
}

.v3-brand__copy {
  display: grid;
  gap: 2px;
  padding-top: 3px;
}

.v3-brand__title {
  color: var(--v3-color-text-strong);
  font-size: 0.92rem;
  font-weight: 800;
  letter-spacing: 0;
}

.v3-brand__meta {
  color: var(--v3-color-muted);
  font-size: 0.72rem;
  font-weight: 700;
  line-height: 1.25;
}

.v3-topbar__right {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--v3-space-2);
  margin-left: auto;
}

/* V2 top-shell action controls: icon-only, 44x44 touch target. */

.v3-top-shell-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
}

.v3-top-shell-actions button {
  position: relative;
  width: 44px;
  height: 44px;
  display: inline-flex;
  flex-shrink: 0;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: 1px solid var(--v3-theme-top-control-border);
  border-radius: 4px;
  appearance: none;
  -webkit-appearance: none;
  background: var(--v3-theme-top-control-bg);
  box-shadow: none;
  color: var(--v3-theme-top-control-icon);
  line-height: 1;
}

.v3-top-shell-actions .v3-profile-chip {
  width: auto;
  max-width: clamp(176px, 28vw, 270px);
  gap: 0.48rem;
  justify-content: flex-start;
  padding: 0 0.72rem 0 0.48rem;
  border-radius: 999px;
}

.v3-profile-chip__avatar {
  width: 24px;
  height: 24px;
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  background: var(--v3-theme-control-bg);
  color: var(--v3-theme-control-text-strong);
  font-size: 0.68rem;
  font-weight: 900;
  line-height: 1;
  text-transform: uppercase;
}

.v3-profile-chip__body {
  min-width: 0;
  display: inline-flex;
  align-items: center;
  gap: 0;
  text-align: left;
  white-space: nowrap;
}

.v3-profile-chip__id,
.v3-profile-chip__role {
  display: inline-flex;
  align-items: center;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.v3-profile-chip__id {
  min-width: 0;
  max-width: min(20ch, 18vw);
  color: var(--v3-theme-control-text-strong);
  font-size: 0.82rem;
  font-weight: 900;
}

.v3-profile-chip__role {
  flex: 0 0 auto;
  color: var(--v3-theme-text-muted);
  font-size: 0.78rem;
  font-weight: 800;
}

.v3-profile-chip__role::before {
  content: "\00b7";
  margin: 0 0.38rem;
  color: var(--v3-theme-text-muted);
  font-weight: 800;
}

.v3-top-shell-actions button:disabled {
  opacity: 0.52;
}

.v3-top-shell-actions svg {
  width: 18px;
  height: 18px;
  display: block;
  flex-shrink: 0;
}

@media (min-width: 641px) {
  #v3-admin-entry-btn {
    display: none;
  }
}

.v3-topbar__actions,
.v3-pill-row {
  display: flex;
  flex-wrap: wrap;
  gap: var(--v3-space-2);
  align-items: center;
}

.v3-topbar__actions {
  justify-content: space-between;
  max-width: none;
}

.v3-shell-status {
  width: 100%;
  color: var(--v3-color-muted);
  font-size: 0.88rem;
  font-weight: 750;
  line-height: 1.35;
  text-align: left;
}

.v3-icon-button {
  display: inline-flex;
  width: 44px;
  height: 44px;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--v3-theme-control-border);
  border-radius: var(--v3-radius-control);
  background: var(--v3-theme-control-bg);
  color: var(--v3-theme-text-muted);
  font-weight: 900;
}

.v3-back-to-top {
  position: fixed;
  right: clamp(12px, 3vw, 28px);
  bottom: calc(18px + env(safe-area-inset-bottom, 0px));
  z-index: 90;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.42rem;
  padding: 0 0.88rem;
  border: 1px solid var(--v3-theme-control-border-strong);
  border-radius: 999px;
  appearance: none;
  -webkit-appearance: none;
  background: var(--v3-theme-surface-elevated);
  color: var(--v3-theme-text-strong);
  box-shadow: 0 14px 32px var(--v3-theme-panel-shadow-color);
  font: inherit;
  font-size: 0.82rem;
  font-weight: 900;
  line-height: 1;
  cursor: pointer;
}

.v3-back-to-top[hidden] {
  display: none;
}

.v3-back-to-top:hover {
  border-color: var(--v3-color-ace-blue);
  color: var(--v3-color-ace-blue);
}

.v3-back-to-top:focus-visible {
  outline: 3px solid var(--v3-theme-focus);
  outline-offset: 3px;
}

.v3-back-to-top svg {
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.1;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.v3-workspace-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--v3-shell-gap);
  align-items: start;
}

.v3-workspace-grid[hidden] {
  display: none;
}

.v3-main-stack {
  display: grid;
  gap: var(--v3-shell-gap);
}

.v3-main-stack[hidden] {
  display: none;
}

.v3-card {
  padding: var(--v3-card-pad);
  border: 1px solid var(--v3-card-border);
  border-radius: var(--v3-radius-card);
  background: var(--v3-theme-surface);
  box-shadow: var(--v3-card-shadow);
}

.v3-shell .v3-recent-jobs--reduced {
  padding: clamp(0.75rem, 1.35vw, 0.98rem);
}

.v3-shell .v3-recent-summary-slot:not([hidden]) {
  margin-bottom: clamp(0.38rem, 0.82vw, 0.58rem);
}

.v3-shell .v3-recent-summary {
  position: relative;
  padding: 3px 34px 3px 3px;
  border: 1px solid rgba(0, 117, 173, 0.52);
  background: #eef8fd;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.88), 0 8px 18px rgba(18, 32, 51, 0.08);
}

.v3-shell .v3-recent-summary::after {
  content: "";
  position: absolute;
  top: 50%;
  right: 14px;
  width: 0.55rem;
  height: 0.55rem;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  color: var(--v3-theme-control-text-strong);
  transform: translateY(-58%) rotate(45deg);
  opacity: 0.82;
}

.v3-shell .v3-recent-summary:hover,
.v3-shell .v3-recent-summary:focus-visible {
  border-color: var(--v3-theme-focus-active-border);
  box-shadow: 0 0 0 3px var(--v3-theme-focus-active-shadow);
}

.v3-shell .v3-recent-summary__main {
  border-color: transparent;
  background: #ffffff;
  box-shadow: none;
}

.v3-shell .v3-recent-summary + .v3-start-new-job,
.v3-shell .v3-recent-summary-slot:not([hidden]) + .v3-recent-body .v3-start-new-job {
  margin-top: clamp(1.05rem, 2.1vw, 1.55rem);
}

.v3-shell .v3-recent-summary-slot:not([hidden]) + .v3-recent-body {
  padding-top: clamp(0.9rem, 1.8vw, 1.25rem);
  border-top: 1px solid rgba(0, 117, 173, 0.18);
}

.v3-shell .v3-recent-jobs--collapsed .v3-recent-summary-slot:not([hidden]) + .v3-recent-body {
  padding-top: 0;
  border-top: 0;
}

.v3-shell .v3-start-new-job {
  min-height: 48px;
  border-color: rgba(0, 117, 173, 0.48);
  background: #f4fbff;
  color: var(--v3-theme-control-text-strong);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.88), 0 6px 14px rgba(18, 32, 51, 0.07);
}

.v3-shell .v3-recent-jobs--collapsed .v3-start-new-job {
  min-height: 36px;
  background: transparent;
  box-shadow: none;
}

.v3-shell .v3-start-new-job:hover,
.v3-shell .v3-start-new-job:focus-visible {
  color: var(--v3-theme-control-text-strong);
}

.v3-shell .v3-create-field input,
.v3-shell .v3-create-field select,
.v3-shell .v3-recent-search input {
  border-color: rgba(0, 117, 173, 0.6);
  background: #f4faff;
  box-shadow: inset 0 0 0 1px rgba(0, 161, 238, 0.16), 0 1px 0 rgba(18, 32, 51, 0.08);
}

.v3-shell .v3-create-field input,
.v3-shell .v3-create-field select,
.v3-shell .v3-recent-search input {
  min-height: 44px;
  color: var(--v3-theme-control-text-strong);
}

.v3-shell .v3-create-field select {
  color-scheme: light;
}

.v3-shell .v3-create-field select option {
  background-color: #ffffff;
  color: #0f172a;
}

.v3-shell .v3-create-field input::placeholder,
.v3-shell .v3-recent-search input::placeholder {
  color: var(--v3-theme-text-muted);
  opacity: 0.92;
}

.v3-shell .v3-start-new-job--compact {
  margin-bottom: var(--v3-space-3);
}

.v3-shell .v3-create-job-card {
  padding: clamp(0.95rem, 1.5vw, 1.16rem);
}

.v3-shell .v3-create-job-form {
  gap: clamp(0.78rem, 1.3vw, 1rem);
}

.v3-shell .v3-create-actions {
  padding-top: 0.18rem;
}

:root[data-v3-theme="dark"] .v3-shell .v3-create-field input,
:root[data-v3-theme="dark"] .v3-shell .v3-create-field select,
:root[data-v3-theme="dark"] .v3-shell .v3-recent-search input {
  border-color: rgba(125, 211, 252, 0.72);
  background: linear-gradient(180deg, #132033, #0b1424);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.075), 0 0 0 1px rgba(56, 189, 248, 0.16);
}

:root[data-v3-theme="dark"] .v3-shell .v3-create-field select {
  color-scheme: dark;
  color: #f8fafc;
}

:root[data-v3-theme="dark"] .v3-shell .v3-create-field select option {
  background-color: #0b1424;
  color: #f8fafc;
}

:root[data-v3-theme="dark"] .v3-shell .v3-recent-summary {
  border-color: rgba(125, 211, 252, 0.64);
  background: #132033;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.07), 0 12px 24px rgba(0, 0, 0, 0.24);
}

:root[data-v3-theme="dark"] .v3-shell .v3-recent-summary__main {
  background: #0b1424;
}

:root[data-v3-theme="dark"] .v3-shell .v3-recent-summary-slot:not([hidden]) + .v3-recent-body {
  border-top-color: rgba(125, 211, 252, 0.2);
}

:root[data-v3-theme="dark"] .v3-shell .v3-start-new-job {
  border-color: rgba(125, 211, 252, 0.64);
  background: #132033;
  color: var(--v3-theme-control-text-strong);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.07), 0 8px 18px rgba(0, 0, 0, 0.22);
}

.v3-card__header {
  display: flex;
  gap: var(--v3-space-3);
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: var(--v3-space-3);
}

.v3-card__header--rail {
  align-items: center;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.v3-card__header--rail:focus-within {
  border-radius: var(--v3-radius-control);
}

.v3-card h2 {
  margin: 0;
  color: var(--v3-theme-text-strong);
  font-size: clamp(1.02rem, 1.5vw, 1.24rem);
  letter-spacing: 0;
}

.v3-kicker,
.v3-eyebrow {
  margin: 0 0 var(--v3-space-1);
  color: var(--v3-color-ace-blue);
  font-size: 0.75rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.v3-muted {
  max-width: 62ch;
  margin: var(--v3-space-1) 0 0;
  color: var(--v3-color-muted);
  line-height: 1.5;
}

.v3-sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.v3-pill,
.v3-count-pill {
  display: inline-flex;
  min-height: 38px;
  align-items: center;
  justify-content: center;
  padding: 0 var(--v3-space-3);
  border: 1px solid var(--v3-color-border-strong);
  border-radius: var(--v3-radius-pill);
  background: var(--v3-color-surface-soft);
  color: var(--v3-theme-count-pill-text);
  font-size: 0.88rem;
  font-weight: 850;
  white-space: nowrap;
}

.v3-pill--accent {
  background: var(--v3-color-ace-blue);
  color: var(--v3-theme-control-bg);
}

.v3-pill--muted,
.v3-count-pill {
  border-color: var(--v3-color-border);
  background: var(--v3-theme-surface-muted);
  color: var(--v3-color-muted);
}

.v3-mini-chip {
  display: inline-flex;
  width: fit-content;
  min-height: 28px;
  align-items: center;
  gap: 0.35rem;
  padding: 0.25rem 0.55rem;
  border: 1px solid var(--v3-color-border);
  border-radius: var(--v3-radius-pill);
  background: var(--v3-theme-control-bg);
  color: var(--v3-color-muted);
  font-size: 0.72rem;
  font-weight: 800;
}

.v3-semantic-icon {
  width: 15px;
  height: 15px;
  flex: 0 0 auto;
}

.v3-mini-chip--ok {
  background: var(--v3-theme-status-ok-bg);
  color: var(--v3-theme-status-ok-text);
}

.v3-mini-chip--warn {
  background: var(--v3-theme-status-warn-bg);
  color: var(--v3-theme-status-warn-text);
}

.v3-mini-chip--danger {
  background: var(--v3-theme-status-danger-bg);
  color: var(--v3-theme-status-danger-text);
}

.v3-mini-chip--info {
  background: var(--v3-theme-status-info-bg);
  color: var(--v3-theme-status-info-text);
}

.v3-mini-chip--muted {
  background: var(--v3-theme-status-muted-bg);
  color: var(--v3-theme-status-muted-text);
}

.v3-empty-card {
  padding: var(--v3-space-3);
  border: 1px dashed var(--v3-theme-border);
  border-radius: var(--v3-radius-control);
  background: var(--v3-theme-surface-warm);
  color: var(--v3-theme-text-muted);
  font-weight: 700;
}

.v3-detail-list--compact {
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 11rem), 1fr));
  gap: 6px;
}

.v3-detail-list {
  display: grid;
  min-width: 0;
  gap: var(--v3-space-2);
  margin: 0;
}

.v3-detail-list div {
  min-width: 0;
  padding: 0.62rem 0.7rem;
  border: 1px solid var(--v3-theme-divider-alpha);
  border-radius: var(--v3-radius-control);
  background: var(--v3-theme-detail-row-bg);
}

.v3-detail-list dt {
  color: var(--v3-color-muted);
  font-size: 0.76rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.v3-detail-list dd {
  min-width: 0;
  margin: var(--v3-space-1) 0 0;
  color: var(--v3-color-text-strong);
  font-weight: 850;
  overflow-wrap: anywhere;
}

@media (max-width: 640px) {
  .v3-shell {
      --v3-shell-pad-x: 10px;
      --v3-shell-pad-y: 10px;
      --v3-shell-gap: 0.65rem;
      --v3-card-pad: 0.72rem;
      --v3-topbar-pad-top: 0.34rem;
      --v3-topbar-pad-bottom: 0.38rem;
      --v3-topbar-clearance: 0.58rem;
    }

  .v3-topbar {
      gap: var(--v3-space-2);
    }

  .v3-top-shell-actions .v3-profile-chip {
      display: none;
    }

  .v3-back-to-top {
      right: 12px;
      bottom: calc(14px + env(safe-area-inset-bottom, 0px));
      width: 46px;
      padding: 0;
    }

  .v3-back-to-top__label {
      position: absolute;
      width: 1px;
      height: 1px;
      padding: 0;
      margin: -1px;
      overflow: hidden;
      clip: rect(0, 0, 0, 0);
      white-space: nowrap;
      border: 0;
    }

  .v3-main-stack {
      gap: 0.65rem;
    }

  .v3-card__header {
      gap: var(--v3-space-2);
      align-items: center;
      margin-bottom: var(--v3-space-2);
    }

  .v3-pill,
  .v3-count-pill {
      min-height: 32px;
      padding: 0 0.65rem;
      font-size: 0.78rem;
    }

  .v3-mini-chip {
      max-width: 100%;
      white-space: normal;
    }
}

@media (min-width: 881px) {
  .v3-shell {
      padding-top: var(--v3-shell-pad-y);
    }

  .v3-topbar {
      flex-direction: row;
      align-items: flex-start;
    }

  .v3-brand {
      align-items: flex-start;
    }

  .v3-topbar__right {
      display: flex;
      flex: 1;
      flex-direction: row;
      align-items: flex-start;
      justify-content: flex-end;
      gap: var(--v3-space-3);
      justify-items: end;
    }

  .v3-top-shell-actions {
      order: 2;
    }

  .v3-topbar__actions {
      order: 1;
    }

  .v3-topbar__actions,
  .v3-top-shell-actions {
      justify-content: flex-end;
    }

  .v3-topbar__actions {
      max-width: 520px;
    }

  .v3-shell-status {
      width: auto;
      text-align: right;
    }

  .v3-workspace-grid {
      grid-template-columns: var(--v3-left-column) minmax(0, 1fr);
    }

  .v3-main-stack > .v3-card {
      min-width: 0;
    }
}
