*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --bg: #eef3f6;
  --bg-accent: #dce9ef;
  --surface: #ffffff;
  --surface-2: #f4f8fa;
  --border: #d5e0e6;
  --text: #1f2d36;
  --text-muted: #667985;
  --accent: #0f766e;
  --accent-hover: #0d9488;
  --success: #15803d;
  --danger: #c2410c;
  --warn: #b45309;
  --info: #1d4ed8;
  --radius: 12px;
  --shadow: 0 8px 28px rgba(31, 45, 54, 0.08);
}

body {
  font-family: "Figtree", "Noto Sans TC", sans-serif;
  background:
    radial-gradient(1200px 500px at 10% -10%, rgba(15, 118, 110, 0.12), transparent 55%),
    radial-gradient(900px 400px at 100% 0%, rgba(14, 116, 144, 0.1), transparent 50%),
    linear-gradient(180deg, var(--bg-accent) 0%, var(--bg) 40%, #f7fafb 100%);
  background-attachment: fixed;
  color: var(--text);
  min-height: 100vh;
  line-height: 1.6;
}

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

.header {
  border-bottom: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.86);
  backdrop-filter: blur(10px);
  padding: 1.5rem 2rem;
}

.header-inner {
  max-width: 1680px;
  margin: 0 auto;
}

.logo {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  color: var(--accent);
}

.logo h1 {
  font-size: 1.35rem;
  font-weight: 600;
  color: var(--text);
}

.subtitle {
  margin-top: 0.35rem;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.main {
  flex: 1;
  max-width: 1680px;
  width: 100%;
  margin: 0 auto;
  padding: 1.5rem 2rem 2rem;
}

.summary-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0.75rem 0.35rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
}

.summary-card.warn {
  border-color: rgba(248, 113, 113, 0.35);
}

.summary-card.ok {
  border-color: rgba(74, 222, 128, 0.35);
}

.summary-value {
  font-size: 1.25rem;
  font-weight: 700;
  line-height: 1.2;
}

.summary-card.warn .summary-value {
  color: var(--danger);
}

.summary-card.ok .summary-value {
  color: var(--success);
}

.summary-label {
  font-size: 0.68rem;
  color: var(--text-muted);
  margin-top: 0.15rem;
}

.dash-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.dash-title {
  padding: 0.65rem 0.85rem;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-muted);
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.dash-timeline {
  padding: 0.65rem 0.65rem 0.65rem 0.35rem;
  overflow-y: auto;
  flex: 1;
  max-height: 420px;
}

.dash-empty {
  padding: 1rem;
  text-align: center;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.timeline-item {
  display: flex;
  gap: 0.65rem;
  width: 100%;
  padding: 0.5rem 0.5rem 0.5rem 0;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--text);
  cursor: pointer;
  text-align: left;
  transition: background 0.15s;
  position: relative;
}

.timeline-item:hover {
  background: rgba(15, 118, 110, 0.06);
}

.timeline-item:not(:last-child)::before {
  content: '';
  position: absolute;
  left: 11px;
  top: 28px;
  bottom: -8px;
  width: 2px;
  background: var(--border);
}

.timeline-dot {
  flex-shrink: 0;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  margin-top: 4px;
  margin-left: 6px;
  background: var(--accent);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.18);
}

.timeline-item.action-upload .timeline-dot {
  background: var(--success);
  box-shadow: 0 0 0 3px rgba(21, 128, 61, 0.18);
}

.timeline-item.action-edit .timeline-dot {
  background: var(--accent);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.18);
}

.timeline-item.action-replace .timeline-dot {
  background: var(--warn);
  box-shadow: 0 0 0 3px rgba(180, 83, 9, 0.18);
}

.timeline-item.action-remove .timeline-dot {
  background: var(--danger);
  box-shadow: 0 0 0 3px rgba(194, 65, 12, 0.18);
}

.timeline-item.action-submit .timeline-dot {
  background: var(--info);
  box-shadow: 0 0 0 3px rgba(29, 78, 216, 0.18);
}

.timeline-item.action-approve .timeline-dot {
  background: var(--success);
  box-shadow: 0 0 0 3px rgba(21, 128, 61, 0.18);
}

.timeline-item.action-reject .timeline-dot {
  background: var(--danger);
  box-shadow: 0 0 0 3px rgba(194, 65, 12, 0.2);
}

.timeline-content {
  flex: 1;
  min-width: 0;
}

.timeline-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.35rem;
  margin-bottom: 0.15rem;
}

.timeline-action {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--accent);
}

.timeline-item.action-upload .timeline-action { color: var(--success); }
.timeline-item.action-edit .timeline-action { color: var(--accent); }
.timeline-item.action-replace .timeline-action { color: var(--warn); }
.timeline-item.action-remove .timeline-action { color: var(--danger); }
.timeline-item.action-submit .timeline-action { color: var(--info); }
.timeline-item.action-approve .timeline-action { color: var(--success); }
.timeline-item.action-reject .timeline-action { color: var(--danger); }

.timeline-time {
  font-size: 0.65rem;
  color: var(--text-muted);
  flex-shrink: 0;
}

.timeline-desc {
  font-size: 0.7rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.slot {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  width: 100%;
  padding: 0.7rem 0.75rem;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  cursor: pointer;
  text-align: left;
  transition: background 0.15s, border-color 0.15s;
}

.slot:hover {
  background: rgba(15, 118, 110, 0.05);
}

.slot.missing:hover {
  background: rgba(194, 65, 12, 0.06);
}

.slot.uploaded:hover {
  background: rgba(21, 128, 61, 0.06);
}

.slot-status {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  flex-shrink: 0;
}

.slot-status.ok {
  color: var(--success);
}

.slot-status.fail {
  color: var(--danger);
}

.slot-body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
}

.slot-hint {
  font-size: 0.88rem;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.slot.missing .slot-hint {
  color: var(--text-muted);
}

.slot-time {
  font-size: 0.7rem;
  color: var(--text-muted);
}

.slot-arrow {
  flex-shrink: 0;
  color: var(--text-muted);
  font-size: 1rem;
  line-height: 1;
}

.preview-area {
  position: sticky;
  top: 1.5rem;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  min-height: 560px;
}

.preview-empty {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  color: var(--text-muted);
  min-height: 560px;
}

.hidden {
  display: none !important;
}

.hidden-source {
  position: absolute;
  left: -9999px;
  width: 1px;
  height: 1px;
  overflow: hidden;
}

.viewer-section {
  display: flex;
  flex-direction: column;
  flex: 1;
}

.toolbar {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
}

.file-info {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  min-width: 0;
}

.file-name {
  font-weight: 500;
  font-size: 0.9rem;
}

.page-info {
  font-size: 0.78rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.upload-time {
  font-size: 0.75rem;
  color: var(--accent);
}

.toolbar-actions {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-wrap: wrap;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.4rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font-size: 0.8rem;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}

.btn:hover:not(:disabled) {
  background: var(--surface-2);
  border-color: var(--accent);
}

.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.btn-icon {
  padding: 0.4rem;
  min-width: 34px;
}

.btn-secondary {
  background: transparent;
  border-color: var(--accent);
  color: var(--accent);
}

.btn-secondary:hover:not(:disabled) {
  background: rgba(15, 118, 110, 0.1);
}

.btn-danger {
  background: transparent;
  border-color: var(--danger);
  color: var(--danger);
}

.btn-danger:hover:not(:disabled) {
  background: rgba(248, 113, 113, 0.12);
}

.divider {
  width: 1px;
  height: 24px;
  background: var(--border);
  margin: 0 0.15rem;
}

.page-num,
.zoom-level {
  font-size: 0.8rem;
  color: var(--text-muted);
  min-width: 48px;
  text-align: center;
}

.canvas-wrapper {
  flex: 1;
  position: relative;
  overflow: auto;
  padding: 1rem;
  background:
    linear-gradient(180deg, #edf3f6 0%, #e4ecef 100%);
  max-height: calc(100vh - 220px);
}

#pdf-canvas {
  display: block;
  margin: 0 auto;
  box-shadow: var(--shadow);
  max-width: none;
  background: #fff;
  cursor: grab;
  user-select: none;
}

#pdf-canvas.is-panning {
  cursor: grabbing;
}

.zoom-hint {
  font-size: 0.72rem;
  color: var(--text-muted);
  white-space: nowrap;
}

.loading {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  background: rgba(238, 243, 246, 0.82);
  color: var(--text-muted);
  font-size: 0.9rem;
}

.spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.footer {
  text-align: center;
  padding: 1.25rem;
  color: var(--text-muted);
  font-size: 0.8rem;
  border-top: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.65);
}

.dash-section,
.preview-area,
.portal-card,
.summary-card {
  box-shadow: var(--shadow);
}

.toast {
  position: fixed;
  bottom: 2rem;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--surface-2);
  border: 1px solid var(--success);
  color: var(--success);
  padding: 0.65rem 1.25rem;
  border-radius: 8px;
  font-size: 0.875rem;
  opacity: 0;
  transition: opacity 0.25s, transform 0.25s;
  pointer-events: none;
  z-index: 100;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.toast.toast-warn {
  border-color: var(--warn);
  color: var(--warn);
}

/* Portal */
.portal-main {
  max-width: 960px;
}

.portal-hero {
  text-align: center;
  margin-bottom: 2rem;
}

.portal-hero h2 {
  font-size: 1.6rem;
  margin-bottom: 0.5rem;
}

.portal-hero p {
  color: var(--text-muted);
}

.portal-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.25rem;
}

.portal-grid-single {
  grid-template-columns: minmax(0, 1fr);
  max-width: 28rem;
  margin: 0 auto;
}

.portal-card {
  display: block;
  padding: 1.5rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: inherit;
  text-decoration: none;
  text-align: left;
  font: inherit;
  cursor: pointer;
  appearance: none;
  width: 100%;
  transition: border-color 0.15s, transform 0.15s, background 0.15s;
}

.portal-card:hover {
  transform: translateY(-2px);
  border-color: var(--accent);
  background: var(--surface-2);
}

.portal-card-disabled,
.portal-card-disabled:hover {
  cursor: not-allowed;
  opacity: 0.72;
  transform: none;
  border-color: var(--border);
  background: var(--surface-2);
  pointer-events: none;
}

.portal-badge {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.15rem 0.55rem;
  border-radius: 999px;
  margin-bottom: 0.75rem;
}

.portal-user .portal-badge {
  color: var(--accent);
  background: rgba(15, 118, 110, 0.12);
}

.portal-admin .portal-badge {
  color: var(--warn);
  background: rgba(180, 83, 9, 0.12);
}

.portal-card h3 {
  font-size: 1.25rem;
  margin-bottom: 0.5rem;
}

.portal-card > p {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-bottom: 1rem;
}

.portal-card ul {
  margin: 0 0 1.25rem 1.1rem;
  color: var(--text-muted);
  font-size: 0.85rem;
}

.portal-card li {
  margin-bottom: 0.3rem;
}

.portal-cta {
  color: var(--accent);
  font-weight: 600;
  font-size: 0.9rem;
}

.portal-cta-muted {
  color: var(--text-muted);
  font-weight: 600;
}

.portal-note {
  margin-top: 1.5rem;
  padding: 1rem 1.15rem;
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text-muted);
  font-size: 0.85rem;
  line-height: 1.7;
}

/* Status */
.status-pill {
  display: inline-flex;
  align-items: center;
  padding: 0.25rem 0.7rem;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 600;
}

.status-draft {
  color: var(--text-muted);
  background: rgba(139, 146, 168, 0.15);
}

.status-submitted,
.status-pending {
  color: var(--warn);
  background: rgba(180, 83, 9, 0.12);
}

.status-initial_review,
.status-final_review,
.status-onsite,
.status-deliberation {
  color: #0f766e;
  background: rgba(15, 118, 110, 0.12);
}

.status-completed,
.status-approved {
  color: var(--success);
  background: rgba(74, 222, 128, 0.15);
}

.status-expired {
  color: var(--warn);
  background: rgba(180, 83, 9, 0.12);
}

.status-rejected,
.status-denied {
  color: var(--danger);
  background: rgba(248, 113, 113, 0.15);
}

.status-pending_deletion {
  color: #9a3412;
  background: rgba(154, 52, 18, 0.12);
}

.status-superseded {
  color: var(--text-muted);
  background: rgba(100, 116, 139, 0.12);
}

.status-subtitle {
  margin-top: 0.2rem;
  font-size: 0.75rem;
  color: var(--text-muted);
  line-height: 1.35;
}

.status-cell {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.2rem;
}

.status-pills {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem;
}

.admin-row-status .status-cell {
  align-items: flex-end;
}

.admin-row-status .status-pills {
  justify-content: flex-end;
}

.admin-row-status .status-subtitle {
  text-align: right;
}

.admin-row-status {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.15rem;
}

.admin-row-delete-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  justify-content: flex-end;
  margin-top: 0.35rem;
}

.admin-deletion-banner {
  margin: 0 1.25rem 0.75rem;
}

.admin-deletion-banner-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  border: 1px solid rgba(154, 52, 18, 0.25);
  background: rgba(154, 52, 18, 0.08);
  border-radius: 8px;
}

.admin-deletion-banner-actions {
  display: flex;
  gap: 0.4rem;
}

.case-row-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  justify-content: flex-end;
}

.btn-danger-text {
  color: var(--danger);
}

.delib-fields {
  margin: 0.35rem 0 0.75rem 1.5rem;
  max-width: 22rem;
}

.review-banner {
  margin-bottom: 1rem;
  padding: 0.85rem 1rem;
  border-radius: 10px;
  font-size: 0.9rem;
  line-height: 1.6;
}

.review-banner.pending {
  border: 1px solid rgba(180, 83, 9, 0.35);
  background: rgba(180, 83, 9, 0.08);
  color: var(--warn);
}

.review-banner.approved {
  border: 1px solid rgba(74, 222, 128, 0.4);
  background: rgba(74, 222, 128, 0.08);
  color: var(--success);
}

.review-banner.rejected {
  border: 1px solid rgba(248, 113, 113, 0.4);
  background: rgba(248, 113, 113, 0.08);
  color: var(--danger);
}

.submit-box {
  padding: 0.85rem;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.submit-hint {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  font-weight: 600;
}

.btn-primary:hover:not(:disabled) {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}

.btn-ghost {
  background: transparent;
}

.btn-block {
  width: 100%;
}

.btn-success {
  background: transparent;
  border-color: var(--success);
  color: var(--success);
}

.btn-success:hover:not(:disabled) {
  background: rgba(74, 222, 128, 0.12);
}

/* App shell + side nav */
.app-shell {
  flex-direction: row;
  min-height: 100vh;
}

.side-nav {
  width: 220px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  background: #fff;
  border-right: 1px solid var(--border);
  position: sticky;
  top: 0;
  height: 100vh;
  z-index: 20;
}

.side-nav-brand {
  padding: 1.25rem 1.15rem 1rem;
  border-bottom: 1px solid var(--border);
}

.side-nav-title {
  display: block;
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text);
}

.side-nav-sub {
  display: block;
  margin-top: 0.2rem;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.side-nav-menu {
  flex: 1;
  overflow-y: auto;
  padding: 0.75rem 0.65rem;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.side-nav-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.4rem;
  padding: 0.7rem 0.9rem;
  border-radius: 8px;
  color: #4b5c66;
  text-decoration: none;
  font-size: 0.92rem;
  font-weight: 500;
  transition: background 0.15s, color 0.15s;
}

.nav-dot {
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 50%;
  background: #e11d48;
  box-shadow: 0 0 0 2px #fff;
  flex-shrink: 0;
  opacity: 0;
}

.side-nav-item.has-change .nav-dot {
  opacity: 1;
}

.side-nav-item:hover {
  background: rgba(15, 118, 110, 0.06);
  color: var(--accent);
}

.side-nav-item.active {
  background: rgba(15, 118, 110, 0.12);
  color: var(--accent);
  font-weight: 600;
}

.side-nav-group-label {
  margin: 0.85rem 0.9rem 0.25rem;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  text-transform: uppercase;
}

.side-nav-footer {
  padding: 0.85rem 1rem 1.15rem;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.side-nav-link {
  font-size: 0.8rem;
  color: var(--text-muted);
  text-decoration: none;
}

.side-nav-link:hover {
  color: var(--accent);
}

.shell-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
  overflow-y: auto;
}

.shell-header {
  padding: 1.25rem 1.5rem 0.75rem;
}

.shell-header-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
}

.shell-header-badges {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.case-id-badge {
  display: inline-flex;
  align-items: center;
  padding: 0.25rem 0.65rem;
  border-radius: 8px;
  font-size: 0.8rem;
  font-weight: 600;
  font-family: Figtree, "Noto Sans TC", sans-serif;
  letter-spacing: 0.02em;
  color: var(--accent);
  background: rgba(15, 118, 110, 0.1);
  border: 1px solid rgba(15, 118, 110, 0.2);
}

.case-id-badge.hidden {
  display: none;
}

.shell-header-actions {
  display: flex;
  align-items: flex-start;
  gap: 0.65rem;
  flex-wrap: wrap;
}

.page-note-wrap {
  position: relative;
}

.page-note-wrap.hidden {
  display: none;
}

.page-note-panel {
  position: absolute;
  top: calc(100% + 0.4rem);
  right: 0;
  z-index: 20;
  width: min(22rem, calc(100vw - 3rem));
  padding: 0.85rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  box-shadow: 0 10px 28px rgba(20, 28, 36, 0.12);
}

.page-note-panel.hidden {
  display: none;
}

.page-note-wrap.has-note #btn-page-note {
  box-shadow: inset 0 0 0 1px var(--accent);
}

.sop-block {
  margin: 0.85rem 0;
  padding: 0.75rem 0.85rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-2, #f6f7f8);
}

.sop-block h3 {
  margin: 0 0 0.45rem;
  font-size: 0.88rem;
}

.sop-group + .sop-group {
  margin-top: 0.75rem;
}

.sop-issue {
  display: block;
  margin: 0.25rem 0;
}

.sop-issue-text {
  margin: 0.2rem 0 0.45rem 1.4rem;
  width: calc(100% - 1.4rem);
}

.initial-sop-summary {
  margin: 0.5rem 0 0.85rem;
  padding: 0.75rem 0.85rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-2, #f6f7f8);
}

.initial-sop-summary p {
  margin: 0.2rem 0;
  font-size: 0.9rem;
}

.sop-line-open {
  color: var(--danger);
  font-weight: 600;
}

.sop-line-resolved {
  color: var(--info);
  font-weight: 600;
}

.sop-summary-list .final-summary-item.sop-line-open > span:not(.final-summary-ok) {
  color: var(--danger);
  font-weight: 600;
}

.sop-summary-list .final-summary-item.is-cleared > span:not(.final-summary-ok),
.sop-summary-list .final-summary-item.sop-line-resolved > span:not(.final-summary-ok) {
  color: var(--info);
  font-weight: 600;
}

.sop-note-line {
  margin: 0.35rem 0 0;
  font-size: 0.9rem;
}

.doc-review-start-row {
  margin: 0 0 1rem;
  padding: 0.85rem 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-2, #f6f7f8);
}

.doc-review-start-row .btn {
  margin-bottom: 0.4rem;
}

.doc-review-banner {
  margin: 0 0 0.85rem;
  padding: 0.55rem 0.8rem;
  border-radius: var(--radius);
  border: 1px solid #93c5fd;
  background: #eff6ff;
  color: #1e3a8a;
  font-weight: 600;
}

.sop-flag {
  display: inline-block;
  margin-left: 0.35rem;
  padding: 0.05rem 0.4rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
  color: #9a3412;
  background: #ffedd5;
}

.overview-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.overview-tabs {
  display: flex;
  gap: 0.35rem;
  padding: 0.2rem;
  background: var(--surface-2);
  border-radius: 10px;
  border: 1px solid var(--border);
}

.overview-tab {
  border: none;
  background: transparent;
  padding: 0.45rem 0.9rem;
  border-radius: 8px;
  font: inherit;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
}

.overview-tab.active {
  background: var(--surface);
  color: var(--accent);
  box-shadow: var(--shadow);
}

.overview-search {
  max-width: 280px;
  width: 100%;
}

.overview-pager {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0.75rem 1rem;
  margin-top: 0.85rem;
}

.overview-pager-status {
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--text-muted);
}

.case-docs-layout {
  grid-template-columns: minmax(200px, 240px) minmax(260px, 340px) minmax(0, 1fr);
}

.case-review-panel {
  max-width: 1280px;
  margin: 0 auto;
}

.review-work-columns {
  display: grid;
  grid-template-columns: minmax(0, 0.9fr) minmax(360px, 1.1fr);
  gap: 1.25rem;
  align-items: start;
}

.review-work-main {
  min-width: 0;
}

.review-work-side {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  min-width: 0;
}

.review-highlights {
  padding: 0.95rem 1rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  font-size: 1.05rem;
  line-height: 1.7;
}

.review-highlights p {
  margin: 0 0 0.4rem;
}

.review-highlights p:last-child {
  margin-bottom: 0;
}

.review-highlight-block {
  margin-top: 0.35rem;
}

.review-highlight-block:first-child {
  margin-top: 0;
}

.review-highlight-block.warn .review-highlight-title {
  color: var(--warn);
  font-weight: 600;
  margin: 0 0 0.45rem;
  font-size: 1.15rem;
}

.review-highlight-heading {
  margin: 0.55rem 0 0.25rem;
  font-size: 1.05rem;
  font-weight: 600;
}

.review-highlight-heading:first-of-type {
  margin-top: 0.1rem;
}

.review-highlight-list {
  margin: 0;
  padding-left: 1.2rem;
  list-style: disc;
}

.review-highlight-list li {
  margin: 0.25rem 0;
}

.review-side-stats h4 {
  margin: 0 0 0.5rem;
  font-size: 0.9rem;
}

.review-side-stats p {
  font-size: 0.85rem;
  margin-bottom: 0.3rem;
}

.review-work-columns.no-side {
  grid-template-columns: minmax(0, 1fr);
}

.review-work-columns.no-side .review-work-side {
  display: none;
}

@media (max-width: 900px) {
  .review-work-columns {
    grid-template-columns: minmax(0, 1fr);
  }
}

.review-work-card h3 {
  margin-bottom: 0.5rem;
}

.review-work-card h4 {
  margin: 0 0 0.5rem;
  font-size: 0.95rem;
}

.review-block {
  margin: 1rem 0;
  padding: 0.85rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface-2);
}

.review-block .check-item {
  margin-bottom: 0.45rem;
}

.initial-summary {
  font-size: 0.85rem;
  line-height: 1.55;
  color: var(--text);
  margin-bottom: 0.75rem;
}

.final-checklist-host {
  margin: 0.75rem 0 1rem;
}

.final-checklist {
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-2);
  padding: 0.85rem 1rem 1rem;
}

.final-checklist .fc-title {
  margin: 0 0 0.35rem;
  font-size: 0.95rem;
}

.fc-group {
  margin-top: 0.85rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border);
}

.fc-group:first-of-type {
  border-top: none;
  padding-top: 0.25rem;
}

.fc-group h5 {
  margin: 0 0 0.45rem;
  font-size: 0.88rem;
}

.fc-group h6 {
  margin: 0 0 0.35rem;
  font-size: 0.8rem;
  color: var(--text-muted);
  font-weight: 600;
}

.fc-tag {
  font-size: 0.72rem;
  font-weight: 500;
  color: var(--text-muted);
}

.fc-options {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.fc-subblock {
  margin-top: 0.65rem;
}

.fc-sub {
  margin-left: 1rem;
}

.fc-note-wrap,
.fc-sub-panel {
  margin: 0.35rem 0 0.25rem;
}

.fc-note-wrap.hidden,
.fc-sub-panel.hidden {
  display: none;
}

.fc-inline-note {
  margin: 0.15rem 0 0.35rem 1.4rem;
  width: calc(100% - 1.4rem);
}

.fc-mat-picker {
  margin-top: 0.45rem;
  padding: 0.55rem 0.65rem;
  border: 1px dashed var(--border);
  border-radius: 8px;
  background: var(--surface);
}

.fc-mat-search {
  margin: 0 0 0.4rem;
  font-size: 0.92rem;
}

.fc-mat-picker-title {
  margin: 0 0 0.35rem;
  font-size: 0.78rem;
  color: var(--text-muted);
}

.fc-mat-picker-list {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  max-height: 200px;
  overflow: auto;
}

.fc-q-sub-wrap {
  margin: 0.25rem 0 0.55rem;
}

.fc-mat-item {
  font-size: 0.82rem;
}

.final-checklist-warn-host:not(.hidden) {
  margin: 0.65rem 0 0.85rem;
}

.final-checklist-warn-box {
  padding: 0.95rem 1rem;
  border-radius: 8px;
  border: 1px solid rgba(180, 83, 9, 0.35);
  background: rgba(180, 83, 9, 0.08);
  font-size: 1.08rem;
  line-height: 1.7;
}

.final-checklist-warn-box .review-highlight-title {
  font-size: 1.18rem;
  font-weight: 600;
  margin: 0 0 0.5rem;
}

.final-checklist-warn-box ul {
  margin: 0.35rem 0 0;
  padding-left: 1.25rem;
}

.final-checklist-warn-box ul.final-summary-list {
  list-style: none;
  padding-left: 0;
}

.final-checklist-warn-box li {
  margin: 0.35rem 0;
}

.final-summary-item {
  display: flex;
  align-items: flex-start;
  gap: 0.45rem;
}

.final-summary-item input[type="checkbox"] {
  margin-top: 0.38em;
  flex-shrink: 0;
}

.final-summary-item.is-cleared > span:not(.final-summary-ok) {
  color: var(--text-muted);
}

.final-summary-item.is-record {
  color: var(--text-muted);
}

.final-summary-mark {
  flex-shrink: 0;
  width: 1.1em;
}

.final-summary-ok {
  font-style: normal;
  font-size: 0.78em;
  font-weight: 600;
  color: var(--accent, #0f766e);
  white-space: nowrap;
  margin-left: auto;
  padding-top: 0.15em;
}

.case-no-editor {
  padding: 0.75rem;
  border-radius: 8px;
  border: 1px dashed var(--accent);
  background: rgba(15, 118, 110, 0.05);
  margin-bottom: 1rem;
}

.case-no-editor .text-input {
  margin-top: 0.35rem;
  max-width: 320px;
}

.readonly-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.65rem 1rem;
}

.readonly-grid p {
  margin: 0.15rem 0 0;
  font-size: 0.9rem;
}

.warn-text {
  color: var(--warn);
  font-weight: 600;
  margin: 0 0 0.5rem;
}

.ok-text {
  color: var(--success);
  font-weight: 600;
  margin: 0;
}

@media (max-width: 768px) {
  .readonly-grid {
    grid-template-columns: 1fr;
  }

  .overview-search {
    max-width: none;
  }
}
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.shell-page-title {
  font-size: 1.35rem;
  font-weight: 700;
}

.shell-page-desc {
  margin-top: 0.25rem;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.shell-banner {
  margin: 0 1.5rem 1rem;
}

.admin-layout .preview-area {
  min-height: 640px;
}

.split-layout {
  display: grid;
  grid-template-columns: 260px minmax(280px, 360px) minmax(0, 1fr);
  gap: 1rem;
  align-items: start;
}

.split-layout.two-col {
  grid-template-columns: minmax(300px, 0.42fr) minmax(0, 0.58fr);
}

/* 產品管理：左右欄固定視窗高度內捲，避免產品／原料一多整頁爆炸 */
#view-products > .split-layout.two-col {
  align-items: stretch;
  min-height: calc(100vh - 10.5rem);
  max-height: calc(100vh - 10.5rem);
}

#view-products .detail-panel.wide {
  display: flex;
  flex-direction: column;
  min-height: 0;
  max-height: 100%;
  overflow-y: auto;
}

#view-products .product-list-panel {
  min-width: 0;
  min-height: 0;
  max-height: 100%;
  overflow-x: hidden;
  overflow-y: auto;
}

#view-products #product-material-selected.picked-list {
  max-height: 260px;
  overflow-y: auto;
  padding-right: 0.15rem;
}

/* 廠商基本資料：單欄，預覽改彈窗 */
.factory-layout {
  display: block;
}

.factory-main {
  min-height: auto;
  max-width: 920px;
}

.list-panel,
.detail-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  min-height: 420px;
  overflow: hidden;
}

.detail-panel.wide {
  min-height: 420px;
}

.panel-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
}

.panel-toolbar h2 {
  font-size: 0.95rem;
}

.toolbar-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  justify-content: flex-end;
}

.entity-list {
  padding: 0.5rem;
}

.entity-item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.7rem 0.75rem;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--text);
  cursor: pointer;
  text-align: left;
  margin-bottom: 0.25rem;
}

.entity-item:hover {
  background: rgba(15, 118, 110, 0.05);
}

.entity-item.active {
  background: rgba(15, 118, 110, 0.1);
  border-color: rgba(15, 118, 110, 0.25);
}

.entity-status {
  width: 1.25rem;
  text-align: center;
  font-weight: 700;
  flex-shrink: 0;
}

.entity-status.ok { color: var(--success); }
.entity-status.fail { color: var(--danger); }

.entity-body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
}

.entity-name {
  font-size: 0.9rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.entity-name-en {
  font-size: 0.75rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.entity-meta {
  font-size: 0.72rem;
  color: var(--text-muted);
}

.detail-card {
  padding: 1rem;
}

.detail-head {
  margin-bottom: 1rem;
}

.detail-block {
  margin-bottom: 1.25rem;
}

.detail-block h3 {
  font-size: 0.9rem;
  margin-bottom: 0.35rem;
}

.hint-text {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-bottom: 0.65rem;
}

.detail-meta {
  margin: 0.2rem 0 0.35rem;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.detail-field {
  margin: 0.35rem 0 0.55rem;
  font-size: 0.95rem;
  color: var(--text);
  line-height: 1.45;
}

.detail-field-label {
  display: inline-block;
  margin-right: 0.45rem;
  color: var(--text-muted);
  font-size: 0.85rem;
}

.detail-change-alert {
  margin: 0.45rem 0 0.65rem;
  color: var(--warn);
  font-weight: 600;
  font-size: 0.9rem;
}

.muted-block {
  padding: 0.85rem;
  border-radius: 8px;
  background: var(--surface-2);
  border: 1px dashed var(--border);
}

.text-input {
  width: 100%;
  margin-top: 0.35rem;
  padding: 0.65rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  font: inherit;
}

.text-input.compact {
  margin-top: 0.45rem;
  padding: 0.45rem 0.6rem;
  font-size: 0.85rem;
}

.text-input:focus {
  outline: none;
  border-color: var(--accent);
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem 1rem;
}

.form-span-2 {
  grid-column: 1 / -1;
}

.packaging-spec-list {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  margin-bottom: 0.65rem;
}

.packaging-spec-row {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 0.65rem;
  padding: 0.75rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface-2);
}

.packaging-spec-row.missing {
  border-style: dashed;
}

.packaging-spec-body {
  flex: 1;
  min-width: 0;
}

.packaging-spec-meta {
  margin-top: 0.3rem;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.check-grid {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.check-item {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.55rem 0.65rem;
  border-radius: 8px;
  background: var(--surface-2);
  cursor: pointer;
  font-size: 0.88rem;
}

.check-item input {
  accent-color: var(--accent);
}

.picked-list {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  margin-bottom: 0.65rem;
}

.picked-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.65rem;
  padding: 0.55rem 0.65rem;
  border-radius: 8px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  font-size: 0.88rem;
}

.picked-item-muted {
  opacity: 0.72;
}

.picked-item-main {
  min-width: 0;
  flex: 1;
}

.picked-item-label {
  display: block;
  font-weight: 500;
}

.material-picker {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.5rem;
}

.material-picker-panel {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  padding: 0.65rem;
}

.material-picker-results {
  margin-top: 0.5rem;
  max-height: 220px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.picker-result {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  width: 100%;
  text-align: left;
  padding: 0.45rem 0.55rem;
  border: none;
  border-radius: 6px;
  background: var(--surface-2);
  color: var(--text);
  cursor: pointer;
  font-size: 0.84rem;
}

.picker-result:hover {
  background: color-mix(in srgb, var(--accent) 10%, var(--surface-2));
}

.picker-result:disabled {
  opacity: 0.55;
  cursor: default;
}

.warn-tag {
  color: var(--danger);
  font-style: normal;
  font-size: 0.75rem;
  margin-left: 0.35rem;
}

.muted-tag {
  color: var(--text-muted);
  font-style: normal;
  font-size: 0.75rem;
  margin-left: 0.35rem;
}


.drag-handle {
  display: inline-block;
  flex: 0 0 1.1rem;
  width: 1.1rem;
  text-align: center;
  cursor: grab;
  color: var(--text-muted);
  touch-action: none;
  user-select: none;
}

.material-no-cell {
  display: inline-flex;
  align-items: center;
  gap: 0.15rem;
  white-space: nowrap;
}

.material-no-text {
  font-variant-numeric: tabular-nums;
}

.toolbar-filter {
  margin-right: 0.35rem;
  font-size: 0.8rem;
}

.file-count {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.usage-case-factory-list {
  margin: 0;
  padding-left: 1.15rem;
  color: var(--text);
  font-size: 0.88rem;
}

.usage-case-factory-list li + li {
  margin-top: 0.2rem;
}

.drag-handle:active {
  cursor: grabbing;
}

.data-row.dragging {
  opacity: 0.4;
}

.data-row.drag-over-top {
  box-shadow: inset 0 2px 0 0 var(--accent);
}

.data-row.drag-over-bottom {
  box-shadow: inset 0 -2px 0 0 var(--accent);
}

.product-list-panel {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.product-list-section .panel-toolbar h2 {
  font-size: 1rem;
}

.product-list-hint {
  margin: 0 0 0.5rem;
  padding: 0 0.25rem;
}

.entity-item-warn {
  border-color: color-mix(in srgb, var(--danger) 45%, var(--border));
  background: color-mix(in srgb, var(--danger) 8%, var(--surface));
}

.entity-item-warn.active {
  border-color: var(--danger);
}

#product-detail.shares-line-warn {
  box-shadow: inset 3px 0 0 var(--danger);
}

.share-line-check {
  font-weight: 600;
}

.change-badge {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 600;
  padding: 0.05rem 0.4rem;
  border-radius: 999px;
  vertical-align: middle;
}

.change-badge.added {
  color: var(--info);
  background: color-mix(in srgb, var(--info) 12%, var(--surface));
}

.change-badge.modified {
  color: var(--warn);
  background: color-mix(in srgb, var(--warn) 14%, var(--surface));
}

.change-summary {
  margin: 0 0 0.75rem;
  padding: 0.5rem 0.75rem;
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--warn) 10%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--warn) 30%, var(--border));
  color: var(--text);
  font-size: 0.85rem;
}

.change-diff-block {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.75rem 1rem;
  margin-bottom: 0.75rem;
  background: var(--surface);
}

.change-diff-block h4 {
  margin: 0 0 0.4rem;
  font-size: 0.95rem;
}

.change-diff-row {
  font-size: 0.85rem;
  padding: 0.15rem 0;
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
}

.change-diff-row .diff-label {
  color: var(--text-muted);
  min-width: 6.5rem;
}

.change-diff-row .diff-before {
  color: var(--text-muted);
  text-decoration: line-through;
}

.change-diff-row .diff-arrow {
  color: var(--text-muted);
}

.change-diff-row .diff-after {
  font-weight: 600;
}

.change-diff-row.risk .diff-after {
  color: var(--danger);
}

.change-diff-list {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin: 0.15rem 0 0.5rem;
}

.change-empty-state {
  padding: 2rem 1rem;
  text-align: center;
  color: var(--text-muted);
}

.review-change-alert {
  color: var(--warn);
  font-weight: 600;
}

.review-resume-note {
  color: var(--info);
  font-weight: 600;
}


.check-item-muted {
  opacity: 0.72;
}

.data-row-muted {
  background: var(--surface-2);
  color: inherit;
}

.data-row-muted td {
  color: inherit;
}

.data-row-warn td:nth-child(3) {
  font-weight: 600;
}

.table-section-row td {
  background: var(--surface-2);
  color: var(--text-muted);
  font-size: 0.8rem;
  padding: 0.45rem 0.75rem;
  border-top: 1px dashed var(--border);
}

.entity-status.muted {
  color: var(--text-muted);
  background: transparent;
  border: none;
}

.btn-sm {
  padding: 0.35rem 0.7rem;
  font-size: 0.82rem;
}

.list-section-label {
  margin: 0.75rem 0 0.35rem;
  padding: 0 0.25rem;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-muted);
  letter-spacing: 0.02em;
}

.list-section-label:first-child {
  margin-top: 0;
}

.doc-list {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.doc-row {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 0.65rem;
  padding: 0.75rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface-2);
}

.version-count {
  margin-left: 0.4rem;
  font-size: 0.72rem;
  font-weight: 500;
  color: var(--text-muted);
}

.version-list {
  flex-basis: 100%;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  margin-top: 0.35rem;
  padding-top: 0.45rem;
  border-top: 1px dashed var(--border);
}

.version-item {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  width: 100%;
  padding: 0.35rem 0.5rem;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  color: var(--text);
  cursor: pointer;
  text-align: left;
  font-size: 0.75rem;
}

.version-item:hover {
  background: rgba(15, 118, 110, 0.06);
}

.version-item.current {
  background: rgba(15, 118, 110, 0.08);
}

.version-item.active {
  border-color: rgba(15, 118, 110, 0.35);
}

.version-badge {
  flex-shrink: 0;
  font-size: 0.65rem;
  padding: 0.1rem 0.35rem;
  border-radius: 4px;
  background: rgba(139, 146, 168, 0.15);
  color: var(--text-muted);
}

.version-item.current .version-badge {
  color: var(--success);
  background: rgba(74, 222, 128, 0.15);
}

.version-name {
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.version-time {
  flex-shrink: 0;
  color: var(--text-muted);
  font-size: 0.68rem;
}

.doc-slot-wrap {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.audit-log {
  max-height: 220px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.audit-item {
  padding: 0.55rem 0.65rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  font-size: 0.78rem;
}

.audit-item.replace {
  border-color: rgba(194, 65, 12, 0.25);
  background: rgba(194, 65, 12, 0.04);
}

.audit-top {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.2rem;
}

.audit-action {
  font-weight: 600;
  color: var(--accent);
}

.audit-item.replace .audit-action {
  color: var(--warn);
}

.audit-time {
  flex-shrink: 0;
  color: var(--text-muted);
  font-size: 0.72rem;
}

.audit-detail {
  color: var(--text);
  line-height: 1.45;
  word-break: break-word;
}

.doc-row.missing {
  border-color: rgba(194, 65, 12, 0.25);
}

.doc-row.uploaded {
  border-color: rgba(21, 128, 61, 0.25);
}

.doc-row-body {
  flex: 1;
  min-width: 0;
}

.doc-row-title {
  font-size: 0.88rem;
  font-weight: 600;
}

.doc-row-meta {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 0.15rem;
}

.doc-cert-meta {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 0.55rem 0.75rem;
  margin-top: 0.55rem;
}

.doc-cert-meta .field-label {
  margin: 0;
  font-size: 0.78rem;
}

@media (max-width: 700px) {
  .doc-cert-meta {
    grid-template-columns: minmax(0, 1fr);
  }
}

.doc-row-actions {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.btn-sm {
  padding: 0.3rem 0.55rem;
  font-size: 0.78rem;
}

.detail-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.submit-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

.submit-checklist {
  margin: 0.25rem 0 0.75rem 1.1rem;
  color: var(--danger);
  font-size: 0.85rem;
}

#review-completeness .submit-checklist {
  max-height: 220px;
  overflow-y: auto;
  padding-right: 0.5rem;
}

.submit-checklist .ok-item {
  color: var(--success);
}

.admin-entity-block {
  padding: 0.5rem 0.25rem 0.75rem;
  border-bottom: 1px solid var(--border);
}

.admin-entity-block:last-child {
  border-bottom: none;
}

.admin-entity-title {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  margin-bottom: 0.35rem;
  padding: 0 0.5rem;
}

.admin-doc-links {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.top-dashboard .summary-value {
  font-size: 1.1rem;
}

.top-dashboard {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 0.75rem;
  padding: 0 1.5rem 1rem;
}

.top-dashboard.hidden {
  display: none;
}

.summary-card.danger .summary-value {
  color: var(--danger);
}

.summary-card.danger {
  border-color: rgba(194, 65, 12, 0.3);
}

.shell-content {
  flex: 1;
  padding: 0 1.5rem 1.5rem;
}

/* Admin */
.admin-view {
  min-width: 0;
}

.admin-list-toolbar {
  margin-bottom: 1rem;
}

.admin-list-toolbar .dash-title {
  margin-bottom: 0.25rem;
}

.admin-nav-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem 1.25rem;
  margin-bottom: 1rem;
}

.breadcrumb {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.breadcrumb-link {
  border: none;
  background: none;
  padding: 0;
  color: var(--accent);
  cursor: pointer;
  font: inherit;
}

.breadcrumb-link:hover {
  text-decoration: underline;
}

.breadcrumb-sep {
  color: var(--text-muted);
}

.breadcrumb-current {
  color: var(--text);
  font-weight: 600;
}

.company-grid,
.case-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 0.85rem;
}

.admin-row-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  padding: 0.4rem;
}

.admin-row {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  width: 100%;
  text-align: left;
  padding: 0.85rem 1rem;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--text);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}

.admin-row:hover {
  background: rgba(15, 118, 110, 0.06);
  border-color: rgba(15, 118, 110, 0.2);
}

.admin-row-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.admin-row-title {
  font-size: 0.98rem;
  font-weight: 700;
}

.admin-row-meta {
  font-size: 0.78rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.admin-row-fields {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem 1.5rem;
  align-items: baseline;
}

.admin-row-fields.secondary {
  gap: 0.35rem 1.25rem;
}

.admin-row-field {
  display: flex;
  align-items: baseline;
  gap: 0.4rem;
  min-width: 0;
}

.admin-row-label {
  flex-shrink: 0;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-muted);
  letter-spacing: 0.02em;
}

.admin-row-value {
  font-size: 0.86rem;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.admin-row-value.primary {
  font-size: 1.02rem;
  font-weight: 700;
  color: var(--text);
}

.admin-row-value.mono {
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
}

.admin-row-aside {
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.35rem;
  min-width: 7.5rem;
}

.admin-row-time {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.1rem;
  text-align: right;
}

.admin-row-time-value {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.admin-row-count {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--accent);
  line-height: 1.1;
}

.admin-row-count-label {
  font-size: 0.72rem;
  color: var(--text-muted);
}

.admin-row-arrow {
  flex-shrink: 0;
  color: var(--text-muted);
  font-size: 1.1rem;
}

.company-card,
.case-card-lg {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  width: 100%;
  text-align: left;
  padding: 1rem 1.1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
  color: var(--text);
  cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.company-card:hover,
.case-card-lg:hover {
  border-color: rgba(15, 118, 110, 0.35);
  box-shadow: 0 4px 16px rgba(15, 40, 50, 0.08);
}

.company-card-top,
.case-card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
}

.company-card-name,
.case-name {
  font-size: 1.05rem;
  font-weight: 700;
}

.company-card-count {
  flex-shrink: 0;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--accent);
  background: rgba(15, 118, 110, 0.1);
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
}

.company-card-meta,
.case-meta {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin: 0;
}

.company-card-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 0.85rem;
  margin-top: 0.35rem;
  font-size: 0.78rem;
  color: var(--text-muted);
}

.company-card-cta {
  margin-top: 0.5rem;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--accent);
}

.admin-empty-block {
  padding: 2rem 1rem;
  text-align: center;
  color: var(--text-muted);
  background: var(--surface);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
}

.admin-layout {
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr);
  gap: 1rem;
  align-items: start;
  width: 100%;
  min-width: 0;
}

.admin-main-pane {
  min-width: 0;
  width: 100%;
}

.panel-empty {
  padding: 1.5rem 1rem;
  color: var(--text-muted);
  font-size: 0.85rem;
  text-align: center;
}

.admin-panel {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  position: sticky;
  top: 1rem;
  max-height: calc(100vh - 2rem);
  overflow-y: auto;
}

.case-list {
  padding: 0.5rem;
}

.case-card {
  width: 100%;
  text-align: left;
  padding: 0.85rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-2);
  color: var(--text);
  cursor: pointer;
}

.case-card.active {
  border-color: var(--accent);
  background: rgba(15, 118, 110, 0.08);
}

.case-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.45rem;
}

.case-name {
  font-weight: 600;
}

.case-meta {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.review-actions {
  padding: 0.85rem;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.review-case-meta {
  font-size: 0.85rem;
  color: var(--text-muted);
  line-height: 1.6;
}

.field-label {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.review-comment {
  width: 100%;
  resize: vertical;
  min-height: 96px;
  padding: 0.7rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  font: inherit;
}

.review-comment:focus {
  outline: none;
  border-color: var(--accent);
}

.review-btns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
}

.admin-empty {
  padding: 2rem;
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text-muted);
  text-align: center;
}

@media (max-width: 1200px) {
  .split-layout {
    grid-template-columns: 260px 1fr;
  }

  .split-layout.two-col {
    grid-template-columns: minmax(280px, 0.42fr) minmax(0, 0.58fr);
  }

  .admin-layout {
    grid-template-columns: 1fr;
  }

  .split-layout .preview-area,
  .preview-area {
    grid-column: 1 / -1;
    position: static;
  }

  .factory-layout {
    grid-template-columns: 1fr;
  }

  .submit-layout {
    grid-template-columns: 1fr;
  }

  .top-dashboard {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
  .form-grid {
    grid-template-columns: 1fr;
  }

  #view-products > .split-layout.two-col {
    max-height: none;
    min-height: 0;
  }

  #view-products .product-list-panel {
    max-height: min(42vh, 360px);
  }

  .admin-layout {
    grid-template-columns: 1fr;
  }

  .portal-grid {
    grid-template-columns: 1fr;
  }

  .admin-panel {
    position: static;
    max-height: none;
  }

  .shell-banner {
    margin-left: 1rem;
    margin-right: 1rem;
  }

  .top-dashboard {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    padding: 0 1rem 1rem;
  }

  .shell-header,
  .shell-content {
    padding-left: 1rem;
    padding-right: 1rem;
  }

  .dash-timeline {
    max-height: 280px;
  }

  .preview-area {
    min-height: 420px;
  }

  .case-factory-layout {
    grid-template-columns: 1fr;
  }

  .main {
    padding: 1rem;
  }
}

/* -------- 原料寬表 + 彈窗預覽 -------- */
.materials-workspace {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  min-width: 0;
}

.materials-workspace .panel-toolbar {
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
}

.table-scroll {
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  max-height: min(48vh, 520px);
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
  min-width: 1280px;
}

.data-table th,
.data-table td {
  padding: 0.65rem 0.75rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
  white-space: nowrap;
}

.data-table th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--surface-2);
  font-weight: 600;
  color: var(--text-muted, #5b6470);
  font-size: 0.78rem;
  letter-spacing: 0.02em;
}

/* 原料表：固定欄寬，避免中間欄被撑出大片空白 */
.materials-table {
  table-layout: fixed;
  min-width: 1280px;
}

.materials-table th,
.materials-table td {
  padding: 0.55rem 0.5rem;
  overflow: hidden;
  text-overflow: ellipsis;
}

.materials-table th:nth-child(1),
.materials-table td:nth-child(1) {
  width: 2.2rem;
  padding-left: 0.2rem;
  padding-right: 0.2rem;
  text-align: center;
} /* 狀態：僅勾叉 */

.materials-table th:nth-child(2),
.materials-table td:nth-child(2) { width: 6rem; } /* 序號 */

.materials-table th:nth-child(3),
.materials-table td:nth-child(3) { width: 9%; } /* 品名 */

.materials-table th:nth-child(4),
.materials-table td:nth-child(4) { width: 8%; } /* 使用落點（廠） */

.materials-table th:nth-child(5),
.materials-table td:nth-child(5) { width: 8%; } /* 用於產品 */

.materials-table th:nth-child(6),
.materials-table td:nth-child(6) { width: 9%; } /* 製造商 */

.materials-table th:nth-child(7),
.materials-table td:nth-child(7) { width: 6.5%; } /* 產地 */

.materials-table th:nth-child(8),
.materials-table td:nth-child(8) { width: 8.5%; } /* 供應商 */

.materials-table th:nth-child(9),
.materials-table td:nth-child(9) { width: 10%; } /* 證明文件種類 */

.materials-table th:nth-child(10),
.materials-table td:nth-child(10) { width: 9%; } /* 證明文件 */

.materials-table th:nth-child(11),
.materials-table td:nth-child(11) { width: 7.5rem; } /* 證書到期日 */

.materials-table th:nth-child(12),
.materials-table td:nth-child(12) { width: 14%; } /* 備註 */

.materials-table td:nth-child(3),
.materials-table td:nth-child(4),
.materials-table td:nth-child(5),
.materials-table td:nth-child(6),
.materials-table td:nth-child(8),
.materials-table td:nth-child(9),
.materials-table td:nth-child(10),
.materials-table td:nth-child(12) {
  white-space: normal;
  word-break: break-word;
  overflow: visible;
  text-overflow: unset;
}

.materials-table td:nth-child(5) {
  white-space: pre-line;
}

.materials-table .material-remark-cell {
  white-space: pre-wrap;
}

.used-in-other-cases {
  margin-top: 0.15rem;
  font-size: 0.72rem;
  color: var(--text-muted);
}

.material-remark-input {
  width: 100%;
  min-height: 4.25rem;
  resize: vertical;
}

#admin-material-remark {
  white-space: pre-wrap;
}

.doc-other-toolbar {
  margin-top: 0.15rem;
}

/* 協會端產品／主檔列表：不要套用原料表 11 欄寬 */
.data-table.stack-table {
  min-width: 0;
  width: 100%;
  table-layout: fixed;
}

.stack-table.stack-cols-6 th:nth-child(1),
.stack-table.stack-cols-6 td:nth-child(1) { width: 3.25rem; } /* 狀態 */

.stack-table.stack-cols-6 th:nth-child(2),
.stack-table.stack-cols-6 td:nth-child(2) { width: 5.5rem; } /* 編號 */

.stack-table.stack-cols-6 th:nth-child(3),
.stack-table.stack-cols-6 td:nth-child(3) { width: 11rem; } /* 名稱靠左 */

.stack-table.stack-cols-6 th:nth-child(4),
.stack-table.stack-cols-6 td:nth-child(4) { width: 12rem; } /* 英文緊貼名稱 */

.stack-table.stack-cols-6 th:nth-child(5),
.stack-table.stack-cols-6 td:nth-child(5) { width: 100%; } /* 類型吃剩餘空白 */

.stack-table.stack-cols-6 th:nth-child(6),
.stack-table.stack-cols-6 td:nth-child(6) { width: 4.5rem; } /* 原料數 */

.stack-table.stack-cols-6 td:nth-child(3),
.stack-table.stack-cols-6 td:nth-child(4),
.stack-table.stack-cols-6 td:nth-child(5) {
  white-space: normal;
  word-break: break-word;
  overflow: visible;
  text-overflow: unset;
}

.stack-table.stack-cols-5 th:nth-child(1),
.stack-table.stack-cols-5 td:nth-child(1) { width: 3.25rem; } /* 狀態 */

.stack-table.stack-cols-5 th:nth-child(2),
.stack-table.stack-cols-5 td:nth-child(2) { width: 5.5rem; } /* 編號 */

.stack-table.stack-cols-5 th:nth-child(3),
.stack-table.stack-cols-5 td:nth-child(3) { width: 100%; } /* 名稱吃剩餘寬度 */

.stack-table.stack-cols-5 th:nth-child(4),
.stack-table.stack-cols-5 td:nth-child(4) { width: 8.5rem; } /* 類型 */

.stack-table.stack-cols-5 th:nth-child(5),
.stack-table.stack-cols-5 td:nth-child(5) { width: 4.5rem; } /* 原料數 */

.stack-table.stack-cols-5 td:nth-child(3),
.stack-table.stack-cols-5 td:nth-child(4) {
  white-space: normal;
  word-break: break-word;
  overflow: visible;
  text-overflow: unset;
}

.stack-table.stack-cols-4 th:nth-child(1),
.stack-table.stack-cols-4 td:nth-child(1) { width: 3.25rem; } /* 狀態 */

.stack-table.stack-cols-4 th:nth-child(2),
.stack-table.stack-cols-4 td:nth-child(2) { width: 100%; } /* 名稱吃剩餘寬度 */

.stack-table.stack-cols-4 th:nth-child(3),
.stack-table.stack-cols-4 td:nth-child(3) { width: 28%; } /* 檔名 */

.stack-table.stack-cols-4 th:nth-child(4),
.stack-table.stack-cols-4 td:nth-child(4) { width: 9rem; } /* 上傳時間 */

.stack-table.stack-cols-4 td:nth-child(2),
.stack-table.stack-cols-4 td:nth-child(3) {
  white-space: normal;
  word-break: break-word;
  overflow: visible;
  text-overflow: unset;
}

.material-name-cell {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  white-space: normal;
  min-width: 0;
}

.material-name-zh {
  line-height: 1.35;
}

.material-name-en {
  font-size: inherit;
  color: inherit;
  line-height: 1.35;
  word-break: break-word;
}

.data-row {
  cursor: pointer;
}

.data-row:hover {
  background: rgba(15, 118, 110, 0.06);
}

.data-row.active {
  background: rgba(15, 118, 110, 0.12);
}

.table-empty {
  text-align: center;
  color: var(--text-muted, #5b6470);
  padding: 1.5rem !important;
}

.material-editor {
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  padding: 0.85rem 1rem 1rem;
}

.material-detail-card {
  border: 0;
  box-shadow: none;
  padding: 0;
  background: transparent;
}

.material-form-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.75rem 1rem;
  margin-bottom: 0.85rem;
}

.readonly-value {
  margin: 0.35rem 0 0;
  font-size: 0.95rem;
}

.readonly-value.used-in-products {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  white-space: normal;
  line-height: 1.45;
  max-height: 10.5rem;
  overflow-y: auto;
}

.used-in-line {
  display: flex;
  flex-wrap: wrap;
  gap: 0.2rem 0.5rem;
  align-items: baseline;
}

.used-in-kind {
  flex: 0 0 auto;
  color: var(--text-muted, #5b6470);
  font-size: 0.8rem;
  font-weight: 600;
}

.used-in-codes {
  display: flex;
  flex-wrap: wrap;
  gap: 0.2rem 0.35rem;
  min-width: 0;
  flex: 1 1 8rem;
}

.used-in-code {
  font-variant-numeric: tabular-nums;
}

.preview-modal {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.25rem;
}

.preview-modal.hidden {
  display: none;
}

.preview-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(18, 24, 32, 0.55);
}

.preview-modal-panel {
  position: relative;
  z-index: 1;
  width: min(1100px, 96vw);
  max-height: 92vh;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border-radius: 12px;
  border: 1px solid var(--border);
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.28);
  overflow: hidden;
}

.preview-modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
}

.preview-modal-head h2 {
  margin: 0;
  font-size: 1rem;
}

.preview-modal-host {
  min-height: 0;
  flex: 1;
  overflow: auto;
}

.preview-modal-host .preview-area {
  min-height: min(70vh, 720px);
  border: 0;
  border-radius: 0;
}

body.modal-open {
  overflow: hidden;
}

@media (max-width: 900px) {
  .material-form-grid {
    grid-template-columns: 1fr;
  }
}

/* 案件管理 / 複數工廠 */
.cases-workspace {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.new-case-panel {
  margin-bottom: 0.25rem;
}

.cases-table .row-active {
  background: rgba(15, 118, 110, 0.08);
}

.cases-table {
  table-layout: fixed;
  width: 100%;
  min-width: 0;
  font-size: 0.95rem;
}

.cases-table th,
.cases-table td {
  vertical-align: middle;
  padding: 0.9rem 1rem;
}

.cases-table th {
  font-size: 0.85rem;
}

.cases-table th:nth-child(1),
.cases-table td:nth-child(1) { width: 16%; }

.cases-table th:nth-child(2),
.cases-table td:nth-child(2) { width: 14%; }

.cases-table th:nth-child(3),
.cases-table td:nth-child(3) { width: 24%; }

.cases-table th:nth-child(4),
.cases-table td:nth-child(4) { width: 16%; }

.cases-table th:nth-child(5),
.cases-table td:nth-child(5) { width: 16%; }

.cases-table th:nth-child(6),
.cases-table td:nth-child(6) { width: 14%; }

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

.cases-table .status-cell {
  width: fit-content;
  max-width: 100%;
  align-items: center;
}

.cases-table .status-pills {
  justify-content: center;
}

.cases-table .status-pill {
  font-size: 0.88rem;
  padding: 0.3rem 0.85rem;
}

.cases-table .status-subtitle {
  font-size: 0.82rem;
  margin-top: 0.25rem;
  text-align: center;
}

.cases-table .case-row-actions {
  align-items: center;
  justify-content: flex-start;
}

.factory-list {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.factory-card {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.85rem 1rem;
  background: var(--surface, #fff);
}

.factory-card.bound {
  border-color: rgba(15, 118, 110, 0.45);
  box-shadow: inset 3px 0 0 var(--accent);
}

.factory-card-head {
  display: flex;
  flex-direction: row;
  flex-wrap: nowrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.65rem;
  cursor: pointer;
}

.factory-card.collapsed .factory-card-head {
  margin-bottom: 0;
}

.factory-card-title {
  font-size: 0.92rem;
  font-weight: 600;
  min-width: 0;
  flex: 1 1 auto;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.factory-card-head-right {
  display: flex;
  flex-direction: row;
  flex-wrap: nowrap;
  align-items: center;
  gap: 0.5rem;
  flex: 0 0 auto;
}

.factory-card-head-right .entity-status,
.factory-file-flag {
  width: auto !important;
  max-width: none !important;
  display: inline-block !important;
  white-space: nowrap !important;
  writing-mode: horizontal-tb !important;
  text-orientation: mixed;
  font-size: 0.78rem;
  font-weight: 600;
  line-height: 1.2;
  padding: 0.12rem 0.5rem;
  border-radius: 999px;
}

.factory-file-flags {
  display: inline-flex !important;
  flex-direction: row !important;
  flex-wrap: nowrap !important;
  align-items: center;
  gap: 0.4rem;
  white-space: nowrap;
  writing-mode: horizontal-tb;
}

.factory-file-flag.ok,
.factory-card-head-right .entity-status.ok {
  color: var(--success);
  background: rgba(15, 118, 110, 0.08);
}

.factory-file-flag.fail,
.factory-card-head-right .entity-status.fail {
  color: var(--danger);
  background: rgba(180, 35, 24, 0.08);
}

.factory-card.collapsed .factory-card-body {
  display: none;
}

.factory-card-grid {
  margin-bottom: 0.65rem;
}

.nav-badge {
  display: inline-block;
  margin-left: 0.35rem;
  padding: 0.05rem 0.4rem;
  border-radius: 999px;
  font-size: 0.68rem;
  font-weight: 700;
  vertical-align: middle;
  background: #fde8e8;
  color: #b42318;
}

.review-status-layout {
  display: grid;
  grid-template-columns: 1.1fr 1fr;
  gap: 1rem;
  align-items: start;
}

@media (max-width: 960px) {
  .review-status-layout {
    grid-template-columns: 1fr;
  }
}

.review-status-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}

.review-stage-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}

.review-stage-note {
  padding: 0.65rem 0.75rem;
  border-radius: 8px;
  background: rgba(15, 118, 110, 0.06);
  color: var(--text);
  font-size: 0.88rem;
}

.review-stage-note.warn {
  background: #fff4e5;
  color: #9a3412;
}

.review-stage-item {
  display: flex;
  gap: 0.7rem;
  align-items: flex-start;
  padding: 0.55rem 0.35rem;
  border-radius: 8px;
}

.review-stage-marker {
  width: 0.7rem;
  height: 0.7rem;
  margin-top: 0.35rem;
  border-radius: 50%;
  background: #d0d7de;
  flex-shrink: 0;
}

.review-stage-item.state-done .review-stage-marker {
  background: var(--accent);
}

.review-stage-item.state-current {
  background: rgba(15, 118, 110, 0.08);
}

.review-stage-item.state-current .review-stage-marker {
  background: var(--accent);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.2);
}

.review-stage-title {
  display: block;
  font-weight: 700;
  font-size: 0.92rem;
}

.review-stage-desc {
  display: block;
  margin-top: 0.15rem;
  font-size: 0.78rem;
  color: var(--text-muted);
}

.review-feedback-list {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.review-feedback-item {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.75rem 0.85rem;
  background: #fff;
}

.review-feedback-item.tone-danger {
  border-color: #f3b4b4;
  background: #fff7f7;
}

.review-feedback-item.tone-warn {
  border-color: rgba(180, 83, 9, 0.35);
  background: rgba(180, 83, 9, 0.08);
}

.review-feedback-item.tone-info {
  border-color: rgba(15, 118, 110, 0.25);
  background: rgba(15, 118, 110, 0.04);
}

.review-feedback-top {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.35rem;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.review-feedback-item p {
  margin: 0;
  font-size: 0.92rem;
  line-height: 1.45;
  white-space: pre-wrap;
}

.review-feedback-list .final-checklist-warn-box {
  margin-bottom: 0.85rem;
}

.case-factory-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(300px, 0.85fr);
  gap: 1rem;
  align-items: start;
  min-width: 0;
}

.case-factory-layout .factory-main {
  min-height: auto;
  max-width: none;
}

.case-factory-layout .admin-factory-timeline-panel {
  min-height: 280px;
}

.case-factory-layout .dash-timeline {
  max-height: min(72vh, 800px);
}

.case-factory-layout .timeline-desc {
  white-space: normal;
}

.case-materials-layout .materials-workspace {
  background: var(--surface, #fff);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 0.85rem 1rem 1rem;
}

.case-stack-layout {
  min-width: 0;
}

.case-stack-layout .stack-workspace {
  background: var(--surface, #fff);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 0.85rem 1rem 1rem;
}

.case-changes-layout {
  min-width: 0;
  max-width: 900px;
}

.stack-editor {
  margin-top: 1rem;
}

.readonly-factory-list {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}

.readonly-factory-card {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.65rem 0.75rem;
  background: rgba(15, 118, 110, 0.03);
}

.readonly-factory-card p {
  margin: 0.25rem 0 0;
  font-size: 0.86rem;
}
