/* ShipmentMonitor PWA — mobile-first day theme (see docs/DESIGN_GUIDE.md) */

:root {
  color-scheme: light;
  -webkit-tap-highlight-color: transparent;

  --bg-app: #f8fafc;
  --bg-surface: #ffffff;
  --bg-card: #ffffff;
  --bg-elevated: #f1f5f9;
  --bg-subtle: #f1f5f9;

  --border: #e2e8f0;
  --border-subtle: #e8eef4;

  --sidebar-bg: #0f172a;
  --sidebar-text: #cbd5e1;
  --sidebar-text-strong: #f8fafc;
  --sidebar-muted: #94a3b8;
  --sidebar-hover: rgba(248, 250, 252, 0.08);
  --sidebar-active: #3b82f6;

  --text-primary: #1f2937;
  --text-secondary: #4b5563;
  --text-label: #5f6772;
  --text-muted: #6b7280;

  --info: #3b82f6;
  --info-soft: #eff6ff;
  --info-text: #1d4ed8;
  --success: #22c55e;
  --success-soft: #f0fdf4;
  --success-text: #15803d;
  --warning: #f59e0b;
  --warning-soft: #fffbeb;
  --warning-text: #b45309;
  --danger: #ef4444;
  --danger-soft: #fef2f2;
  --danger-text: #b91c1c;

  --accent: var(--info);
  --accent-hover: #2563eb;
  --accent-soft: var(--info-soft);
  --hover-overlay: rgba(31, 41, 55, 0.05);

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --shadow-xs: 0 1px 2px rgba(15, 23, 42, 0.05);
  --shadow-sm: 0 1px 3px rgba(15, 23, 42, 0.07), 0 1px 2px rgba(15, 23, 42, 0.04);

  --nav-height: 4.5rem;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --header-height: 3.25rem;
}

[data-theme="dark"] {
  color-scheme: dark;

  --bg-app: #0d1117;
  --bg-surface: #161b22;
  --bg-card: #21262d;
  --bg-elevated: #2b3038;
  --bg-subtle: #30363d;

  --border: #30363d;
  --border-subtle: #3d444d;

  --text-primary: #e6edf3;
  --text-secondary: #8b949e;
  --text-label: #8b949e;
  --text-muted: #6e7681;

  --info-soft: rgba(56, 139, 253, 0.15);
  --info-text: #58a6ff;
  --success-soft: rgba(34, 197, 94, 0.15);
  --success-text: #3fb950;
  --warning-soft: rgba(245, 158, 11, 0.15);
  --warning-text: #d29922;
  --danger-soft: rgba(239, 68, 68, 0.15);
  --danger-text: #f85149;

  --hover-overlay: rgba(255, 255, 255, 0.06);
  --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.35);
}

@media (prefers-color-scheme: dark) {
  [data-theme="system"] {
    color-scheme: dark;
    --bg-app: #0d1117;
    --bg-surface: #161b22;
    --bg-card: #21262d;
    --bg-elevated: #2b3038;
    --bg-subtle: #30363d;
    --border: #30363d;
    --border-subtle: #3d444d;
    --text-primary: #e6edf3;
    --text-secondary: #8b949e;
    --text-label: #8b949e;
    --text-muted: #6e7681;
    --info-soft: rgba(56, 139, 253, 0.15);
    --info-text: #58a6ff;
    --success-soft: rgba(34, 197, 94, 0.15);
    --success-text: #3fb950;
    --warning-soft: rgba(245, 158, 11, 0.15);
    --warning-text: #d29922;
    --danger-soft: rgba(239, 68, 68, 0.15);
    --danger-text: #f85149;
    --hover-overlay: rgba(255, 255, 255, 0.06);
    --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.35);
  }
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  overflow-x: hidden;
}

body {
  background: var(--bg-app);
  color: var(--text-primary);
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}

.app-shell {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

.app-workspace {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-width: 0;
}

.desktop-sidebar,
.desktop-topbar,
.shipment-table-wrap,
.desktop-only,
html.is-mobile .desktop-only {
  display: none;
}

html.is-mobile .desktop-only.view,
html.is-mobile .desktop-only.view.active {
  display: none !important;
}

@media (max-width: 899.98px) {
  .desktop-only,
  .desktop-only.view,
  .desktop-only.view.active {
    display: none !important;
  }

  #view-shipments .shipment-table-wrap {
    display: none !important;
  }

  #view-shipments .shipment-list {
    display: block;
  }

  .shipments-toolbar {
    flex-wrap: nowrap;
    gap: 8px;
  }

  .shipments-clear-btn {
    width: auto;
    flex: 0 0 auto;
  }

  #shipments-filters .filter-chip {
    min-height: 36px;
    padding: 0 12px;
    font-size: 0.75rem;
  }

  .pm-list-toolbar {
    flex-wrap: wrap;
  }

  #pm-clear-filters {
    min-height: 40px;
  }

  .shipments-filter-wrap {
    margin: 0 -4px;
  }
}

.mobile-header {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: var(--header-height);
  padding: 8px 16px;
  border-bottom: 1px solid var(--border);
  background: color-mix(in srgb, var(--bg-surface) 95%, transparent);
  backdrop-filter: blur(12px);
}

.logo-mark {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: var(--accent);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.85rem;
  box-shadow: var(--shadow-xs);
  flex-shrink: 0;
}

.header-titles {
  min-width: 0;
  flex: 1;
}

.header-titles h1 {
  margin: 0;
  font-size: 0.9375rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.header-titles p {
  margin: 0;
  font-size: 0.75rem;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.app-main {
  flex: 1;
  width: 100%;
  max-width: 640px;
  margin: 0 auto;
  padding: 16px 16px calc(var(--nav-height) + var(--safe-bottom) + 16px);
}

.app-main.detail-mode {
  padding-bottom: calc(var(--safe-bottom) + 24px);
}

.detail-stack {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.detail-card {
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--bg-card);
  box-shadow: var(--shadow-xs);
  padding: 16px;
}

.detail-summary-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.detail-tracking {
  margin: 0;
  font-size: 1.0625rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--text-primary);
  word-break: break-all;
}

.detail-description {
  margin: 0 0 12px;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-secondary);
  line-height: 1.45;
}

.detail-meta-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px 16px;
  margin: 0;
}

.detail-meta-grid div {
  min-width: 0;
}

.detail-meta-grid dt {
  margin: 0 0 2px;
  font-size: 0.6875rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-label);
}

.detail-meta-grid dd {
  margin: 0;
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.35;
}

.detail-actions-card {
  padding: 12px;
}

.detail-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin: 0;
}

.detail-actions button {
  width: 100%;
}

.detail-section {
  margin: 0;
}

.detail-empty {
  margin: 0;
  padding: 8px 4px;
  font-size: 0.875rem;
  color: var(--text-secondary);
  text-align: center;
}

.milestone-track {
  list-style: none;
  margin: 0;
  padding: 0;
}

.milestone-step {
  position: relative;
  display: flex;
  gap: 12px;
  padding-bottom: 18px;
}

.milestone-step:last-child {
  padding-bottom: 0;
}

.milestone-line {
  position: absolute;
  left: 8px;
  top: 20px;
  width: 2px;
  height: calc(100% - 8px);
  border-radius: 999px;
  background: var(--border-subtle);
}

.milestone-step.reached .milestone-line,
.milestone-step.current .milestone-line {
  background: var(--success);
}

.milestone-dot {
  position: relative;
  z-index: 1;
  flex-shrink: 0;
  width: 18px;
  height: 18px;
  margin-top: 1px;
  border-radius: 50%;
  border: 2px solid var(--border);
  background: var(--bg-elevated);
}

.milestone-step.reached .milestone-dot {
  border-color: var(--success);
  background: var(--success);
}

.milestone-step.current .milestone-dot {
  border-color: var(--info);
  background: var(--info-soft);
  box-shadow: 0 0 0 3px var(--info-soft);
}

.milestone-copy {
  min-width: 0;
  padding-top: 1px;
}

.milestone-label {
  margin: 0;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text-secondary);
  line-height: 1.35;
}

.milestone-step.reached .milestone-label,
.milestone-step.current .milestone-label {
  color: var(--text-primary);
}

.milestone-step.current .milestone-label {
  color: var(--info-text);
}

.milestone-time {
  margin: 2px 0 0;
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-muted);
}

.event-cards {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.event-card {
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--bg-card);
  box-shadow: var(--shadow-xs);
  padding: 14px 16px;
}

.event-date {
  margin: 0 0 6px;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-label);
}

.event-description {
  margin: 0;
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.4;
}

.event-location {
  margin: 6px 0 0;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text-secondary);
}

.event-time {
  margin: 4px 0 0;
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-muted);
}

.detail-map-card {
  padding: 0;
  overflow: hidden;
}

.map-preview {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 120px;
  background: linear-gradient(180deg, var(--info-soft) 0%, var(--bg-elevated) 100%);
  border-bottom: 1px solid var(--border-subtle);
}

.map-preview-pin {
  font-size: 2rem;
  line-height: 1;
  opacity: 0.85;
}

.map-meta-grid {
  padding: 16px 16px 0;
}

.detail-map-card .module-note {
  padding: 0 16px 16px;
}

#view-detail .link-btn {
  margin-bottom: 14px;
}

.view {
  display: none !important;
}

.view.active {
  display: block !important;
  animation: page-enter 220ms cubic-bezier(0.22, 1, 0.36, 1);
}

@keyframes page-enter {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

html.overview-only #view-detail,
html.overview-only #view-add {
  display: none !important;
}

.operational-strip {
  display: none;
}

.operational-strip strong {
  color: var(--text-primary);
}

.widget-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  grid-auto-rows: 1fr;
  gap: 10px;
  margin-bottom: 20px;
}

.dashboard-widget,
.widget-card {
  position: relative;
  display: flex;
  min-height: 116px;
  height: 100%;
  margin: 0;
  padding: 0;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--bg-card);
  box-shadow: var(--shadow-xs);
  cursor: pointer;
  overflow: hidden;
  transition: transform 180ms ease, box-shadow 180ms ease;
  -webkit-tap-highlight-color: transparent;
}

.widget-card:hover {
  box-shadow: var(--shadow-sm);
}

.widget-card:active {
  transform: scale(0.995);
}

.widget-card.active {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent);
}

.widget-accent {
  display: none;
}

.widget-accent-info {
  background: var(--info);
}

.widget-accent-success {
  background: var(--success);
}

.widget-accent-warning {
  background: var(--warning);
}

.widget-accent-danger {
  background: var(--danger);
}

.widget-inner {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  align-items: flex-start;
  flex: 1;
  width: 100%;
  min-height: 108px;
  padding: 16px 18px;
  box-sizing: border-box;
}

.widget-label {
  display: block;
  min-height: 0;
  margin: 0;
  padding: 0;
  font-size: 0.9375rem;
  font-weight: 700;
  line-height: 1.3;
  letter-spacing: -0.01em;
  text-align: left;
  text-transform: none;
  color: var(--text-primary);
}

.widget-value-wrap {
  display: flex;
  align-items: flex-end;
  justify-content: flex-start;
  min-height: 44px;
  width: 100%;
}

.widget-value {
  display: block;
  margin: 0;
  font-size: 1.75rem;
  font-weight: 700;
  line-height: 1;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
  text-align: left;
  color: var(--text-primary);
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
}

.section-header h2 {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--text-primary);
}

.text-link {
  border: none;
  background: none;
  padding: 0;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--info-text);
  cursor: pointer;
}

.card-surface {
  overflow: hidden;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--bg-card);
  box-shadow: var(--shadow-xs);
}

.shipment-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.shipment-item {
  display: block;
  width: 100%;
  text-align: left;
  border: none;
  background: var(--bg-card);
  padding: 14px 16px;
  cursor: pointer;
  transition: background 150ms ease;
}

.card-surface .shipment-item + .shipment-item {
  border-top: 1px solid var(--border-subtle);
}

.shipment-item:active {
  background: var(--bg-elevated);
}

.shipment-item.selected {
  background: var(--accent-soft);
}

.row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
}

.row strong {
  font-size: 0.9375rem;
  font-weight: 600;
}

.meta {
  margin-top: 4px;
  font-size: 0.8125rem;
  color: var(--text-secondary);
}

.badge {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 3px 10px;
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  white-space: nowrap;
  flex-shrink: 0;
}

.badge-tone-neutral {
  background: #f3f4f6;
  color: var(--text-secondary);
}

.badge-tone-info {
  background: var(--info-soft);
  color: var(--info-text);
}

.badge-tone-success {
  background: var(--success-soft);
  color: var(--success-text);
}

.badge-tone-warning {
  background: var(--warning-soft);
  color: var(--warning-text);
}

.badge-tone-danger {
  background: var(--danger-soft);
  color: var(--danger-text);
}

.toolbar {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}

input,
button,
select {
  font: inherit;
}

input,
select {
  min-height: 44px;
  width: 100%;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-surface);
  color: var(--text-primary);
  padding: 10px 14px;
}

input[type="date"] {
  color-scheme: dark;
}

input:focus,
select:focus {
  outline: none;
  border-color: var(--info);
  box-shadow: 0 0 0 3px var(--info-soft);
}

button {
  min-height: 44px;
  border: none;
  border-radius: var(--radius-sm);
  background: var(--accent);
  color: #fff;
  font-weight: 600;
  padding: 10px 16px;
  cursor: pointer;
}

button.secondary {
  background: var(--bg-surface);
  color: var(--text-primary);
  border: 1px solid var(--border);
}

button.danger {
  background: var(--danger-soft);
  color: var(--danger-text);
  border: 1px solid var(--danger-soft);
}

.link-btn {
  background: transparent;
  color: var(--info-text);
  padding: 0;
  min-height: auto;
  margin-bottom: 12px;
}

.filter-scroll-wrap {
  margin: 0 -16px 12px;
  overflow: hidden;
}

.filter-scroll {
  display: flex;
  align-items: stretch;
  gap: 8px;
  overflow-x: auto;
  overflow-y: hidden;
  overscroll-behavior-x: contain;
  scroll-behavior: smooth;
  scroll-snap-type: x proximity;
  scroll-padding-inline: 16px;
  -webkit-overflow-scrolling: touch;
  padding: 2px 16px 6px;
  -ms-overflow-style: none;
  scrollbar-width: none;
}

.filter-scroll::-webkit-scrollbar {
  display: none;
}

.filter-chip {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 0 16px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg-surface);
  color: var(--text-secondary);
  font-size: 0.8125rem;
  font-weight: 500;
  white-space: nowrap;
  scroll-snap-align: center;
}

.filter-chip.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.fab-add {
  position: fixed;
  right: 16px;
  bottom: calc(var(--nav-height) + var(--safe-bottom) + 16px);
  z-index: 25;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  box-shadow: var(--shadow-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}

.fab-add svg {
  width: 24px;
  height: 24px;
}

.fab-add.hidden,
.bottom-nav.hidden {
  display: none;
}

.connection-error {
  margin: 0 16px 12px;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  background: var(--danger-soft);
  border: 1px solid var(--danger-soft);
  color: var(--danger-text);
  font-size: 0.875rem;
}

.sync-status {
  margin-top: 12px;
  font-size: 0.75rem;
  color: var(--text-muted);
  text-align: center;
}

.empty-state {
  padding: 28px 20px;
  text-align: center;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--bg-card);
  box-shadow: var(--shadow-xs);
  color: var(--text-secondary);
  font-size: 0.875rem;
}

.placeholder-card {
  padding: 24px 20px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--bg-card);
  box-shadow: var(--shadow-xs);
}

.placeholder-card h3 {
  margin: 0 0 8px;
  font-size: 1rem;
}

.placeholder-card p {
  margin: 0;
  color: var(--text-secondary);
  font-size: 0.875rem;
  line-height: 1.5;
}

.page-lead {
  margin: 0 0 16px;
  font-size: 0.875rem;
  line-height: 1.5;
  color: var(--text-secondary);
}

.info-banner {
  margin-bottom: 16px;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--info-soft);
  background: var(--info-soft);
  color: var(--info-text);
  font-size: 0.8125rem;
  line-height: 1.45;
}

.module-stack {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 16px;
}

.activity-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 0 0 10px;
}

.activity-filters .filter-chip {
  min-height: 32px;
  padding: 0 12px;
  font-size: 0.75rem;
}

.activity-log {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 16px;
}

.activity-line {
  margin: 0;
  font-size: 0.8125rem;
  line-height: 1.4;
  color: var(--text-primary);
}

.activity-line .activity-time {
  font-variant-numeric: tabular-nums;
  color: var(--text-secondary);
}

.activity-line.activity-imported {
  color: var(--text-primary);
}

.activity-line.activity-duplicate {
  color: var(--text-secondary);
}

.activity-line.activity-discarded {
  color: var(--text-secondary);
}

.activity-line.activity-error {
  color: var(--danger-text);
}

.module-empty,
.roadmap-card,
.mailbox-card {
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--bg-card);
  box-shadow: var(--shadow-xs);
  padding: 16px;
}

.mailbox-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.mailbox-card-head strong {
  overflow-wrap: anywhere;
}

.mailbox-health-line .badge {
  margin-left: 4px;
}

.mailbox-detail-panel {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
}

.mailbox-detail-toggle.linkish {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--accent, #1d4ed8);
  padding: 0;
  margin-top: 8px;
  cursor: pointer;
  font: inherit;
  text-decoration: underline;
}

.module-empty-title {
  margin: 0 0 6px;
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--text-primary);
}

.module-empty-text,
.module-note {
  margin: 0;
  font-size: 0.8125rem;
  line-height: 1.45;
  color: var(--text-secondary);
}

.action-stack {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 16px;
}

button.full-width {
  width: 100%;
}

button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.roadmap-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.roadmap-card h3 {
  margin: 0 0 8px;
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-primary);
}

.roadmap-card p {
  margin: 0 0 10px;
  font-size: 0.8125rem;
  line-height: 1.5;
  color: var(--text-secondary);
}

.roadmap-status {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  background: var(--bg-subtle);
  color: var(--text-muted);
}

.settings-list {
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--bg-card);
  overflow: hidden;
  box-shadow: var(--shadow-xs);
}

.settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  padding: 14px 16px;
  border: none;
  background: transparent;
  text-align: left;
  color: var(--text-primary);
  font: inherit;
  min-height: 52px;
}

.settings-row + .settings-row {
  border-top: 1px solid var(--border-subtle);
}

.settings-row.is-static {
  cursor: default;
}

#settings-open-pm {
  cursor: pointer;
}

.settings-row span {
  font-size: 0.9375rem;
  font-weight: 600;
}

.settings-row-stack {
  flex-direction: column;
  align-items: stretch;
}

.api-key-controls {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 100%;
}

.login-view {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px calc(24px + var(--safe-bottom));
}

.login-card {
  width: 100%;
  max-width: 420px;
  padding: 24px 20px;
}

.login-brand {
  text-align: center;
  margin-bottom: 20px;
}

.login-brand .logo-mark {
  margin: 0 auto 12px;
}

.login-brand h1 {
  margin: 0 0 8px;
  font-size: 1.375rem;
}

.login-lead {
  margin: 0;
  color: var(--text-secondary);
  font-size: 0.9375rem;
}

.login-form label {
  display: block;
  margin-bottom: 14px;
}

.login-form label > span {
  display: block;
  margin-bottom: 6px;
  font-size: 0.8125rem;
  font-weight: 600;
}

.login-form button[type="submit"] {
  width: 100%;
  margin-top: 4px;
}

.operator-fallback {
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--border-subtle);
}

.operator-fallback > summary {
  cursor: pointer;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-secondary);
  list-style: none;
}

.operator-fallback > summary::-webkit-details-marker {
  display: none;
}

.operator-fallback > summary::before {
  content: "▸ ";
}

.operator-fallback[open] > summary::before {
  content: "▾ ";
}

.operator-fallback .api-key-controls {
  margin-top: 12px;
}

.profile-details {
  display: flex;
  flex-direction: column;
  gap: 6px;
  width: 100%;
}

.profile-field {
  margin: 0;
  font-size: 0.875rem;
  color: var(--text-secondary);
}

.settings-row-stack.operator-fallback > summary {
  width: 100%;
  cursor: pointer;
  list-style: none;
}

.settings-row-stack.operator-fallback > summary::-webkit-details-marker {
  display: none;
}

.settings-row-stack.operator-fallback > summary span {
  display: block;
}

.settings-row small {
  display: block;
  margin-top: 2px;
  font-size: 0.8125rem;
  font-weight: 400;
  color: var(--text-secondary);
}

.hidden {
  display: none !important;
}

.bottom-nav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 30;
  border-top: 1px solid var(--border);
  background: color-mix(in srgb, var(--bg-surface) 95%, transparent);
  backdrop-filter: blur(12px);
  padding-bottom: var(--safe-bottom);
}

.bottom-nav ul {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  list-style: none;
  margin: 0;
  padding: 4px 4px 0;
  max-width: 640px;
  margin-inline: auto;
}

.nav-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  min-height: 3.25rem;
  padding: 6px 4px;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-secondary);
  font-size: 0.625rem;
  font-weight: 600;
}

.nav-btn svg {
  width: 22px;
  height: 22px;
}

.nav-btn.active {
  color: var(--accent);
  background: var(--accent-soft);
}

.add-form label {
  display: block;
  margin-bottom: 14px;
}

.add-form label > span {
  display: block;
  margin-bottom: 6px;
  font-size: 0.8125rem;
  font-weight: 600;
}

.error {
  color: var(--danger-text);
  font-size: 0.875rem;
}

/* ——— Desktop application shell (≥900px) ——— */
@media (min-width: 900px) {
  html.is-desktop,
  html.is-desktop body {
    height: 100%;
    overflow: hidden;
  }

  .app-shell {
    display: grid;
    grid-template-columns: 260px minmax(0, 1fr);
    grid-template-rows: minmax(0, 1fr);
    height: 100dvh;
    min-height: 100dvh;
    overflow: hidden;
  }

  .desktop-sidebar {
    display: flex;
    flex-direction: column;
    gap: 16px;
    height: 100dvh;
    padding: 18px 14px 14px;
    border-right: none;
    background: var(--sidebar-bg);
    color: var(--sidebar-text);
    overflow: hidden;
  }

  .desktop-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0 4px;
  }

  .desktop-brand .logo-mark {
    width: 40px;
    height: 40px;
    font-size: 0.9rem;
  }

  .desktop-brand-copy {
    min-width: 0;
  }

  .desktop-product {
    margin: 0;
    font-size: 0.95rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    color: var(--sidebar-text-strong);
  }

  .desktop-product-sub {
    margin: 2px 0 0;
    font-size: 0.75rem;
    color: var(--sidebar-muted);
  }

  .desktop-add-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 38px;
    width: 100%;
    border-radius: var(--radius-sm);
    background: var(--sidebar-active);
    box-shadow: none;
  }

  .desktop-add-btn svg {
    width: 18px;
    height: 18px;
  }

  .desktop-nav-scroll {
    display: flex;
    flex-direction: column;
    gap: 16px;
    flex: 1;
    min-height: 0;
    overflow: auto;
    padding-right: 2px;
  }

  .desktop-nav,
  .desktop-account-nav {
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex: 0 0 auto;
  }

  .desktop-admin-nav {
    display: flex;
    flex-direction: column;
    gap: 2px;
    margin-top: 4px;
    padding: 8px 0 0;
    border: none;
    border-top: 1px solid rgba(148, 163, 184, 0.18);
    border-radius: 0;
    background: transparent;
  }

  .desktop-admin-nav.hidden,
  .desktop-admin-nav[hidden] {
    display: none;
  }

  .desktop-nav-heading {
    margin: 0 0 6px;
    padding: 0 12px;
    font-size: 0.6875rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--sidebar-muted);
  }

  .desktop-admin-nav .desktop-nav-heading {
    margin-bottom: 4px;
    font-size: 0.625rem;
    color: var(--sidebar-muted);
  }

  .desktop-admin-nav .desktop-nav-btn {
    min-height: 30px;
    padding: 4px 10px;
    font-size: 0.75rem;
  }

  .desktop-admin-nav .desktop-nav-btn svg {
    width: 16px;
    height: 16px;
  }

  .desktop-nav-btn {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 10px;
    min-height: 36px;
    width: 100%;
    padding: 6px 10px;
    border: none;
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--sidebar-text);
    font-size: 0.875rem;
    font-weight: 600;
    text-align: left;
  }

  .desktop-nav-btn svg {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
  }

  .desktop-nav-btn:hover {
    background: var(--sidebar-hover);
    color: var(--sidebar-text-strong);
  }

  .desktop-nav-btn.active {
    background: var(--sidebar-active);
    color: #fff;
  }

  .desktop-sidebar-footer {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding-top: 12px;
    border-top: 1px solid rgba(148, 163, 184, 0.18);
  }

  .desktop-user-email {
    margin: 0;
    font-size: 0.75rem;
    color: var(--sidebar-muted);
    word-break: break-all;
  }

  .desktop-user-role {
    margin: 0;
    font-size: 0.6875rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--sidebar-muted);
  }

  .desktop-account-users-link {
    font-size: 0.8125rem;
    font-weight: 600;
    color: #93c5fd;
    text-decoration: none;
  }

  .desktop-account-users-link:hover {
    text-decoration: underline;
  }

  .desktop-logout-btn {
    min-height: 38px;
    width: 100%;
    background: transparent;
    color: var(--sidebar-text-strong);
    border: 1px solid rgba(148, 163, 184, 0.28);
  }

  .desktop-logout-btn:hover {
    background: var(--sidebar-hover);
  }

  .app-workspace {
    height: 100dvh;
    overflow: auto;
    background: var(--bg-app);
  }

  .mobile-header,
  .bottom-nav,
  .fab-add {
    display: none !important;
  }

  .desktop-topbar {
    display: flex;
    position: sticky;
    top: 0;
    z-index: 20;
    align-items: center;
    gap: 16px;
    min-height: 64px;
    padding: 10px 28px;
    border-bottom: 1px solid var(--border);
    background: var(--bg-surface);
    backdrop-filter: blur(12px);
  }

  .desktop-topbar .header-titles h1 {
    font-size: 1.25rem;
  }

  .desktop-topbar .header-titles p {
    font-size: 0.8125rem;
  }

  .desktop-topbar #desktop-refresh {
    min-height: 38px;
    padding: 8px 14px;
  }

  .app-main {
    max-width: none;
    width: 100%;
    margin: 0;
    padding: 24px 28px 32px;
  }

  .app-main.detail-mode {
    padding-bottom: 32px;
  }

  .connection-error {
    margin: 16px 28px 0;
  }

  .widget-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 14px;
    margin-bottom: 24px;
  }

  .dashboard-widget,
  .widget-card,
  .widget-inner {
    min-height: 108px;
  }

  .widget-value {
    font-size: 2rem;
  }

  .operational-strip,
  .desktop-status-panel {
    display: none;
  }

  .desktop-status-panel .section-header {
    align-items: flex-end;
  }

  .desktop-status-legend {
    margin: 0;
    font-size: 0.75rem;
    color: var(--text-secondary);
  }

  .shipment-list {
    display: none;
  }

  .shipment-table-wrap {
    display: block;
    overflow-x: auto;
  }

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

  .shipment-table th,
  .shipment-table td {
    padding: 12px 16px;
    text-align: left;
    vertical-align: middle;
    border-bottom: 1px solid var(--border-subtle);
    white-space: nowrap;
  }

  .shipment-table th {
    position: sticky;
    top: 0;
    z-index: 1;
    font-size: 0.6875rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-label);
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    padding-top: 10px;
    padding-bottom: 10px;
  }

  .shipment-table td.col-tracking {
    font-weight: 600;
    color: var(--text-primary);
  }

  .shipment-table-row {
    cursor: pointer;
  }

  .shipment-table-row:hover {
    background: var(--hover-overlay);
  }

  .shipment-table tbody tr:last-child td {
    border-bottom: none;
  }

  .toolbar {
    max-width: 420px;
  }

  .filter-scroll-wrap {
    margin: 0 0 14px;
    overflow: visible;
  }

  .filter-scroll {
    flex-wrap: wrap;
    overflow: visible;
    padding: 0;
    scroll-snap-type: none;
  }

  .filter-chip {
    min-height: 36px;
    scroll-snap-align: unset;
  }

  #view-mailboxes .action-stack {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
  }

  #view-mailboxes .action-stack .full-width,
  #view-more .profile-details .full-width {
    width: auto;
  }

  .detail-stack {
    max-width: 1080px;
  }

  .detail-meta-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .add-form {
    max-width: 480px;
    padding: 24px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
    background: var(--bg-card);
    box-shadow: var(--shadow-xs);
  }

  .settings-list {
    max-width: 640px;
  }

  .desktop-only {
    display: block;
  }

  .desktop-extra-stats {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 14px;
    margin: 0 0 24px;
  }

  .desktop-stat-card,
  .admin-panel-card,
  .admin-unavailable-card {
    margin: 0;
    padding: 16px 18px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
    background: var(--bg-card);
    box-shadow: var(--shadow-xs);
  }

  .admin-filter-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 0 0 12px;
    align-items: center;
  }

  .admin-filter-row input,
  .admin-filter-row select {
    min-width: 160px;
  }

  .desktop-stat-label,
  .admin-light-label {
    margin: 0 0 6px;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-secondary);
  }

  .desktop-stat-value {
    margin: 0;
    font-size: 1.75rem;
    font-weight: 700;
    letter-spacing: -0.03em;
    color: var(--text-primary);
  }

  .desktop-dashboard-columns {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 20px;
    margin-bottom: 24px;
  }

  .desktop-dash-panel .section-header {
    margin-top: 0;
  }

  .desktop-table-always {
    display: block;
    overflow-x: auto;
  }

  .admin-status-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 14px;
    margin-bottom: 20px;
  }

  .admin-status-light {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 16px 18px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
    background: var(--bg-card);
    box-shadow: var(--shadow-xs);
  }

  .admin-light-dot {
    width: 12px;
    height: 12px;
    margin-top: 4px;
    border-radius: 50%;
    flex-shrink: 0;
    background: var(--text-label);
  }

  .admin-light-dot.is-green {
    background: var(--success-text);
  }

  .admin-light-dot.is-yellow {
    background: #c9a227;
  }

  .admin-light-dot.is-red {
    background: var(--danger-text);
  }

  .admin-light-dot.is-unknown {
    background: var(--text-label);
  }

  .admin-light-copy {
    min-width: 0;
  }

  .admin-light-value {
    margin: 0;
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--text-primary);
  }

  .admin-light-note,
  .admin-panel-card p,
  .admin-unavailable-card p {
    margin: 6px 0 0;
    font-size: 0.8125rem;
    color: var(--text-secondary);
  }

  .admin-panel-card dl {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px 20px;
    margin: 0;
  }

  .admin-panel-card dt {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-secondary);
  }

  .admin-panel-card dd {
    margin: 2px 0 0;
    font-size: 0.9375rem;
    font-weight: 600;
    color: var(--text-primary);
  }

  .admin-unavailable-card h2 {
    margin: 0 0 8px;
  }

  .admin-unavailable-card {
    margin-top: 20px;
  }

  .admin-unavailable-card .roadmap-status {
    display: inline-block;
    margin: 0 0 8px;
    padding: 4px 8px;
    border-radius: 999px;
    background: var(--warning-soft);
    color: var(--warning-text);
    font-size: 0.75rem;
    font-weight: 700;
  }

  @media (max-width: 1199px) {
    .desktop-dashboard-columns,
    .admin-panel-card dl {
      grid-template-columns: 1fr;
    }

    .admin-status-grid {
      grid-template-columns: repeat(2, minmax(0, 1fr));
    }
  }
}

/* Mailbox connection wizard (mobile sheet + desktop ≥900px modal) */
.mailbox-wizard-overlay {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: flex;
  align-items: stretch;
  justify-content: center;
  background: rgba(15, 23, 42, 0.45);
  padding: 0;
}

.mailbox-wizard-overlay.hidden {
  display: none;
}

.mailbox-wizard-sheet {
  display: flex;
  flex-direction: column;
  width: 100%;
  max-height: 100dvh;
  overflow: auto;
  background: var(--bg-surface);
  color: var(--text-primary);
  padding: 16px 16px calc(16px + var(--safe-bottom));
}

.mailbox-wizard-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.mailbox-wizard-kicker {
  margin: 0 0 4px;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-secondary);
}

.mailbox-wizard-head h2 {
  margin: 0;
  font-size: 1.25rem;
}

.mailbox-wizard-form label {
  display: block;
  margin-bottom: 14px;
}

.mailbox-wizard-form label > span {
  display: block;
  margin-bottom: 6px;
  font-size: 0.8125rem;
  font-weight: 600;
}

.mailbox-wizard-form input,
.mailbox-wizard-form select {
  width: 100%;
}

.mailbox-wizard-radios {
  border: 0;
  margin: 0;
  padding: 0;
}

.mailbox-wizard-radios legend {
  margin-bottom: 10px;
  font-size: 0.8125rem;
  font-weight: 700;
}

.mailbox-wizard-choice {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 10px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg-card);
}

.mailbox-wizard-choice input {
  width: auto;
  margin-top: 4px;
}

.mailbox-wizard-choice small {
  display: block;
  margin-top: 2px;
  color: var(--text-secondary);
  font-size: 0.8125rem;
}

.mailbox-wizard-choice:has(input:checked) {
  border-color: var(--info);
  background: var(--info-soft);
}

.mailbox-wizard-imap-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.mailbox-wizard-actions {
  display: flex;
  gap: 10px;
  margin-top: 8px;
}

.mailbox-wizard-actions button {
  flex: 1;
}

.mailbox-wizard-status {
  padding: 20px 16px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--bg-card);
  text-align: center;
}

.mailbox-wizard-status.is-connecting {
  border-color: var(--info);
  background: var(--info-soft);
}

.mailbox-wizard-status.is-connected {
  border-color: var(--success);
  background: var(--success-soft);
}

.mailbox-wizard-status.is-info {
  border-color: var(--info);
  background: var(--info-soft);
}

.mailbox-wizard-status.is-error {
  border-color: var(--danger);
  background: var(--danger-soft);
}

#mailbox-wizard-status-title {
  margin: 0 0 8px;
  font-size: 1.125rem;
  font-weight: 700;
}

body.mailbox-wizard-open {
  overflow: hidden;
}

@media (min-width: 900px) {
  .mailbox-wizard-overlay {
    align-items: center;
    padding: 24px;
  }

  .mailbox-wizard-sheet {
    width: min(760px, 92vw);
    max-height: min(88vh, 720px);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    padding: 24px;
  }

  .mailbox-wizard-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 20px;
    align-items: start;
  }
}

.pm-list-toolbar {
  gap: 8px;
}

#view-admin-pm {
  min-width: 0;
  max-width: 100%;
}

#view-admin-pm .card-surface {
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
}

#view-admin-pm .pm-table-scroll {
  display: block;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  overflow-x: scroll;
  overflow-y: hidden;
  overscroll-behavior-x: contain;
  -webkit-overflow-scrolling: touch;
  scrollbar-gutter: stable;
  scrollbar-width: auto;
  scrollbar-color: #334155 #cbd5e1;
}

#view-admin-pm .pm-table-scroll::-webkit-scrollbar {
  height: 16px;
  display: block;
  background: #cbd5e1;
}

#view-admin-pm .pm-table-scroll::-webkit-scrollbar-track {
  background: #cbd5e1;
}

#view-admin-pm .pm-table-scroll::-webkit-scrollbar-thumb {
  background: #334155;
  border-radius: 8px;
  border: 2px solid #cbd5e1;
}

#view-admin-pm .pm-record-table {
  width: 100%;
  min-width: 0;
  border-collapse: collapse;
  table-layout: fixed;
}

#view-admin-pm .pm-record-table th,
#view-admin-pm .pm-record-table td {
  white-space: normal;
  vertical-align: top;
  padding: 6px 5px;
  overflow-wrap: anywhere;
}

#view-admin-pm .pm-record-table th {
  min-width: 0;
  padding-top: 6px;
  padding-bottom: 6px;
}

#view-admin-pm .pm-record-table th[data-pm-sort="id"] {
  width: 7%;
}

#view-admin-pm .pm-cell-id {
  white-space: nowrap;
}

#view-admin-pm .pm-record-table th[data-pm-sort="description"] {
  width: 18%;
}

#view-admin-pm .pm-cell-description {
  word-break: break-word;
}

#view-admin-pm .pm-record-table th.pm-col-priority {
  width: 24%;
}

#view-admin-pm .pm-cell-priority {
  text-align: center;
  white-space: nowrap;
  overflow-wrap: normal;
}

#view-admin-pm .pm-col-priority .pm-th-filter,
#view-admin-pm .pm-col-priority .pm-sort {
  align-items: center;
  justify-content: center;
  text-align: center;
}

#view-admin-pm .pm-record-table th[data-pm-sort="status"] {
  width: 8%;
}

#view-admin-pm .pm-record-table th[data-pm-sort="entry_date"],
#view-admin-pm .pm-record-table th[data-pm-sort="work_started"],
#view-admin-pm .pm-record-table th[data-pm-sort="deployment_date"] {
  width: 8%;
}

#view-admin-pm .pm-record-table th[data-pm-sort="related"],
#view-admin-pm .pm-record-table th[data-pm-sort="tests_run"],
#view-admin-pm .pm-record-table th[data-pm-sort="attachments"] {
  width: 7%;
}

#view-admin-pm .pm-cell-entry,
#view-admin-pm .pm-cell-work,
#view-admin-pm .pm-cell-deploy,
#view-admin-pm .pm-cell-related,
#view-admin-pm .pm-cell-attach {
  white-space: nowrap;
  overflow-wrap: normal;
}

.pm-th-filter {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 6px;
}

.pm-sort {
  display: flex;
  align-items: center;
  gap: 4px;
  width: 100%;
  margin: 0;
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  letter-spacing: inherit;
  text-transform: inherit;
  text-align: left;
  white-space: normal;
  line-height: 1.2;
  cursor: pointer;
}

.pm-sort.is-active::after {
  content: "▼";
  font-size: 0.625rem;
  line-height: 1;
}

.pm-sort.is-active[aria-sort="ascending"]::after {
  content: "▲";
}

.pm-th-filter input:not([type="checkbox"]),
.pm-th-filter select {
  min-height: 28px;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  padding: 4px 6px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-surface);
  color: var(--text-primary);
  font-size: 0.75rem;
  font-weight: 500;
  letter-spacing: 0;
  text-transform: none;
}

.pm-priority-filter {
  display: flex;
  flex-direction: row;
  flex-wrap: nowrap;
  justify-content: center;
  align-items: flex-start;
  gap: 2px;
  margin: 0 auto;
  padding: 0;
  border: 0;
  width: 100%;
  min-height: 0;
}

.pm-priority-option {
  display: inline-flex;
  flex: 1 1 0;
  flex-direction: column;
  align-items: center;
  gap: 1px;
  min-width: 0;
  max-width: 3rem;
  color: var(--text-primary);
  font-size: 0.6875rem;
  font-weight: 600;
  line-height: 1.15;
  letter-spacing: 0;
  text-transform: none;
  text-align: center;
  white-space: normal;
  cursor: pointer;
}

.pm-priority-option input[type="checkbox"] {
  width: 18px;
  height: 18px;
  min-width: 18px;
  min-height: 18px;
  margin: 0;
  flex: 0 0 18px;
  accent-color: #1d4ed8;
}

.pm-priority-mark {
  flex: 0 0 auto;
  font-size: 0.8rem;
  line-height: 1;
}

.pm-priority-text {
  display: block;
  max-width: 100%;
  overflow-wrap: normal;
  word-break: normal;
  hyphens: none;
}

.pm-table-hscroll {
  display: none;
  width: 100%;
  height: 18px;
  margin: 8px 0 0;
  accent-color: #334155;
}

.pm-table-hscroll.is-active {
  display: block;
}

@media (max-width: 1100px) {
  #view-admin-pm .pm-record-table {
    width: 1040px;
    min-width: 1040px;
  }
}

.pm-form textarea,
.pm-form select,
.pm-form input {
  min-height: 40px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-surface);
  color: var(--text-primary);
}

.pm-form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.pm-confirm {
  margin-bottom: 16px;
}

#view-admin-pm #pm-attachments:hover,
#view-admin-pm #pm-attachments:focus-within,
#view-admin-pm #pm-attachments.is-dragover {
  border-color: var(--info-text);
  border-style: dashed;
  background: var(--info-soft);
}

.pm-attach-file {
  display: inline-block;
  margin-top: 12px;
  color: var(--info-text);
  cursor: pointer;
  font-weight: 600;
}

.pm-dropzone {
  margin-top: 12px;
  padding: 20px 16px;
  border: 1px dashed var(--border);
  border-radius: var(--radius-md);
  background: var(--bg-surface);
  color: var(--text-secondary);
  text-align: center;
  cursor: pointer;
}

.pm-dropzone.is-active {
  border-color: var(--info-text);
  background: var(--info-soft);
  color: var(--info-text);
}

#pm-upload-status {
  margin-top: 8px;
}

.pm-attachment-list {
  list-style: none;
  margin: 12px 0 0;
  padding: 0;
}

.pm-attachment-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  padding: 10px 0;
  border-top: 1px solid var(--border-subtle);
}

#pm-banner.pm-banner-info {
  background: var(--bg-card);
  color: var(--text-secondary);
  border-color: var(--border);
}

#pm-table-body tr {
  cursor: pointer;
}

/* Shared SaaS surfaces — Dashboard, Shipments, Details */
.sm-card,
.card-surface.sm-card,
.detail-card {
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--bg-card);
  box-shadow: var(--shadow-xs);
}

.sm-card {
  padding: 16px;
}

.app-workspace.detail-mode #desktop-refresh,
.app-workspace.detail-mode #header-refresh {
  display: none;
}

.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;
}

#view-shipments {
  min-width: 0;
  overflow-x: hidden;
}

.shipments-controls {
  margin-bottom: 16px;
}

.shipments-toolbar {
  align-items: center;
  margin-bottom: 12px;
}

.shipments-search-field {
  flex: 1;
  min-width: 0;
}

#shipments-search {
  min-height: 40px;
  padding: 8px 12px;
}

.shipments-clear-btn {
  flex: 0 0 auto;
  min-height: 40px;
  padding: 8px 12px;
  white-space: nowrap;
}

.shipments-filter-wrap {
  margin: 0;
}

#shipments-filters.has-active-filter .filter-chip.active {
  box-shadow: 0 0 0 3px var(--info-soft);
}

#shipments-filters .filter-chip.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.shipments-list-card {
  overflow: hidden;
  padding: 0;
}

.shipment-id {
  color: var(--text-primary);
  font-weight: 650;
  text-decoration: none;
}

.shipment-item:hover {
  background: var(--hover-overlay);
}

.shipment-datetime {
  color: var(--text-muted);
  font-size: 0.8125rem;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}

.detail-redesign {
  gap: 18px;
}

.detail-header,
.detail-split,
.detail-bottom {
  display: grid;
  gap: 14px;
}

.detail-header {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-xs);
  padding: 18px;
}

.detail-header-top {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
}

.detail-header-identity {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.detail-shipment-number {
  margin: 0;
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text-primary);
}

.detail-header-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.detail-header-actions button {
  min-height: 40px;
  padding: 8px 12px;
}

.detail-header-meta {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px 16px;
  margin: 16px 0 0;
}

.detail-header-meta dt {
  margin: 0 0 2px;
  font-size: 0.6875rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-label);
}

.detail-header-meta dd {
  margin: 0;
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--text-primary);
}

.detail-split .detail-card h3,
.detail-bottom .detail-card h3 {
  margin: 0 0 12px;
  font-size: 0.95rem;
}

.detail-timeline-card {
  overflow: hidden;
  padding-bottom: 8px;
}

.detail-section .section-header h2 {
  margin: 0 0 10px;
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.journey-timeline {
  list-style: none;
  display: flex;
  gap: 0;
  margin: 0;
  padding: 8px 4px 4px;
  overflow-x: auto;
  overscroll-behavior-x: contain;
}

.journey-stop {
  position: relative;
  flex: 0 0 168px;
  min-width: 168px;
  padding: 0 12px 8px;
  text-align: center;
}

.journey-line {
  position: absolute;
  top: 22px;
  left: 50%;
  width: 100%;
  height: 2px;
  background: var(--border);
}

.journey-completed .journey-line {
  background: var(--info);
}

.journey-icon {
  position: relative;
  z-index: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 2px solid var(--border);
  background: var(--bg-card);
  color: var(--text-secondary);
}

.journey-icon svg {
  width: 22px;
  height: 22px;
}

.journey-completed .journey-icon {
  border-color: var(--info);
  background: var(--info-soft);
  color: var(--info-text);
}

.journey-current .journey-icon {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}

.journey-upcoming .journey-icon {
  opacity: 0.55;
}

.journey-copy {
  margin-top: 10px;
}

.journey-title,
.journey-time,
.journey-location {
  margin: 0;
}

.journey-title {
  font-size: 0.8125rem;
  font-weight: 650;
  color: var(--text-primary);
}

.journey-time,
.journey-location {
  margin-top: 3px;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.tracking-event-list {
  display: grid;
  gap: 10px;
}

.tracking-event {
  display: grid;
  grid-template-columns: 44px 1fr;
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg-card);
  box-shadow: var(--shadow-xs);
}

.tracking-event-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--info-soft);
  color: var(--info-text);
}

.tracking-event-icon svg {
  width: 20px;
  height: 20px;
}

.tracking-event-when,
.tracking-event-title,
.tracking-event-description,
.tracking-event-location {
  margin: 0;
}

.tracking-event-when,
.tracking-event-location {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.tracking-event-title {
  margin-top: 2px;
  font-weight: 650;
}

.tracking-event-description {
  margin-top: 4px;
  font-size: 0.875rem;
  color: var(--text-secondary);
}

.route-map-canvas {
  width: 100%;
  height: 280px;
  min-height: 220px;
  border-radius: var(--radius-sm);
  background: #d7e3f0;
  overflow: hidden;
}

.route-map-canvas.is-empty {
  display: none;
}

.route-map-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 16px;
  margin: 12px 0 0;
  padding: 0;
  list-style: none;
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.route-map-legend li {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.route-map-unresolved {
  margin: 8px 0 0;
  padding-left: 1.1rem;
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.route-marker {
  background: transparent;
  border: 0;
}

.route-marker-dot,
.route-map-legend .route-marker-dot {
  display: inline-block;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 2px solid #fff;
  box-shadow: 0 0 0 1px rgba(15, 23, 42, 0.2);
  background: #64748b;
}

.route-marker-origin .route-marker-dot,
.route-map-legend .route-marker-dot.origin {
  background: #16a34a;
  width: 14px;
  height: 14px;
}

.route-marker-destination .route-marker-dot,
.route-map-legend .route-marker-dot.destination {
  background: #dc2626;
  width: 14px;
  height: 14px;
}

.route-marker-current .route-marker-dot,
.route-map-legend .route-marker-dot.current {
  background: #2563eb;
  width: 16px;
  height: 16px;
  animation: route-pulse 1.6s ease-out infinite;
}

.route-marker-history .route-marker-dot,
.route-map-legend .route-marker-dot.history {
  background: #94a3b8;
}

@keyframes route-pulse {
  0% {
    box-shadow: 0 0 0 0 rgba(37, 99, 235, 0.45);
  }
  100% {
    box-shadow: 0 0 0 10px rgba(37, 99, 235, 0);
  }
}

#view-detail {
  min-width: 0;
  overflow-x: hidden;
}

@media (max-width: 899.98px) {
  .detail-header-actions {
    width: 100%;
  }

  .detail-header-actions button {
    flex: 1 1 calc(50% - 8px);
  }

  .journey-timeline {
    scroll-snap-type: x proximity;
  }

  .journey-stop {
    scroll-snap-align: start;
  }
}

@media (min-width: 900px) {
  .detail-redesign {
    max-width: 1180px;
  }

  .detail-header-meta {
    grid-template-columns: repeat(5, minmax(0, 1fr));
  }

  .detail-split,
  .detail-bottom {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .detail-bottom {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .shipments-toolbar.toolbar {
    max-width: none;
  }

  .shipment-table .col-status {
    width: 1%;
  }

  .shipment-table .col-updated,
  .shipment-table .col-eta,
  .shipment-table th:nth-last-child(2),
  .shipment-table th:last-child {
    text-align: right;
  }
}
