/* ANJU shared-system candidate: formal mapping of the approved full-system prototype. */
:root {
  --system-navy-950: #0c2230;
  --system-navy-900: #102a3a;
  --system-navy-800: #18384b;
  --system-bg: #eef2f4;
  --system-surface: #ffffff;
  --system-surface-soft: #f5f7f8;
  --system-ink: #24313a;
  --system-muted: #6c7a83;
  --system-line: #d6dfe4;
  --system-blue: #2e6f9e;
  --system-blue-dark: #235d87;
  --system-blue-soft: #eaf3f9;
  --system-amber: #9e6a1c;
  --system-amber-soft: #fff6e6;
  --system-red: #b94739;
  --system-red-soft: #fff0ee;
  --system-green: #2f6b4f;
  --system-green-soft: #eaf4ef;
  --system-radius: 8px;
  --system-shadow: 0 8px 20px rgba(23, 42, 53, 0.07);
}

body {
  background: var(--system-bg);
  color: var(--system-ink);
}

#workbenchView {
  display: none !important;
}

.panel,
.form-band,
.kpi,
.modal-card {
  border-color: var(--system-line);
  border-radius: var(--system-radius);
}

.panel {
  box-shadow: var(--system-shadow);
}

.panel-head {
  border-bottom-color: var(--system-line);
}

.panel-head .eyebrow,
.ui-system-home-head .eyebrow {
  min-height: 0;
  display: block;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  margin-bottom: 2px;
  color: var(--system-muted);
  font-size: 10px;
  font-weight: 820;
  letter-spacing: 0.04em;
}

.panel-head h2,
.ui-system-home-head h2 {
  color: var(--system-ink);
  font-size: 16px;
  letter-spacing: -0.015em;
}

.panel-head p,
.ui-system-home-head p {
  margin: 0;
  color: var(--system-muted);
  line-height: 1.45;
}

.primary-btn {
  border-color: var(--system-blue);
  background: var(--system-blue);
}

.primary-btn:hover {
  border-color: var(--system-blue-dark);
  background: var(--system-blue-dark);
}

.secondary-btn,
.icon-btn,
.row-btn {
  border-color: var(--system-line);
}

.text-btn {
  color: var(--system-blue-dark);
}

.badge.ok {
  border-color: #bed8ca;
  background: var(--system-green-soft);
  color: var(--system-green);
}

.badge.warn {
  border-color: #ecd39f;
  background: var(--system-amber-soft);
  color: #835912;
}

table thead th {
  background: var(--system-surface-soft);
  color: #5d6d76;
}

table tbody tr:hover td {
  background: #f6fafd;
}

@media (min-width: 761px) {
  :root {
    --sidebar-collapsed-width: 154px;
    --sidebar-expanded-width: 154px;
  }

  .app-shell {
    grid-template-columns: 154px minmax(0, 1fr);
    background: var(--system-bg);
  }

  .sidebar,
  .sidebar:hover,
  .sidebar:focus-within,
  .sidebar.force-collapsed,
  .sidebar.force-collapsed:hover,
  .sidebar.force-collapsed:focus-within {
    width: 154px;
    padding: 14px 8px;
    background: var(--system-navy-950);
    box-shadow: none;
  }

  .sidebar .brand,
  .sidebar:hover .brand,
  .sidebar:focus-within .brand,
  .sidebar.force-collapsed .brand {
    justify-content: flex-start;
    padding: 0 8px 14px;
    border-bottom: 1px solid rgba(211, 226, 235, 0.14);
  }

  .sidebar .brand > div:last-child,
  .sidebar:hover .brand > div:last-child,
  .sidebar:focus-within .brand > div:last-child,
  .sidebar.force-collapsed .brand > div:last-child {
    max-width: 106px;
    opacity: 1;
    transform: none;
  }

  .sidebar .current-account {
    display: none;
  }

  .sidebar .nav {
    gap: 2px;
    padding-top: 9px;
  }

  .sidebar .nav-item,
  .sidebar .nav-utility,
  .sidebar:hover .nav-item,
  .sidebar:hover .nav-utility,
  .sidebar:focus-within .nav-item,
  .sidebar:focus-within .nav-utility,
  .sidebar.force-collapsed .nav-item,
  .sidebar.force-collapsed .nav-utility {
    width: 100%;
    min-height: 38px;
    grid-template-columns: 24px minmax(0, 1fr);
    grid-template-rows: none;
    gap: 8px;
    padding: 0 10px;
    border-radius: 5px;
  }

  .sidebar .nav-item > .lucide,
  .sidebar .nav-item > span,
  .sidebar .nav-utility > .lucide,
  .sidebar .nav-utility > span,
  .sidebar.force-collapsed .nav-item > .lucide,
  .sidebar.force-collapsed .nav-item > span,
  .sidebar.force-collapsed .nav-utility > .lucide,
  .sidebar.force-collapsed .nav-utility > span {
    grid-column: auto;
    grid-row: auto;
    justify-self: auto;
  }

  .sidebar .nav-item span,
  .sidebar .nav-utility span,
  .sidebar.force-collapsed .nav-item span,
  .sidebar.force-collapsed .nav-utility span {
    max-width: 104px;
    opacity: 1;
    transform: none;
    font-size: 13px;
    font-weight: 760;
  }

  .workspace,
  .workspace.view-orders-active {
    min-width: 0;
    padding: 0;
    background: var(--system-bg);
  }

  .workspace > .topbar,
  .workspace.view-orders-active > .topbar {
    position: sticky;
    top: 0;
    z-index: 90;
    min-height: 56px;
    margin: 0;
    padding: 0 14px 0 18px;
    border: 0;
    border-bottom: 1px solid rgba(211, 226, 235, 0.14);
    border-radius: 0;
    background: var(--system-navy-900);
    box-shadow: none;
    color: #eef5f8;
  }

  .topbar-title {
    min-width: 230px;
  }

  .topbar-title .eyebrow {
    display: inline-flex;
    min-height: 30px;
    align-items: center;
    padding: 0 10px;
    border: 1px solid rgba(197, 217, 228, 0.18);
    border-radius: 5px;
    background: rgba(255, 255, 255, 0.04);
    color: #d5e1e7;
    font-size: 11px;
    letter-spacing: 0;
    text-transform: none;
  }

  .topbar-title h1 {
    display: none;
  }

  .topbar-system {
    display: flex;
    color: #cad9e1;
  }

  .topbar .user-badge,
  .topbar .status-dot {
    border-color: transparent;
    background: transparent;
    color: #dce8ed;
  }

  .topbar .icon-btn {
    border-color: transparent;
    background: transparent;
    color: #dce8ed;
  }

  .topbar .icon-btn:hover {
    border-color: rgba(255, 255, 255, 0.12);
    background: rgba(255, 255, 255, 0.08);
  }

  .workspace > .view {
    padding: 12px 14px 32px;
  }

  .workspace > #ordersView,
  .workspace > #dashboardView {
    padding: 0 0 32px;
  }
}

.ui-system-home {
  background: var(--system-bg);
}

.ui-system-home .panel {
  opacity: 1;
  transform: none;
  animation: none !important;
}

/* Safari can leave dynamically inserted `soft-pop` animations pending with
   opacity: 0. Keep operational cards visible even when the tab is backgrounded. */
.view.active .kpi,
.view.active .mini-kpi,
.view.active .panel,
.view.active .form-band,
.view.active .mobile-data-card,
.view.active .order-card,
.view.active .export-card {
  opacity: 1 !important;
  transform: none !important;
  animation: none !important;
}

#dashboardView .dashboard-alert-rail {
  display: grid;
  grid-template-columns: 150px repeat(5, minmax(0, 1fr));
  gap: 0;
  margin: 0;
  padding-left: 16px;
  overflow: hidden;
  border: 0;
  border-radius: 0;
  background: var(--system-navy-900);
  box-shadow: none;
}

#dashboardView .dashboard-alert-rail::before {
  display: flex;
  min-height: 68px;
  align-items: center;
  padding: 0 12px;
  border-right: 1px solid rgba(210, 226, 235, 0.16);
  color: #edf5f8;
  content: "异常与风险";
  font-size: 13px;
  font-weight: 820;
}

#dashboardView .dashboard-alert {
  min-width: 0;
  min-height: 68px;
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr);
  grid-template-rows: 1fr 1fr;
  align-items: end;
  gap: 0 8px;
  padding: 11px 12px;
  border: 0;
  border-right: 1px solid rgba(210, 226, 235, 0.16);
  border-radius: 0;
  background: transparent;
  color: #edf5f8;
  text-align: left;
  box-shadow: none;
}

#dashboardView .dashboard-alert:hover {
  background: rgba(255, 255, 255, 0.06);
}

#dashboardView .dashboard-alert-icon {
  grid-row: 1 / span 2;
  align-self: center;
  width: 24px;
  height: 24px;
  display: inline-grid;
  place-items: center;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: #9eb5c2;
}

#dashboardView .dashboard-alert-icon .lucide {
  width: 18px;
  height: 18px;
}

#dashboardView .dashboard-alert span:nth-child(2) {
  display: flex;
  align-items: baseline;
  gap: 8px;
}

#dashboardView .dashboard-alert strong {
  color: #f4f8fa;
  font-size: 22px;
  font-variant-numeric: tabular-nums;
}

#dashboardView .dashboard-alert small {
  color: #b6c8d1;
  font-size: 11px;
  font-weight: 760;
}

#dashboardView .dashboard-alert em {
  align-self: start;
  color: #7fc3ea;
  font-size: 10px;
  font-style: normal;
  font-weight: 760;
}

#dashboardView .dashboard-alert.danger strong,
#dashboardView .dashboard-alert.danger em {
  color: #ff7a6b;
}

#dashboardView .dashboard-alert.warn strong,
#dashboardView .dashboard-alert.warn em {
  color: #f4bd4f;
}

.ui-system-home-head {
  min-height: 80px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin: 0;
  padding: 14px 16px 10px;
  border: 0;
  background: transparent;
}

.ui-system-home-head h2 {
  margin: 0 0 3px;
  font-size: 22px;
}

.ui-system-home-grid {
  min-width: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 318px;
  align-items: start;
  gap: 12px;
  padding: 0 16px;
}

.ui-system-home-rail {
  display: grid;
  align-content: start;
  gap: 12px;
}

.ui-system-priority-panel,
.ui-system-workload-panel,
.ui-system-platform-panel,
.ui-system-boss-daily,
.ui-system-loop-panel {
  overflow: hidden;
}

.ui-system-priority-head,
.ui-system-priority-row {
  display: grid;
  grid-template-columns: 1.15fr 1.25fr 0.78fr 0.92fr 0.62fr;
  gap: 10px;
  align-items: center;
}

.ui-system-priority-head {
  min-height: 34px;
  padding: 0 12px;
  border-bottom: 1px solid var(--system-line);
  background: var(--system-surface-soft);
  color: #5d6d76;
  font-size: 11px;
  font-weight: 820;
}

.ui-system-priority-row {
  width: 100%;
  min-height: 76px;
  padding: 8px 12px;
  border: 0;
  border-bottom: 1px solid #e4eaed;
  background: white;
  color: var(--system-ink);
  text-align: left;
}

.ui-system-priority-row:last-child {
  border-bottom: 0;
}

.ui-system-priority-row:hover {
  background: #f6fafd;
}

.ui-system-priority-row.danger {
  box-shadow: inset 3px 0 0 var(--system-red);
}

.ui-system-priority-row.warn {
  box-shadow: inset 3px 0 0 var(--system-amber);
}

.ui-system-priority-row > span {
  min-width: 0;
  display: grid;
  gap: 3px;
}

.ui-system-priority-row strong,
.ui-system-priority-row small {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ui-system-priority-row strong {
  font-size: 12.5px;
  line-height: 1.35;
}

.ui-system-priority-row small {
  color: var(--system-muted);
  font-size: 10.5px;
  line-height: 1.35;
}

.ui-system-priority-order {
  grid-template-columns: 34px minmax(0, 1fr) !important;
  gap: 8px !important;
}

.ui-system-priority-order .home-platform-mark {
  grid-row: 1 / span 2;
}

.ui-system-priority-order > span {
  min-width: 0;
  display: grid;
  gap: 3px;
}

.ui-system-priority-next {
  grid-template-columns: minmax(0, 1fr) auto !important;
  color: var(--system-blue-dark);
}

.ui-system-priority-next .lucide {
  width: 16px;
  height: 16px;
}

.ui-system-workload-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  padding: 6px 12px;
}

.ui-system-workload-grid > span {
  min-width: 0;
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-rows: auto auto;
  gap: 2px 4px;
  padding: 10px;
  border-bottom: 1px solid var(--system-line);
}

.ui-system-workload-grid > span:nth-child(odd) {
  border-right: 1px solid var(--system-line);
}

.ui-system-workload-grid > span:nth-last-child(-n + 2) {
  border-bottom: 0;
}

.ui-system-workload-grid small {
  grid-column: 1 / span 2;
  color: var(--system-muted);
  font-size: 11px;
}

.ui-system-workload-grid strong {
  color: var(--system-ink);
  font-size: 23px;
  font-variant-numeric: tabular-nums;
}

.ui-system-workload-grid em {
  align-self: end;
  padding-bottom: 3px;
  color: var(--system-muted);
  font-size: 10px;
  font-style: normal;
}

.ui-system-capacity-note {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 2px 12px 12px;
  padding: 9px 10px;
  border: 1px solid #cbdbe5;
  border-radius: 6px;
  background: var(--system-blue-soft);
  color: var(--system-blue-dark);
}

.ui-system-capacity-note > span {
  display: grid;
  gap: 2px;
}

.ui-system-capacity-note small {
  color: #53758a;
  font-size: 10.5px;
}

.ui-system-platform-panel .dashboard-platform-row {
  width: calc(100% - 24px);
  height: 50px;
  min-height: 50px;
  grid-template-columns: 34px minmax(0, 1fr) auto auto;
  gap: 7px;
  margin-inline: 12px;
  padding: 0;
}

.ui-system-platform-panel .dashboard-notice-mini {
  display: none;
}

.ui-system-home-bottom {
  min-width: 0;
  display: grid;
  grid-template-columns: 0.9fr 1.05fr 1.05fr;
  gap: 12px;
  margin-top: 12px;
  padding: 0 16px;
}

.ui-system-home-bottom .ops-panel {
  min-width: 0;
}

.ui-system-boss-daily {
  border-top: 3px solid var(--system-amber);
}

.ui-system-boss-metrics {
  display: grid;
  grid-template-columns: 0.72fr 0.9fr 1.38fr;
  border-bottom: 1px solid var(--system-line);
}

.ui-system-boss-metrics > span {
  min-width: 0;
  display: grid;
  gap: 2px;
  padding: 10px 12px;
  border-right: 1px solid var(--system-line);
}

.ui-system-boss-metrics > span:last-child {
  border-right: 0;
  background: var(--system-amber-soft);
}

.ui-system-boss-metrics small,
.ui-system-boss-products small {
  color: var(--system-muted);
  font-size: 10px;
}

.ui-system-boss-metrics strong {
  overflow: hidden;
  color: var(--system-ink);
  font-size: 18px;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.ui-system-boss-metrics > span:last-child strong {
  color: #7a5216;
}

.ui-system-boss-products {
  display: grid;
  gap: 0;
}

.ui-system-boss-products > span {
  min-width: 0;
  display: grid;
  gap: 2px;
  padding: 7px 12px;
  border-bottom: 1px solid #e8edef;
}

.ui-system-boss-products > span:last-child {
  border-bottom: 0;
}

.ui-system-boss-products strong {
  overflow: hidden;
  font-size: 11px;
  line-height: 1.35;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ui-system-loop-panel {
  margin: 12px 16px 0;
}

.ui-system-loop-panel .dashboard-loop-grid {
  grid-template-columns: repeat(6, minmax(0, 1fr));
}

@media (max-width: 1180px) and (min-width: 761px) {
  #dashboardView .dashboard-alert-rail {
    grid-template-columns: repeat(5, minmax(138px, 1fr));
    padding-left: 0;
    overflow-x: auto;
  }

  #dashboardView .dashboard-alert-rail::before {
    display: none;
  }

  .ui-system-home-grid {
    grid-template-columns: minmax(0, 1fr) 280px;
  }

  .ui-system-priority-head,
  .ui-system-priority-row {
    grid-template-columns: 1.1fr 1.12fr 0.76fr 0.9fr 0.62fr;
  }

  .ui-system-home-bottom {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .ui-system-boss-daily {
    grid-column: 1 / -1;
  }

  .ui-system-loop-panel .dashboard-loop-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 760px) {
  .workspace > .topbar {
    min-height: 58px;
    margin: 0;
    padding: 6px 10px;
    border: 0;
    border-bottom: 1px solid rgba(211, 226, 235, 0.14);
    border-radius: 0;
    background: var(--system-navy-900) !important;
    color: #eef5f8 !important;
  }

  .topbar-title .eyebrow {
    color: #b9cbd4;
  }

  .topbar-title h1 {
    color: #ffffff !important;
  }

  .topbar .icon-btn,
  .topbar .user-badge,
  .topbar .status-dot {
    border-color: transparent;
    background: transparent !important;
    color: #eef5f8 !important;
  }

  #dashboardView {
    padding: 0 0 84px;
  }

  #dashboardView .dashboard-alert-rail {
    grid-template-columns: repeat(5, minmax(132px, 1fr));
    padding-left: 0;
    overflow-x: auto;
    scroll-snap-type: x proximity;
  }

  #dashboardView .dashboard-alert-rail::before {
    display: none;
  }

  #dashboardView .dashboard-alert {
    min-height: 64px;
    scroll-snap-align: start;
  }

  .ui-system-home-head {
    min-height: 0;
    display: grid;
    padding: 14px 12px 10px;
  }

  .ui-system-home-head h2 {
    font-size: 20px;
  }

  .ui-system-home-head .dashboard-command-actions {
    justify-content: stretch;
  }

  .ui-system-home-head .dashboard-command-actions > button {
    flex: 1 1 0;
    min-height: 44px;
  }

  .ui-system-home-grid,
  .ui-system-home-bottom {
    grid-template-columns: 1fr;
    padding-inline: 12px;
  }

  .ui-system-priority-head {
    display: none;
  }

  .ui-system-priority-row {
    min-height: 0;
    grid-template-columns: 1fr auto;
    gap: 8px 12px;
    padding: 12px;
  }

  .ui-system-priority-row > span {
    grid-column: 1;
  }

  .ui-system-priority-row > span:nth-child(2),
  .ui-system-priority-row > span:nth-child(3) {
    padding-left: 42px;
  }

  .ui-system-priority-row > span:nth-child(4) {
    grid-column: 2;
    grid-row: 1 / span 2;
    align-self: start;
    text-align: right;
  }

  .ui-system-priority-next {
    grid-column: 1 / -1 !important;
    min-height: 38px;
    align-items: center;
    justify-content: center;
    padding: 0 10px;
    border: 1px solid #c4d9e7;
    border-radius: 6px;
    background: var(--system-blue-soft);
  }

  .ui-system-home-rail {
    grid-template-columns: 1fr;
  }

  .ui-system-home-bottom {
    margin-top: 12px;
  }

  .ui-system-boss-metrics {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .ui-system-boss-metrics strong {
    font-size: 15px;
  }

  .ui-system-loop-panel {
    margin: 12px 12px 0;
  }

  .ui-system-loop-panel .dashboard-loop-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (prefers-reduced-motion: reduce) {
  .ui-system-priority-row,
  #dashboardView .dashboard-alert {
    transition: none;
  }
}

/* iOS zooms the visual viewport when a keyboard-enabled field is below 16px. */
@media (max-width: 760px) {
  input:not([type="hidden"]):not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="file"]):not([type="button"]):not([type="submit"]):not([type="reset"]):not([type="image"]):not([type="color"]),
  select,
  textarea,
  [contenteditable]:not([contenteditable="false"]) {
    font-size: 16px !important;
  }
}
