:root {
  --bg: #f4f6f7;
  --panel: #ffffff;
  --ink: #17212b;
  --muted: #637282;
  --line: #dbe2e7;
  --green: #2f7d63;
  --teal: #2f6f73;
  --amber: #a66f16;
  --red: #b8462c;
  --blue: #315f9f;
  --soft-green: #e3f2e8;
  --soft-amber: #fff2d8;
  --soft-red: #fde8e2;
  --shadow: 0 10px 25px rgba(24, 33, 42, 0.08);
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

body.login-required .sidebar,
body.login-required .main,
body.login-required .modal {
  display: none;
}

body.is-authenticated .login-screen {
  display: none;
}

.module-picker { display: none; }
body.is-authenticated.module-selection .module-picker { display: block; }
body.module-selection .sidebar,
body.module-selection .main,
body.module-selection .modal { display: none; }
body.modal-open { overflow: hidden; }
body.active-module-supply-chain [data-module-nav="complaints"],
body.active-module-supply-chain [data-module-nav="system-admin"],
body.active-module-complaints [data-module-nav="supply-chain"],
body.active-module-complaints [data-module-nav="system-admin"],
body.active-module-system-admin [data-module-nav="supply-chain"],
body.active-module-system-admin [data-module-nav="complaints"] { display: none; }

button, input, select {
  font: inherit;
}

.hidden { display: none !important; }

button {
  height: 36px;
  border: 0;
  border-radius: 6px;
  background: var(--ink);
  color: #fff;
  padding: 0 14px;
  font-weight: 800;
  cursor: pointer;
}

button.secondary { background: var(--teal); }
button:disabled { opacity: .55; cursor: wait; }
.mini-link {
  background: transparent;
  color: var(--teal);
  border: 0;
  padding: 0;
  font-size: 12px;
  font-weight: 900;
  box-shadow: none;
}
.mini-link:hover { text-decoration: underline; }

input, select {
  height: 36px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 10px;
  background: #fff;
  min-width: 160px;
}

.login-screen {
  min-height: 100vh;
  position: relative;
  overflow: hidden;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(360px, 430px);
  background: #090b0f;
}

.login-screen::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image: url("/assets/login-cover.png");
  background-size: cover;
  background-position: center;
  transform: scale(1.01);
}

.login-screen::after {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(90deg, rgba(4, 6, 10, .28), rgba(5, 7, 11, .12) 48%, rgba(5, 7, 11, .78) 72%, rgba(5, 7, 11, .94)),
    linear-gradient(0deg, rgba(3, 4, 7, .54), transparent 42%);
}

.login-visual {
  grid-column: 1;
  grid-row: 1;
  color: #fff;
  z-index: 1;
  padding: clamp(48px, 7vw, 96px);
  display: grid;
  align-content: space-between;
  gap: 28px;
  position: relative;
}

.login-logo {
  width: min(340px, 42vw);
  height: auto;
  filter: drop-shadow(0 12px 28px rgba(0,0,0,.45));
}

.login-visual h1 {
  font-size: clamp(40px, 5.4vw, 72px);
  line-height: 1.04;
  max-width: 760px;
  text-shadow: 0 18px 45px rgba(0,0,0,.36);
}

.login-copy {
  display: grid;
  gap: 14px;
  align-self: end;
}

.login-copy .login-kicker {
  margin: 0;
  color: rgba(255,255,255,.72);
  font-size: 14px;
  font-weight: 800;
}

.login-visual p {
  max-width: 560px;
  color: rgba(255,255,255,.82);
  font-size: 18px;
  line-height: 1.7;
}

.login-metrics {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-self: end;
}

.login-metrics span {
  border: 1px solid rgba(239, 207, 69, .4);
  border-radius: 999px;
  padding: 9px 14px;
  color: rgba(255,255,255,.9);
  background: rgba(8, 10, 14, .36);
  backdrop-filter: blur(12px);
  font-weight: 800;
}

.login-metrics span.is-live {
  border-color: rgba(239, 207, 69, .82);
  background: rgba(239, 207, 69, .14);
}

.login-metrics small {
  margin-left: 6px;
  color: rgba(255,255,255,.58);
  font-size: 11px;
  font-weight: 700;
}

.login-card {
  grid-column: 2;
  grid-row: 1;
  z-index: 1;
  align-self: center;
  justify-self: center;
  width: min(372px, calc(100vw - 36px));
  display: grid;
  gap: 16px;
  padding: 30px;
  border: 1px solid rgba(255,255,255,.16);
  border-radius: 8px;
  background: rgba(255,255,255,.94);
  box-shadow: 0 26px 80px rgba(0, 0, 0, .34);
  margin-right: clamp(24px, 4vw, 72px);
}

.login-card label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.login-card input,
.login-card button {
  width: 100%;
  height: 44px;
}

.login-card input {
  min-width: 0;
}

.login-message {
  min-height: 18px;
  color: var(--red);
  font-size: 13px;
  font-weight: 800;
}

.login-note {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}

.login-version {
  position: absolute;
  right: 24px;
  bottom: 18px;
  z-index: 1;
  color: rgba(255,255,255,.58);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
}

.module-picker {
  min-height: 100vh;
  padding: 34px clamp(20px, 5vw, 72px) 56px;
  background: #eef2f3;
}
.module-picker-head {
  max-width: 1220px;
  margin: 0 auto 40px;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
}
.module-picker-brand { display: grid; gap: 8px; }
.module-picker-brand span { color: var(--muted); font-size: 13px; font-weight: 800; }
.module-picker-brand h1 { font-size: 32px; }
.module-grid {
  max-width: 1220px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}
.module-option {
  min-width: 0;
  min-height: 310px;
  display: grid;
  grid-template-rows: auto auto 1fr auto;
  gap: 22px;
  padding: 24px;
  border: 1px solid var(--line);
  border-top: 4px solid var(--green);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow);
}
.module-option.complaints { border-top-color: var(--amber); }
.module-option.system-admin { border-top-color: var(--blue); }
.module-option.planned { border-top-color: var(--muted); box-shadow: none; opacity: .72; }
.module-option-index { color: var(--muted); font-size: 13px; font-weight: 900; }
.module-option p { color: var(--muted); font-size: 13px; font-weight: 800; }
.module-option h2 { margin-top: 6px; font-size: 22px; }
.module-option dl { margin: 0; display: grid; align-content: start; gap: 10px; }
.module-option dl div { display: grid; grid-template-columns: 52px 1fr; gap: 10px; border-bottom: 1px solid var(--line); padding-bottom: 10px; }
.module-option dt { color: var(--muted); font-size: 12px; font-weight: 800; }
.module-option dd { margin: 0; font-weight: 800; }
.module-option button { width: 100%; height: 42px; }
.module-option[hidden] { display: none; }

.account-summary-band {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  margin-bottom: 12px;
  overflow: hidden;
}
.account-metric { min-width: 0; padding: 14px 16px; border-right: 1px solid var(--line); }
.account-metric:last-child { border-right: 0; }
.account-metric span { display: block; color: var(--muted); font-size: 12px; font-weight: 800; }
.account-metric strong { display: block; margin-top: 5px; font-size: 24px; font-variant-numeric: tabular-nums; }
.account-panel { padding: 0; }
.account-panel .panel-head { padding: 16px; margin: 0; }
.account-table-wrap { border-width: 1px 0 0; border-radius: 0 0 8px 8px; }
.account-table { min-width: 900px; }
.account-identity { display: grid; gap: 3px; }
.account-identity strong { font-size: 14px; }
.account-identity span { color: var(--muted); font-size: 12px; }
.account-module-list { display: flex; gap: 5px; flex-wrap: wrap; }
.account-module-tag { padding: 4px 7px; border-radius: 4px; background: #edf3f3; color: var(--teal); font-size: 11px; font-weight: 900; }
.account-state { font-weight: 900; }
.account-state.is-off { color: var(--red); }
.account-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.account-actions button { height: 30px; padding: 0 9px; font-size: 12px; }
.modal-panel.account-modal-panel {
  inset: 48px auto auto 50%;
  width: min(680px, calc(100vw - 36px));
  max-height: calc(100vh - 96px);
  transform: translateX(-50%);
  grid-template-rows: auto minmax(0, 1fr);
}
.account-form { min-height: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 12px; overflow: auto; }
.account-form > label { display: grid; gap: 6px; color: var(--muted); font-size: 13px; font-weight: 800; }
.account-form input, .account-form select { width: 100%; min-width: 0; }
.account-module-fields { grid-column: 1 / -1; display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 0; padding: 12px; border: 1px solid var(--line); border-radius: 6px; }
.account-module-fields legend { padding: 0 6px; color: var(--muted); font-size: 12px; font-weight: 900; }
.account-module-fields label, .account-active-field { display: flex !important; align-items: center; gap: 7px; color: var(--ink) !important; }
.account-module-fields input, .account-active-field input { width: 16px; height: 16px; min-width: 16px; }
.account-active-field, .account-form .modal-actions, .account-form .ticket-form-message { grid-column: 1 / -1; }
.account-password-result { display: grid; gap: 8px; margin: 10px 0 18px; }
.account-password-result span { color: var(--muted); font-size: 13px; font-weight: 800; }
.account-password-result code { display: block; overflow-wrap: anywhere; padding: 14px; border: 1px solid var(--line); border-radius: 6px; background: #f4f6f7; font-size: 18px; font-weight: 900; user-select: all; }

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: 220px;
  background: #fff;
  border-right: 1px solid var(--line);
  padding: 18px 14px;
  display: flex;
  flex-direction: column;
}

.brand {
  display: grid;
  gap: 4px;
  padding: 6px 8px 18px;
}
.brand span { color: var(--muted); font-size: 12px; font-weight: 800; }
.brand strong { font-size: 18px; line-height: 1.25; }
nav { display: grid; gap: 4px; align-content: start; flex: 1; }
.nav-group-label {
  margin: 12px 10px 2px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 900;
}
nav a {
  color: var(--ink);
  text-decoration: none;
  padding: 10px 12px;
  border-radius: 6px;
  font-weight: 800;
}
nav a.active, nav a:hover { background: #edf3f3; color: var(--teal); }
.module-switch-button {
  width: 100%;
  margin-top: 18px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--teal);
}
.module-switch-top { background: transparent; color: var(--teal); border: 1px solid var(--line); }

.main {
  margin-left: 220px;
  min-height: 100vh;
  padding: 22px 24px 40px;
}

.topbar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 18px;
}
.eyebrow { margin: 0 0 6px; color: var(--muted); font-size: 13px; font-weight: 800; }
h1, h2, p { margin: 0; }
h1 { font-size: 28px; }
h2 { font-size: 18px; }
.top-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; }

.user-box {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
}

.user-box span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.toast {
  position: fixed;
  right: 24px;
  top: 20px;
  z-index: 5;
  min-width: 220px;
  max-width: 520px;
  padding: 12px 14px;
  border-radius: 8px;
  color: #fff;
  background: var(--ink);
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateY(-10px);
  pointer-events: none;
  transition: .2s ease;
}
.toast.show { opacity: 1; transform: none; }
.toast.error { background: var(--red); }

.page { display: none; }
.page.active { display: block; }

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 14px;
}
.kpi, .panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}
.kpi {
  min-height: 112px;
  padding: 16px;
  display: grid;
  align-content: space-between;
}
.kpi span { color: var(--muted); font-size: 13px; font-weight: 800; }
.kpi strong { font-size: 30px; font-variant-numeric: tabular-nums; }
.kpi em { color: var(--muted); font-size: 12px; font-style: normal; }

.panel { padding: 16px; margin-bottom: 16px; }
.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 14px;
}
.panel-head span, .hint { color: var(--muted); font-size: 13px; margin-top: 5px; }
.actions, .form-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.quick-filters {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin: -4px 0 12px;
}
.chip {
  height: 30px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--muted);
  border-radius: 999px;
  padding: 0 12px;
  font-size: 13px;
}
.chip.active {
  background: #edf3f3;
  border-color: #bdd6d5;
  color: var(--teal);
}

.flow {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 8px;
}
.flow span {
  text-align: center;
  padding: 12px 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #f8fafb;
  color: var(--muted);
  font-weight: 800;
  font-size: 13px;
}

.table-wrap {
  overflow: auto;
  max-height: calc(100vh - 220px);
  border: 1px solid var(--line);
  border-radius: 8px;
}
table {
  width: 100%;
  border-collapse: collapse;
  min-width: 1180px;
  background: #fff;
}
th, td {
  border-bottom: 1px solid var(--line);
  padding: 9px 10px;
  text-align: left;
  font-size: 13px;
  vertical-align: middle;
  white-space: nowrap;
}
th {
  position: sticky;
  top: 0;
  background: #f8fafb;
  color: var(--muted);
  z-index: 1;
}
td input {
  min-width: 82px;
  width: 82px;
  height: 30px;
}
.row-check {
  width: 16px;
  min-width: 16px;
  height: 16px;
  padding: 0;
  margin: 0;
  cursor: pointer;
  vertical-align: middle;
}
.name-cell { max-width: 260px; overflow: hidden; text-overflow: ellipsis; }
.name-cell.wide { max-width: 560px; }
.order-no-cell {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-width: 168px;
}
.hover-action {
  opacity: 0;
  pointer-events: none;
  transition: opacity .15s ease;
}
tr:hover .hover-action,
.order-no-cell:focus-within .hover-action {
  opacity: 1;
  pointer-events: auto;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-width: 42px;
  justify-content: center;
  border-radius: 999px;
  padding: 4px 8px;
  font-size: 12px;
  font-weight: 900;
}
.risk-high { background: var(--soft-red); color: var(--red); }
.risk-mid { background: var(--soft-amber); color: var(--amber); }
.risk-low { background: var(--soft-green); color: var(--green); }
.risk-safe { background: #edf3f3; color: var(--teal); }
.status-pending { background: #eef2f6; color: var(--muted); }
.status-ok { background: var(--soft-green); color: var(--green); }
.status-export { background: #e8effb; color: var(--blue); }
.arrival-complete td {
  background: #edf8f1;
}
.arrival-complete td:last-child {
  color: var(--green);
  font-weight: 800;
}
.hot30-row td {
  background: #fff8df;
}
.hot7-row td {
  background: #edf9f9;
}
.hot30-row.hot7-row td {
  background: linear-gradient(90deg, #fff5ce 0, #fff5ce 52%, #e6f8f8 100%);
}
.hot30-row td:first-child {
  border-left: 4px solid #e7b722;
}
.hot7-row td:first-child {
  border-left: 4px solid #2f9da0;
}
.hot30-row.hot7-row td:first-child {
  border-left-color: #1a1510;
}
.hot-tag {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-left: 8px;
  min-width: 34px;
  height: 20px;
  border-radius: 999px;
  background: #1a1510;
  color: #f4cf45;
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0;
  box-shadow: 0 5px 14px rgba(166, 111, 22, .22);
}
.hot7-tag {
  background: #0e4d52;
  color: #baf7f3;
  box-shadow: 0 5px 14px rgba(47, 111, 115, .2);
}
.trend-trigger {
  cursor: crosshair;
  text-decoration: underline dotted rgba(23, 33, 43, .35);
  text-underline-offset: 4px;
}
.trend-tooltip {
  position: fixed;
  z-index: 40;
  width: 286px;
  padding: 12px;
  border: 1px solid rgba(255,255,255,.12);
  border-radius: 8px;
  background: rgba(15, 18, 22, .96);
  color: #fff;
  box-shadow: 0 22px 60px rgba(0,0,0,.28);
  pointer-events: none;
  opacity: 0;
  transform: translateY(6px);
  transition: opacity .14s ease, transform .14s ease;
}
.trend-tooltip.show {
  opacity: 1;
  transform: none;
}
.trend-title {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 900;
  font-size: 13px;
}
.trend-sub {
  margin-top: 4px;
  color: rgba(255,255,255,.6);
  font-size: 12px;
}
.sparkline {
  width: 100%;
  height: 82px;
  margin-top: 8px;
  display: block;
}
.sparkline-area {
  fill: rgba(244, 207, 69, .14);
  stroke: none;
}
.sparkline-line {
  fill: none;
  stroke: #f4cf45;
  stroke-width: 3;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.trend-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  margin-top: 8px;
}
.trend-stats span {
  border-radius: 6px;
  background: rgba(255,255,255,.08);
  padding: 6px 4px;
  text-align: center;
  color: rgba(255,255,255,.86);
  font-size: 12px;
  font-weight: 800;
}
.trend-loading {
  color: rgba(255,255,255,.74);
  font-size: 13px;
  font-weight: 800;
}

.split {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 18px;
  align-items: stretch;
}

.import-grid {
  display: grid;
  grid-template-columns: minmax(260px, 1.4fr) minmax(180px, .8fr) minmax(240px, 1fr);
  gap: 12px;
  margin: 14px 0;
}
.import-grid label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 900;
}
.import-grid input,
.import-grid select {
  width: 100%;
}
.import-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  min-height: 32px;
  align-items: center;
  margin: 4px 0 12px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}
.cell-note {
  display: inline-block;
  margin-left: 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.label-preview {
  border: 1px dashed var(--line);
  border-radius: 8px;
  display: grid;
  align-content: center;
  gap: 8px;
  padding: 18px;
  min-height: 160px;
  background: #f8fafb;
}
.label-preview span { color: var(--muted); }

.settings-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 16px;
}
.settings-grid label { display: grid; gap: 6px; color: var(--muted); font-size: 13px; font-weight: 800; margin-bottom: 10px; }
.settings-grid input { width: 100%; }
.kv {
  display: grid;
  grid-template-columns: 130px 1fr;
  gap: 8px 12px;
  margin: 12px 0;
  font-size: 13px;
}
.kv span:nth-child(odd) { color: var(--muted); font-weight: 800; }
pre {
  white-space: pre-wrap;
  background: #f8fafb;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  max-height: 260px;
  overflow: auto;
}
.logs {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}
.log-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #f8fafb;
  min-height: 220px;
  max-height: 520px;
  overflow: auto;
}
.log-card h3 { margin: 0 0 8px; font-size: 15px; }
.log-card p { font-size: 12px; color: var(--muted); margin: 0 0 8px; border-bottom: 1px solid var(--line); padding-bottom: 8px; }

.ticket-summary-band {
  display: grid;
  grid-template-columns: repeat(6, minmax(110px, 1fr));
  margin-bottom: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: #fff;
  box-shadow: var(--shadow);
}
.ticket-flow-guide {
  margin-bottom: 12px;
  padding: 14px 16px 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow);
  overflow: hidden;
}
.ticket-flow-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}
.ticket-flow-head p { color: var(--muted); font-size: 11px; font-weight: 900; }
.ticket-flow-head h2 { margin-top: 3px; font-size: 16px; }
.ticket-flow-head > span { color: var(--muted); font-size: 12px; font-weight: 800; }
.ticket-flow-steps {
  display: grid;
  grid-template-columns: repeat(7, minmax(128px, 1fr));
  width: 100%;
  overflow-x: auto;
}
.ticket-flow-step {
  min-width: 0;
  min-height: 66px;
  position: relative;
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr);
  gap: 8px;
  align-items: start;
  padding: 8px 12px 6px 0;
}
.ticket-flow-step:not(:last-child)::after {
  content: "";
  position: absolute;
  left: 28px;
  right: 0;
  top: 18px;
  height: 2px;
  background: var(--line);
  z-index: 0;
}
.ticket-flow-number {
  width: 24px;
  height: 24px;
  position: relative;
  z-index: 1;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: #fff;
  color: var(--muted);
  font-size: 11px;
  font-weight: 900;
}
.ticket-flow-step b, .ticket-flow-step small { display: block; position: relative; z-index: 1; background: #fff; }
.ticket-flow-step b { padding-right: 4px; font-size: 12px; }
.ticket-flow-step small { margin-top: 5px; padding-right: 5px; color: var(--muted); line-height: 1.35; }
.ticket-flow-step.completed .ticket-flow-number { border-color: var(--green); background: var(--green); color: #fff; }
.ticket-flow-step.completed:not(:last-child)::after { background: var(--green); }
.ticket-flow-step.active .ticket-flow-number { border: 2px solid var(--blue); color: var(--blue); }
.ticket-flow-step.active b { color: var(--blue); }
.ticket-flow-step.attention .ticket-flow-number { border: 2px solid var(--red); color: var(--red); }
.ticket-flow-step.attention b { color: var(--red); }
.ticket-metric { min-height: 78px; padding: 13px 14px; border-right: 1px solid var(--line); }
.ticket-metric:last-child { border-right: 0; }
.ticket-metric span { display: block; color: var(--muted); font-size: 12px; font-weight: 800; }
.ticket-metric strong { display: block; margin-top: 6px; font-size: 25px; line-height: 1; font-variant-numeric: tabular-nums; }
.ticket-metric.danger strong { color: var(--red); }
.ticket-metric.warning strong { color: var(--amber); }
.ticket-metric.good strong { color: var(--green); }
.ticket-toolbar { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; }
.ticket-toolbar input { flex: 1; min-width: 260px; }
.ticket-toolbar button[aria-label="刷新"] { width: 38px; padding: 0; font-size: 20px; }
.ticket-workspace { display: grid; grid-template-columns: minmax(620px, 1fr) minmax(360px, 440px); gap: 12px; align-items: start; }
.ticket-queue, .ticket-detail { min-width: 0; min-height: 620px; border: 1px solid var(--line); border-radius: 8px; background: #fff; box-shadow: var(--shadow); }
.ticket-section-head { height: 50px; padding: 0 14px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--line); }
.ticket-section-head h2 { font-size: 16px; }
.ticket-section-head span { color: var(--muted); font-size: 12px; }
.ticket-table-wrap { width: 100%; max-height: calc(100vh - 270px); border: 0; border-radius: 0 0 8px 8px; }
.ticket-table { min-width: 920px; table-layout: fixed; }
.ticket-table th:nth-child(1) { width: 58px; }
.ticket-table th:nth-child(2) { width: 31%; }
.ticket-table th:nth-child(3) { width: 82px; }
.ticket-table th:nth-child(4) { width: 116px; }
.ticket-table th:nth-child(5) { width: 142px; }
.ticket-table th:nth-child(6) { width: 98px; }
.ticket-table tbody tr { cursor: pointer; }
.ticket-table tbody tr:hover, .ticket-table tbody tr.selected { background: #eef5f4; }
.ticket-table td { white-space: normal; vertical-align: top; }
.ticket-id { font-weight: 900; word-break: break-all; }
.ticket-subline { margin-top: 3px; color: var(--muted); font-size: 12px; line-height: 1.35; word-break: break-word; }
.ticket-badge { display: inline-flex; min-width: 34px; min-height: 24px; align-items: center; justify-content: center; border-radius: 5px; padding: 2px 7px; color: #fff; font-size: 12px; font-weight: 900; }
.ticket-badge.p0 { background: var(--red); }
.ticket-badge.p1 { background: var(--amber); }
.ticket-badge.p2 { background: var(--blue); }
.ticket-badge.p3 { background: var(--green); }
.ticket-health-overdue { color: var(--red); font-weight: 900; }
.ticket-health-due_soon { color: var(--amber); font-weight: 900; }
.ticket-health-completed_late { color: #7852a3; font-weight: 900; }
.ticket-health-normal, .ticket-health-completed { color: var(--green); font-weight: 900; }
.ticket-health-blocked { color: var(--muted); font-weight: 900; }
.ticket-detail .empty { padding: 36px 24px; color: var(--muted); text-align: center; }
.ticket-detail-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; padding: 14px; border-bottom: 1px solid var(--line); }
.ticket-detail-head h2 { font-size: 17px; word-break: break-all; }
.ticket-detail-head p { margin-top: 4px; color: var(--muted); font-size: 12px; }
.ticket-detail-actions { display: flex; gap: 6px; flex-shrink: 0; }
.ticket-detail-section { padding: 13px 14px; border-bottom: 1px solid var(--line); }
.ticket-detail-section:last-child { border-bottom: 0; }
.ticket-detail-section h3 { margin: 0 0 9px; font-size: 13px; }
.ticket-facts { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 12px; }
.ticket-fact label { display: block; color: var(--muted); font-size: 11px; }
.ticket-fact div { margin-top: 2px; white-space: pre-wrap; word-break: break-word; }
.ticket-fact.full { grid-column: 1 / -1; }
.ticket-nodes { display: grid; gap: 7px; }
.ticket-node { display: grid; grid-template-columns: 24px 1fr auto; gap: 8px; align-items: start; min-height: 48px; }
.ticket-node-index { width: 21px; height: 21px; display: grid; place-items: center; border: 1px solid var(--line); font-size: 11px; }
.ticket-node.completed .ticket-node-index { border-color: var(--green); background: var(--green); color: #fff; }
.ticket-node b, .ticket-node small { display: block; }
.ticket-node b { font-size: 12px; }
.ticket-node small { color: var(--muted); }
.ticket-node button { height: 28px; padding: 0 8px; background: transparent; color: var(--teal); }
.ticket-events { max-height: 190px; overflow: auto; }
.ticket-event { padding: 7px 0; border-bottom: 1px solid var(--line); }
.ticket-event:last-child { border-bottom: 0; }
.ticket-event small { color: var(--muted); }
.ticket-event p { margin-top: 3px; white-space: pre-wrap; }
.ticket-page-panel { padding: 0; }
.ticket-page-panel .panel-head { padding: 14px 16px 0; }
.ticket-page-panel .table-wrap { border-width: 1px 0 0; border-radius: 0; }
.ticket-wide-table { min-width: 980px; }
.ticket-analysis-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.ticket-analysis-list { display: grid; }
.ticket-analysis-row { min-height: 45px; display: flex; align-items: center; justify-content: space-between; gap: 12px; border-bottom: 1px solid var(--line); }
.ticket-analysis-row:last-child { border-bottom: 0; }
.ticket-analysis-row span { color: var(--muted); }
.ticket-analysis-row strong { font-size: 18px; }
.ticket-form { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; overflow: auto; padding: 2px 2px 4px; }
.ticket-form label, .ticket-node-form label { display: grid; gap: 5px; color: var(--muted); font-size: 12px; font-weight: 800; }
.ticket-form input, .ticket-form select, .ticket-form textarea, .ticket-node-form input, .ticket-node-form textarea { width: 100%; min-width: 0; }
.ticket-form textarea, .ticket-node-form textarea { min-height: 72px; padding: 8px 10px; resize: vertical; border: 1px solid var(--line); border-radius: 6px; font: inherit; }
.ticket-form-wide { grid-column: 1 / -1; }
.ticket-form-message { min-height: 20px; margin: 0; color: var(--red); }
.ticket-node-form { display: grid; gap: 12px; }


.modal {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: none;
}
.modal.open { display: block; }
.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(23, 33, 43, 0.42);
}
.modal-panel {
  position: absolute;
  inset: 42px 42px auto 42px;
  max-height: calc(100vh - 84px);
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 24px 70px rgba(23, 33, 43, 0.24);
  padding: 16px;
}
.modal-panel.ticket-modal-panel {
  inset: 24px auto auto 50%;
  width: min(880px, calc(100vw - 36px));
  max-height: calc(100vh - 48px);
  transform: translateX(-50%);
  grid-template-rows: auto minmax(0, 1fr);
}
.modal-panel.ticket-node-modal {
  inset: 100px auto auto 50%;
  width: min(620px, calc(100vw - 36px));
  transform: translateX(-50%);
  grid-template-rows: auto auto;
}
.compact-modal {
  inset: 120px auto auto 50%;
  width: min(560px, calc(100vw - 48px));
  max-height: calc(100vh - 160px);
  transform: translateX(-50%);
  grid-template-rows: auto auto auto;
}
.modal-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}
.modal-head span {
  display: block;
  margin-top: 6px;
  color: var(--muted);
  font-size: 13px;
}
.icon-button {
  width: 34px;
  height: 34px;
  padding: 0;
  border-radius: 6px;
  background: #eef2f6;
  color: var(--ink);
  font-size: 22px;
  line-height: 1;
}
.modal-tools {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}
.modal-tools input {
  width: min(520px, 60vw);
}
.plan-add-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  min-width: min(520px, 100%);
}
.plan-add-controls input[list] {
  width: min(360px, 38vw);
}
.plan-add-controls input[type="number"] {
  width: 88px;
  min-width: 88px;
}
.modal-section-title {
  margin: 0 0 8px;
  color: var(--ink);
  font-weight: 900;
}
.row-actions {
  display: flex;
  gap: 6px;
  align-items: center;
  white-space: nowrap;
}
.draft-cell {
  min-width: 150px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.draft-pick {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: var(--teal);
  font-size: 12px;
  font-weight: 900;
  opacity: 1;
  white-space: nowrap;
}
.draft-pick input {
  width: 14px;
  height: 14px;
  min-width: 14px;
  padding: 0;
}
.draft-qty {
  width: 58px;
  min-width: 58px;
  padding: 5px 6px;
  text-align: center;
  font-size: 12px;
  font-weight: 900;
}
.draft-qty:disabled {
  opacity: .45;
  background: #f3f6f8;
}
.draft-selected-row {
  box-shadow: inset 3px 0 0 var(--teal);
  background: #edfafa;
}
button.danger,
button.danger-text {
  background: #fff1f2;
  color: #be123c;
  border: 1px solid #fecdd3;
}
.modal-table {
  max-height: calc(100vh - 230px);
}
.modal-table table {
  min-width: 1500px;
}
.modal-table .reason-input {
  width: 180px;
  min-width: 180px;
}
.modal-form {
  display: grid;
  gap: 12px;
  margin-bottom: 14px;
}
.modal-form label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}
.modal-form input,
.modal-form select {
  width: 100%;
}
.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}
.label-workbench {
  inset: 18px 20px auto 20px;
  width: auto;
  max-height: calc(100vh - 36px);
  padding: 18px;
}
.label-controls {
  align-items: end;
  grid-template-columns: 1fr 1.4fr 120px auto auto;
}
.label-workbench-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(430px, 0.9fr);
  gap: 16px;
  min-height: 0;
}
.label-workbench-panel {
  min-width: 0;
  min-height: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: #fbfcfd;
}
.panel-subhead {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}
.panel-subhead h3 {
  margin: 0;
  font-size: 15px;
}
.panel-subhead span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}
.label-items-wrap {
  max-height: calc(100vh - 250px);
}
.label-items-wrap table {
  min-width: 980px;
}
.label-items-wrap th:first-child,
.label-items-wrap td:first-child {
  width: 46px;
  text-align: center;
}
.label-items-wrap .print-qty-input {
  width: 68px;
  min-width: 68px;
}
.label-wave-list {
  display: grid;
  gap: 10px;
  max-height: calc(100vh - 250px);
  overflow: auto;
  padding-right: 4px;
}
.label-wave-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fff;
}
.label-wave-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}
.label-wave-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 900;
}
.label-wave-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  margin-bottom: 10px;
}
.label-wave-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.label-mini-preview {
  width: 180px;
  height: 120px;
  border: 1px solid #111827;
  border-radius: 3px;
  padding: 6px;
  background: #fff;
  color: #111827;
  font-size: 10px;
  line-height: 1.25;
}
.label-mini-preview strong {
  display: block;
  font-size: 12px;
  margin-bottom: 4px;
}

.muted-line {
  color: var(--muted);
  font-size: 13px;
  margin: -4px 0 14px;
}
.fulfillment-board {
  display: grid;
  gap: 14px;
}
.fulfillment-toolbar {
  flex-wrap: wrap;
}
.fulfillment-toolbar select {
  min-width: 180px;
}
.fulfillment-toolbar #fulfillmentProductSelect {
  min-width: 260px;
}
.fulfillment-toolbar #fulfillmentItemId {
  max-width: 170px;
}
.fulfillment-toolbar input[type="date"] {
  min-width: 138px;
}
.fulfillment-kpis {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}
.fulfillment-kpi,
.fulfillment-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}
.fulfillment-kpi {
  min-height: 96px;
  padding: 14px;
  display: grid;
  align-content: space-between;
}
.fulfillment-kpi span,
.fulfillment-kpi em,
.fulfillment-card-head span {
  color: var(--muted);
}
.fulfillment-kpi span {
  font-size: 13px;
  font-weight: 900;
}
.fulfillment-kpi strong {
  font-size: 26px;
  line-height: 1.15;
}
.fulfillment-kpi em {
  font-size: 12px;
  font-style: normal;
}
.fulfillment-routes {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr);
  gap: 14px;
}
.fulfillment-card {
  padding: 14px;
}
.fulfillment-card-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: baseline;
  margin-bottom: 12px;
}
.fulfillment-card-head h3 {
  margin: 0;
  font-size: 17px;
}
.fulfillment-card-head span {
  font-size: 12px;
  font-weight: 800;
}
.fulfillment-mini {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 12px;
}
.fulfillment-mini-stat {
  border: 1px solid #e5edf0;
  border-radius: 7px;
  padding: 8px 10px;
  background: #f8fbfb;
}
.fulfillment-mini-stat span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  margin-bottom: 4px;
}
.fulfillment-mini-stat strong {
  font-size: 18px;
}
.fulfillment-stages {
  display: grid;
  gap: 7px;
}
.fulfillment-stage {
  display: grid;
  grid-template-columns: minmax(110px, 150px) 1fr minmax(82px, auto);
  gap: 10px;
  align-items: center;
  font-size: 13px;
}
.fulfillment-stage-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 800;
}
.fulfillment-bar {
  height: 8px;
  border-radius: 999px;
  background: #edf2f4;
  overflow: hidden;
}
.fulfillment-bar span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--teal);
}
.fulfillment-stage-count {
  text-align: right;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.brand-maintenance-grid {
  display: grid;
  grid-template-columns: 340px minmax(0, 1fr);
  min-height: 560px;
  border-top: 1px solid var(--line);
}
.brand-profile-editor {
  display: grid;
  align-content: start;
  gap: 14px;
  padding: 20px 22px 20px 0;
  border-right: 1px solid var(--line);
}
.brand-profile-editor label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}
.brand-logo-preview {
  height: 100px;
  display: grid;
  place-items: center;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #f7f9f9;
  overflow: hidden;
}
.brand-logo-preview img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}
.brand-logo-preview strong {
  font-size: 24px;
  line-height: 1.1;
  text-align: center;
}
.brand-product-panel {
  min-width: 0;
  padding: 20px 0 20px 22px;
}
.brand-product-panel .panel-subhead {
  align-items: flex-start;
  margin-bottom: 14px;
}
.brand-product-panel .toolbar {
  flex-wrap: wrap;
  justify-content: flex-end;
}
.brand-product-panel .toolbar input {
  width: 220px;
}
.brand-product-panel .compact-table {
  max-height: 520px;
}

@media (max-width: 980px) {
  .module-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .module-option.planned { grid-column: 1 / -1; min-height: 240px; }
  .login-screen {
    grid-template-columns: 1fr;
    padding: 18px;
  }
  .login-visual {
    padding: 34px 4px 10px;
  }
  .login-visual h1 {
    font-size: 34px;
  }
  .login-card {
    align-self: start;
    margin-right: 0;
  }
  .login-version {
    right: 18px;
    bottom: 14px;
  }
  .sidebar { position: static; width: auto; border-right: 0; border-bottom: 1px solid var(--line); }
  nav { grid-template-columns: repeat(4, 1fr); }
  .nav-group-label { grid-column: 1 / -1; margin-top: 8px; }
  .main { margin-left: 0; padding: 16px; }
  .topbar, .panel-head { align-items: stretch; flex-direction: column; }
  .user-box { justify-content: flex-start; }
  .modal-panel { inset: 16px; max-height: calc(100vh - 32px); }
  .compact-modal { width: auto; transform: none; }
  .modal-tools { align-items: stretch; flex-direction: column; }
  .modal-tools input { width: 100%; }
  .plan-add-controls { min-width: 0; flex-wrap: wrap; }
  .plan-add-controls input[list] { width: 100%; }
  .label-controls,
  .label-workbench-grid {
    grid-template-columns: 1fr;
  }
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .fulfillment-kpis,
  .fulfillment-routes {
    grid-template-columns: 1fr;
  }
  .flow { grid-template-columns: repeat(2, 1fr); }
  .settings-grid, .split, .logs { grid-template-columns: 1fr; }
  .brand-maintenance-grid { grid-template-columns: 1fr; }
  .brand-profile-editor {
    padding: 18px 0;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }
  .brand-product-panel { padding: 18px 0 0; }
  .brand-product-panel .toolbar { justify-content: flex-start; }
  .brand-product-panel .toolbar input { width: 100%; }
  .ticket-summary-band { grid-template-columns: repeat(3, 1fr); }
  .ticket-workspace { grid-template-columns: 1fr; }
  .ticket-queue, .ticket-detail { min-height: 0; }
  .ticket-table-wrap { max-height: none; }
  .ticket-analysis-grid { grid-template-columns: 1fr; }
  .account-summary-band { grid-template-columns: repeat(2, 1fr); }
  .account-metric:nth-child(2) { border-right: 0; }
  .account-metric { border-bottom: 1px solid var(--line); }
  .account-metric:nth-last-child(-n+2) { border-bottom: 0; }
}

@media (max-width: 680px) {
  .module-picker { padding: 22px 16px 36px; }
  .module-picker-head { align-items: flex-start; flex-direction: column; margin-bottom: 24px; }
  .module-picker-brand h1 { font-size: 27px; }
  .module-grid { grid-template-columns: 1fr; }
  .module-option, .module-option.planned { grid-column: auto; min-height: 270px; }
  .sidebar { padding-bottom: 10px; }
  .sidebar nav { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 6px; }
  .sidebar .nav-group-label { display: none; }
  .sidebar nav a { flex: 0 0 auto; padding: 8px 10px; }
  .ticket-flow-head { align-items: flex-start; flex-direction: column; }
  .ticket-summary-band { grid-template-columns: repeat(2, 1fr); }
  .ticket-metric { border-bottom: 1px solid var(--line); }
  .ticket-toolbar { flex-wrap: wrap; }
  .ticket-toolbar input { min-width: 100%; }
  .ticket-toolbar select, .ticket-toolbar button { flex: 1 1 120px; }
  .ticket-facts, .ticket-form { grid-template-columns: 1fr; }
  .ticket-fact.full, .ticket-form-wide { grid-column: auto; }
  .ticket-detail-head { flex-direction: column; }
  .ticket-detail-actions { width: 100%; }
  .ticket-detail-actions button { flex: 1; }
  .modal-panel.ticket-modal-panel, .modal-panel.ticket-node-modal { inset: 12px; width: auto; max-height: calc(100vh - 24px); transform: none; }
  .modal-panel.account-modal-panel { inset: 12px; width: auto; max-height: calc(100vh - 24px); transform: none; }
  .account-form, .account-module-fields { grid-template-columns: 1fr; }
}
