@import "./tokens.css";

:root {
  color-scheme: light;
  --portal-canvas: var(--ul-color-canvas);
  --portal-surface: var(--ul-color-surface);
  --portal-surface-subtle: var(--ul-color-surface-raised);
  --portal-map-field: var(--ul-color-map);
  --portal-text: var(--ul-color-text);
  --portal-text-muted: var(--ul-color-text-muted);
  --portal-primary: var(--ul-color-primary);
  --portal-on-primary: var(--ul-color-on-primary);
  --portal-attention: var(--ul-color-accent);
  --portal-success: var(--ul-color-success);
  --portal-warning: var(--ul-color-warning);
  --portal-danger: var(--ul-color-error);
  --portal-border: var(--ul-color-border);
  --portal-border-strong: var(--ul-color-text-muted);
  --portal-focus: var(--ul-color-focus);
  --portal-font-ui: var(--ul-type-family-sans);
  --portal-font-mono: var(--ul-type-family-mono);
  --portal-space-1: var(--ul-space-2xs);
  --portal-space-2: var(--ul-space-xs);
  --portal-space-3: var(--ul-space-sm);
  --portal-space-4: var(--ul-space-md);
  --portal-space-6: var(--ul-space-lg);
  --portal-space-8: var(--ul-space-xl);
  --portal-radius-sm: var(--ul-radius-sm);
  --portal-radius-md: var(--ul-radius-md);
  --portal-shadow: var(--ul-elevation-raised);
  --portal-motion: var(--ul-motion-base) ease-out;
}

* {
  box-sizing: border-box;
}

html {
  background: var(--portal-canvas);
  color: var(--portal-text);
  font-family: var(--portal-font-ui);
}

body {
  min-width: 20rem;
  min-height: 100vh;
  margin: 0;
  background: var(--portal-canvas);
  color: var(--portal-text);
  font-family: var(--portal-font-ui);
  line-height: 1.5;
}

a {
  color: var(--portal-primary);
  text-underline-offset: 0.2em;
}

button,
input,
select,
textarea {
  color: inherit;
  font: inherit;
}

button,
select,
input[type="button"],
input[type="submit"] {
  min-height: var(--ul-touch-minimum);
}

input,
select,
textarea {
  min-height: var(--ul-touch-minimum);
  border: 1px solid var(--portal-border-strong);
  border-radius: var(--portal-radius-sm);
  background: var(--portal-surface);
  padding: var(--portal-space-2) var(--portal-space-3);
}

:where(a, button, input, select, textarea, summary):focus-visible {
  outline: 3px solid var(--portal-focus);
  outline-offset: 3px;
}

.ul-skip-link {
  position: fixed;
  z-index: 1000;
  top: var(--portal-space-2);
  left: var(--portal-space-2);
  translate: 0 -200%;
  border-radius: var(--portal-radius-sm);
  background: var(--portal-surface);
  padding: var(--portal-space-3) var(--portal-space-4);
  color: var(--portal-text);
  font-weight: 700;
  box-shadow: var(--portal-shadow);
}

.ul-skip-link:focus {
  translate: 0;
}

.ul-shell__header {
  position: sticky;
  z-index: 50;
  top: 0;
  display: flex;
  min-height: 4.5rem;
  align-items: center;
  gap: var(--portal-space-6);
  border-bottom: 1px solid var(--portal-border);
  background: var(--portal-surface);
  padding: var(--portal-space-3) clamp(1rem, 3vw, 2rem);
  box-shadow: var(--portal-shadow);
}

.ul-shell__brand {
  display: inline-flex;
  flex: 0 0 auto;
  min-height: var(--ul-touch-minimum);
  align-items: center;
  gap: var(--portal-space-2);
  color: var(--portal-text);
  font-size: 1.125rem;
  font-weight: 750;
  text-decoration: none;
}

.ul-shell__brand-mark {
  display: block;
  box-sizing: border-box;
  width: 2.5rem;
  height: 2.5rem;
  object-fit: contain;
  padding: 0.375rem;
  border-radius: var(--portal-radius-sm);
  border: 1px solid var(--portal-border);
  background: var(--portal-surface);
}

.ul-shell__nav {
  display: flex;
  align-items: center;
  gap: var(--portal-space-1);
}

.ul-shell__nav-link {
  display: inline-flex;
  min-height: var(--ul-touch-minimum);
  align-items: center;
  border-radius: var(--portal-radius-sm);
  padding: 0 var(--portal-space-3);
  color: var(--portal-text-muted);
  font-weight: 650;
  text-decoration: none;
}

.ul-shell__nav-link:hover,
.ul-shell__nav-link[aria-current="page"] {
  background: var(--portal-surface-subtle);
  color: var(--portal-text);
}

.ul-shell__nav-link[aria-current="page"] {
  box-shadow: inset 0 -0.2rem var(--portal-primary);
}

.ul-shell__context {
  display: flex;
  min-width: 0;
  flex: 1 1 auto;
  align-items: center;
  justify-content: flex-end;
  gap: var(--portal-space-4);
}

.ul-org-context {
  display: grid;
  min-width: 10rem;
  grid-template-columns: minmax(0, auto) auto;
  align-items: center;
  column-gap: var(--portal-space-2);
}

.ul-org-context__label {
  grid-column: 1 / -1;
  color: var(--portal-text-muted);
  font-size: 0.75rem;
  font-weight: 650;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.ul-org-context__select {
  max-width: 13rem;
  height: var(--ul-touch-minimum);
  min-height: var(--ul-touch-minimum);
  padding-block: 0;
  font-weight: 700;
}

.ul-org-context__name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ul-org-context__role {
  border: 1px solid var(--portal-border);
  border-radius: 999px;
  padding: 0 var(--portal-space-2);
  color: var(--portal-text-muted);
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: lowercase;
}

.ul-shell__account {
  display: flex;
  align-items: center;
  gap: var(--portal-space-2);
}

.ul-shell__email {
  max-width: 12rem;
  overflow: hidden;
  color: var(--portal-text-muted);
  font-size: 0.875rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ul-shell__menu {
  display: none;
  position: relative;
}

.ul-shell__menu summary {
  display: inline-flex;
  min-height: var(--ul-touch-minimum);
  cursor: pointer;
  align-items: center;
  border: 1px solid var(--portal-border-strong);
  border-radius: var(--portal-radius-sm);
  padding: 0 var(--portal-space-3);
  font-weight: 700;
  list-style: none;
}

.ul-shell__menu summary::-webkit-details-marker {
  display: none;
}

.ul-shell__nav--mobile {
  position: absolute;
  top: calc(100% + var(--portal-space-2));
  right: 0;
  width: min(18rem, calc(100vw - 2rem));
  flex-direction: column;
  align-items: stretch;
  border: 1px solid var(--portal-border);
  border-radius: var(--portal-radius-md);
  background: var(--portal-surface);
  padding: var(--portal-space-2);
  box-shadow: var(--portal-shadow);
}

.ul-shell__mobile-account {
  display: grid;
  gap: var(--portal-space-2);
  margin-top: var(--portal-space-2);
  border-top: 1px solid var(--portal-border);
  padding: var(--portal-space-3) var(--portal-space-2) var(--portal-space-2);
  color: var(--portal-text-muted);
  overflow-wrap: anywhere;
}

.ul-shell__main {
  width: min(100% - 2rem, 75rem);
  margin-inline: auto;
  padding-block: clamp(1.25rem, 4vw, 2.5rem) 4rem;
}

.ul-button {
  display: inline-flex;
  min-height: var(--ul-touch-minimum);
  cursor: pointer;
  align-items: center;
  justify-content: center;
  border: 1px solid transparent;
  border-radius: var(--portal-radius-sm);
  background: var(--portal-primary);
  padding: 0 var(--portal-space-4);
  color: var(--portal-on-primary);
  font-weight: 700;
  text-decoration: none;
  transition:
    filter var(--portal-motion),
    transform var(--portal-motion);
}

.ul-button:hover {
  filter: brightness(0.9);
}

.ul-button:active {
  transform: translateY(1px);
}

.ul-button:disabled {
  cursor: not-allowed;
  filter: grayscale(1);
  opacity: 0.6;
}

.ul-button--quiet {
  border-color: var(--portal-border);
  background: transparent;
  color: var(--portal-text);
}

.ul-page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--portal-space-4);
  margin-bottom: var(--portal-space-6);
}

.ul-page-header__title-group {
  min-width: 0;
}

.ul-page-header h1,
.ul-detail-header h1 {
  margin: 0;
  font-size: clamp(1.75rem, 4vw, 2.5rem);
  line-height: 1.15;
}

.ul-page-header__eyebrow,
.ul-section-heading__eyebrow,
.ul-detail-header__eyebrow {
  display: block;
  margin-bottom: var(--portal-space-1);
  color: var(--portal-text-muted);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.ul-page-header__meta,
.ul-detail-header__subtitle {
  margin: var(--portal-space-1) 0 0;
  color: var(--portal-text-muted);
}

.ul-panel {
  border: 1px solid var(--portal-border);
  border-radius: var(--portal-radius-md);
  background: var(--portal-surface);
  box-shadow: var(--portal-shadow);
}

.ul-filter-bar {
  display: grid;
  grid-template-columns: minmax(14rem, 1fr) minmax(10rem, auto);
  gap: var(--portal-space-3);
  margin-bottom: var(--portal-space-4);
  padding: var(--portal-space-4);
}

.ul-field {
  display: grid;
  gap: var(--portal-space-1);
}

.ul-field__label {
  color: var(--portal-text-muted);
  font-size: 0.875rem;
  font-weight: 700;
}

.ul-table-wrap {
  overflow-x: auto;
}

.ul-table {
  width: 100%;
  border-collapse: collapse;
}

.ul-table th,
.ul-table td {
  padding: var(--portal-space-3) var(--portal-space-4);
  border-bottom: 1px solid var(--portal-border);
  text-align: left;
  vertical-align: middle;
}

.ul-table th {
  background: var(--portal-surface-subtle);
  color: var(--portal-text-muted);
  font-size: 0.75rem;
  font-weight: 750;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.ul-table tbody tr:last-child td {
  border-bottom: 0;
}

.ul-table tbody tr:hover {
  background: color-mix(
    in srgb,
    var(--portal-primary) 5%,
    var(--portal-surface)
  );
}

.ul-table__numeric {
  font-family: var(--portal-font-mono);
  font-variant-numeric: tabular-nums;
  text-align: right !important;
}

.ul-ticket-link {
  display: inline-flex;
  min-height: var(--ul-touch-minimum);
  align-items: center;
  font-family: var(--portal-font-mono);
  font-weight: 700;
}

.ul-status-badge {
  display: inline-flex;
  min-height: 2rem;
  align-items: center;
  gap: var(--portal-space-2);
  border: 1px solid currentColor;
  border-radius: 999px;
  padding: 0 var(--portal-space-3);
  font-size: 0.8125rem;
  font-weight: 750;
  line-height: 1.2;
  white-space: nowrap;
}

.ul-status-badge__icon {
  font-family: var(--portal-font-mono);
  font-size: 1rem;
}

.ul-status-badge--info {
  color: var(--portal-primary);
}

.ul-status-badge--success {
  color: var(--portal-success);
}

.ul-status-badge--warning {
  color: var(--portal-warning);
}

.ul-status-badge--danger {
  color: var(--portal-danger);
}

.ul-status-badge--neutral {
  color: var(--portal-text-muted);
}

.ul-page-state {
  display: flex;
  min-height: 7rem;
  align-items: center;
  justify-content: center;
  gap: var(--portal-space-3);
  border: 1px dashed var(--portal-border-strong);
  border-radius: var(--portal-radius-md);
  background: var(--portal-surface-subtle);
  padding: var(--portal-space-6);
  color: var(--portal-text-muted);
  text-align: left;
}

.ul-page-state--error {
  border-style: solid;
  color: var(--portal-danger);
}

.ul-page-state__icon {
  display: inline-grid;
  width: 2rem;
  height: 2rem;
  flex: 0 0 auto;
  place-items: center;
  border: 1px solid currentColor;
  border-radius: 50%;
  font-family: var(--portal-font-mono);
  font-weight: 800;
}

.ul-page-state__detail {
  margin-top: var(--portal-space-1);
}

.ul-detail-header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(12rem, auto);
  gap: var(--portal-space-6);
  align-items: end;
  margin-bottom: var(--portal-space-4);
}

.ul-detail-header__title-row {
  display: flex;
  align-items: baseline;
  gap: var(--portal-space-3);
  flex-wrap: wrap;
}

.ul-detail-header__title {
  font-size: clamp(1.125rem, 2vw, 1.375rem);
  font-weight: 550;
}

.ul-breadcrumb {
  margin-bottom: var(--portal-space-4);
}

.ul-breadcrumb a {
  display: inline-flex;
  min-height: var(--ul-touch-minimum);
  align-items: center;
  font-weight: 700;
}

.ul-job-summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--portal-space-4);
  margin-block: var(--portal-space-4) var(--portal-space-6);
  padding: var(--portal-space-4);
}

.ul-job-summary__description {
  grid-column: 1 / -1;
  margin: 0;
  padding-top: var(--portal-space-3);
  border-top: 1px solid var(--portal-border);
}

.ul-metric {
  display: grid;
  align-content: start;
  gap: var(--portal-space-1);
}

.ul-metric__label {
  color: var(--portal-text-muted);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.ul-metric__value {
  font-family: var(--portal-font-mono);
  font-size: 1.5rem;
  font-variant-numeric: tabular-nums;
  line-height: 1.2;
}

.ul-metric__detail {
  color: var(--portal-text-muted);
  font-size: 0.875rem;
}

.ul-live-strip {
  display: flex;
  align-items: center;
  gap: var(--portal-space-3);
  flex-wrap: wrap;
  margin-bottom: var(--portal-space-4);
  border: 1px solid var(--portal-border);
  border-radius: var(--portal-radius-md);
  background: var(--portal-surface);
  padding: var(--portal-space-3) var(--portal-space-4);
}

.ul-live-strip__latest {
  min-width: 12rem;
  flex: 1 1 auto;
  color: var(--portal-text-muted);
  font-family: var(--portal-font-mono);
  font-size: 0.875rem;
}

.ul-map-section {
  overflow: hidden;
  border: 1px solid var(--portal-border);
  border-radius: var(--portal-radius-md);
  background: var(--portal-map-field);
  box-shadow: var(--portal-shadow);
}

.ul-section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--portal-space-4);
  border-bottom: 1px solid var(--portal-border);
  background: var(--portal-surface);
  padding: var(--portal-space-3) var(--portal-space-4);
}

.ul-section-heading h2 {
  margin: 0;
  font-size: 1.25rem;
}

.ul-map {
  position: relative;
  height: 30rem;
  overflow: hidden;
  background: var(--portal-map-field);
}

.ul-map--compact {
  height: 20rem;
}

.ul-map--detail {
  height: min(32.5rem, 65vh);
  min-height: 24rem;
}

.ul-map__canvas {
  height: 100%;
}

.ul-map__fallback {
  display: grid;
  place-items: center;
  padding: var(--portal-space-6);
}

.ul-map-popup-table {
  border-collapse: collapse;
  font-family: var(--portal-font-ui);
}

.ul-map-popup-table td {
  padding-block: var(--portal-space-1);
}

.ul-map-popup-table__label {
  padding-right: var(--portal-space-3);
  color: var(--portal-text-muted);
  white-space: nowrap;
}

.ul-map-popup-table__value {
  font-family: var(--portal-font-mono);
  font-weight: 650;
}

.ul-visually-hidden {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  overflow: hidden !important;
  clip: rect(0 0 0 0) !important;
  clip-path: inset(50%) !important;
  white-space: nowrap !important;
}

/* CSS custom properties are not valid in media conditions; values mirror the generated breakpoint tokens. */
@media (max-width: 1200px) {
  .ul-shell__nav--desktop,
  .ul-shell__email {
    display: none;
  }

  .ul-shell__menu {
    display: block;
  }
}

@media (max-width: 900px) {
  .ul-shell__header {
    align-items: flex-start;
    gap: var(--portal-space-3);
    flex-wrap: wrap;
  }

  .ul-shell__context {
    width: 100%;
    justify-content: space-between;
  }

  .ul-org-context {
    min-width: 0;
    flex: 1 1 auto;
  }

  .ul-shell__account {
    order: 3;
  }

  .ul-page-header,
  .ul-detail-header {
    grid-template-columns: 1fr;
    flex-direction: column;
  }

  .ul-page-header .ul-button {
    width: 100%;
  }

  .ul-filter-bar {
    grid-template-columns: 1fr;
  }

  .ul-table-wrap {
    overflow: visible;
  }

  .ul-table,
  .ul-table tbody,
  .ul-table tr,
  .ul-table td {
    display: block;
    width: 100%;
  }

  .ul-table thead {
    display: none;
  }

  .ul-table tbody {
    display: grid;
    gap: var(--portal-space-3);
  }

  .ul-table tbody tr {
    overflow: hidden;
    border: 1px solid var(--portal-border);
    border-radius: var(--portal-radius-md);
    background: var(--portal-surface);
  }

  .ul-table td {
    display: grid;
    min-height: var(--ul-touch-minimum);
    grid-template-columns: 7rem minmax(0, 1fr);
    align-items: center;
    gap: var(--portal-space-3);
    border-bottom: 1px solid var(--portal-border);
    text-align: left !important;
  }

  .ul-table td::before {
    content: attr(data-label);
    color: var(--portal-text-muted);
    font-size: 0.75rem;
    font-weight: 750;
    letter-spacing: 0.04em;
    text-transform: uppercase;
  }

  .ul-table td:first-child {
    background: var(--portal-surface-subtle);
  }

  .ul-table td:last-child {
    border-bottom: 0;
  }

  .ul-job-summary {
    grid-template-columns: 1fr 1fr;
  }

  .ul-map--detail {
    height: 28rem;
    min-height: 22rem;
  }
}

@media (max-width: 600px) {
  .ul-shell__header {
    position: static;
  }

  .ul-shell__brand span:last-child,
  .ul-shell__account {
    display: none;
  }

  .ul-org-context__role {
    display: none;
  }

  .ul-shell__main {
    width: min(100% - 1.5rem, 75rem);
  }

  .ul-page-header h1,
  .ul-detail-header h1 {
    overflow-wrap: anywhere;
  }

  .ul-job-summary {
    grid-template-columns: 1fr;
  }

  .ul-job-summary__description {
    grid-column: auto;
  }

  .ul-live-strip {
    align-items: flex-start;
    flex-direction: column;
  }

  .ul-map--detail {
    height: 24rem;
    min-height: 20rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}

@media (forced-colors: active) {
  .ul-status-badge,
  .ul-page-state,
  .ul-panel,
  .ul-map-section {
    forced-color-adjust: auto;
  }
}
