:root {
  --bg: #f4f7fb;
  --panel: #ffffff;
  --text: #172033;
  --muted: #667085;
  --line: #d9e1ec;
  --primary: #1f5aa6;
  --primary-dark: #16457f;
  --success: #197647;
  --warning: #a15c00;
  --danger: #b42318;
  --info: #245b8f;
  --shadow: 0 6px 24px rgba(23, 32, 51, .08);
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: "Microsoft YaHei", "PingFang SC", Arial, sans-serif;
  color: var(--text);
  background: var(--bg);
  font-size: 16px;
  line-height: 1.55;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
.topbar {
  height: 64px;
  background: #153e73;
  color: white;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 10;
  box-shadow: 0 2px 10px rgba(0,0,0,.12);
}
.brand { font-size: 20px; font-weight: 700; letter-spacing: .5px; }
.topbar nav { display: flex; align-items: center; gap: 18px; }
.topbar a { color: white; }
.user-box { display: flex; align-items: center; gap: 12px; }
.container { max-width: 1380px; margin: 22px auto 44px; padding: 0 22px; }
.page-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 18px; }
h1 { font-size: 28px; margin: 0 0 6px; }
h2 { font-size: 22px; margin: 0 0 14px; }
h3 { font-size: 18px; margin: 0 0 10px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: var(--shadow);
  padding: 20px;
  margin-bottom: 18px;
}
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.stat { padding: 18px; border-left: 5px solid var(--primary); }
.stat .number { font-size: 30px; font-weight: 800; }
.stat .label { color: var(--muted); }
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 42px;
  padding: 9px 16px;
  border-radius: 7px;
  border: 1px solid transparent;
  background: var(--primary);
  color: white;
  cursor: pointer;
  font: inherit;
  font-weight: 600;
  text-decoration: none;
}
.btn:hover { background: var(--primary-dark); text-decoration: none; }
.btn.secondary { background: white; color: var(--primary); border-color: var(--primary); }
.btn.success { background: var(--success); }
.btn.warning { background: var(--warning); }
.btn.danger { background: var(--danger); }
.btn.gray { background: #5e6878; }
.btn.small-btn { min-height: 34px; padding: 5px 10px; font-size: 14px; }
.btn[disabled] { opacity: .45; cursor: not-allowed; }
.actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
label { display: block; font-weight: 700; margin-bottom: 6px; }
input, select, textarea {
  width: 100%;
  min-height: 43px;
  padding: 9px 11px;
  border: 1px solid #b9c5d5;
  border-radius: 6px;
  background: #fff;
  font: inherit;
  color: var(--text);
}
textarea { min-height: 92px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 3px solid rgba(31,90,166,.15); border-color: var(--primary); }
.field { margin-bottom: 14px; }
.required::after { content: " *"; color: var(--danger); }
.help { margin-top: 4px; color: var(--muted); font-size: 13px; }
table { width: 100%; border-collapse: collapse; }
th, td { border: 1px solid var(--line); padding: 11px 10px; vertical-align: top; }
th { background: #eaf1fa; text-align: left; font-weight: 700; }
tbody tr:nth-child(even) { background: #fafcff; }
.table-wrap { width: 100%; overflow-x: auto; }
.badge {
  display: inline-block;
  padding: 4px 9px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 700;
  background: #e9eef5;
  color: #344054;
  white-space: nowrap;
}
.badge.COMPLETED, .badge.APPROVED { background: #dff4e8; color: var(--success); }
.badge.ABNORMAL, .badge.REJECTED { background: #fde8e7; color: var(--danger); }
.badge.DRAFT { background: #fff0d6; color: var(--warning); }
.badge.PENDING { background: #e7eef8; color: var(--info); }
.badge.task-APPROVED { background: #dff4e8; color: var(--success); }
.badge.task-ABNORMAL, .badge.task-REJECTED { background: #fde8e7; color: var(--danger); }
.alert { border-radius: 7px; padding: 12px 15px; margin-bottom: 12px; border: 1px solid; }
.alert.success { background: #e7f6ed; border-color: #b8dfc7; color: #155d38; }
.alert.error { background: #fdeceb; border-color: #f0b7b2; color: #8c1d16; }
.alert.warning { background: #fff5df; border-color: #ead29d; color: #7b4a04; }
.alert.info { background: #eaf2fb; border-color: #bdd1ea; color: #234f80; }
.stage-list { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 12px; }
.stage-card { border: 1px solid var(--line); border-radius: 9px; padding: 15px; background: white; min-height: 145px; }
.stage-card.locked { opacity: .6; background: #f4f4f4; }
.stage-card h3 { margin-bottom: 8px; }
.stage-no { font-size: 13px; color: var(--muted); }
.progress-line { height: 7px; border-radius: 4px; background: #dfe7f1; overflow: hidden; margin: 14px 0 20px; }
.progress-line span { display: block; height: 100%; background: var(--primary); }
.check-table th:nth-child(1) { min-width: 170px; }
.check-table th:nth-child(2) { min-width: 330px; }
.check-table th:nth-child(3) { min-width: 130px; }
.check-table th:nth-child(4), .check-table th:nth-child(5) { min-width: 210px; }
.check-table select, .check-table input, .check-table textarea { font-size: 15px; }
.check-table textarea { min-height: 70px; }
.info-list { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 1px; background: var(--line); border: 1px solid var(--line); }
.info-item { background: white; padding: 11px 13px; min-height: 76px; }
.info-item .k { font-size: 13px; color: var(--muted); margin-bottom: 3px; }
.info-item .v { font-weight: 700; word-break: break-word; }
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 22px; background: linear-gradient(135deg, #123a6c, #2e73ba); }
.login-card { width: min(460px, 100%); background: white; border-radius: 14px; padding: 34px; box-shadow: 0 20px 50px rgba(0,0,0,.22); }
.login-card h1 { text-align: center; font-size: 25px; }
.login-card .company { text-align: center; color: var(--muted); margin-bottom: 24px; }
.inline-form { display: inline; }
.filter-bar { display: grid; grid-template-columns: minmax(240px,1fr) 190px 170px auto; gap: 10px; }
.note-box { background: #f5f8fc; border-left: 4px solid var(--primary); padding: 12px 14px; }
.report-page { background: white; max-width: 1120px; margin: 0 auto; padding: 30px; }
.report-title { text-align: center; }
.report-section { margin-top: 24px; page-break-inside: avoid; }
.signature-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 26px; margin-top: 28px; }
.hidden-print { }
@media (max-width: 1000px) {
  .grid-4, .grid-3, .stage-list, .info-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .topbar { height: auto; padding: 12px 16px; align-items: flex-start; }
  .topbar nav { flex-wrap: wrap; }
}
@media (max-width: 680px) {
  body { font-size: 15px; }
  .container { padding: 0 12px; }
  .grid-2, .grid-3, .grid-4, .stage-list, .info-list, .filter-bar { grid-template-columns: 1fr; }
  .topbar { position: static; display: block; }
  .topbar nav { margin-top: 10px; }
  .page-header { display: block; }
  .page-header .actions { margin-top: 12px; }
}
@media print {
  body { background: white; font-size: 11pt; }
  .topbar, .hidden-print, .alert { display: none !important; }
  .container { max-width: none; margin: 0; padding: 0; }
  .panel { box-shadow: none; border: 0; padding: 0; }
  .report-page { max-width: none; padding: 0; }
  th, td { padding: 5px; }
  a { color: black; text-decoration: none; }
}

.test-banner {
  position: sticky; top: 0; z-index: 1000;
  background: #fff3cd; color: #664d03; border-bottom: 1px solid #ffecb5;
  padding: 9px 16px; text-align: center; font-weight: 700;
}

/* v1.5 mobile inspection and inline photo experience */
.stage-last-submit { margin-bottom: 14px; }
.mobile-photo-tip { display: none; }
.compact-header { margin-bottom: 12px; }
.item-title { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.photo-required-badge {
  display: inline-flex; align-items: center; min-height: 25px; padding: 2px 8px;
  border-radius: 999px; background: #fff0d6; color: #8a4b00; border: 1px solid #efc374;
  font-size: 12px; font-weight: 800; white-space: nowrap;
}
.photo-required-row { background: #fffdf7 !important; }
.photo-cell { min-width: 270px; }
.photo-hint { color: #704100; background: #fff7e6; border-left: 4px solid #e39a22; padding: 8px 10px; margin-bottom: 9px; font-size: 13px; }
.photo-input { position: absolute; width: 1px; height: 1px; opacity: 0; overflow: hidden; pointer-events: none; }
.photo-picker {
  display: inline-flex; align-items: center; justify-content: center; width: 100%; min-height: 44px;
  padding: 9px 12px; margin: 0; border: 1px dashed var(--primary); border-radius: 8px;
  background: #edf5ff; color: var(--primary); font-weight: 800; cursor: pointer;
}
.photo-picker:hover { background: #e1efff; }
.photo-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin-top: 10px; }
.photo-thumb {
  position: relative; display: block; width: 100%; aspect-ratio: 1 / 1; padding: 0; overflow: hidden;
  border: 1px solid #cbd7e6; border-radius: 8px; background: #eef2f6; cursor: zoom-in;
}
.photo-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.photo-thumb span {
  position: absolute; left: 0; right: 0; bottom: 0; padding: 4px 5px;
  background: rgba(0,0,0,.62); color: white; font-size: 11px; text-align: center;
}
.photo-thumb.large { aspect-ratio: 4 / 3; }
.photo-count { margin-top: 6px; color: var(--muted); font-size: 12px; }
.new-photo-card { min-width: 0; }
.new-photo-card img { width: 100%; aspect-ratio: 1 / 1; object-fit: cover; border-radius: 7px; border: 1px solid var(--line); display: block; }
.new-photo-card span { display: block; margin-top: 3px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 11px; color: var(--muted); }
.attachment-list { display: flex; flex-wrap: wrap; gap: 9px; }
.task-photo-gallery { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
.task-photo-card { border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: white; }
.task-photo-meta { padding: 10px 11px 12px; }
.lightbox {
  position: fixed; inset: 0; z-index: 2000; display: none; align-items: center; justify-content: center;
  padding: 18px; background: rgba(5, 12, 24, .92);
}
.lightbox.open { display: flex; flex-direction: column; }
.lightbox img { max-width: min(1200px, 96vw); max-height: 82vh; object-fit: contain; border-radius: 8px; box-shadow: 0 20px 60px rgba(0,0,0,.45); }
.lightbox-close { position: fixed; right: 18px; top: 12px; width: 48px; height: 48px; border: 0; border-radius: 50%; color: white; background: rgba(255,255,255,.16); font-size: 34px; cursor: pointer; }
.lightbox-caption { color: white; margin-top: 10px; text-align: center; max-width: 90vw; }
.no-scroll { overflow: hidden; }
.stage-submit-bar { margin: 14px 0 28px; }

@media (max-width: 920px) {
  .task-photo-gallery { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .topbar nav { overflow-x: auto; max-width: 100%; padding-bottom: 4px; flex-wrap: nowrap; }
  .topbar nav a { white-space: nowrap; }
  .user-box { margin-top: 10px; justify-content: space-between; width: 100%; }
}

@media (max-width: 680px) {
  body { font-size: 16px; }
  h1 { font-size: 23px; }
  h2 { font-size: 20px; }
  .container { padding: 0 9px; margin-top: 12px; }
  .panel { padding: 13px; border-radius: 9px; margin-bottom: 12px; }
  .mobile-photo-tip { display: block; }
  .inspection-panel { padding: 0; background: transparent; border: 0; box-shadow: none; overflow: visible; }
  .mobile-card-table, .mobile-card-table tbody, .mobile-card-table tr, .mobile-card-table td { display: block; width: 100%; }
  .mobile-card-table thead { display: none; }
  .mobile-card-table .inspection-row {
    margin-bottom: 14px; border: 1px solid var(--line); border-radius: 11px; overflow: hidden;
    background: white !important; box-shadow: 0 4px 14px rgba(23,32,51,.07);
  }
  .mobile-card-table .inspection-row.photo-required-row { border-left: 5px solid #e39a22; }
  .mobile-card-table td { border: 0; border-bottom: 1px solid #e9eef5; padding: 12px; }
  .mobile-card-table td:last-child { border-bottom: 0; }
  .mobile-card-table td::before {
    content: attr(data-label); display: block; margin-bottom: 6px; color: var(--muted);
    font-size: 13px; font-weight: 800;
  }
  .mobile-card-table td:first-child { background: #edf3fb; }
  .mobile-card-table td:first-child::before { display: none; }
  .mobile-card-table select { min-height: 50px; font-size: 17px; }
  .mobile-card-table textarea { min-height: 86px; font-size: 16px; }
  .photo-cell { min-width: 0; }
  .photo-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .photo-picker { min-height: 50px; font-size: 17px; }
  .task-photo-gallery { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; }
  .task-photo-meta { padding: 8px; }
  .task-photo-meta .small { font-size: 11px; }
  .stage-submit-bar {
    position: sticky; bottom: 0; z-index: 30; display: grid; grid-template-columns: 1fr 1fr;
    gap: 8px; margin: 0 -9px; padding: 10px 9px calc(10px + env(safe-area-inset-bottom));
    background: rgba(244,247,251,.96); border-top: 1px solid var(--line); backdrop-filter: blur(8px);
  }
  .stage-submit-bar .btn { min-height: 50px; padding: 9px 8px; }
  .stage-submit-bar .btn.warning { grid-column: 1 / -1; min-height: 42px; }
  .topbar { padding: 10px 12px; }
  .brand { font-size: 18px; }
  .topbar nav { gap: 14px; }
  .user-box { display: grid; grid-template-columns: 1fr auto; gap: 8px; font-size: 13px; }
  .lightbox { padding: 8px; }
  .lightbox img { max-width: 98vw; max-height: 78vh; }
}

@media (max-width: 420px) {
  .task-photo-gallery { grid-template-columns: 1fr; }
  .photo-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media print {
  .photo-picker, .photo-input, .new-photo-preview, .stage-submit-bar, .lightbox { display: none !important; }
  .photo-grid { grid-template-columns: repeat(4, 1fr); }
  .photo-thumb span { display: none; }
}

/* v1.5.1: separate mobile photo upload, progress and fast final submit */
.upload-global-notice {
  display: none;
  position: sticky;
  top: 8px;
  z-index: 20;
  margin: 0 0 12px;
  padding: 11px 14px;
  border-radius: 9px;
  font-weight: 700;
  box-shadow: 0 4px 14px rgba(0,0,0,.08);
}
.upload-global-notice:not(:empty) { display: block; }
.upload-global-notice.working { background: #fff4d6; color: #6d4700; border: 1px solid #efcf7b; }
.upload-global-notice.success { background: #e9f8ee; color: #176b35; border: 1px solid #9ed8b1; }
.upload-global-notice.error { background: #fff0f0; color: #a11c1c; border: 1px solid #e8aaaa; }
.photo-upload-status { min-height: 20px; margin-top: 7px; font-size: 13px; font-weight: 700; }
.photo-upload-status.success { color: #176b35; }
.photo-upload-status.error { color: #a11c1c; }
.photo-card { position: relative; min-width: 0; }
.photo-delete {
  width: 100%; margin-top: 4px; min-height: 34px; border: 1px solid #e0a2a2; border-radius: 6px;
  background: #fff3f3; color: #9b2020; font-weight: 700; cursor: pointer;
}
.photo-delete:disabled { opacity: .6; cursor: wait; }
.new-photo-card.uploading { opacity: .92; }
.new-photo-card.upload-error-card { padding: 6px; border: 1px solid #e7a5a5; border-radius: 8px; background: #fff4f4; }
.new-photo-card.upload-error-card span { color: #a11c1c; white-space: normal; font-weight: 700; }
.upload-progress { height: 7px; margin-top: 6px; overflow: hidden; border-radius: 999px; background: #d9e2ec; }
.upload-progress i { display: block; width: 0; height: 100%; background: #2878c8; transition: width .15s linear; }

@media (max-width: 720px) {
  .upload-global-notice { top: 4px; font-size: 15px; }
  .photo-upload-status { font-size: 14px; }
  .photo-delete { min-height: 42px; font-size: 15px; }
}

/* v1.7: instant photo preview + resilient long-form workflow */
.lightbox-image-wrap {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: min(1200px, 98vw);
  min-height: min(240px, 45vh);
}
.lightbox-image-wrap img {
  transition: filter .18s ease, opacity .18s ease;
}
.lightbox-image-wrap img.low-resolution {
  filter: blur(1.5px);
  opacity: .92;
  image-rendering: auto;
}
.lightbox-loading {
  position: absolute;
  left: 50%;
  bottom: 12px;
  transform: translateX(-50%);
  max-width: 92%;
  padding: 7px 12px;
  border-radius: 999px;
  background: rgba(0, 0, 0, .7);
  color: #fff;
  font-size: 13px;
  text-align: center;
  cursor: pointer;
}
.lightbox-loading[hidden] { display: none; }
.lightbox-original {
  margin-top: 9px;
  padding: 7px 13px;
  border: 1px solid rgba(255,255,255,.55);
  border-radius: 7px;
  color: #fff;
  text-decoration: none;
  font-size: 13px;
}
.lightbox-original:hover { background: rgba(255,255,255,.12); }

.draft-recovery-notice {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0 0 12px;
  padding: 12px 14px;
  border: 1px solid #e1b04d;
  border-radius: 9px;
  background: #fff7df;
  color: #674500;
  font-weight: 700;
}
.draft-recovery-notice[hidden] { display: none; }
.autosave-status {
  margin: 0 0 10px;
  min-height: 22px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}
.autosave-status.working { color: #7a5200; }
.autosave-status.success { color: #176b35; }
.autosave-status.warning { color: #8a5d00; }
.autosave-status.error { color: #a11c1c; }
.operation-error-panel { max-width: 760px; margin: 50px auto; }

@media (max-width: 680px) {
  .lightbox-image-wrap { width: 99vw; min-height: 36vh; }
  .lightbox-loading { bottom: 8px; font-size: 12px; }
  .draft-recovery-notice { align-items: stretch; }
  .draft-recovery-notice > span { width: 100%; }
  .draft-recovery-notice .btn { flex: 1; min-height: 44px; }
  .autosave-status { padding: 0 4px; font-size: 14px; }
  .operation-error-panel { margin: 18px auto; }
}


/* v1.8: urgent order and production schedule board */
.urgent-toggle {
  display: flex; align-items: center; gap: 10px; min-height: 43px; padding: 9px 12px;
  border: 1px solid #e2a5a1; border-radius: 7px; background: #fff5f4; color: #8d1e18; cursor: pointer;
}
.urgent-toggle input { width: 21px; height: 21px; min-height: 0; margin: 0; }
.urgent-toggle span { font-weight: 800; }
.badge.priority-urgent { background: #ffe1df; color: #a31912; border: 1px solid #efaaa5; }
.badge.priority-normal { background: #edf1f6; color: #536170; }
.badge.due-overdue { background: #b42318; color: white; }
.badge.due-today, .badge.due-critical { background: #ffe1df; color: #a31912; }
.badge.due-soon { background: #fff0cc; color: #855000; }
.badge.due-normal { background: #e7f5ec; color: #17653c; }
.badge.due-no-date { background: #edf1f6; color: #596579; }
.schedule-panel { border-top: 5px solid #d33b2f; }
.schedule-table th { white-space: nowrap; }
.schedule-row.urgent-row td:first-child { border-left: 5px solid #d92d20; }
.schedule-row.overdue-row { background: #fff0ef !important; }
.schedule-row.today-row, .schedule-row.critical-row { background: #fff8f0 !important; }
.schedule-row.soon-row { background: #fffdf3 !important; }
.urgent-note { margin-top: 5px; color: #9f251d; font-weight: 700; max-width: 280px; }

@media (max-width: 760px) {
  .schedule-table, .schedule-table tbody, .schedule-table tr, .schedule-table td { display: block; width: 100%; }
  .schedule-table thead { display: none; }
  .schedule-table tr { margin-bottom: 12px; border: 1px solid var(--line); border-radius: 9px; overflow: hidden; }
  .schedule-table td { border: 0; border-bottom: 1px solid #e9eef5; padding: 10px 12px; }
  .schedule-table td:last-child { border-bottom: 0; }
  .schedule-row.urgent-row td:first-child { border-left: 5px solid #d92d20; }
}

/* v1.10 customer service portal */
.portal-welcome {
  padding: 18px 20px;
  border-radius: 14px;
  background: linear-gradient(135deg, #123f78, #2776bd);
  color: #fff;
  box-shadow: var(--shadow);
}
.portal-welcome .muted { color: rgba(255,255,255,.82); }
.portal-action-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0,1fr));
  gap: 15px;
  margin-bottom: 18px;
}
.portal-action-card {
  min-height: 198px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 12px;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: #fff;
  box-shadow: var(--shadow);
  color: var(--text);
  text-decoration: none;
  transition: transform .16s ease, box-shadow .16s ease, border-color .16s ease;
}
.portal-action-card:hover {
  text-decoration: none;
  transform: translateY(-2px);
  border-color: #8eb6df;
  box-shadow: 0 10px 28px rgba(23,32,51,.13);
}
.portal-action-card h2 { margin: 0 0 5px; font-size: 21px; }
.portal-action-card p { margin: 0; color: var(--muted); }
.portal-action-card > span { font-weight: 800; color: var(--primary); }
.portal-icon { font-size: 36px; line-height: 1; }
.portal-stats .stat { min-height: 112px; }
.portal-list { display: grid; gap: 8px; }
.portal-list-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 12px 13px;
  border: 1px solid #e1e7ef;
  border-radius: 9px;
  background: #fbfdff;
  color: var(--text);
  text-decoration: none;
}
.portal-list-row:hover { text-decoration: none; border-color: #9dbce0; background: #f3f8fe; }
.align-right { text-align: right; }
.portal-empty {
  padding: 24px 12px;
  text-align: center;
  color: var(--muted);
  border: 1px dashed #c7d2e0;
  border-radius: 9px;
  background: #fafcff;
}
.portal-form { max-width: 1100px; margin: 0 auto; }
.compact-fields { gap: 8px; }
.check-option {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 13px;
  margin: 8px 0 14px;
  border: 1px solid #efc374;
  border-radius: 9px;
  background: #fff8e8;
  cursor: pointer;
}
.check-option input { width: 20px; min-height: 20px; margin-top: 2px; }
.check-option span { display: grid; gap: 2px; }
.check-option small { color: #7a5a1e; font-weight: 400; }
.portal-submit-bar { display: flex; gap: 10px; margin: 10px 0 26px; }
.order-notes { margin: 14px 0; }
.portal-progress-panel { border-left: 5px solid var(--success); }
.review-panel { border-left: 5px solid var(--primary); }
.customer-order-alert { border-left: 5px solid #d88400; }
.urgent-row { background: #fffaf0 !important; }
.badge.order-SUBMITTED { background: #fff0d6; color: #8a4b00; }
.badge.order-CONFIRMED, .badge.order-COMPLETED { background: #dff4e8; color: var(--success); }
.badge.order-REJECTED, .badge.order-CANCELLED { background: #fde8e7; color: var(--danger); }
.badge.shipment-PREPARING { background: #e7eef8; color: var(--info); }
.badge.shipment-SHIPPED, .badge.shipment-IN_TRANSIT { background: #e8f2ff; color: #1b5fa7; }
.badge.shipment-DELIVERED { background: #dff4e8; color: var(--success); }
.badge.shipment-EXCEPTION { background: #fde8e7; color: var(--danger); }
.badge.feedback-OPEN { background: #fff0d6; color: #8a4b00; }
.badge.feedback-PROCESSING { background: #e8f2ff; color: #1b5fa7; }
.badge.feedback-WAITING_CUSTOMER { background: #f0e8ff; color: #6741a5; }
.badge.feedback-RESOLVED, .badge.feedback-CLOSED { background: #dff4e8; color: var(--success); }
.badge.priority-high { background: #fde8e7; color: var(--danger); }
.badge.priority-normal { background: #e8f2ff; color: #1b5fa7; }
.badge.priority-low { background: #edf0f4; color: #586474; }
.large-textarea { min-height: 160px; }
.shipment-hero { padding-top: 28px; padding-bottom: 28px; }
.shipment-status-line { display: grid; grid-template-columns: repeat(4, 1fr); position: relative; }
.shipment-status-line::before {
  content: "";
  position: absolute;
  left: 12.5%; right: 12.5%; top: 18px;
  height: 4px;
  background: #dce4ee;
  z-index: 0;
}
.shipment-step { position: relative; z-index: 1; display: grid; justify-items: center; gap: 8px; color: var(--muted); text-align: center; }
.shipment-step span {
  width: 38px; height: 38px; display: grid; place-items: center;
  border-radius: 50%; background: #dce4ee; color: #596879; font-weight: 800;
}
.shipment-step.active { color: var(--success); }
.shipment-step.active span { background: var(--success); color: #fff; }
.feedback-origin { border-left: 5px solid var(--primary); }
.feedback-message { margin-top: 10px; white-space: pre-wrap; font-size: 17px; }
.feedback-links { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 12px; }
.feedback-thread { display: grid; gap: 12px; }
.feedback-bubble { max-width: 82%; padding: 13px 15px; border-radius: 12px; border: 1px solid var(--line); white-space: pre-wrap; }
.feedback-bubble.customer { justify-self: end; background: #edf5ff; border-color: #bdd4ed; }
.feedback-bubble.staff { justify-self: start; background: #f4f8f5; border-color: #c6ddcd; }
.feedback-author { margin-bottom: 7px; font-size: 13px; font-weight: 800; color: var(--muted); }
.feedback-author span { font-weight: 400; margin-left: 8px; }

@media (max-width: 1050px) {
  .portal-action-grid { grid-template-columns: repeat(2, minmax(0,1fr)); }
}
@media (max-width: 680px) {
  .portal-welcome { padding: 16px; }
  .portal-action-grid { grid-template-columns: 1fr 1fr; gap: 9px; }
  .portal-action-card { min-height: 165px; padding: 14px; }
  .portal-action-card h2 { font-size: 18px; }
  .portal-action-card p { font-size: 13px; }
  .portal-icon { font-size: 29px; }
  .portal-list-row { align-items: flex-start; }
  .portal-submit-bar { position: sticky; bottom: 0; z-index: 20; padding: 10px; margin: 0 -9px; background: rgba(244,247,251,.96); border-top: 1px solid var(--line); }
  .portal-submit-bar .btn { flex: 1; min-height: 48px; }
  .shipment-status-line { grid-template-columns: repeat(4, minmax(68px,1fr)); overflow-x: auto; }
  .shipment-step strong { font-size: 12px; }
  .feedback-bubble { max-width: 94%; }
}
@media (max-width: 430px) {
  .portal-action-grid { grid-template-columns: 1fr; }
  .portal-action-card { min-height: 142px; }
}

/* v1.11: login feedback, core-customer order forms and editable order example */
.login-submit { position: relative; min-height: 46px; }
.login-spinner {
  display: none; width: 18px; height: 18px; margin-left: 9px; vertical-align: -4px;
  border: 2px solid rgba(255,255,255,.45); border-top-color: #fff; border-radius: 50%;
  animation: login-spin .75s linear infinite;
}
.login-submit.is-loading .login-spinner { display: inline-block; }
.login-status { min-height: 24px; margin-top: 10px; text-align: center; color: var(--muted); font-weight: 700; }
@keyframes login-spin { to { transform: rotate(360deg); } }

.customer-profile-banner {
  display: flex; align-items: flex-start; gap: 12px; margin: 0 auto 16px; max-width: 1100px;
  padding: 13px 15px; border: 1px solid #bad1e8; border-left: 5px solid var(--primary);
  border-radius: 10px; background: #f3f8fe;
}
.customer-profile-banner strong { min-width: 150px; color: #174d84; }
.customer-profile-banner span { color: #40566e; }
.customer-profile-banner.profile-delixi { border-left-color: #1f6fb2; }
.customer-profile-banner.profile-renmin { border-left-color: #c23b2b; background: #fff7f5; }
.customer-profile-banner.profile-chint { border-left-color: #246bb0; background: #f3f8ff; }
.order-items-panel { overflow: visible; }
.bulk-paste-box { margin: 12px 0 15px; border: 1px dashed #9eb8d3; border-radius: 9px; background: #f8fbff; }
.bulk-paste-box summary { padding: 12px 14px; cursor: pointer; font-weight: 800; color: var(--primary); }
.bulk-paste-content { padding: 0 14px 14px; }
.bulk-paste-content textarea { min-height: 120px; font-family: Consolas, monospace; }
.order-item-list { display: grid; gap: 14px; }
.order-item-card { border: 1px solid #cbd7e5; border-radius: 12px; background: #fbfdff; overflow: hidden; }
.order-item-head {
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  padding: 11px 13px; background: #edf4fb; border-bottom: 1px solid #d6e1ed;
}
.order-item-head > div { display: flex; align-items: center; gap: 10px; }
.order-line-badge { display: inline-flex; padding: 4px 9px; border-radius: 999px; background: #1f66aa; color: #fff; font-size: 12px; }
.order-item-main, .order-item-more > .grid { padding: 14px; }
.order-item-more { border-top: 1px solid #e0e7ef; background: #fff; }
.order-item-more summary { padding: 10px 14px; cursor: pointer; color: #375b7c; font-weight: 700; }
.span-2 { grid-column: span 2; }
.span-3 { grid-column: span 3; }
.param-chip { display: inline-block; margin: 2px 3px 2px 0; padding: 3px 7px; border-radius: 999px; background: #eaf2fb; color: #275d91; font-size: 12px; }
.order-lines-table td { vertical-align: top; }

/* Show the most relevant fields more prominently for each core customer. */
.portal-form[data-customer-profile="DELIXI"] .profile-delixi label,
.portal-form[data-customer-profile="CHINT"] .profile-chint label { color: #194f82; font-weight: 800; }
.portal-form[data-customer-profile="RENMIN"] textarea[name="item_description"] { min-height: 86px; border-color: #d8aaa3; }

.example-timeline { position: relative; display: grid; gap: 0; max-width: 1120px; margin: 0 auto 30px; }
.example-timeline::before { content: ""; position: absolute; left: 24px; top: 25px; bottom: 25px; width: 4px; background: #c9d8e8; border-radius: 4px; }
.example-step { position: relative; display: grid; grid-template-columns: 50px minmax(0,1fr); gap: 12px; }
.example-marker { position: relative; z-index: 2; display: flex; justify-content: center; padding-top: 22px; }
.example-marker span { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 50%; background: var(--primary); color: #fff; font-weight: 900; box-shadow: 0 0 0 5px #f4f7fb; }
.example-card { margin-bottom: 15px; }
.example-step.inactive { opacity: .62; }
.example-content { display: grid; gap: 18px; }
.example-content.with-image { grid-template-columns: minmax(0,1fr) minmax(180px,300px); }
.example-description { margin-top: 0; white-space: pre-wrap; font-size: 16px; line-height: 1.75; }
.example-meta-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 10px; }
.example-meta-grid > div { padding: 10px 12px; border-radius: 8px; background: #f5f8fc; }
.example-meta-grid span { display: block; color: var(--muted); font-size: 12px; margin-bottom: 4px; }
.example-meta-grid .wide { grid-column: 1 / -1; }
.example-image { display: block; align-self: start; border: 1px solid #d4dee9; border-radius: 10px; overflow: hidden; background: #f4f6f9; }
.example-image img { display: block; width: 100%; max-height: 240px; object-fit: cover; }
.example-delete-form { margin-top: 12px; text-align: right; }
.link-danger { border: 0; background: none; color: var(--danger); cursor: pointer; text-decoration: underline; }
.toggle-line { display: flex; align-items: center; gap: 8px; min-height: 43px; }
.toggle-line input { width: 20px; min-height: 20px; }
.current-example-image { display: flex; align-items: center; gap: 14px; margin-top: 10px; }
.current-example-image img { width: 180px; max-height: 120px; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); }

@media (max-width: 900px) {
  .order-item-main.grid-4, .order-item-more .grid-4 { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .example-content.with-image { grid-template-columns: 1fr; }
  .example-image { max-width: 420px; }
}
@media (max-width: 680px) {
  .customer-profile-banner { display: grid; gap: 5px; }
  .customer-profile-banner strong { min-width: 0; }
  .order-item-head { align-items: flex-start; }
  .order-item-head > div { align-items: flex-start; flex-direction: column; gap: 5px; }
  .order-item-main.grid-4, .order-item-more .grid-4 { grid-template-columns: 1fr; }
  .span-2, .span-3 { grid-column: span 1; }
  .example-timeline::before { left: 17px; }
  .example-step { grid-template-columns: 36px minmax(0,1fr); gap: 7px; }
  .example-marker span { width: 30px; height: 30px; }
  .example-meta-grid { grid-template-columns: 1fr; }
  .example-meta-grid .wide { grid-column: auto; }
  .current-example-image { align-items: flex-start; flex-direction: column; }
}

/* v1.12: simplified customer ordering */
.simple-order-page-header { max-width: 1120px; margin-left: auto; margin-right: auto; }
.simple-order-guide {
  display: flex; align-items: center; gap: 14px; max-width: 1120px; margin: 0 auto 16px;
  padding: 13px 16px; border: 1px solid #b9d3ee; border-left: 5px solid var(--primary);
  border-radius: 11px; background: #f2f7fd; color: #35516d;
}
.simple-order-guide strong { flex: 0 0 auto; color: #174d84; font-size: 17px; }
.simple-order-form { max-width: 1120px; margin: 0 auto; }
.simple-order-header-panel { padding-bottom: 14px; }
.simple-order-header-grid { align-items: start; }
.simple-urgent-field .compact-check { min-height: 46px; margin: 0; padding: 8px 11px; }
.simple-optional-box {
  margin-top: 12px; border: 1px dashed #a9bfd5; border-radius: 10px; background: #fafcff;
}
.simple-optional-box summary { padding: 11px 14px; cursor: pointer; color: #315d87; font-weight: 800; }
.simple-optional-content { padding: 0 14px 14px; }
.simple-order-items-panel { padding-bottom: 16px; }
.simple-items-heading { margin-bottom: 8px; }
.simple-bulk-paste { margin-top: 8px; margin-bottom: 13px; }
.simple-order-item-list { gap: 12px; }
.simple-order-card { border-color: #bfcfe0; box-shadow: 0 2px 8px rgba(35,74,112,.05); }
.simple-order-card-head { background: #edf5fd; }
.simple-order-card-head > div:first-child { display: grid; gap: 2px; }
.simple-card-actions { flex-wrap: nowrap; }
.simple-order-grid { padding: 13px; align-items: start; }
.simple-order-grid .field { margin-bottom: 0; }
.simple-order-grid select, .simple-order-grid input { min-height: 46px; }
.simple-order-grid input[name="item_remarks"] { min-height: 46px; }
.simple-order-submit-bar { max-width: 1120px; margin-left: auto; margin-right: auto; }

.simple-parameter-table th, .simple-parameter-table td { white-space: nowrap; }
.simple-parameter-table .model-cell { white-space: normal; min-width: 180px; }
.simple-parameter-table .notes-cell { white-space: normal; min-width: 160px; }
.internal-item-editor { display: grid; gap: 12px; }
.internal-item-card { border: 1px solid #c7d5e4; border-radius: 10px; background: #fbfdff; padding: 13px; }
.internal-item-card h3 { margin: 0 0 10px; font-size: 17px; color: #234f79; }
.internal-item-card .grid { margin-bottom: 0; }

@media (max-width: 900px) {
  .simple-order-header-grid.grid-4, .simple-order-grid.grid-4 { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .simple-order-grid .span-2 { grid-column: span 2; }
  .simple-order-grid .span-3 { grid-column: span 2; }
}
@media (max-width: 680px) {
  .simple-order-guide { display: grid; gap: 4px; padding: 11px 13px; }
  .simple-order-page-header { align-items: flex-start; }
  .simple-order-header-grid.grid-4, .simple-order-grid.grid-4 { grid-template-columns: 1fr; }
  .simple-order-grid .span-2, .simple-order-grid .span-3 { grid-column: auto; }
  .simple-order-card-head { align-items: flex-start; gap: 8px; }
  .simple-order-card-head > div:first-child { max-width: 58%; }
  .simple-card-actions { gap: 6px; }
  .simple-card-actions .btn { padding-left: 9px; padding-right: 9px; }
  .simple-order-grid { padding: 11px; }
}


/* v1.12.1: homepage feedback priority panel */
.feedback-home-alert {
  border: 2px solid #f0b8b8;
  background: linear-gradient(180deg, #fffafa 0%, #ffffff 100%);
}
.feedback-home-alert h2 { color: #9f1f1f; }
.feedback-home-alert .urgent-row td:first-child { border-left: 5px solid #c92a2a; }

/* production footer */
.site-footer {
  max-width: 1320px;
  margin: 28px auto 18px;
  padding: 16px 20px;
  text-align: center;
  color: #667085;
  font-size: 13px;
  line-height: 1.8;
}
.site-footer a { color: #475467; text-decoration: none; }
.site-footer a:hover { text-decoration: underline; }


/* v1.12.3 customer model memory */
.history-order-guide {
  margin-top: -6px;
  border-left-color: #1f8f63;
  background: #f1fbf6;
}
.model-history-tools {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  margin-top: 7px;
}
.model-history-tools[hidden] { display: none !important; }
.model-history-status {
  color: #176847;
  font-size: 13px;
  font-weight: 600;
}
.tiny-btn {
  padding: 5px 9px;
  min-height: 30px;
  font-size: 12px;
}
@media (max-width: 700px) {
  .model-history-tools { align-items: flex-start; }
  .model-history-status { width: 100%; }
}
