﻿:root {
  color-scheme: light;
  --bg: #f4f6f8;
  --surface: #ffffff;
  --surface-soft: #eef4f3;
  --ink: #18202a;
  --muted: #687381;
  --line: #d9e1e6;
  --primary: #276c64;
  --primary-dark: #1f554f;
  --accent: #b85922;
  --warn: #a84d37;
  --ok: #2f7a4f;
  --shadow: 0 16px 40px rgba(29, 42, 53, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  color: var(--ink);
  background: var(--bg);
}

body.auth-locked {
  background: #eef4f3;
}

body.auth-pending .app-shell {
  display: none;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

[hidden] {
  display: none !important;
}

.auth-gate {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 20px;
}

.auth-card {
  display: grid;
  width: min(100%, 380px);
  gap: 14px;
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.auth-card h1,
.auth-card p {
  margin: 0;
}

.auth-card h1 {
  font-size: 24px;
  letter-spacing: 0;
}

.auth-card > p:not(.eyebrow):not(.helper-text) {
  color: var(--muted);
  line-height: 1.6;
}

.auth-card label {
  display: grid;
  gap: 6px;
  color: #2f3a45;
  font-size: 13px;
}

.auth-card input {
  min-height: 42px;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px 10px;
}

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

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 28px;
  padding: 24px 18px;
  background: #172326;
  color: #f6fbfa;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 8px;
  background: #d7efe8;
  color: #153f39;
  font-weight: 800;
}

.brand h1,
.brand p,
.topbar h2,
.topbar p,
.panel h3,
.panel p,
.dialog-header h3,
.dialog-header p {
  margin: 0;
}

.brand h1 {
  font-size: 18px;
  letter-spacing: 0;
}

.brand p,
.sidebar-note span {
  color: #a9bab8;
  font-size: 13px;
}

.nav {
  display: grid;
  gap: 8px;
}

.nav-item {
  min-height: 42px;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 0 14px;
  text-align: left;
  color: #d7e5e2;
  background: transparent;
}

.nav-item:hover,
.nav-item.active {
  color: #ffffff;
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.12);
}

.sidebar-note {
  margin-top: auto;
  display: grid;
  gap: 8px;
  padding: 14px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.08);
}

.sidebar-note strong {
  font-size: 16px;
}

.main {
  min-width: 0;
  padding: 24px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 22px;
}

.eyebrow {
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

.topbar h2 {
  font-size: 28px;
  letter-spacing: 0;
}

.network-strip {
  display: grid;
  grid-template-columns: minmax(160px, 1fr) repeat(3, minmax(0, 1.4fr));
  gap: 10px;
  margin-bottom: 16px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.sync-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
  padding: 12px 14px;
  border: 1px solid #f1c76b;
  border-radius: 8px;
  background: #fffaf0;
}

.sync-banner[hidden] {
  display: none;
}

.sync-banner.conflict {
  border-color: #e2a273;
  background: #fff2ea;
}

.sync-banner p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.sync-banner button {
  flex: 0 0 auto;
}

.network-strip div {
  display: grid;
  gap: 5px;
  min-width: 0;
}

.network-strip span,
.helper-text {
  color: var(--muted);
  font-size: 12px;
}

.network-strip strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
}

.network-strip input {
  min-height: 32px;
  padding: 6px 8px;
}

.onboarding-panel {
  display: grid;
  grid-template-columns: minmax(160px, 0.8fr) minmax(0, 2fr) auto;
  gap: 14px;
  align-items: center;
  margin-bottom: 16px;
  padding: 14px;
  border: 1px solid #cddfdb;
  border-radius: 8px;
  background: #f6fbfa;
}

.onboarding-panel[hidden] {
  display: none;
}

.onboarding-panel h3,
.onboarding-panel p {
  margin: 0;
}

.onboarding-panel ol {
  margin: 0;
  padding-left: 20px;
  color: #34404b;
  line-height: 1.7;
  font-size: 13px;
}

.topbar-actions,
.dialog-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.primary,
.secondary,
.icon-btn {
  border-radius: 8px;
  min-height: 38px;
  border: 1px solid transparent;
  padding: 0 14px;
  font-weight: 700;
}

.primary {
  color: #ffffff;
  background: var(--primary);
}

.primary:hover {
  background: var(--primary-dark);
}

.secondary {
  color: var(--ink);
  background: #ffffff;
  border-color: var(--line);
}

.secondary:hover {
  border-color: #b8c7ce;
}

.secondary.danger {
  color: var(--warn);
  border-color: #efc0b4;
}

.small {
  min-height: 32px;
  padding: 0 10px;
  font-size: 13px;
}

.icon-btn {
  width: 38px;
  padding: 0;
  font-size: 24px;
  line-height: 1;
  background: #ffffff;
  border-color: var(--line);
}

.view {
  display: none;
}

.view.active {
  display: block;
}

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

.metric,
.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 1px 0 rgba(29, 42, 53, 0.02);
}

.metric {
  padding: 18px;
}

.metric span {
  display: block;
  color: var(--muted);
  font-size: 13px;
}

.metric strong {
  display: block;
  margin-top: 8px;
  font-size: 26px;
}

.workbench,
.split-layout,
.export-grid {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(320px, 1fr);
  gap: 16px;
}

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

.panel {
  padding: 18px;
}

.panel-wide {
  min-width: 0;
}

.panel-header {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.panel-header h3,
.panel h3 {
  font-size: 18px;
  letter-spacing: 0;
}

.panel-header p,
.panel p {
  margin-top: 5px;
  color: var(--muted);
  font-size: 13px;
}

.tight {
  margin-bottom: 8px;
}

.table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.panel-table {
  background: #ffffff;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 880px;
}

th,
td {
  padding: 11px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
  font-size: 14px;
}

th {
  color: var(--muted);
  background: #f9fbfb;
  font-weight: 700;
}

tr:last-child td {
  border-bottom: 0;
}

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 14px;
}

.search-box {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: min(480px, 100%);
  padding: 0 12px;
  min-height: 42px;
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 8px;
}

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

.search-box input {
  border: 0;
  outline: 0;
  width: 100%;
}

select,
input,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px 10px;
  background: #ffffff;
  color: var(--ink);
}

textarea {
  resize: vertical;
}

.stage-list {
  display: grid;
  gap: 10px;
}

.stage-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: center;
  padding: 12px;
  border-radius: 8px;
  background: #f7faf9;
  border: 1px solid var(--line);
}

.tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.tag {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  background: var(--surface-soft);
  color: #245b55;
}

.tag.warn {
  color: var(--warn);
  background: #fff1ec;
}

.tag.risk {
  color: #7a4c00;
  background: #fff6d8;
}

.tag.done {
  color: var(--ok);
  background: #edf8f0;
}

.tag.imported {
  color: #245b55;
  background: #e7f3f1;
}

.row-actions {
  display: flex;
  gap: 8px;
  white-space: nowrap;
}

.row-action {
  min-height: 30px;
  padding: 0 10px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #ffffff;
  font-weight: 700;
}

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

.form-grid.single {
  grid-template-columns: 1fr;
}

label {
  display: grid;
  gap: 6px;
  color: #34404b;
  font-size: 13px;
  font-weight: 700;
}

.full {
  margin-top: 14px;
}

.customer-list {
  display: grid;
  gap: 10px;
}

.duplicate-alerts {
  display: grid;
  gap: 10px;
  margin-bottom: 12px;
}

.duplicate-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 12px;
  border: 1px solid #f1c76b;
  border-radius: 8px;
  background: #fffaf0;
}

.duplicate-item p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.duplicate-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.customer-item {
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfc;
}

.customer-item h4 {
  margin: 0 0 7px;
  font-size: 15px;
}

.customer-item p {
  margin: 3px 0;
  color: var(--muted);
  font-size: 13px;
}

.next-list {
  margin: 12px 0 0;
  padding-left: 18px;
  color: var(--muted);
  line-height: 1.8;
}

.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 12px;
}

.helper-text {
  margin-top: 10px;
  line-height: 1.5;
  word-break: break-all;
}

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

.health-grid.compact {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-top: 12px;
}

.health-pill {
  display: grid;
  gap: 5px;
  min-height: 68px;
  padding: 10px;
  border: 1px solid #bee0c8;
  border-radius: 8px;
  background: #f1faf4;
}

.health-pill.warn {
  border-color: #edd49b;
  background: #fff9e8;
}

.health-pill span {
  color: var(--muted);
  font-size: 12px;
}

.health-pill strong {
  overflow-wrap: anywhere;
  font-size: 14px;
  line-height: 1.35;
}

.cleanup-result {
  display: grid;
  gap: 10px;
  margin-top: 12px;
}

.compact-table table {
  font-size: 13px;
}

.import-form {
  display: grid;
  grid-template-columns: minmax(160px, 220px) minmax(260px, 1fr) auto;
  gap: 12px;
  align-items: end;
}

.import-result {
  display: grid;
  gap: 12px;
  margin-top: 16px;
}

.import-status,
.empty-panel,
.issue-box {
  display: grid;
  gap: 6px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfc;
}

.import-status strong,
.issue-box strong {
  font-size: 14px;
}

.import-status span,
.issue-box li {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}

.import-status.error {
  border-color: #efc0b4;
  background: #fff6f3;
}

.issue-box {
  border-color: #edd49b;
  background: #fff9e8;
}

.issue-box.ok {
  border-color: #bee0c8;
  background: #f1faf4;
}

.issue-box ul {
  margin: 0;
  padding-left: 18px;
}

.privacy-notice {
  margin: 8px 0 12px;
  padding: 8px 12px;
  background: #fffbeb;
  border: 1px solid #fde68a;
  border-radius: 6px;
  font-size: 12px;
  color: #92400e;
  line-height: 1.5;
}

.ai-status {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-bottom: 12px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f7f9fb;
  color: var(--muted);
  font-size: 13px;
}

.ai-status strong {
  color: var(--text);
}

.ai-status span {
  padding-right: 8px;
  border-right: 1px solid var(--line);
}

.ai-status span:last-child {
  border-right: 0;
}

.ai-controls {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) minmax(220px, 1fr) auto;
  gap: 12px;
  align-items: end;
  margin-bottom: 12px;
}

.ai-controls label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
}

.ai-controls select {
  width: 100%;
}

.ai-hint {
  min-height: 38px;
  margin-bottom: 12px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffdf6;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.ai-result-title {
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 13px;
}

.ai-result pre {
  min-height: 280px;
  max-height: 560px;
  overflow: auto;
  margin: 0;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfc;
  color: var(--text);
  font-family: inherit;
  font-size: 14px;
  line-height: 1.7;
  white-space: pre-wrap;
}

.ai-copy-fallback {
  width: 100%;
  min-height: 260px;
  margin-top: 10px;
  resize: vertical;
  font-size: 14px;
  line-height: 1.7;
}

.ai-draft-panel {
  margin-top: 14px;
}

.ai-draft-list {
  display: grid;
  gap: 8px;
  margin-top: 10px;
}

.ai-draft-item {
  display: grid;
  gap: 8px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.ai-draft-item div {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.ai-draft-item strong {
  padding: 2px 8px;
  border-radius: 999px;
  background: #edf7f2;
  color: var(--accent-dark);
  font-size: 12px;
}

.ai-draft-item span,
.ai-draft-item p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.ai-draft-item p {
  color: var(--text);
  font-size: 13px;
}

.ai-history-panel {
  margin-top: 14px;
}

.ai-history-panel h3 {
  font-size: 15px;
}

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

.ai-history-item {
  display: grid;
  gap: 4px;
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  color: var(--text);
  text-align: left;
}

.ai-history-item span,
.ai-history-item p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.ai-tool-panel {
  margin-top: 16px;
}

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

.ai-tool-card {
  display: grid;
  gap: 8px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.ai-tool-card-wide {
  grid-column: 1 / -1;
}

.ai-tool-card h4 {
  margin: 0;
  font-size: 14px;
}

.ai-tool-card input,
.ai-tool-card select,
.ai-tool-card textarea {
  width: 100%;
}

.ai-tool-result {
  margin-top: 12px;
}

.ai-tool-result pre {
  min-height: 160px;
  max-height: 420px;
  overflow: auto;
  margin: 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfc;
  white-space: pre-wrap;
  line-height: 1.7;
}

/* 文本智能录入 - AI 解析结果审核面板 */
.ai-parse-review {
  margin-top: 16px;
  padding: 16px;
  border: 2px solid var(--accent, #2563eb);
  border-radius: 10px;
  background: #f8faff;
}

.ai-parse-review .panel-header {
  margin-bottom: 12px;
}

.parse-result-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.parse-field {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.parse-field label {
  font-size: 11px;
  font-weight: 600;
  color: #555;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.parse-field input,
.parse-field select {
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  font-size: 14px;
  background: #fff;
}

.parse-field input:focus {
  border-color: var(--accent, #2563eb);
  outline: none;
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.12);
}

.parse-items-table {
  margin-bottom: 14px;
  overflow-x: auto;
}

.parse-items-table table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.parse-items-table th {
  text-align: left;
  padding: 6px 10px;
  background: #eef2ff;
  font-weight: 600;
  font-size: 12px;
  color: #444;
  border-bottom: 2px solid var(--line);
}

.parse-items-table td {
  padding: 6px 10px;
  border-bottom: 1px solid var(--line);
}

.parse-items-table input {
  width: 100%;
  padding: 4px 6px;
  border: 1px solid var(--line);
  border-radius: 4px;
  font-size: 13px;
}

.parse-issues {
  margin-bottom: 14px;
  padding: 10px 14px;
  background: #fffbeb;
  border: 1px solid #fde68a;
  border-radius: 8px;
  font-size: 13px;
  color: #92400e;
}

.parse-issues ul {
  margin: 6px 0 0;
  padding-left: 20px;
}

.parse-raw {
  margin-top: 10px;
}

.parse-raw details {
  font-size: 12px;
}

.parse-raw summary {
  cursor: pointer;
  color: #777;
}

.parse-raw pre {
  max-height: 200px;
  overflow: auto;
  margin-top: 6px;
  padding: 10px;
  background: #f5f5f5;
  border-radius: 6px;
  font-size: 12px;
  white-space: pre-wrap;
}

.helper-text {
  margin: 0;
  font-size: 12px;
  color: #888;
}

/* AI inline overlay (shared by order dialog, customer form, quick-complete, import preview) */
.ai-inline-overlay {
  margin-bottom: 14px;
  padding: 14px;
  border: 2px solid var(--accent, #b85922);
  border-radius: 10px;
  background: #fffbf5;
}

.ai-inline-header {
  margin-bottom: 10px;
}

.ai-inline-header strong {
  display: block;
  font-size: 15px;
  margin-bottom: 4px;
}

.ai-inline-overlay textarea {
  width: 100%;
  min-height: 90px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 13px;
  line-height: 1.6;
  resize: vertical;
}

.ai-inline-result {
  margin-top: 8px;
  font-size: 13px;
}

.ai-inline-result .issue-box,
.ai-inline-result .empty-panel {
  margin: 0;
  padding: 8px 12px;
  font-size: 13px;
}

.ai-inline-actions {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}

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

.ai-match-item {
  display: grid;
  gap: 4px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.ai-match-item span,
.ai-match-item p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.mapping-panel,
.import-plan {
  display: grid;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

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

.import-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.import-actions span {
  color: var(--muted);
  font-size: 13px;
}

.import-table table {
  min-width: 960px;
}

.import-batches {
  display: grid;
  gap: 10px;
}

.batch-item {
  display: grid;
  gap: 7px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfc;
}

.batch-topline {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
}

.batch-topline strong {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 14px;
}

.batch-item p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.batch-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.batch-actions span {
  color: var(--muted);
  font-size: 12px;
}

.batch-detail {
  display: grid;
  gap: 10px;
  padding-top: 8px;
  border-top: 1px solid var(--line);
}

.batch-detail strong {
  display: block;
  margin-bottom: 5px;
  font-size: 13px;
}

.batch-detail p {
  word-break: break-all;
}

.monthly-summary {
  margin-bottom: 16px;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 10px;
}

.summary-item {
  display: grid;
  gap: 6px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfc;
}

.summary-item span {
  color: var(--muted);
  font-size: 12px;
}

.summary-item strong {
  font-size: 22px;
}

.detail-drawer {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: none;
  justify-content: flex-end;
  background: rgba(14, 25, 31, 0.28);
}

.detail-drawer.open {
  display: flex;
}

.detail-card {
  width: min(720px, 100vw);
  height: 100vh;
  overflow: auto;
  padding: 20px;
  background: #ffffff;
  box-shadow: var(--shadow);
}

.detail-topline {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfc;
}

.detail-actions {
  display: flex;
  gap: 10px;
  margin: 14px 0;
}

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

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

.detail-grid section,
.detail-section {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.detail-section.import-followup {
  border-color: #f1c76b;
  background: #fffaf0;
}

.detail-grid h4,
.detail-section h4 {
  margin: 0 0 10px;
  font-size: 15px;
}

.detail-grid p,
.detail-section p {
  margin: 6px 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
}

.detail-section {
  margin-top: 12px;
}

.detail-tags {
  align-content: start;
}

.mini-table {
  display: grid;
  gap: 8px;
}

.mini-table div {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 12px;
  align-items: center;
  padding: 9px 10px;
  border-radius: 8px;
  background: #f7faf9;
}

.timeline {
  display: grid;
  gap: 10px;
}

.timeline-item {
  padding-left: 12px;
  border-left: 3px solid var(--primary);
}

.timeline-item span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.timeline-item strong {
  display: block;
  margin-top: 3px;
  font-size: 14px;
}

.timeline-item p {
  margin: 3px 0 0;
}

.document-grid {
  display: grid;
  gap: 12px;
}

.document-preview {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: #fbfcfc;
}

.doc-company {
  text-align: center;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.document-preview h4 {
  margin: 6px 0 12px;
  text-align: center;
  font-size: 18px;
}

.doc-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 18px;
  margin-bottom: 8px;
  color: #34404b;
  font-size: 13px;
}

.doc-table {
  width: 100%;
  min-width: 0;
  border-collapse: collapse;
  background: #ffffff;
}

.doc-table th,
.doc-table td {
  padding: 8px;
  border: 1px solid #cfd9df;
  font-size: 12px;
}

.doc-note {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.6;
}

.table-input {
  min-width: 120px;
  max-width: 160px;
  padding: 7px 8px;
}

.negative-cell {
  color: var(--warn);
  font-weight: 800;
}

dialog {
  width: min(960px, calc(100vw - 28px));
  border: 0;
  border-radius: 8px;
  padding: 0;
  box-shadow: var(--shadow);
}

dialog::backdrop {
  background: rgba(11, 21, 26, 0.46);
}

#order-form,
#quick-complete-form {
  padding: 20px;
}

.quick-summary {
  display: grid;
  gap: 8px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfc;
}

.quick-summary p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.dialog-header {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 18px;
}

.inline-section {
  margin-top: 18px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfc;
}

.inline-section h4 {
  margin: 0;
  font-size: 15px;
}

.section-title {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

.items-editor {
  display: grid;
  gap: 8px;
}

.item-row {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr 40px;
  gap: 8px;
  align-items: end;
}

.remove-item {
  width: 40px;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  font-size: 20px;
}

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

.check-grid label {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 38px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.check-grid input {
  width: auto;
}

.totals {
  display: flex;
  justify-content: flex-end;
  gap: 24px;
  color: var(--muted);
}

.totals strong {
  color: var(--ink);
}

.dialog-actions {
  justify-content: flex-end;
  margin-top: 18px;
}

.empty {
  padding: 18px;
  color: var(--muted);
  text-align: center;
}

.readonly-mode .network-strip {
  border-color: #e7b866;
  background: #fff8e7;
}

.real-data-mode .network-strip {
  border-color: #a9d8b7;
  background: #f2fbf5;
}

.real-data-mode .sidebar-note strong {
  color: #d7efe8;
}

.readonly-mode .primary,
.readonly-mode .secondary:disabled,
.readonly-mode .row-action:disabled {
  opacity: 0.55;
}

button:disabled {
  cursor: not-allowed;
}

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

  .sidebar {
    position: static;
    gap: 16px;
  }

  .nav {
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  }

  .nav-item {
    text-align: center;
  }

  .sidebar-note {
    display: none;
  }

  .metrics,
  .workbench,
  .split-layout,
  .export-grid,
  .ai-controls,
  .import-form,
  .mapping-grid,
  .summary-grid,
  .detail-grid,
  .health-grid,
  .health-grid.compact {
    grid-template-columns: 1fr;
  }

  .topbar,
  .toolbar,
  .network-strip {
    align-items: stretch;
    flex-direction: column;
  }

  .network-strip,
  .onboarding-panel {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 640px) {
  .main {
    padding: 16px;
  }

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

  .topbar-actions,
  .button-row,
  .import-actions,
  .dialog-actions,
  .detail-actions,
  .totals {
    flex-direction: column;
    align-items: stretch;
  }

  .form-grid,
  .network-strip,
  .onboarding-panel,
  .check-grid,
  .item-row {
    grid-template-columns: 1fr;
  }

  .remove-item {
    width: 100%;
  }
}

/* Overdue alerts */
.overdue-card { border-left: 4px solid #a84d37; }
.overdue-card strong { color: #a84d37; font-size: 28px; }

/* Batch operations bar */
.batch-bar {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 14px; margin-bottom: 10px;
  background: #eef4f3; border-radius: 8px; font-size: 13px;
}
.batch-check { width: auto; }

.logout-top {
  margin-left: auto;
}

