:root {
  --bg: #efe6d6;
  --bg-soft: rgba(255, 250, 240, 0.62);
  --panel-line: rgba(14, 32, 46, 0.12);
  --ink: #132433;
  --ink-soft: rgba(19, 36, 51, 0.7);
  --copper: #bc7a34;
  --teal: #1e6a73;
  --night: #0d1a26;
  --light: #fff8ef;
  --shadow: 0 24px 60px rgba(16, 28, 38, 0.15);
  --radius-lg: 28px;
  --radius-md: 18px;
  --font-sans: "Microsoft YaHei UI", "PingFang SC", "Hiragino Sans GB", "Noto Sans CJK SC", "Source Han Sans SC", "Segoe UI", sans-serif;
  --font-display: "Microsoft YaHei UI", "PingFang SC", "Hiragino Sans GB", "Noto Sans CJK SC", "Source Han Sans SC", "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background:
    radial-gradient(circle at top left, rgba(188, 122, 52, 0.18), transparent 28%),
    radial-gradient(circle at right center, rgba(30, 106, 115, 0.18), transparent 26%),
    linear-gradient(180deg, #f4ead8 0%, #e8dcc9 100%);
  color: var(--ink);
  font-family: var(--font-sans);
  text-rendering: optimizeLegibility;
}

body {
  position: relative;
}

body.auth-locked {
  overflow: hidden;
}

.grain {
  pointer-events: none;
  position: fixed;
  inset: 0;
  opacity: 0.12;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.08) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.08) 1px, transparent 1px);
  background-size: 5px 5px, 5px 5px;
  mix-blend-mode: soft-light;
}

.app-shell {
  position: relative;
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr);
  min-height: 100vh;
}

.app-shell.locked {
  filter: blur(2px);
  pointer-events: none;
  user-select: none;
}

.auth-overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(13, 26, 38, 0.42);
  backdrop-filter: blur(12px);
}

.auth-overlay.active {
  display: flex;
}

.auth-card {
  width: min(520px, 100%);
  padding: 30px;
  border-radius: 28px;
  background:
    linear-gradient(135deg, rgba(255, 248, 239, 0.96), rgba(255, 251, 246, 0.92)),
    linear-gradient(135deg, rgba(188, 122, 52, 0.08), rgba(30, 106, 115, 0.08));
  border: 1px solid rgba(19, 36, 51, 0.08);
  box-shadow: var(--shadow);
}

.auth-card h2 {
  margin: 0;
  font-size: clamp(30px, 4vw, 48px);
  line-height: 1.15;
  font-family: var(--font-display);
  font-weight: 700;
}

.auth-copy {
  margin: 14px 0 18px;
  color: var(--ink-soft);
  line-height: 1.75;
}

.auth-form {
  margin-top: 18px;
}

.auth-note {
  margin-top: 16px;
}

.hidden {
  display: none !important;
}

.sidebar {
  padding: 28px 24px;
  background: linear-gradient(180deg, rgba(13, 26, 38, 0.96), rgba(16, 39, 58, 0.9));
  color: var(--light);
  display: flex;
  flex-direction: column;
  gap: 24px;
  border-right: 1px solid rgba(255, 255, 255, 0.08);
}

.brand-block h1,
.hero h2,
.panel h3,
.ledger-card h4 {
  font-family: var(--font-display);
  font-weight: 700;
}

.brand-kicker,
.hero-kicker,
.section-label {
  margin: 0 0 8px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  font-size: 11px;
  color: rgba(255, 248, 239, 0.72);
}

.brand-block h1 {
  margin: 0;
  font-size: 42px;
  line-height: 0.96;
}

.brand-copy {
  margin: 12px 0 0;
  color: rgba(255, 248, 239, 0.78);
  line-height: 1.7;
}

.flow-card,
.note-card {
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: var(--radius-md);
  padding: 18px;
  background: rgba(255, 255, 255, 0.04);
}

.flow-list {
  margin: 10px 0 0;
  padding-left: 20px;
  line-height: 1.9;
}

.nav-list,
.quick-actions {
  display: grid;
  gap: 10px;
}

.nav-item,
.action-button,
.primary-button,
input,
textarea,
select {
  font: inherit;
}

.nav-item,
.action-button,
.primary-button {
  border: none;
  border-radius: 999px;
  cursor: pointer;
  transition: transform 180ms ease, background 180ms ease, color 180ms ease;
}

.nav-item {
  text-align: left;
  padding: 14px 16px;
  background: rgba(255, 255, 255, 0.05);
  color: rgba(255, 248, 239, 0.86);
}

.nav-item:hover,
.nav-item.active {
  background: linear-gradient(90deg, rgba(188, 122, 52, 0.78), rgba(30, 106, 115, 0.78));
  color: #fff;
  transform: translateX(4px);
}

.action-button,
.primary-button {
  padding: 14px 18px;
  background: linear-gradient(90deg, var(--copper), #d19f54);
  color: #fff9f1;
}

.action-button.ghost {
  background: rgba(255, 255, 255, 0.08);
  color: var(--light);
}

.action-button.subtle {
  background: rgba(255, 255, 255, 0.04);
  color: rgba(255, 248, 239, 0.78);
}

.action-button:hover,
.primary-button:hover {
  transform: translateY(-1px);
}

.main-panel {
  padding: 28px;
}

.platform-ribbon {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 16px;
}

.platform-ribbon span {
  padding: 8px 12px;
  border-radius: 999px;
  background: rgba(13, 26, 38, 0.08);
  color: var(--night);
  font-size: 12px;
}

.hero {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 24px;
  padding: 28px 30px;
  border-radius: 32px;
  background:
    linear-gradient(135deg, rgba(255, 248, 239, 0.78), rgba(255, 251, 246, 0.48)),
    linear-gradient(135deg, rgba(188, 122, 52, 0.08), rgba(30, 106, 115, 0.08));
  border: 1px solid rgba(19, 36, 51, 0.08);
  box-shadow: var(--shadow);
}

.hero-kicker,
.panel .section-label {
  color: rgba(19, 36, 51, 0.58);
}

.hero h2 {
  margin: 0;
  max-width: 780px;
  font-size: clamp(42px, 4vw, 68px);
  line-height: 0.95;
}

.hero-copy {
  max-width: 760px;
  margin: 14px 0 0;
  color: var(--ink-soft);
  line-height: 1.8;
}

.hero-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.hero-badges span {
  padding: 10px 14px;
  border-radius: 999px;
  background: rgba(13, 26, 38, 0.08);
  color: var(--night);
  font-size: 13px;
}

.progress-strip {
  margin-bottom: 24px;
}

.progress-steps {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.progress-step {
  padding: 14px 16px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.6);
  border: 1px solid rgba(19, 36, 51, 0.08);
}

.progress-step.active {
  background: linear-gradient(135deg, rgba(188, 122, 52, 0.18), rgba(30, 106, 115, 0.18));
  border-color: rgba(30, 106, 115, 0.25);
}

.progress-step.done {
  background: linear-gradient(135deg, rgba(30, 106, 115, 0.14), rgba(30, 106, 115, 0.08));
}

.progress-step strong {
  display: block;
  margin-bottom: 4px;
}

.progress-step span {
  font-size: 12px;
  color: var(--ink-soft);
}

.view {
  display: none;
  animation: reveal 260ms ease;
}

.view.active {
  display: block;
}

.grid {
  display: grid;
  gap: 20px;
  align-items: start;
}

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

.wide-left {
  grid-template-columns: 1.35fr 0.95fr;
}

.detail-grid {
  grid-template-columns: 1.15fr 1fr 0.9fr;
}

.panel {
  padding: 22px;
  border-radius: var(--radius-lg);
  background: rgba(255, 250, 242, 0.74);
  border: 1px solid rgba(19, 36, 51, 0.08);
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
}

.panel-head {
  margin-bottom: 18px;
}

.panel-head.split {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 18px;
}

.panel h3 {
  margin: 0;
  font-size: 34px;
  line-height: 1;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
}

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

.metric-card {
  padding: 18px;
  border-radius: var(--radius-md);
  background: linear-gradient(180deg, rgba(13, 26, 38, 0.94), rgba(20, 43, 63, 0.86));
  color: var(--light);
}

.metric-card strong {
  display: block;
  margin-top: 8px;
  font-size: 36px;
  font-family: var(--font-display);
  font-weight: 700;
}

.simple-list,
.timeline-list {
  margin: 0;
  padding-left: 20px;
  line-height: 1.9;
}

.ledger-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}

.ledger-card {
  padding: 18px;
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.62);
  border: 1px solid rgba(19, 36, 51, 0.08);
}

.ledger-card.accent {
  background: linear-gradient(180deg, rgba(30, 106, 115, 0.12), rgba(188, 122, 52, 0.12));
}

.ledger-card h4 {
  margin: 0 0 10px;
  font-size: 28px;
}

.search-input,
.stack-form input,
.stack-form textarea,
.stack-form select {
  width: 100%;
  padding: 14px 16px;
  border-radius: 14px;
  border: 1px solid rgba(19, 36, 51, 0.12);
  background: rgba(255, 255, 255, 0.72);
  color: var(--ink);
}

.stack-form {
  display: grid;
  gap: 14px;
}

.compact-form {
  gap: 12px;
}

.stack-form label {
  display: grid;
  gap: 8px;
}

.stack-form label span {
  font-size: 13px;
  color: var(--ink-soft);
}

.mini-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.table-shell {
  overflow: hidden;
  border-radius: 18px;
  border: 1px solid rgba(19, 36, 51, 0.08);
}

table {
  width: 100%;
  border-collapse: collapse;
}

thead {
  background: rgba(13, 26, 38, 0.9);
  color: var(--light);
}

th,
td {
  padding: 14px 16px;
  text-align: left;
  border-bottom: 1px solid rgba(19, 36, 51, 0.08);
  vertical-align: top;
}

tbody tr {
  background: rgba(255, 255, 255, 0.62);
  cursor: pointer;
  transition: background 180ms ease;
}

tbody tr:hover {
  background: rgba(30, 106, 115, 0.1);
}

.tag {
  display: inline-flex;
  align-items: center;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(188, 122, 52, 0.12);
  color: #8e5214;
  font-size: 12px;
}

.detail-block,
.linked-list {
  display: grid;
  gap: 14px;
  min-height: 0;
}

.top-gap {
  margin-top: 16px;
}

.kv-card,
.history-card {
  padding: 16px;
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.64);
  border: 1px solid rgba(19, 36, 51, 0.08);
}

.history-card {
  text-align: left;
  width: 100%;
  border: none;
}

.history-card strong {
  color: var(--night);
}

.history-card h4 {
  margin: 10px 0 8px;
  color: var(--night);
}

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

.history-card-grid {
  display: grid;
  gap: 8px;
  margin-top: 10px;
}

.history-card-grid p {
  font-size: 14px;
}

.history-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 14px;
}

.archive-history-toolbar {
  display: grid;
  gap: 12px;
  margin-bottom: 14px;
}

.archive-stats {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.archive-stat {
  display: inline-flex;
  align-items: center;
  padding: 8px 12px;
  border-radius: 999px;
  background: rgba(30, 106, 115, 0.12);
  color: var(--teal);
  font-size: 12px;
}

.kv-card p,
.history-card p,
.note-card p {
  margin: 0;
  line-height: 1.7;
  color: var(--ink-soft);
}

.kv-row {
  display: grid;
  grid-template-columns: 112px 1fr;
  gap: 14px;
  padding: 10px 0;
  border-bottom: 1px dashed rgba(19, 36, 51, 0.12);
}

.kv-row:last-child {
  border-bottom: none;
}

.kv-row strong {
  color: var(--night);
}

.kv-row.changed {
  background: rgba(188, 122, 52, 0.08);
  border-radius: 12px;
  padding: 12px;
  margin: 4px 0;
  border-bottom: none;
}

.value-stack {
  display: grid;
  gap: 6px;
}

.diff-badge {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  padding: 4px 8px;
  border-radius: 999px;
  background: rgba(188, 122, 52, 0.14);
  color: #9d6225;
  font-size: 12px;
}

.compare-hint {
  font-size: 12px;
  color: var(--ink-soft);
}

.status-line {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
  color: var(--ink-soft);
}

.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: var(--teal);
  box-shadow: 0 0 0 6px rgba(30, 106, 115, 0.12);
}

.cta-stack {
  display: grid;
  gap: 14px;
}

.empty-state {
  padding: 20px;
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.52);
  color: var(--ink-soft);
}

.task-card {
  padding: 18px;
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.64);
  border: 1px solid rgba(19, 36, 51, 0.08);
}

.task-card h4 {
  margin: 0 0 8px;
  font-size: 22px;
  font-family: var(--font-display);
  font-weight: 700;
}

.task-card p {
  margin: 0;
  line-height: 1.7;
  color: var(--ink-soft);
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border-radius: 999px;
  background: rgba(30, 106, 115, 0.12);
  color: var(--teal);
  font-size: 12px;
}

.status-pill.warn {
  background: rgba(188, 122, 52, 0.12);
  color: #9d6225;
}

.inline-state {
  margin-top: 12px;
  font-size: 13px;
  color: var(--ink-soft);
}

.inline-state.pending {
  color: var(--teal);
}

.inline-state strong {
  color: var(--night);
}

.ai-note {
  background: linear-gradient(135deg, rgba(30, 106, 115, 0.12), rgba(188, 122, 52, 0.08));
}

.ai-source-label {
  display: grid;
  gap: 8px;
}

.ai-source-label span {
  font-size: 13px;
  color: var(--ink-soft);
}

.ai-source-label input[type="file"] {
  padding: 12px 14px;
  border-radius: 16px;
  border: 1px dashed rgba(19, 36, 51, 0.18);
  background: rgba(255, 255, 255, 0.72);
  color: var(--ink);
}

.inline-meta {
  font-size: 12px;
  color: var(--ink-soft);
  line-height: 1.6;
}

.ai-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  position: relative;
  z-index: 3;
}

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

.ai-summary-grid {
  display: grid;
  gap: 14px;
}

.ai-summary-card {
  padding: 16px;
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.68);
  border: 1px solid rgba(19, 36, 51, 0.08);
}

.ai-summary-card h4 {
  margin: 0 0 10px;
  font-size: 18px;
  color: var(--night);
}

.ai-summary-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}

.ai-summary-head h4 {
  margin: 0;
}

.mini-button {
  width: fit-content;
  padding: 8px 12px;
  border: none;
  border-radius: 999px;
  cursor: pointer;
  font: inherit;
  background: rgba(30, 106, 115, 0.12);
  color: var(--teal);
}

.mini-button.subtle {
  background: rgba(13, 26, 38, 0.06);
  color: var(--ink-soft);
}

.mini-button.active {
  background: var(--copper);
  color: #fff9f1;
}

.mini-toggle-group {
  display: inline-flex;
  gap: 8px;
  flex-wrap: wrap;
}

.line-items-field {
  display: grid;
  gap: 10px;
}

.form-group-block {
  display: grid;
  gap: 12px;
  padding: 16px;
  border: 1px solid rgba(19, 36, 51, 0.08);
  border-radius: 18px;
  background: rgba(247, 249, 252, 0.72);
}

.form-group-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

.form-group-head h4 {
  margin: 0;
  font-size: 15px;
  color: var(--ink);
}

.stage-inline-head {
  padding: 0;
  margin: 0 0 12px;
  border: none;
  background: transparent;
}

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

.line-items-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.line-items-head span {
  font-size: 13px;
  color: var(--ink-soft);
}

.line-items-shell {
  overflow: auto;
  border-radius: 18px;
  border: 1px solid rgba(19, 36, 51, 0.1);
  background: rgba(255, 255, 255, 0.62);
}

.line-items-table {
  min-width: 860px;
}

.line-items-table th {
  font-size: 12px;
  letter-spacing: 0.04em;
  white-space: nowrap;
  background: #f7f9fc;
}

.line-items-table td {
  min-width: 120px;
  background: rgba(255, 255, 255, 0.82);
}

.line-items-table td:first-child {
  min-width: 320px;
}

.line-items-table td:last-child,
.line-items-table th:last-child {
  min-width: 92px;
  text-align: center;
}

.line-items-table input,
.line-items-table textarea {
  width: 100%;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid rgba(19, 36, 51, 0.12);
  background: rgba(255, 255, 255, 0.94);
  color: var(--ink);
  font: inherit;
}

.line-items-table textarea {
  min-height: 76px;
  resize: vertical;
}

.line-items-meta {
  display: inline-flex;
  align-items: center;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(30, 106, 115, 0.12);
  color: var(--teal);
  font-size: 12px;
}

.line-items-empty {
  padding: 18px;
  color: var(--ink-soft);
  font-size: 14px;
}

.line-items-danger {
  background: rgba(153, 66, 32, 0.12);
  color: #994220;
}

.validation-panel {
  display: grid;
  gap: 10px;
  padding: 14px 16px;
  border-radius: 18px;
  border: 1px solid rgba(19, 36, 51, 0.1);
  background: rgba(255, 255, 255, 0.7);
}

.doc-line-preview {
  margin-top: 18px;
  padding: 18px;
  border: 1px solid rgba(19, 36, 51, 0.08);
  border-radius: 18px;
  background: #fff;
}

.doc-line-preview-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.doc-line-preview-head h4 {
  margin: 0;
  font-size: 16px;
  color: var(--ink);
}

.doc-line-preview-shell {
  overflow: auto;
  border: 1px solid rgba(19, 36, 51, 0.08);
  border-radius: 14px;
}

.doc-line-preview-table {
  width: 100%;
  min-width: 640px;
  border-collapse: collapse;
  background: #fff;
}

.doc-line-preview-table th,
.doc-line-preview-table td {
  padding: 12px 14px;
  border-bottom: 1px solid rgba(19, 36, 51, 0.08);
  text-align: left;
  vertical-align: top;
  font-size: 13px;
}

.doc-line-preview-table th {
  position: sticky;
  top: 0;
  background: #f7f9fc;
  color: var(--ink-soft);
  font-weight: 600;
  white-space: nowrap;
}

.doc-line-preview-table tfoot td {
  background: #fbfcfe;
  font-weight: 600;
}

.doc-line-preview-table td:first-child {
  min-width: 160px;
}

.doc-line-preview-table td:nth-child(2) {
  min-width: 320px;
}

.validation-panel.empty {
  color: var(--ink-soft);
  font-size: 14px;
}

.validation-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.validation-copy {
  font-size: 13px;
  color: var(--ink-soft);
}

.validation-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.validation-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
}

.validation-chip.error {
  background: rgba(153, 66, 32, 0.14);
  color: #994220;
}

.validation-chip.warning {
  background: rgba(196, 132, 26, 0.14);
  color: #9a6b10;
}

.validation-list {
  display: grid;
  gap: 8px;
}

.validation-item {
  display: grid;
  gap: 4px;
  padding: 10px 12px;
  border-radius: 14px;
  background: rgba(250, 244, 236, 0.78);
}

.validation-item.error {
  border-left: 4px solid #b14c21;
}

.validation-item.warning {
  border-left: 4px solid #c48f20;
}

.validation-item strong {
  font-size: 13px;
  color: var(--night);
}

.validation-item p {
  margin: 0;
  font-size: 13px;
  color: var(--ink-soft);
}

.validation-item-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 6px;
}

.ai-summary-list {
  margin: 0;
  padding-left: 18px;
  display: grid;
  gap: 8px;
  color: var(--ink-soft);
}

.ai-summary-list li::marker {
  color: var(--copper);
}

.decision-card {
  padding: 18px;
  border-radius: var(--radius-md);
  background: rgba(210, 148, 59, 0.08);
  border: 1px solid rgba(210, 148, 59, 0.22);
}

.decision-card h4 {
  margin: 0 0 8px;
  font-size: 18px;
  color: var(--night);
}

.decision-card p {
  margin: 0;
  color: var(--ink-soft);
  line-height: 1.7;
}

.decision-grid {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.decision-row {
  display: grid;
  gap: 6px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid rgba(19, 36, 51, 0.08);
}

.decision-row strong {
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

.decision-row span {
  color: var(--night);
  line-height: 1.6;
  word-break: break-word;
}

.decision-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 16px;
}

.ai-compare-list {
  display: grid;
  gap: 12px;
  min-height: 0;
}

.ai-compare-row {
  display: grid;
  grid-template-columns: 120px 1fr 1fr auto;
  gap: 12px;
  padding: 14px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.78);
  border: 1px solid rgba(19, 36, 51, 0.08);
}

.ai-compare-row.changed {
  background: linear-gradient(135deg, rgba(188, 122, 52, 0.1), rgba(255, 255, 255, 0.82));
}

.ai-compare-row strong {
  color: var(--night);
}

.ai-compare-cell {
  display: grid;
  gap: 6px;
}

.ai-compare-cell span {
  font-size: 12px;
  color: var(--ink-soft);
}

.ai-compare-cell p {
  margin: 0;
  color: var(--ink);
  line-height: 1.6;
  word-break: break-word;
}

.ai-compare-empty {
  color: rgba(19, 36, 51, 0.42);
  font-style: italic;
}

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

@media (max-width: 1200px) {
  .detail-grid,
  .two-col,
  .wide-left,
  .metric-grid,
  .ledger-grid,
  .progress-steps {
    grid-template-columns: 1fr;
  }

  .ai-compare-row {
    grid-template-columns: 1fr;
  }

  .hero {
    flex-direction: column;
    align-items: start;
  }
}

@media (min-width: 1201px) {
  #customersView .panel,
  #orderCreateView .panel,
  #invoiceView .panel,
  #packingView .panel,
  #archiveView .panel,
  #docWorkspaceView .panel {
    max-height: calc(100vh - 168px);
    overflow: hidden;
    display: flex;
    flex-direction: column;
  }

  #customersView .panel:nth-of-type(2) {
    overflow: auto;
    scrollbar-gutter: stable;
    padding-right: 16px;
  }

  #customersView .panel:nth-of-type(2) > * {
    flex-shrink: 0;
  }

  #orderCreateView .panel:nth-of-type(2) {
    overflow: auto;
    scrollbar-gutter: stable;
    padding-right: 16px;
  }

  #orderCreateView .panel:nth-of-type(2) > * {
    flex-shrink: 0;
  }

  #invoiceView .detail-grid,
  #packingView .detail-grid {
    grid-template-columns: minmax(300px, 0.9fr) minmax(0, 1.35fr);
    align-items: start;
  }

  #invoiceView .detail-grid > .panel:nth-child(1),
  #packingView .detail-grid > .panel:nth-child(1) {
    grid-column: 1;
    grid-row: 1 / span 2;
  }

  #invoiceView .detail-grid > .panel:nth-child(2),
  #packingView .detail-grid > .panel:nth-child(2) {
    grid-column: 2;
    grid-row: 1;
    overflow: auto;
    scrollbar-gutter: stable;
    padding-right: 16px;
  }

  #invoiceView .detail-grid > .panel:nth-child(2) > *,
  #packingView .detail-grid > .panel:nth-child(2) > * {
    flex-shrink: 0;
  }

  #invoiceView .detail-grid > .panel:nth-child(3),
  #packingView .detail-grid > .panel:nth-child(3) {
    grid-column: 2;
    grid-row: 2;
  }

  #archiveView .grid.two-col > .panel:nth-child(2) {
    overflow: auto;
    scrollbar-gutter: stable;
    padding-right: 16px;
  }

  #archiveView .grid.two-col > .panel:nth-child(2) > * {
    flex-shrink: 0;
  }

  #customerTable,
  #taskQueue,
  #archiveQueue,
  #customerDraftHistory,
  #customerAiSummary,
  #draftAiSummary,
  #draftAssistPanel,
  #draftChecklistPanel,
  #invoiceFields,
  #packingFields,
  #archiveOutputs,
  #archiveDownloadLinks,
  #workspaceSummary,
  #workspaceStatus,
  #workspaceInvoiceCard,
  #workspacePackingCard,
  #currentTaskCard {
    max-height: 100%;
    overflow: auto;
    padding-right: 6px;
    scrollbar-gutter: stable;
  }

  #customerForm,
  #draftForm,
  #invoiceEditForm,
  #packingEditForm {
    max-height: 100%;
    overflow: auto;
    padding-right: 6px;
    scrollbar-gutter: stable;
  }

  #draftAiSummary .ai-summary-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    align-items: start;
  }

  #draftAiSummary .ai-summary-card {
    min-height: 0;
    max-height: 360px;
    overflow: auto;
    padding-right: 6px;
    scrollbar-gutter: stable;
  }

  #customerConfirmCard,
  #customerAiSummary {
    max-height: none;
    overflow: visible;
  }

  #customerAiSummary .ai-summary-grid {
    grid-template-columns: 1fr;
    align-items: start;
  }

  #customerAiSummary .ai-summary-card {
    min-height: 0;
    max-height: none;
    overflow: visible;
    padding-right: 0;
  }

  #customerAiSummary .ai-compare-row {
    grid-template-columns: 1fr;
  }

  #draftAiSummary,
  #draftAssistPanel,
  #draftChecklistPanel {
    max-height: none;
    overflow: visible;
  }

  #draftAiSummary .ai-summary-card {
    max-height: none;
    overflow: visible;
    padding-right: 0;
  }

  #draftAiSummary .ai-summary-grid {
    grid-template-columns: 1fr;
  }

  #draftAiSummary .ai-compare-row {
    grid-template-columns: 1fr;
  }

  #invoiceMeta,
  #packingMeta,
  #archiveSummary,
  #customerDetailMeta,
  #customerDetailPreferences,
  #draftDetailMeta,
  #draftMapping {
    max-height: 100%;
    overflow: auto;
    padding-right: 6px;
    scrollbar-gutter: stable;
  }

  #invoiceFields .kv-row,
  #packingFields .kv-row,
  #archiveOutputs .kv-row,
  #archiveDownloadLinks .kv-row {
    grid-template-columns: 96px 1fr;
    gap: 12px;
  }
}

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

  .main-panel {
    padding: 18px;
  }

  .hero,
  .panel {
    border-radius: 24px;
  }

  .mini-grid,
  .kv-row {
    grid-template-columns: 1fr;
  }

  .panel-head.split {
    flex-direction: column;
    align-items: stretch;
  }
}

/* White workspace refactor */
:root {
  --bg: #f5f7fa;
  --bg-soft: #ffffff;
  --panel-line: #e6ebf2;
  --ink: #1f2937;
  --ink-soft: #6b7280;
  --copper: #2563eb;
  --teal: #0f766e;
  --night: #111827;
  --light: #ffffff;
  --shadow: 0 10px 28px rgba(15, 23, 42, 0.06);
}

html,
body {
  background: #f5f7fa;
}

body {
  color: var(--ink);
  font-family: var(--font-sans);
}

.grain {
  display: none;
}

.app-shell {
  grid-template-columns: 248px minmax(0, 1fr);
  background: #f5f7fa;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 22px 18px;
  gap: 18px;
  background: #ffffff;
  color: var(--ink);
  border-right: 1px solid var(--panel-line);
}

.brand-block {
  padding-bottom: 14px;
  border-bottom: 1px solid var(--panel-line);
}

.brand-kicker,
.hero-kicker,
.section-label {
  letter-spacing: 0;
  text-transform: none;
  font-size: 12px;
  color: #6b7280;
}

.brand-block h1 {
  font-size: 28px;
  line-height: 1.2;
  color: #111827;
}

.brand-copy {
  color: #6b7280;
  line-height: 1.6;
  font-size: 13px;
}

.flow-card,
.note-card {
  background: #f9fafb;
  border: 1px solid var(--panel-line);
  color: var(--ink);
  box-shadow: none;
}

.flow-list {
  margin-top: 8px;
  color: #4b5563;
}

.nav-list,
.quick-actions {
  gap: 8px;
}

.nav-item {
  padding: 11px 14px;
  border-radius: 12px;
  background: #ffffff;
  color: #374151;
  border: 1px solid transparent;
}

.nav-item:hover,
.nav-item.active {
  transform: none;
  background: #eff6ff;
  border-color: #bfdbfe;
  color: #1d4ed8;
}

.action-button,
.primary-button {
  padding: 11px 16px;
  border-radius: 12px;
  background: #2563eb;
  color: #ffffff;
  box-shadow: none;
}

.action-button:hover,
.primary-button:hover {
  transform: none;
  background: #1d4ed8;
}

.action-button.ghost,
.action-button.subtle {
  background: #ffffff;
  color: #374151;
  border: 1px solid var(--panel-line);
}

.main-panel {
  padding: 22px 24px 28px;
  max-width: 1600px;
}

.platform-ribbon {
  gap: 8px;
  margin-bottom: 12px;
}

.platform-ribbon span {
  background: #ffffff;
  border: 1px solid var(--panel-line);
  color: #4b5563;
}

.hero {
  margin-bottom: 18px;
  padding: 18px 22px;
  align-items: center;
  background: #ffffff;
  border: 1px solid var(--panel-line);
  border-radius: 18px;
  box-shadow: var(--shadow);
}

.hero h2 {
  font-size: clamp(28px, 2.4vw, 40px);
  line-height: 1.2;
  letter-spacing: -0.02em;
  color: #111827;
}

.hero-copy {
  margin-top: 10px;
  max-width: 920px;
  color: #6b7280;
  line-height: 1.65;
  font-size: 14px;
}

.hero-badges span {
  padding: 8px 12px;
  background: #f9fafb;
  border: 1px solid var(--panel-line);
  color: #4b5563;
}

.progress-strip {
  margin-bottom: 18px;
}

.progress-step {
  background: #ffffff;
  border: 1px solid var(--panel-line);
  border-radius: 14px;
}

.progress-step.active {
  background: #eff6ff;
  border-color: #bfdbfe;
}

.progress-step.done {
  background: #ecfdf5;
  border-color: #a7f3d0;
}

.grid {
  gap: 16px;
}

.wide-left {
  grid-template-columns: minmax(360px, 0.9fr) minmax(0, 1.1fr);
}

.detail-grid {
  grid-template-columns: 320px minmax(0, 1fr);
  gap: 16px;
}

#invoiceView .detail-grid > .panel:nth-child(1),
#packingView .detail-grid > .panel:nth-child(1) {
  grid-column: 1;
  grid-row: 1;
}

#invoiceView .detail-grid > .panel:nth-child(2),
#packingView .detail-grid > .panel:nth-child(2) {
  grid-column: 2;
  grid-row: 1;
}

#invoiceView .detail-grid > .panel:nth-child(3),
#packingView .detail-grid > .panel:nth-child(3) {
  grid-column: 1 / -1;
  grid-row: 2;
}

.panel {
  padding: 18px 20px;
  border-radius: 18px;
  background: #ffffff;
  border: 1px solid var(--panel-line);
  box-shadow: var(--shadow);
  backdrop-filter: none;
}

.panel h3 {
  font-size: 22px;
  line-height: 1.35;
  color: #111827;
}

.metric-grid,
.compact-metrics,
.ledger-grid {
  gap: 12px;
}

.metric-card,
.ledger-card,
.kv-card,
.history-card,
.task-card {
  background: #ffffff;
  border: 1px solid var(--panel-line);
  color: var(--ink);
  box-shadow: none;
}

.metric-card strong {
  font-size: 30px;
  color: #111827;
}

.metric-card {
  position: relative;
  overflow: hidden;
}

.metric-card::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 4px;
  background: #2563eb;
}

.ledger-card.accent,
.ai-note,
.empty-state {
  background: #f9fafb;
  border: 1px solid var(--panel-line);
}

.search-input,
.stack-form input,
.stack-form textarea,
.stack-form select {
  border-radius: 12px;
  border: 1px solid #d7dee8;
  background: #ffffff;
  padding: 12px 14px;
  color: #111827;
  box-shadow: none;
}

.search-input:focus,
.stack-form input:focus,
.stack-form textarea:focus,
.stack-form select:focus,
.line-items-table input:focus,
.line-items-table textarea:focus {
  outline: none;
  border-color: #93c5fd;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.stack-form {
  gap: 12px;
}

.stack-form label span,
.ai-source-label span,
.line-items-head span {
  font-size: 12px;
  color: #6b7280;
}

.table-shell,
.line-items-shell {
  background: #ffffff;
  border: 1px solid var(--panel-line);
  border-radius: 14px;
}

thead {
  background: #f8fafc;
  color: #374151;
}

th,
td {
  padding: 12px 14px;
  border-bottom: 1px solid #edf1f6;
}

tbody tr {
  background: #ffffff;
}

tbody tr:hover {
  background: #f8fbff;
}

.tag,
.status-pill,
.archive-stat {
  background: #eff6ff;
  color: #1d4ed8;
}

.status-pill.warn,
.validation-chip.warning,
.diff-badge {
  background: #fff7ed;
  color: #b45309;
}

.validation-chip.error {
  background: #fef2f2;
  color: #b91c1c;
}

.kv-row {
  grid-template-columns: 100px 1fr;
  gap: 12px;
}

.kv-row.changed {
  background: #fff7ed;
}

.status-line,
.inline-state,
.kv-card p,
.history-card p,
.note-card p,
.task-card p {
  color: #6b7280;
}

.status-dot {
  background: #2563eb;
  box-shadow: 0 0 0 5px rgba(37, 99, 235, 0.1);
}

.validation-panel,
.decision-card {
  background: #ffffff;
  border: 1px solid var(--panel-line);
}

.validation-item {
  background: #fafbfc;
}

.validation-item.error {
  border-left-color: #dc2626;
}

.validation-item.warning {
  border-left-color: #d97706;
}

#customersView .panel,
#orderCreateView .panel,
#invoiceView .panel,
#packingView .panel,
#archiveView .panel,
#docWorkspaceView .panel {
  max-height: none !important;
  overflow: visible !important;
  display: block !important;
}

#customerTable,
#taskQueue,
#archiveQueue,
#customerDraftHistory,
#customerAiSummary,
#draftAiSummary,
#draftAssistPanel,
#draftChecklistPanel,
#invoiceFields,
#packingFields,
#archiveOutputs,
#archiveDownloadLinks,
#workspaceSummary,
#workspaceStatus,
#workspaceInvoiceCard,
#workspacePackingCard,
#currentTaskCard,
#invoiceMeta,
#packingMeta,
#archiveSummary,
#customerDetailMeta,
#customerDetailPreferences,
#draftDetailMeta,
#draftMapping,
#customerForm,
#draftForm,
#invoiceEditForm,
#packingEditForm {
  max-height: none !important;
  overflow: visible !important;
  padding-right: 0 !important;
}

#customersView .panel:nth-of-type(2),
#orderCreateView .panel:nth-of-type(2),
#archiveView .grid.two-col > .panel:nth-child(2),
#invoiceView .detail-grid > .panel:nth-child(2),
#packingView .detail-grid > .panel:nth-child(2) {
  padding-right: 20px !important;
}

.panel-section {
  display: grid;
  gap: 14px;
}

.panel-section + .panel-section {
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px solid var(--panel-line);
}

.featured-section,
.workflow-section,
.muted-section {
  padding: 16px;
  border-radius: 16px;
  border: 1px solid var(--panel-line);
}

.featured-section {
  background: linear-gradient(180deg, #ffffff 0%, #f8fbff 100%);
}

.workflow-section {
  background: #fbfdff;
}

.muted-section {
  background: #fafbfc;
}

.panel-section .panel-head {
  margin-bottom: 0;
}

.panel-section .panel-head h3 {
  font-size: 18px;
}

.panel-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.panel-actions .inline-state {
  min-height: auto;
  margin: 0;
}

.action-rail {
  display: grid;
  gap: 14px;
}

.editor-section {
  background: #ffffff;
}

.preview-section .detail-block {
  background: #ffffff;
  border-radius: 14px;
  border: 1px solid var(--panel-line);
  padding: 14px 16px;
}

.dual-support-section {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.sub-panel {
  display: grid;
  gap: 12px;
  align-content: start;
}

#customersView .panel:nth-of-type(2),
#orderCreateView .panel:nth-of-type(2) {
  display: grid !important;
  align-content: start;
  gap: 0;
}

#invoiceView .detail-grid > .panel:nth-child(3),
#packingView .detail-grid > .panel:nth-child(3) {
  align-self: start;
}

#invoiceView .detail-grid > .panel:nth-child(2),
#packingView .detail-grid > .panel:nth-child(2),
#archiveView .grid.two-col > .panel:nth-child(2) {
  display: grid !important;
  align-content: start;
  gap: 0;
}

#invoiceView .detail-grid,
#packingView .detail-grid {
  grid-template-columns: 300px minmax(0, 1fr);
}

#archiveView .wide-left {
  grid-template-columns: minmax(340px, 0.88fr) minmax(0, 1.12fr);
}

#archiveOutputs,
#archiveDownloadLinks,
#invoiceFields,
#packingFields {
  background: transparent;
  border: 0;
  padding: 0;
}

@media (max-width: 1200px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
    border-right: none;
    border-bottom: 1px solid var(--panel-line);
  }

  .wide-left,
  .detail-grid,
  .two-col {
    grid-template-columns: 1fr;
  }

  #invoiceView .detail-grid > .panel:nth-child(1),
  #invoiceView .detail-grid > .panel:nth-child(2),
  #invoiceView .detail-grid > .panel:nth-child(3),
  #packingView .detail-grid > .panel:nth-child(1),
  #packingView .detail-grid > .panel:nth-child(2),
  #packingView .detail-grid > .panel:nth-child(3) {
    grid-column: auto;
    grid-row: auto;
  }

  .dual-support-section {
    grid-template-columns: 1fr;
  }

  .panel-actions {
    display: grid;
  }
}

/* Combined reference overhaul: Notion-like restraint + Linear-like workbench hierarchy */
:root {
  --bg: #f4f6f8;
  --bg-soft: #ffffff;
  --panel-line: #e3e8ef;
  --ink: #0f172a;
  --ink-soft: #5b6472;
  --copper: #2563eb;
  --teal: #0f766e;
  --night: #0f172a;
  --light: #ffffff;
  --shadow: 0 18px 40px rgba(15, 23, 42, 0.05);
  --radius-lg: 24px;
  --radius-md: 16px;
}

html,
body {
  background: #f4f6f8 !important;
  color: var(--ink);
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(circle at top left, rgba(37, 99, 235, 0.05), transparent 24%),
    radial-gradient(circle at bottom right, rgba(15, 118, 110, 0.04), transparent 22%);
}

.grain {
  display: none !important;
}

.app-shell {
  grid-template-columns: 280px minmax(0, 1fr);
  background: transparent;
}

.sidebar {
  position: sticky;
  top: 0;
  align-self: start;
  min-height: 100vh;
  padding: 28px 22px 24px;
  background: #ffffff !important;
  color: var(--ink);
  border-right: 1px solid var(--panel-line);
  box-shadow: 10px 0 32px rgba(15, 23, 42, 0.03);
}

.brand-kicker,
.hero-kicker,
.section-label {
  color: #94a3b8 !important;
  letter-spacing: 0.12em;
  font-weight: 700;
}

.brand-block {
  padding-bottom: 18px;
  border-bottom: 1px solid var(--panel-line);
}

.brand-block h1 {
  font-size: 30px;
  line-height: 1;
  color: var(--ink);
}

.brand-copy {
  color: var(--ink-soft);
  font-size: 13px;
  line-height: 1.7;
}

.flow-card,
.note-card {
  background: #f8fafc;
  border: 1px solid var(--panel-line);
  color: var(--ink);
  box-shadow: none;
}

.nav-list,
.quick-actions {
  gap: 8px;
}

.nav-item {
  background: transparent;
  color: #334155;
  border: 1px solid transparent;
  border-radius: 14px;
  padding: 12px 14px;
  font-weight: 600;
}

.nav-item:hover {
  transform: none;
  background: #f8fafc;
  border-color: var(--panel-line);
  color: var(--ink);
}

.nav-item.active {
  transform: none;
  background: #eff6ff;
  border-color: rgba(37, 99, 235, 0.16);
  color: #1d4ed8;
  box-shadow: inset 0 0 0 1px rgba(37, 99, 235, 0.02);
}

.action-button,
.primary-button {
  background: #2563eb;
  color: #ffffff;
  border-radius: 14px;
  box-shadow: 0 8px 20px rgba(37, 99, 235, 0.18);
}

.action-button:hover,
.primary-button:hover {
  background: #1d4ed8;
  transform: translateY(-1px);
}

.action-button.ghost,
.action-button.subtle {
  background: #ffffff;
  color: #334155;
  border: 1px solid var(--panel-line);
  box-shadow: none;
}

.action-button.ghost:hover,
.action-button.subtle:hover {
  background: #f8fafc;
  color: var(--ink);
}

.main-panel {
  padding: 26px 28px 34px;
}

.platform-ribbon {
  gap: 8px;
  margin-bottom: 12px;
}

.platform-ribbon span {
  background: #ffffff;
  border: 1px solid var(--panel-line);
  color: #475569;
  font-weight: 600;
}

.hero {
  align-items: start;
  margin-bottom: 18px;
  padding: 22px 24px;
  background: #ffffff !important;
  border: 1px solid var(--panel-line);
  box-shadow: var(--shadow);
}

.hero h2 {
  font-size: clamp(28px, 3vw, 38px);
  line-height: 1.08;
  letter-spacing: -0.03em;
  margin-bottom: 10px;
  color: var(--ink);
}

.hero-copy {
  max-width: 760px;
  color: var(--ink-soft);
  font-size: 14px;
  line-height: 1.7;
}

.hero-badges {
  gap: 8px;
}

.hero-badges span {
  background: #f8fafc;
  border: 1px solid var(--panel-line);
  color: #475569;
  font-weight: 600;
}

.view {
  gap: 18px;
}

.grid,
.detail-grid,
.wide-left,
.two-col {
  gap: 18px;
}

.panel {
  background: #ffffff !important;
  border: 1px solid var(--panel-line) !important;
  box-shadow: var(--shadow);
  border-radius: 18px;
  padding: 22px 22px 20px;
}

.panel h3 {
  font-size: 20px;
  line-height: 1.2;
  color: var(--ink);
}

.panel-head {
  margin-bottom: 16px;
}

.panel-head.split {
  gap: 14px;
}

.panel-section + .panel-section {
  margin-top: 16px;
  padding-top: 16px;
}

.featured-section,
.workflow-section,
.muted-section,
.editor-section,
.preview-section .detail-block,
.sub-panel,
.decision-card,
.validation-panel {
  background: #fbfcfd !important;
  border: 1px solid var(--panel-line) !important;
  border-radius: 16px;
  box-shadow: none;
}

.featured-section {
  background: linear-gradient(180deg, #ffffff 0%, #f8fbff 100%) !important;
}

.muted-section {
  background: #f8fafc !important;
}

.task-card,
.metric-card,
.ledger-card,
.kv-card,
.history-card {
  background: #ffffff;
  border: 1px solid var(--panel-line);
  box-shadow: none;
}

.task-card {
  border-radius: 16px;
}

.task-card h4,
.ledger-card h4,
.metric-card strong {
  color: var(--ink);
}

.task-card p,
.ledger-card p,
.metric-card span,
.status-line,
.inline-state,
.note-card p,
.kv-card p,
.history-card p {
  color: var(--ink-soft) !important;
}

input,
textarea,
select {
  background: #ffffff !important;
  color: var(--ink);
  border: 1px solid #d9e1ea !important;
  border-radius: 14px;
  box-shadow: inset 0 1px 2px rgba(15, 23, 42, 0.02);
}

input::placeholder,
textarea::placeholder {
  color: #94a3b8;
}

input:focus,
textarea:focus,
select:focus,
.line-items-table input:focus,
.line-items-table textarea:focus {
  border-color: rgba(37, 99, 235, 0.48) !important;
  box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.08);
  outline: none;
}

.stack-form,
.stack-form .mini-grid,
.stack-form .grid,
.mini-grid,
.decision-grid,
.history-card-grid {
  gap: 14px;
}

.table-shell,
.doc-line-preview-shell {
  background: #ffffff;
  border: 1px solid var(--panel-line);
  border-radius: 16px;
  overflow: hidden;
}

.line-items-table,
.doc-line-preview-table {
  background: #ffffff;
}

.line-items-table th,
.doc-line-preview-table th {
  background: #f8fafc;
  color: #475569;
  font-size: 12px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  border-bottom: 1px solid var(--panel-line);
}

.line-items-table td,
.doc-line-preview-table td,
.doc-line-preview-table tfoot td {
  border-bottom: 1px solid #edf1f5;
  color: var(--ink);
}

.doc-line-preview-table tfoot td {
  background: #fbfcfd;
  font-weight: 700;
}

.status-pill,
.validation-chip,
.diff-badge {
  border-radius: 999px;
  font-weight: 700;
}

.status-pill.good,
.validation-chip.good {
  background: #ecfdf5;
  color: #047857;
}

.status-pill.warn,
.validation-chip.warning,
.diff-badge {
  background: #fff7ed;
  color: #b45309;
}

.validation-chip.error {
  background: #fef2f2;
  color: #b91c1c;
}

.status-dot {
  background: #2563eb;
  box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.12);
}

.kv-row {
  grid-template-columns: 112px 1fr;
}

.kv-row.changed {
  background: #fffaf0;
}

.validation-item {
  background: #ffffff;
  border: 1px solid var(--panel-line);
}

.validation-item.error {
  background: #fffafa;
}

.validation-item.warning {
  background: #fffdfa;
}

.archive-history-toolbar,
.panel-actions,
.validation-actions,
.history-actions,
.decision-actions,
.action-rail {
  gap: 10px;
}

#invoiceView .detail-grid,
#packingView .detail-grid {
  grid-template-columns: minmax(320px, 0.9fr) minmax(0, 1.1fr);
}

#archiveView .wide-left,
#customersView .grid.two-col,
#orderCreateView .grid.two-col {
  grid-template-columns: minmax(320px, 0.9fr) minmax(0, 1.1fr);
}

#invoiceView .detail-grid > .panel:nth-child(2),
#packingView .detail-grid > .panel:nth-child(2),
#archiveView .grid.two-col > .panel:nth-child(2),
#customersView .panel:nth-of-type(2),
#orderCreateView .panel:nth-of-type(2) {
  background: #ffffff !important;
}

.auth-overlay {
  background: rgba(244, 246, 248, 0.78);
  backdrop-filter: blur(10px);
}

.auth-card {
  background: #ffffff;
  border: 1px solid var(--panel-line);
  box-shadow: 0 26px 56px rgba(15, 23, 42, 0.08);
}

.auth-copy,
.auth-note {
  color: var(--ink-soft);
}

@media (max-width: 1200px) {
  .sidebar {
    min-height: auto;
    position: static;
    box-shadow: none;
  }

  #archiveView .wide-left,
  #customersView .grid.two-col,
  #orderCreateView .grid.two-col,
  #invoiceView .detail-grid,
  #packingView .detail-grid {
    grid-template-columns: 1fr;
  }
}

/* 2026-04 commercial workflow refinement */
.app-shell {
  grid-template-columns: 228px minmax(0, 1fr) !important;
}

.sidebar {
  padding: 22px 16px 18px !important;
}

.brand-block {
  padding-bottom: 14px !important;
  margin-bottom: 12px !important;
}

.brand-block h1 {
  font-size: 24px !important;
  margin-bottom: 6px !important;
}

.brand-copy,
.flow-card,
.hero-copy,
.hero-badges {
  display: none !important;
}

.main-panel {
  padding: 18px 22px 28px !important;
}

.platform-ribbon {
  position: sticky;
  top: 12px;
  z-index: 10;
  padding: 10px 12px;
  background: rgba(245, 247, 250, 0.92);
  backdrop-filter: blur(12px);
  border-radius: 14px;
}

.hero {
  padding: 16px 18px !important;
  margin-bottom: 12px !important;
}

.hero h2 {
  font-size: 22px !important;
  margin-bottom: 0 !important;
}

.progress-strip {
  margin-bottom: 12px !important;
}

#customersView .wide-left,
#orderCreateView .wide-left {
  grid-template-columns: minmax(0, 1.35fr) minmax(360px, 0.95fr) !important;
  align-items: start;
}

#customerCreateView .detail-grid {
  grid-template-columns: minmax(0, 1fr) !important;
  max-width: 980px;
}

#customerCreateView .panel {
  max-width: 980px;
}

#customerCreateView .panel-head.split {
  align-items: start;
}

#customerCreateView .ai-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, max-content));
  gap: 12px;
  align-items: center;
}

#customerCreateView .ai-actions .ghost {
  grid-column: 1 / -1;
  width: fit-content;
}

#customerCreateView .detail-block {
  min-width: 0;
}

#customerCreateView input[type="file"] {
  width: 100%;
}

#customersView .panel:first-child,
#orderCreateView .panel:first-child,
#invoiceView .detail-grid > .panel:nth-child(2),
#packingView .detail-grid > .panel:nth-child(2) {
  min-width: 0;
}

#customersView .panel:nth-of-type(2),
#orderCreateView .panel:nth-of-type(2) {
  position: sticky;
  top: 88px;
  align-self: start;
  max-height: calc(100vh - 112px);
  overflow: auto !important;
}

.workspace-tabset {
  display: grid;
  gap: 14px;
}

.workspace-tabnav {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 4px;
  background: #f8fafc;
  border: 1px solid var(--panel-line);
  border-radius: 14px;
}

.workspace-tab {
  appearance: none;
  border: 0;
  background: transparent;
  color: #64748b;
  font-weight: 700;
  font-size: 13px;
  line-height: 1;
  padding: 11px 14px;
  border-radius: 10px;
  cursor: pointer;
  transition: background-color 160ms ease, color 160ms ease, box-shadow 160ms ease;
}

.workspace-tab:hover {
  background: rgba(37, 99, 235, 0.06);
  color: #1e293b;
}

.workspace-tab.active {
  background: #ffffff;
  color: #1d4ed8;
  box-shadow: 0 1px 0 rgba(15, 23, 42, 0.02), 0 8px 18px rgba(37, 99, 235, 0.08);
}

.workspace-tabbody {
  min-width: 0;
}

.workspace-pane[hidden] {
  display: none !important;
}

.workspace-pane > .panel-section,
.workspace-pane > .form-group-block,
.workspace-pane > .stage-inline-head {
  margin-top: 0 !important;
}

.workspace-pane > .panel-section {
  padding-top: 0 !important;
  border-top: 0 !important;
}

.stage-inline-head {
  padding: 0 !important;
  border: 0 !important;
  background: transparent !important;
  margin-bottom: 14px;
}

.stage-inline-head .form-group-head {
  margin-bottom: 0;
}

#customerForm,
#draftForm,
#invoiceEditForm,
#packingEditForm {
  gap: 14px;
}

.form-group-block {
  padding: 16px 16px 14px !important;
  border-radius: 16px;
  background: #fbfcfd;
}

.form-group-head {
  margin-bottom: 14px !important;
}

.form-group-head h4 {
  font-size: 16px;
  line-height: 1.3;
  color: var(--ink);
}

.mini-grid {
  gap: 12px !important;
}

label > span {
  font-size: 12px;
  font-weight: 700;
  color: #475569;
}

textarea,
input,
select {
  min-height: 48px;
}

textarea {
  min-height: 108px;
}

.note-card.ai-note {
  background: #f8fafc !important;
  border-style: dashed !important;
}

#invoiceView .detail-grid,
#packingView .detail-grid,
#archiveView .grid.two-col {
  align-items: start;
}

#invoiceView .detail-grid > .panel:nth-child(1),
#packingView .detail-grid > .panel:nth-child(1) {
  max-width: 320px;
}

#invoiceView .detail-grid > .panel:nth-child(3),
#packingView .detail-grid > .panel:nth-child(3) {
  max-width: 320px;
}

.action-rail {
  position: sticky;
  top: 88px;
}

@media (max-width: 1200px) {
  .app-shell {
    grid-template-columns: 1fr !important;
  }

  .sidebar {
    position: static !important;
    border-right: 0 !important;
    border-bottom: 1px solid var(--panel-line) !important;
  }

  #customersView .wide-left,
  #orderCreateView .wide-left,
  #customerCreateView .detail-grid,
  #invoiceView .detail-grid,
  #packingView .detail-grid,
  #archiveView .grid.two-col {
    grid-template-columns: 1fr !important;
  }

  #customerCreateView .ai-actions {
    grid-template-columns: 1fr;
  }

  #customerCreateView .ai-actions .ghost {
    grid-column: auto;
    width: 100%;
  }

  #customersView .panel:nth-of-type(2),
  #orderCreateView .panel:nth-of-type(2),
  .action-rail {
    position: static;
    max-height: none;
  }
}
