:root {
  --bg: #f5f7f8;
  --surface: #ffffff;
  --surface-soft: #f8fafb;
  --ink: #18212b;
  --muted: #667085;
  --line: #dfe5ea;
  --line-strong: #c8d1d8;
  --accent: #12645a;
  --accent-soft: #e7f3f0;
  --warning: #a15c11;
  --danger: #b42318;
  --ok: #087443;
  --shadow: 0 12px 32px rgba(22, 34, 45, 0.07);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  display: grid;
  grid-template-columns: 236px minmax(0, 1fr);
  color: var(--ink);
  background: var(--bg);
  font-family: "Microsoft YaHei", "PingFang SC", system-ui, sans-serif;
}

body.is-locked {
  display: block;
}

body.is-locked .sidebar,
body.is-locked main {
  display: none;
}

.login-screen {
  display: none;
  min-height: 100vh;
  place-items: center;
  padding: 24px;
  background: radial-gradient(circle at 20% 20%, #e7f3f0, transparent 28%), var(--bg);
}

body.is-locked .login-screen {
  display: grid;
}

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

.login-card h1 {
  margin: 2px 0 0;
  font-size: 24px;
}

.login-card p {
  margin: 0;
  color: var(--muted);
  line-height: 1.6;
}

.session-box {
  display: grid;
  gap: 6px;
  margin-top: 8px;
  padding: 8px 6px 10px;
  border-top: 1px solid rgba(255, 255, 255, 0.12);
}

.session-box span {
  color: #b9ccc8;
  font-size: 13px;
}

.session-box label {
  display: grid;
  gap: 5px;
  color: #b9ccc8;
  font-size: 12px;
}

.session-box select {
  width: 100%;
  min-height: 34px;
}

.session-box button {
  color: #d9e6e2;
  background: transparent;
  border-color: rgba(255, 255, 255, 0.16);
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 22px 16px;
  color: #fff;
  background: #10231f;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 2px 6px 10px;
}

.brand-mark {
  display: grid;
  width: 40px;
  height: 40px;
  place-items: center;
  border-radius: 8px;
  background: #f0c66c;
  color: #10231f;
  font-weight: 800;
  overflow: hidden;
  flex: 0 0 auto;
}

.brand-mark.logo-uploaded {
  background: transparent;
}

.brand-mark img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.brand strong,
.brand small {
  display: block;
}

.brand small {
  margin-top: 2px;
  color: #b9ccc8;
}

nav {
  display: grid;
  gap: 6px;
}

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

button {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 13px;
  color: var(--ink);
  background: #fff;
  cursor: pointer;
}

button:hover {
  border-color: var(--line-strong);
}

.nav {
  min-height: 42px;
  border: 0;
  color: #d9e6e2;
  background: transparent;
  text-align: left;
}

.nav.active {
  color: #fff;
  background: #1d4038;
}

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

.topbar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 18px;
}

.eyebrow,
.panel p {
  margin: 0;
  color: var(--muted);
}

.eyebrow {
  margin-bottom: 6px;
  color: var(--accent);
  font-weight: 700;
}

h1,
h2,
h3 {
  margin: 0;
  letter-spacing: 0;
}

h1 { font-size: 26px; }
h2 { font-size: 18px; }
h3 { font-size: 15px; }

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

.metric-strip span {
  min-height: 72px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.metric-strip small {
  display: block;
  color: var(--muted);
}

.metric-strip b {
  display: block;
  margin-top: 6px;
  font-size: 21px;
}

.notice {
  margin-bottom: 16px;
  padding: 12px 14px;
  border: 1px solid #f0d9a8;
  border-radius: 8px;
  color: #714500;
  background: #fff8e6;
}

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

.workbench {
  display: grid;
  gap: 16px;
}

.bot-layout,
.two-col {
  grid-template-columns: minmax(340px, 0.82fr) minmax(460px, 1.18fr);
}

.panel {
  min-width: 0;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

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

.panel-title p {
  margin-top: 5px;
  font-size: 13px;
}

.badge,
.pill,
.status {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: 999px;
  padding: 0 9px;
  font-size: 12px;
  font-weight: 700;
}

.badge,
.pill {
  color: var(--accent);
  background: var(--accent-soft);
}

label {
  display: grid;
  gap: 7px;
  margin-bottom: 12px;
  color: var(--muted);
  font-size: 13px;
}

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

textarea {
  resize: vertical;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 10px;
}
.form-grid label { font-size: 12px; gap: 3px; }
.form-grid input { min-height: 30px; font-size: 12px; }

.check {
  display: flex;
  align-items: center;
  gap: 8px;
}

.check input {
  width: 18px;
}

.primary {
  width: 100%;
  min-height: 42px;
  border-color: var(--accent);
  color: #fff;
  background: var(--accent);
  font-weight: 700;
}

.quick-actions {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
  margin: 4px 0 14px;
}

.quick-actions button {
  padding: 0 8px;
  font-size: 13px;
}

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

.inline-actions button {
  min-height: 34px;
  padding: 0 12px;
  font-size: 13px;
}

.chat-log,
.stack,
.timeline,
.log-list {
  display: grid;
  gap: 10px;
}

.chat-log {
  min-height: 360px;
  align-content: start;
}

.empty {
  place-items: center;
  border: 1px dashed var(--line-strong);
  border-radius: 8px;
  color: var(--muted);
  background: var(--surface-soft);
}

.bubble,
.row-card,
.role-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.bubble {
  padding: 13px;
}

.bubble strong {
  display: block;
  margin-bottom: 5px;
}

.bubble hr {
  margin: 12px 0;
  border: 0;
  border-top: 1px solid var(--line);
}

.board-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 14px;
}

.role-card {
  padding: 15px;
}

.role-card h3 {
  margin-bottom: 12px;
}

.role-metrics {
  display: grid;
  gap: 9px;
}

.role-metrics p {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin: 0;
}

.role-metrics strong {
  font-size: 18px;
}

.row-card {
  display: grid;
  gap: 7px;
  padding: 13px;
}

.row-card header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.row-card p {
  font-size: 13px;
}

.link-button {
  width: auto;
  min-height: 0;
  padding: 0;
  border: 0;
  color: var(--accent);
  background: transparent;
  font: inherit;
  font-weight: 800;
}

.icon-button {
  width: 34px;
  min-height: 34px;
  padding: 0;
  border-radius: 50%;
  font-size: 22px;
  line-height: 1;
}

.detail-backdrop {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(15, 23, 42, 0.36);
}

.detail-panel {
  width: min(720px, 100%);
  max-height: 86vh;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 24px 70px rgba(15, 23, 42, 0.22);
}

.detail-panel header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 18px;
  border-bottom: 1px solid var(--line);
}

.detail-panel h2 {
  margin: 4px 0 0;
  font-size: 22px;
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1px;
  padding: 18px;
  background: var(--line);
}

.detail-grid p {
  display: grid;
  gap: 5px;
  margin: 0;
  padding: 12px;
  background: var(--surface);
}

.detail-grid span,
.detail-note {
  color: var(--muted);
  font-size: 13px;
}

.detail-note {
  padding: 0 18px 18px;
}

.detail-subsection {
  display: grid;
  gap: 10px;
  padding: 0 18px 18px;
}

.detail-subsection h3 {
  margin: 0;
  font-size: 15px;
}

.detail-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  padding: 0 18px 18px;
}

.save-status {
  min-height: 20px;
  color: var(--accent);
  font-weight: 700;
}

.logo-uploader {
  display: grid;
  gap: 12px;
}

.logo-preview-row {
  display: flex;
  align-items: center;
  gap: 14px;
}

.logo-preview {
  width: 48px;
  height: 48px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #f0c66c;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}
.logo-preview img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}
.logo-placeholder {
  display: grid;
  width: 48px;
  height: 48px;
  place-items: center;
  border-radius: 8px;
  background: #f0c66c;
  color: #10231f;
  font-weight: 800;
 font-size: 14px;
}

.section-label {
  margin: 4px 0 2px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.admin-hero {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: linear-gradient(135deg, #f7fbff, #f7faf8);
  margin-bottom: 6px;
}

.admin-hero h2 {
  font-size: 17px;
}

.admin-hero p {
  margin: 0;
  color: var(--muted);
}

.admin-health {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: var(--text);
  font-weight: 700;
  font-size: 13px;
}

.ok-dot,
.warn-dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
}

.ok-dot {
  background: var(--ok);
}

.warn-dot {
  background: var(--warning);
}

.admin-stat-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-bottom: 8px;
}

.admin-stat-grid .mini-card {
  display: flex;
  flex-direction: column;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.admin-stat-grid .mini-card.clickable {
  cursor: pointer;
  transition: box-shadow 0.15s, transform 0.1s;
}
.admin-stat-grid .mini-card.clickable:hover {
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
  transform: translateY(-1px);
  border-color: var(--accent);
}
.admin-stat-grid .mini-card.clickable:active {
  transform: translateY(0);
}

.admin-stat-grid span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.admin-stat-grid b {
  display: block;
  margin-top: 4px;
  color: var(--ink);
  font-size: 18px;
}

.admin-section {
  display: grid;
  gap: 10px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
}

.admin-console {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  gap: 16px;
}

.admin-menu {
  display: grid;
  align-content: start;
  gap: 6px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
}

.admin-menu button {
  justify-content: flex-start;
  border: 0;
  background: transparent;
  color: var(--muted);
  text-align: left;
  font-weight: 700;
}

.admin-menu button.active,
.admin-menu button:hover {
  background: #eef4ff;
  color: #2454a6;
}

.admin-content {
  display: grid;
  gap: 16px;
  min-width: 0;
}

.admin-section-title {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.admin-section-title h3 {
  margin: 0 0 4px;
  font-size: 17px;
}

.admin-section-title p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.admin-table {
  width: 100%;
  border-collapse: collapse;
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
}

.admin-table th,
.admin-table td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

.admin-table th {
  color: var(--muted);
  background: #f6f8fb;
  font-size: 13px;
}

.admin-row {
  display: grid;
  grid-template-columns: 1.3fr 0.8fr 1fr auto;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
}

.admin-row:last-child {
  border-bottom: 0;
}

.admin-row small {
  display: block;
  margin-top: 3px;
  color: var(--muted);
}

.role-bind-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}
.model-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

.role-bind-card,
.model-card {
  display: grid;
  gap: 6px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfd;
}

.role-bind-card header,
.model-card header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}
.role-bind-card label { font-size: 12px; gap: 3px; }
.role-bind-card input, .role-bind-card textarea { min-height: 28px; font-size: 12px; }
.role-bind-card textarea { min-height: 40px; }
.role-bind-card .role-chip { font-size: 11px; padding: 2px 6px; }

.button-row,
.filter-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.filter-row input {
  min-width: 180px;
  flex: 1;
}

.role-chip {
  width: fit-content;
  padding: 4px 8px;
  border-radius: 999px;
  background: #eef4ff;
  color: #2454a6;
  font-size: 12px;
  font-weight: 700;
}

.callback-box {
  display: grid;
  gap: 6px;
  padding: 12px;
  border: 1px dashed #b7c5d8;
  border-radius: 10px;
  background: #f8fbff;
}

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

.callback-box code {
  overflow-wrap: anywhere;
  color: #16427b;
}

.compact-stack {
  gap: 8px;
}

@media (max-width: 900px) {
  .admin-hero,
  .admin-section-title {
    display: grid;
  }

  .admin-stat-grid,
  .module-grid,
  .role-bind-grid,
  .model-grid,
  .admin-console,
  .admin-row {
    grid-template-columns: 1fr;
  }
}

.status-draft,
.status-pending {
  color: var(--warning);
  background: #fff3df;
}

.status-confirmed,
.status-completed,
.status-qualified {
  color: var(--ok);
  background: #e8f6ef;
}

.status-defective {
  color: var(--danger);
  background: #fff0ee;
}

.log-list {
  max-height: 520px;
  overflow: auto;
}

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

  .sidebar {
    position: static;
    height: auto;
  }

  nav {
    grid-template-columns: repeat(3, 1fr);
  }

  .topbar,
  .bot-layout,
  .two-col {
    display: grid;
    grid-template-columns: 1fr;
  }

  .metric-strip,
  .quick-actions,
  .detail-grid,
  .detail-actions,
  .form-grid {
    grid-template-columns: 1fr;
  }
}

/* ===== Rule Engine Panel ===== */
.rule-engine-layout {
  display: grid;
  gap: 16px;
}

.rules-ai-chat {
  max-height: 320px;
  overflow-y: auto;
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
}

.rules-ai-placeholder {
  color: var(--muted);
  font-size: 13px;
}

.rules-ai-placeholder ul {
  margin: 8px 0 0;
  padding-left: 20px;
}

.rules-ai-placeholder li {
  margin-bottom: 4px;
}

.rules-ai-msg {
  padding: 10px 12px;
  border-radius: 8px;
  background: #fff;
  border: 1px solid var(--line);
}

.rules-ai-msg.user {
  background: #e7f3f0;
  border-color: #cde3de;
}

.rules-ai-msg.ai {
  background: #f0f4ff;
  border-color: #d8e2f5;
}

.rules-ai-msg.error {
  background: #fff0ee;
  border-color: #fcd5d0;
}

.rules-ai-msg b {
  display: block;
  margin-bottom: 4px;
  font-size: 12px;
  color: var(--muted);
}

.rules-ai-msg p {
  margin: 0;
  white-space: pre-wrap;
  line-height: 1.6;
}

.rules-ai-input-row {
  display: flex;
  gap: 8px;
  align-items: flex-start;
}

.rules-ai-input-row textarea {
  flex: 1;
  min-height: 44px;
}

.rules-ai-input-row button {
  width: auto;
  min-width: 80px;
  min-height: 44px;
}

/* ===== Log Items ===== */
.log-item {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
}
.log-item .role-chip {
  flex: 0 0 auto;
  margin-top: 1px;
  min-width: 44px;
  text-align: center;
}
.log-item p {
  flex: 1;
  margin: 0;
  color: var(--ink);
  font-size: 12px;
  line-height: 1.4;
}
.log-item .log-time {
  flex: 0 0 auto;
  color: var(--muted);
  font-size: 11px;
  white-space: nowrap;
}

/* ===== Section Labels ===== */
.section-label {
  margin: 16px 0 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

/* ===== Inline Actions ===== */
.inline-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}

.inline-actions button {
  min-height: 34px;
  padding: 0 12px;
  font-size: 13px;
}

/* ===== Master Data Table ===== */
.master-tabs { display: flex; gap: 4px; margin-bottom: 12px; }
.master-tab {
  padding: 8px 16px;
  border: 1px solid var(--line);
  border-radius: 6px 6px 0 0;
  background: var(--surface-soft);
  cursor: pointer;
  font-size: 14px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.master-tab.active {
  background: var(--surface);
  border-bottom-color: var(--surface);
  font-weight: 700;
  color: var(--accent);
}
.master-tab .badge {
  background: var(--accent-soft);
  color: var(--accent);
  padding: 1px 8px;
  border-radius: 10px;
  font-size: 12px;
}
.master-tab:hover { background: var(--surface); }
.master-toolbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  gap: 8px;
  margin-bottom: 8px;
  flex-wrap: wrap;
}
.master-toolbar input { flex: 1; min-width: 180px; }
.master-table-wrap {
  max-height: 480px;
  overflow-y: auto;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 6px;
}
.master-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.master-table th {
  background: var(--surface-soft);
  padding: 8px 10px;
  text-align: left;
  font-weight: 600;
  white-space: nowrap;
  border-bottom: 1px solid var(--line-strong);
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.master-table th.th-actions { width: 80px; text-align: center; }
.master-table td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--line);
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.master-table tr:hover td { background: var(--accent-soft); }
.master-table td.empty { text-align: center; color: var(--muted); padding: 40px 16px; font-style: italic; }
.td-actions { text-align: center; white-space: nowrap; }
.master-add-form, .master-import-area {
  margin-top: 12px;
  padding: 16px;
  border: 1px dashed var(--line-strong);
  border-radius: 8px;
  background: var(--surface-soft);
}
.master-add-form h4, .master-import-area h4 { margin: 0 0 10px; }
.master-add-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 10px;
}

/* ===== Modal ===== */
.modal-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}
.modal-box {
  background: var(--surface);
  border-radius: 10px;
  padding: 24px;
  max-width: 640px;
  width: 90%;
  max-height: 80vh;
  overflow-y: auto;
  box-shadow: 0 16px 48px rgba(0,0,0,0.2);
}
.modal-box h4 { margin: 0 0 14px; }
.modal-box .master-add-grid { max-height: 50vh; overflow-y: auto; }

/* ===== System Admin ===== */
.sysadmin-grid { display: grid; gap: 16px; }
.form-narrow { max-width: 400px; }

/* ===== List Row (Sales / Purchase view) ===== */
.list-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-bottom: 1px solid var(--line);
}
.list-row:last-child { border-bottom: 0; }
.list-row-main {
  flex: 1;
  min-width: 0;
  font-size: 13px;
}
.list-row-main b { font-size: 13px; }
.list-row-meta {
  color: var(--muted);
  font-size: 11px;
  white-space: nowrap;
}
.list-row .badge {
  flex: 0 0 auto;
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
  background: var(--accent-soft);
  color: var(--accent);
}
.badge.warn { background: #fff3e0; color: #b76a00; }
.badge.error { background: #fee8e6; color: var(--danger); }
.badge-orange { background: #fff3e0; color: #b76a00; }
.badge-blue { background: #e3f0ff; color: #1a6bb0; }
.badge-green { background: #e3f5ec; color: #087443; }
.badge-red { background: #fee8e6; color: var(--danger); }

/* ===== Backup / Restore ===== */
.backup-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.backup-buttons button {
  font-size: 13px;
  min-height: 34px;
  min-width: 120px;
}
.compare-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}
.compare-col {
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface-soft);
}
.compare-col b { display: block; font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.compare-val { display: block; font-size: 13px; font-weight: 700; }
.compare-diff { display: block; font-size: 11px; margin-top: 2px; }
.compare-diff.up { color: var(--ok); }
.compare-diff.down { color: var(--danger); }

.dash-scroll { overflow: hidden; }
.dash-scroll-inner {
  max-height: 280px;
  overflow-y: auto;
  margin: 0 -14px;
  padding: 0 14px;
}

/* ===== Accordion (采购看板) ===== */
.purchase-accordion {
  display: grid;
  gap: 4px;
}
.accordion-section {
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: #fff;
}
.accordion-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  cursor: pointer;
  user-select: none;
  font-size: 13px;
  font-weight: 700;
  background: var(--surface-soft);
  transition: background 0.1s;
}
.accordion-header:hover { background: #eef2f5; }
.accordion-header.open { background: var(--accent-soft); color: var(--accent); }
.accordion-arrow {
  margin-left: auto;
  font-size: 10px;
  color: var(--muted);
}
.accordion-body { display: none; }
.accordion-inner {
  max-height: 300px;
  overflow-y: auto;
  border-top: 1px solid var(--line);
}
.accordion-inner .list-row:last-child { border-bottom: 0; }

.toolbar {
  display: flex;
  gap: 6px;
  margin-bottom: 6px;
  align-items: center;
}
.toolbar input { flex: 1; min-width: 200px; font-size: 14px; padding: 6px 10px; }
.toolbar select.order-sort { width: auto; min-width: 90px; min-height: 30px; font-size: 12px; }
.toolbar button { min-width: 90px; min-height: 32px; font-size: 12px; }
.search-go-btn { min-width: 50px !important; min-height: 30px !important; font-size: 13px; font-weight: 700; }

/* ===== Item Table (in order detail) ===== */
.item-table {
  border: 1px solid var(--line);
  border-radius: 6px;
  font-size: 12px;
}
.item-table-header {
  display: grid;
  grid-template-columns: 1.2fr 72px 50px 50px 70px 70px;
  gap: 4px;
  padding: 4px 8px;
  background: var(--surface-soft);
  font-weight: 700;
  color: var(--muted);
  font-size: 11px;
  border-bottom: 1px solid var(--line-strong);
}
.item-table-header span:not(:first-child) { text-align: right; }
.item-row {
  display: grid;
  grid-template-columns: 1.2fr 72px 50px 50px 70px 70px;
  gap: 4px;
  padding: 5px 8px;
  border-bottom: 1px solid var(--line);
}
.item-row:last-child { border-bottom: 0; }
.item-model { font-weight: 600; font-size: 12px; }
.item-dd { color: #2563eb; font-size: 11px; white-space: nowrap; }
.item-qty, .item-shipped, .item-price, .item-total { text-align: right; color: var(--muted); font-size: 12px; }
.item-shipped.done { color: var(--ok); font-weight: 700; }
.item-total { font-weight: 700; color: var(--ink); }

.results-scroll { overflow: hidden; }
.results-inner {
  max-height: 400px;
  overflow-y: auto;
  margin: 0 -14px;
  padding: 0 14px;
}
.clickable-row { cursor: pointer; transition: background 0.1s; }
.clickable-row:hover { background: var(--accent-soft); }

.order-detail { max-width: 520px; }
.order-detail h4 { font-size: 15px; }
.order-detail-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 4px 12px;
  font-size: 13px;
}
.detail-field { padding: 3px 0; }
.detail-field b { color: var(--muted); font-weight: 600; display: inline-block; min-width: 50px; margin-right: 6px; }
.stage-track {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-top: 12px;
  padding: 10px;
  background: var(--surface-soft);
  border-radius: 8px;
  font-size: 12px;
  flex-wrap: wrap;
}
.stage-dot {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  border-radius: 999px;
  background: var(--line);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
}
.stage-dot.done { background: var(--ok); }
.stage-line {
  width: 16px;
  height: 2px;
  background: var(--line);
}

.form-card {
  display: grid;
  gap: 12px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
}
.form-card textarea { resize: vertical; min-height: 40px; }

.form-prod-info {
  display: flex;
  gap: 16px;
  padding: 8px 12px;
  background: var(--accent-soft);
  border-radius: 6px;
  font-size: 13px;
  flex-wrap: wrap;
}
.form-prod-info span { color: var(--muted); }
.form-prod-info b { color: var(--ink); font-weight: 700; }
.form-total { font-size: 18px; font-weight: 700; color: var(--accent); display: block; padding-top: 4px; }

/* ===== Reconcile (legacy rows) ===== */
.reconcile-items {
  display: grid;
  gap: 2px;
  margin-top: 6px;
  max-height: 300px;
  overflow-y: auto;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 4px;
}
.reconcile-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 13px;
}
.reconcile-row:hover { background: var(--accent-soft); }
.reconcile-row input[type=checkbox] { width: 16px; height: 16px; }
.reconcile-row .list-row-main { flex: 1; }
.reconcile-row .list-row-meta { font-weight: 700; }
.reconcile-row .list-row-meta.negative { color: var(--danger); }
.reconcile-row .list-row-meta.positive { color: var(--ok); }

.back-btn {
  padding: 4px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  cursor: pointer;
  font-size: 12px;
}
.back-btn:hover { background: var(--accent-soft); }

.backup-list {
  display: grid;
  gap: 4px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface-soft);
  font-size: 12px;
  max-height: 150px;
  overflow-y: auto;
}
.backup-list b { display: block; margin-bottom: 4px; }
.backup-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 3px 0;
}
.restore-btn {
  font-size: 11px;
  min-height: 24px;
  padding: 0 8px;
}

/* ===== WeChat Config Tabs ===== */
.wecom-tabs { display: grid; gap: 0; }
.wecom-tab-bar {
  display: flex;
  gap: 0;
  margin-bottom: 10px;
  border-bottom: 1px solid var(--line);
}
.wecom-tab {
  padding: 8px 16px;
  border: 1px solid transparent;
  border-bottom: none;
  border-radius: 6px 6px 0 0;
  background: transparent;
  cursor: pointer;
  font-size: 13px;
  font-weight: 700;
  color: var(--muted);
  margin-bottom: -1px;
}
.wecom-tab.active {
  border-color: var(--line);
  background: #fff;
  color: var(--accent);
}
.wecom-tab:hover { color: var(--ink); }
.wecom-tab-content { min-height: 0; }

/* ===== Master Detail Grid ===== */
.master-detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 4px 12px;
  font-size: 12px;
}
.master-detail-grid span { display: flex; gap: 4px; }
.master-detail-grid b { color: var(--muted); font-weight: 600; min-width: 60px; }
.master-expand-btn { font-size: 12px; padding: 2px 6px; min-height: 0; }

/* ===== Log list compact ===== */
.log-list { display: grid; gap: 4px; width: 100%; }
.log-list .log-item {
  padding: 5px 8px;
}
.log-list .log-item .log-time { font-size: 10px; }

/* ===== Compact view tweaks ===== */
main { padding: 14px; }
.admin-section-title { margin-bottom: 0; }
.admin-section-title h3 { font-size: 14px; }
.admin-section-title p { font-size: 12px; }

/* Missing CSS classes from app.js modules */
.order-search { width:100%; padding:8px 12px; border:1px solid var(--line); border-radius:6px; font-size:14px; }
.order-create-btn { padding:6px 16px; background:var(--accent); color:#fff; border:none; border-radius:6px; cursor:pointer; font-size:13px; }
.btn-sm { padding:4px 12px; font-size:12px; border:1px solid var(--line); border-radius:4px; cursor:pointer; background:#fff; }
.btn-cancel { padding:6px 16px; background:var(--surface); color:var(--ink); border:1px solid var(--line); border-radius:6px; cursor:pointer; font-size:13px; }
.btn-inbound-confirm, .btn-confirm-outbound { padding:4px 10px; font-size:12px; background:var(--ok); color:#fff; border:none; border-radius:4px; cursor:pointer; }
.btn-inbound-defective { padding:4px 10px; font-size:12px; background:var(--danger); color:#fff; border:none; border-radius:4px; cursor:pointer; }
.toolbar { display:flex; gap:8px; align-items:center; margin-bottom:12px; }
.dash-scroll { margin-bottom:12px; }
.dash-scroll-inner { max-height:300px; overflow-y:auto; }
.timeline-item { padding:8px 0; border-bottom:1px solid var(--line); }
.reconcile-check { width:18px; height:18px; }
.reconcile-confirm-btn, .reconcile-open-btn { padding:3px 8px; font-size:11px; background:var(--accent); color:#fff; border:none; border-radius:4px; cursor:pointer; }
.reconcile-del-btn { padding:3px 8px; font-size:11px; background:var(--danger); color:#fff; border:none; border-radius:4px; cursor:pointer; }
.master-add-btn, .master-edit-btn { padding:4px 10px; font-size:12px; background:var(--accent); color:#fff; border:none; border-radius:4px; cursor:pointer; }
.master-del-btn { padding:4px 10px; font-size:12px; background:var(--danger); color:#fff; border:none; border-radius:4px; cursor:pointer; }
.master-import-btn { padding:6px 14px; background:var(--surface); border:1px solid var(--line); border-radius:6px; cursor:pointer; }
.master-export-btn { padding:6px 14px; background:var(--surface); border:1px solid var(--line); border-radius:6px; cursor:pointer; }
.bind-ids { width:100%; padding:6px; border:1px solid var(--line); border-radius:4px; font-size:13px; min-height:60px; }
.bind-name { width:100%; padding:6px; border:1px solid var(--line); border-radius:4px; font-size:13px; }
.model-provider, .model-name, .model-key, .model-url { width:100%; padding:6px; border:1px solid var(--line); border-radius:4px; font-size:13px; box-sizing:border-box; }
.model-enabled { width:18px; height:18px; }
.edit-field { width:100%; padding:6px; border:1px solid var(--line); border-radius:4px; font-size:13px; box-sizing:border-box; }
.close-order-btn { padding:4px 10px; font-size:12px; background:var(--warning); color:#fff; border:none; border-radius:4px; cursor:pointer; }
.master-search { width:100%; padding:6px 10px; border:1px solid var(--line); border-radius:4px; font-size:13px; }
.form-prod-select, .form-qty-input { padding:6px; border:1px solid var(--line); border-radius:4px; font-size:13px; }
.inbound-qty, .outbound-qty { width:60px; padding:4px; border:1px solid var(--line); border-radius:4px; text-align:center; }
.rule-value-input { width:100%; padding:6px; border:1px solid var(--line); border-radius:4px; }
.rule-value-text { font-size:13px; color:var(--muted); }
.rule-save-btn { padding:3px 8px; background:var(--ok); color:#fff; border:none; border-radius:4px; cursor:pointer; }
.rule-cancel-btn { padding:3px 8px; background:var(--surface); border:1px solid var(--line); border-radius:4px; cursor:pointer; }
.rule-edit-btn { padding:2px 6px; font-size:11px; background:transparent; border:1px solid var(--line); border-radius:3px; cursor:pointer; }
.ret-complete-btn { padding:3px 8px; background:var(--ok); color:#fff; border:none; border-radius:4px; cursor:pointer; }
.ret-del-btn { padding:3px 8px; background:var(--danger); color:#fff; border:none; border-radius:4px; cursor:pointer; }
.reconcile-contact { font-size:12px; color:var(--muted); }
.reconcile-date { font-size:11px; color:var(--muted); }
.master-detail-row { display:flex; gap:6px; align-items:center; margin:4px 0; }
.master-add-input { flex:1; padding:6px; border:1px solid var(--line); border-radius:4px; }

/* Master data table - hidden rows */
[hidden] { display: none !important; }
.master-expand-btn { cursor: pointer; padding: 2px 6px; border: 1px solid var(--line); border-radius: 4px; background: #fff; font-size: 11px; }

.wecom-login-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 4px 0;
  color: var(--muted);
  font-size: 12px;
}
.wecom-login-divider::before,
.wecom-login-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--line);
}

.wecom-login-btn {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  padding: 0 13px;
  color: #333;
  background: #fff;
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  transition: all 0.15s;
}
.wecom-login-btn:hover {
  border-color: #07c160;
  color: #07c160;
  background: #f0faf4;
}

/* ===== 移动端优化（企微内置浏览器）===== */
@media (max-width: 768px) {
  body { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; padding: 8px; }
  .sidebar .brand { font-size: 14px; padding: 6px; }
  nav { grid-template-columns: repeat(2, 1fr); gap: 3px; }
  nav button { font-size: 11px; padding: 6px 4px; min-height: 36px; }
  .topbar { padding: 6px 10px; }
  main { padding: 8px; }
  
  .admin-hero { padding: 8px 10px; }
  .admin-hero h2 { font-size: 15px; }
  .admin-section { padding: 8px; gap: 6px; }
  .admin-section-title h3 { font-size: 13px; }
  
  .admin-stat-grid { grid-template-columns: repeat(2, 1fr); gap: 4px; }
  .mini-card { padding: 6px; font-size: 11px; }
  .mini-card b { font-size: 16px; }
  
  /* 表单优化 */
  .form-card { padding: 10px; }
  .form-grid { grid-template-columns: 1fr; gap: 6px; }
  .form-grid label { font-size: 12px; }
  .form-grid input, .form-grid select, .form-grid textarea { font-size: 14px; padding: 8px; }
  .form-prod-info { font-size: 11px; gap: 4px; flex-wrap: wrap; }
  .form-prod-info span { padding: 2px 6px; }
  
  .button-row { flex-direction: column; gap: 4px; }
  .button-row button { width: 100%; min-height: 40px; font-size: 14px; }
  
  /* 表格 */
  .admin-row { grid-template-columns: 1fr; gap: 2px; padding: 6px; }
  .admin-row b { font-size: 13px; }
  .admin-row span { font-size: 11px; }
  .admin-row button { min-height: 34px; }
  
  /* 日志 */
  .log-list { max-height: 240px; }
  .log-item { font-size: 11px; padding: 4px 6px; }
  
  /* 企业微信配置 */
  .wecom-tab-bar { overflow-x: auto; white-space: nowrap; }
  .wecom-tab { font-size: 11px; padding: 6px 10px; }
  .role-bind-grid { grid-template-columns: 1fr; }
  
  /* 邮件 */
  #adminContent > div[style*="height:calc(100vh - 140px)"] { flex-direction: column; height: auto !important; }
  #adminContent > div[style*="height:calc(100vh - 140px)"] > div:first-child { width: 100% !important; min-width: unset !important; max-height: 50vh; }
  #emailFolderTree { max-height: 20vh !important; }
  .email-actions { flex-wrap: wrap; }
  #emailActions button { font-size: 10px; padding: 3px 8px; }
  
  /* 销售订单详情 */
  .order-detail { max-width: 100%; }
  .order-detail .order-summary { flex-direction: column; gap: 4px; }
  .order-detail .order-summary span { font-size: 12px; }
  .toolbar { flex-wrap: wrap; }
  .toolbar input { min-width: 120px; font-size: 13px; }
  .toolbar button { min-width: 60px; min-height: 30px; font-size: 11px; }
  .search-go-btn { min-width: 40px !important; }
  
  /* 新建订单页面 */
  [data-view="sales-new"] .form-prod-info { display: grid; grid-template-columns: repeat(2, 1fr); }
  
  /* 规则引擎 */
  .rules-grid { grid-template-columns: 1fr; }
  .rules-ai-chat { max-height: 200px; }
  
  /* 系统设置 */
  .sysadmin-grid { grid-template-columns: 1fr; }
  .master-tabs { overflow-x: auto; }
  .master-tab { font-size: 11px; padding: 6px 10px; }
  .master-toolbar { flex-direction: column; }
  position: sticky;
  top: 0;
  z-index: 10;
  .master-table { font-size: 11px; }
  .master-table th, .master-table td { padding: 4px 6px; }
  
  /* 看板数字 */
  .ceo-summary-grid { grid-template-columns: repeat(2, 1fr); }
  .ceo-card { padding: 8px; }
  .ceo-card .num { font-size: 18px; }
  
  /* AI对话窗口 */
  .brain-chat { max-height: 200px; }
  .brain-msg { font-size: 12px; padding: 6px 8px; }
  
  /* 模态框 */
  div[style*="position:fixed"][style*="z-index:9999"] > div { width: 92% !important; max-width: 92% !important; padding: 16px !important; }
  
  /* 底部用户区域 */
  .bot-layout { grid-template-columns: 1fr; }
  #sessionRole { font-size: 11px; }
}


/* ===== Sales order list (multi-line PO) ===== */
.so-list-head,
.so-list-row {
  display: grid;
  grid-template-columns: minmax(110px, 1.1fr) minmax(90px, 1fr) minmax(180px, 2fr) minmax(72px, 0.7fr) minmax(88px, 0.8fr) minmax(64px, 0.55fr);
  gap: 8px;
  align-items: start;
  padding: 8px 10px;
  border-bottom: 1px solid var(--line);
}
.so-list-head {
  background: var(--surface-soft);
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
  position: sticky;
  top: 0;
  z-index: 1;
}
.so-list-row { font-size: 12px; cursor: pointer; transition: background 0.1s; }
.so-list-row:hover { background: var(--accent-soft); }
.so-col { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.so-col b { font-size: 12px; line-height: 1.35; }
.so-col small { font-size: 10px; color: var(--muted); line-height: 1.3; word-break: break-all; }
.so-col-amt b { color: var(--ink); font-size: 13px; }
.so-col-meta { align-items: flex-end; text-align: right; }
.so-col-attach { display: flex; align-items: center; justify-content: center; gap: 4px; padding-top: 2px; flex-wrap: wrap; }
.so-order-thumb { position: relative; border: 1px solid #c5ddf8; border-radius: 8px; padding: 0; width: 52px; height: 52px; overflow: hidden; cursor: pointer; background: #fff; display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; box-shadow: 0 1px 4px rgba(21,101,192,.12); transition: transform .12s, box-shadow .12s; }
.so-order-thumb:hover { transform: scale(1.04); box-shadow: 0 4px 12px rgba(21,101,192,.22); }
.so-order-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; pointer-events: none; }
.so-order-thumb-lg { width: 88px; height: 88px; border-radius: 10px; }
.so-order-thumb-pdf { flex-direction: column; gap: 2px; background: linear-gradient(145deg, #eef6ff, #f8fafc); color: #1565C0; font-size: 11px; font-weight: 700; }
.so-thumb-pdf-label { font-size: 13px; line-height: 1; }
.so-thumb-hint { position: absolute; left: 0; right: 0; bottom: 0; padding: 2px 0; font-size: 9px; line-height: 1.1; text-align: center; color: #fff; background: rgba(15,23,42,.55); opacity: 0; transition: opacity .12s; pointer-events: none; }
.so-order-thumb:hover .so-thumb-hint { opacity: 1; }
.so-file-preview-overlay { position: fixed; inset: 0; background: rgba(15,23,42,.72); z-index: 9999; display: none; align-items: center; justify-content: center; padding: 20px; }
.so-file-preview-box { position: relative; background: #fff; border-radius: 10px; max-width: min(96vw, 980px); max-height: 92vh; overflow: auto; box-shadow: 0 20px 60px rgba(0,0,0,.35); }
.so-file-preview-box img { display: block; max-width: min(96vw, 960px); max-height: 88vh; }
.so-file-preview-box iframe { display: block; width: min(92vw, 900px); height: min(88vh, 820px); border: 0; }
.so-file-preview-close { position: absolute; top: 8px; right: 8px; z-index: 2; border: none; background: rgba(0,0,0,.55); color: #fff; width: 32px; height: 32px; border-radius: 50%; cursor: pointer; font-size: 16px; }
.so-row-actions { display: inline-flex; gap: 2px; margin-top: 2px; }
.so-row-actions button { background: none; border: none; cursor: pointer; font-size: 12px; padding: 0 2px; }
.so-inline-items { display: grid; gap: 3px; }
.so-inline-items.compact { gap: 2px; }
.so-inline-item {
  display: grid;
  grid-template-columns: 1fr 0.8fr 72px auto auto auto;
  gap: 6px;
  align-items: center;
  font-size: 11px;
  line-height: 1.3;
}
.so-inline-part { font-weight: 600; color: var(--ink); word-break: break-all; }
.so-inline-model { color: var(--muted); word-break: break-all; font-size: 10px; }
.so-inline-dd { color: #2563eb; white-space: nowrap; font-size: 10px; }
.so-inline-qty, .so-inline-price { color: var(--muted); white-space: nowrap; }
.so-inline-amt { font-weight: 700; white-space: nowrap; text-align: right; }
.so-inline-single { font-size: 11px; color: var(--muted); line-height: 1.4; word-break: break-all; }
@media (max-width: 900px) {
  .so-list-head { display: none; }
  .so-list-row {
    grid-template-columns: 1fr;
    gap: 6px;
    padding: 10px;
    border: 1px solid var(--line);
    border-radius: 8px;
    margin-bottom: 8px;
  }
  .so-col-meta { align-items: flex-start; text-align: left; flex-direction: row; flex-wrap: wrap; gap: 8px; }
}
/* ===== Expandable order list ===== */
.order-list-wrap { border-bottom: 1px solid var(--line); }
.order-list-wrap.expanded { background: #f8fafc; }
.order-summary-row { border-bottom: none !important; }
.order-items-brief { font-size: 11px; color: var(--muted); line-height: 1.4; word-break: break-all; }
.order-chevron { font-size: 10px; color: var(--muted); margin-left: 4px; }
.order-expand-panel { padding: 0 10px 12px 10px; border-bottom: 1px solid var(--line); background: #f8fafc; }
.order-expand-inner { padding: 10px 4px 4px; }
.order-detail-table.item-table-header,
.order-detail-table.item-row { grid-template-columns: 1.2fr 0.9fr 72px 64px 72px 80px; }
.order-row-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; padding-top: 10px; border-top: 1px dashed var(--line); }
.order-act-btn { padding: 5px 12px; border: 1px solid var(--line); border-radius: 4px; background: #fff; cursor: pointer; font-size: 12px; text-decoration: none; color: inherit; display: inline-block; }
.order-act-btn.primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.order-act-btn.danger { border-color: #e74c3c; color: #e74c3c; }
.po-list-head { margin-top: 0; }

.order-original-file-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; padding: 10px 12px; background: #eef6ff; border: 1px solid #c5ddf8; border-radius: 8px; margin-bottom: 4px; }
.order-original-label { font-size: 12px; }
.order-line-card { border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; margin-bottom: 10px; background: #fff; }
.order-line-head { font-size: 13px; margin-bottom: 4px; }
.order-line-meta { font-size: 11px; color: var(--muted); margin-bottom: 8px; }
.line-stage-track { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; font-size: 11px; margin: 8px 0; padding: 6px 8px; background: #f8fafc; border-radius: 6px; }
.line-stage-track-full { flex-wrap: nowrap; overflow-x: auto; padding: 8px 10px; gap: 2px; -webkit-overflow-scrolling: touch; }
.line-stage-track-full .stage-dot { flex-shrink: 0; width: 18px; height: 18px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; font-size: 10px; background: #e2e8f0; color: #64748b; }
.line-stage-track-full .stage-dot.done { background: #dcfce7; color: #15803d; }
.line-stage-track-full .stage-dot.active { background: #dbeafe; color: #1565C0; box-shadow: 0 0 0 2px #93c5fd; }
.line-stage-track-full .stage-label { flex-shrink: 0; white-space: nowrap; font-size: 10px; color: var(--muted); margin-right: 2px; }
.line-stage-track-full .stage-label.current { color: #1565C0; font-weight: 700; }
.line-stage-track-full .stage-line { flex-shrink: 0; width: 10px; height: 1px; background: #cbd5e1; margin: 0 1px; }
.line-row-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; padding-top: 8px; border-top: 1px dashed var(--line); }

.io-modal-box { background: #fff; border-radius: 12px; padding: 24px; width: 560px; max-width: 92vw; box-shadow: 0 16px 48px rgba(0,0,0,.18); }
.io-modal-actions { margin-top: 16px; display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; }
.io-modal-actions button { padding: 8px 16px; border: 1px solid var(--line); border-radius: 6px; background: #fff; cursor: pointer; font-size: 13px; }
.io-modal-actions button.primary { background: #12645a; color: #fff; border-color: #12645a; }
.io-modal-actions .btn-inbound-defective { border-color: #b42318; color: #b42318; }
.io-qty-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.io-qty-table th, .io-qty-table td { padding: 6px 8px; border-bottom: 1px solid var(--line); }
.io-qty-table th { text-align: left; font-size: 11px; color: var(--muted); }
.io-qty-table .io-num { text-align: center; }
.io-qty-table input { width: 72px; text-align: center; padding: 4px; border: 1px solid var(--line); border-radius: 4px; }

.wh-io-tabs { display: flex; gap: 8px; margin-bottom: 10px; flex-wrap: wrap; }
.wh-io-tab { padding: 8px 14px; border: 1px solid var(--line); border-radius: 8px; background: #fff; cursor: pointer; font-size: 13px; }
.wh-io-tab.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.io-record-row { align-items: center; gap: 10px; }

.io-list-wrap { border-bottom: 1px solid var(--line); }
.io-list-wrap.expanded { background: #f8fafc; }
.io-slip-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin: 12px 0; padding: 10px; background: #eef6ff; border-radius: 8px; font-size: 12px; }
.io-slip-thumb { width: 44px; height: 44px; flex-shrink: 0; }
.io-no-slip { font-size: 10px; color: var(--muted); }
.io-record-row { cursor: pointer; }

.io-defect-panel { border: 1px solid #f5c2c7; background: #fff5f5; border-radius: 8px; padding: 12px; margin-top: 12px; }
.defect-reason-row { display: flex; gap: 8px; margin-bottom: 6px; align-items: center; }
.io-defect-radio { display: block; font-size: 12px; margin: 4px 0; cursor: pointer; }
.io-defect-summary { font-size: 12px; padding: 10px; background: #fff8e6; border: 1px solid #f0d78c; border-radius: 6px; margin-bottom: 8px; line-height: 1.6; }

.io-defect-options-top { background: #fff; border: 1px solid #f5c2c7; border-radius: 6px; padding: 10px; margin-bottom: 4px; }

/* ===== Reconcile long-bar lists ===== */
.reconcile-flow-hint {
  font-size: 12px;
  line-height: 1.55;
  color: var(--muted);
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  margin-bottom: 12px;
}
.reconcile-flow-hint b { color: var(--ink); display: block; margin-bottom: 4px; }
.reconcile-stat-grid { margin-bottom: 12px; }
.reconcile-toolbar { flex-wrap: wrap; margin-bottom: 8px; }
.reconcile-list-wrap {
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: #fff;
}
.reconcile-list-head,
.reconcile-list-row,
.reconcile-draft-head,
.reconcile-draft-row {
  display: grid;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-bottom: 1px solid var(--line);
  font-size: 12px;
}
.reconcile-list-head,
.reconcile-draft-head {
  background: var(--surface-soft);
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
  position: sticky;
  top: 0;
  z-index: 1;
}
.reconcile-list-head,
.reconcile-list-row {
  grid-template-columns: 28px 72px minmax(88px, 1fr) minmax(80px, 1fr) 72px minmax(100px, 1.4fr) 48px 80px;
}
.reconcile-draft-head,
.reconcile-draft-row {
  grid-template-columns: 72px minmax(140px, 2fr) minmax(88px, 1fr) 48px 88px 72px 80px minmax(120px, auto);
}
.reconcile-list-row {
  cursor: pointer;
  transition: background 0.1s;
}
.reconcile-list-row:hover { background: var(--accent-soft); }
.reconcile-list-row:last-child,
.reconcile-draft-row:last-child { border-bottom: 0; }
.reconcile-draft-row { font-size: 12px; }
.reconcile-col-check { display: flex; align-items: center; justify-content: center; }
.reconcile-col-check input { width: 16px; height: 16px; margin: 0; }
.reconcile-col-no b,
.reconcile-col-title b { font-size: 12px; word-break: break-all; }
.reconcile-col-detail,
.reconcile-col-party,
.reconcile-col-title { min-width: 0; word-break: break-all; }
.reconcile-col-qty,
.reconcile-col-count,
.reconcile-col-date { text-align: center; color: var(--muted); white-space: nowrap; }
.reconcile-col-amt { text-align: right; font-weight: 700; white-space: nowrap; }
.reconcile-col-amt.positive { color: var(--ok); }
.reconcile-col-amt.negative { color: var(--danger); }
.reconcile-col-status { text-align: center; }
.reconcile-col-actions,
.reconcile-draft-actions { display: flex; gap: 4px; align-items: center; justify-content: flex-end; flex-wrap: wrap; }
.reconcile-type-badge {
  display: inline-block;
  padding: 2px 6px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 700;
  white-space: nowrap;
  background: #eef2ff;
  color: #4338ca;
}
.reconcile-type-badge.ship, .reconcile-type-badge.recv { background: #e3f5ec; color: #087443; }
.reconcile-type-badge.return, .reconcile-type-badge.claim { background: #fee8e6; color: var(--danger); }
.reconcile-type-badge.repl { background: #fff3e0; color: #b76a00; }
.reconcile-type-badge.fee { background: #f3e8ff; color: #7c3aed; }
.reconcile-type-badge.sales { background: #e3f0ff; color: #1a6bb0; }
.reconcile-type-badge.purchase { background: #fef3c7; color: #92400e; }
.reconcile-list-body { max-height: min(52vh, 520px); overflow-y: auto; }
.reconcile-draft-wrap .reconcile-list-body { max-height: none; }
.reconcile-empty { padding: 24px 12px; text-align: center; }
.reconcile-modal-items .reconcile-list-head,
.reconcile-modal-items .reconcile-list-row {
  grid-template-columns: 72px minmax(96px, 1fr) minmax(100px, 1.4fr) 56px 88px;
}
.reconcile-modal-row { cursor: default; }
.reconcile-modal-row:hover { background: transparent; }
.reconcile-actions { margin-top: 10px; }
@media (max-width: 900px) {
  .reconcile-list-head { display: none; }
  .reconcile-list-row,
  .reconcile-draft-row {
    grid-template-columns: 1fr;
    gap: 4px;
    padding: 10px;
    border: 1px solid var(--line);
    border-radius: 8px;
    margin: 6px 8px;
  }
  .reconcile-list-body { max-height: none; background: var(--surface-soft); padding-bottom: 4px; }
}

.reconcile-cutoff-label { font-size: 12px; color: var(--muted); display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.reconcile-col-bizdate { text-align: center; color: var(--muted); font-size: 11px; white-space: nowrap; }
.session-pw-btn {
  width: 100%;
  padding: 7px 10px;
  font-size: 12px;
  color: #d9e6e2;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 6px;
  cursor: pointer;
  text-align: left;
}
.session-pw-btn:hover {
  background: rgba(255, 255, 255, 0.14);
}

/* fin-arap draft table: checkbox column */
.fin-arap-draft-head,
.fin-arap-draft-row {
  grid-template-columns: 28px 72px minmax(140px, 2fr) minmax(88px, 1fr) 48px 88px minmax(100px, 1fr) 80px minmax(120px, auto);
}
.fin-arap-draft-wrap .reconcile-list-body { max-height: none; }
/* expense monthly groups */
.expense-group-list { display: flex; flex-direction: column; gap: 6px; }
.expense-group-section {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  overflow: hidden;
}
.expense-group-section.open { border-color: var(--accent-soft); }
.expense-flow-hint { line-height: 1.65; }
.expense-group-header {
  display: grid;
  grid-template-columns: 28px 1fr auto auto auto;
  align-items: center;
  gap: 8px 10px;
  padding: 10px 12px;
}
.expense-group-toggle {
  border: none;
  background: transparent;
  cursor: pointer;
  padding: 0;
  font: inherit;
  color: inherit;
  display: flex;
  align-items: center;
  justify-content: center;
}
.expense-group-toggle:hover .expense-group-arrow { color: var(--accent); }
.expense-group-arrow { font-size: 10px; color: var(--muted); width: 14px; flex-shrink: 0; }
.expense-group-main { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.expense-group-title { font-weight: 700; font-size: 13px; line-height: 1.35; }
.expense-group-party { font-size: 12px; color: var(--muted); }
.expense-group-amt { font-weight: 700; font-size: 13px; white-space: nowrap; text-align: right; }
.expense-period-tag { font-weight: 400; font-size: 11px; color: var(--muted); margin-left: 6px; }
.expense-group-actions { display: flex; gap: 6px; justify-content: flex-end; }
@media (max-width: 720px) {
  .expense-group-header {
    grid-template-columns: 28px 1fr auto;
    grid-template-areas: "arrow main amt" "arrow status actions";
  }
  .expense-group-toggle { grid-area: arrow; }
  .expense-group-main { grid-area: main; }
  .expense-group-amt { grid-area: amt; }
  .expense-group-header > .badge { grid-area: status; justify-self: start; }
  .expense-group-actions { grid-area: actions; }
}
.expense-group-actions .btn-sm,
.expense-btn-disabled {
  padding: 4px 12px;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 11px;
  min-width: 52px;
}
.expense-group-confirm-btn { background: var(--ok); color: #fff; }
.expense-group-pay-btn { background: var(--accent); color: #fff; }
.expense-btn-disabled { background: #c8cdd2 !important; color: #fff !important; cursor: not-allowed !important; opacity: 0.75; }
.expense-group-body { border-top: 1px solid var(--line); }
.expense-detail-row { padding: 6px 12px !important; }
.badge-gray { background: #eef2f5; color: var(--muted); }
/* sales compare tabs */
.sales-compare-tabs { display: flex; gap: 6px; margin-bottom: 10px; flex-wrap: wrap; }
.sales-compare-tab {
  padding: 6px 14px; border: 1px solid var(--line); border-radius: 6px;
  background: var(--surface); cursor: pointer; font-size: 12px; font-weight: 600;
}
.sales-compare-tab:hover { border-color: var(--accent); color: var(--accent); }
.sales-compare-tab.active { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.sales-compare-sub { font-size: 12px; color: var(--muted); margin-bottom: 8px; }
.sales-compare-table {
  width: 100%; border-collapse: collapse; font-size: 13px;
  border: 1px solid var(--line); border-radius: 8px; overflow: hidden;
}
.sales-compare-table th, .sales-compare-table td {
  padding: 8px 12px; border-bottom: 1px solid var(--line); text-align: right;
}
.sales-compare-table th:first-child, .sales-compare-table td:first-child { text-align: left; }
.sales-compare-table thead th { background: var(--surface-soft); font-weight: 700; }
.sales-compare-table tbody tr:last-child td { border-bottom: 0; }
.sales-compare-note { font-size: 10px; color: var(--muted); margin-top: 8px; }
.sales-compare-section { margin-bottom: 12px; }
/* CEO dashboard compact layout */
.ceo-dash-top { margin-bottom: 10px; }
.ceo-stat-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 6px;
  margin-bottom: 6px;
}
.ceo-mini-card {
  padding: 6px 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s;
  min-width: 0;
}
.ceo-mini-card:hover { border-color: var(--accent); box-shadow: 0 1px 4px rgba(0,0,0,0.06); }
.ceo-mini-card span {
  display: block;
  font-size: 10px;
  color: var(--muted);
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ceo-mini-card b {
  display: block;
  font-size: 14px;
  font-weight: 700;
  color: var(--ink);
  margin: 2px 0 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ceo-mini-card em {
  display: block;
  font-style: normal;
  font-size: 10px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ceo-funds-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 10px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: linear-gradient(90deg, var(--surface-soft) 0%, #fff 100%);
  cursor: pointer;
  font-size: 12px;
  line-height: 1.3;
  transition: border-color 0.15s;
}
.ceo-funds-bar:hover { border-color: var(--accent); }
.ceo-funds-label { font-weight: 700; color: var(--ink); white-space: nowrap; }
.ceo-funds-total b { font-size: 15px; color: var(--ink); }
.ceo-funds-sep { color: var(--line); user-select: none; }
.ceo-funds-item { color: var(--muted); white-space: nowrap; }
.ceo-funds-tax { color: var(--danger); white-space: nowrap; }
.ceo-funds-avail { color: var(--ok); font-weight: 600; white-space: nowrap; }
.ceo-funds-rate { font-size: 10px; color: var(--muted); text-decoration: none; margin-left: auto; white-space: nowrap; }
.ceo-funds-rate:hover { color: var(--accent); }
@media (max-width: 768px) {
  .ceo-stat-grid { grid-template-columns: repeat(3, 1fr); }
  .ceo-funds-bar { font-size: 11px; padding: 6px 8px; gap: 4px 8px; }
  .ceo-funds-rate { margin-left: 0; }
}
@media (max-width: 480px) {
  .ceo-stat-grid { grid-template-columns: repeat(2, 1fr); }
}

.memo-done { opacity: 0.55; }
.memo-done b { text-decoration: line-through; }
.report-content { line-height: 1.6; }

.memo-row-todo { border-left: 4px solid #16a34a !important; background: rgba(22,163,74,0.07) !important; }
.memo-row-memo { border-left: 4px solid #d97706 !important; background: rgba(217,119,6,0.08) !important; }
.memo-type-badge { display: inline-block; font-size: 11px; padding: 2px 8px; border-radius: 4px; font-weight: 600; margin-right: 4px; }
.memo-badge-todo { background: #dcfce7; color: #15803d; }
.memo-badge-memo { background: #fef3c7; color: #b45309; }
.memo-content-preview { font-size: 12px; color: var(--text); line-height: 1.5; }
.memo-meta { font-size: 11px; color: var(--muted); }
.memo-src-ai, .memo-src-manual { font-size: 11px; color: var(--muted); margin-right: 4px; }
.memo-kind-btn { transition: background .15s, box-shadow .15s; }
.memo-kind-btn:hover { filter: brightness(1.05); }

.memo-form-box { margin-top: 10px; padding: 16px; border-radius: 10px; border: 2px solid var(--line); background: var(--surface); transition: border-color .2s, background .2s, box-shadow .2s; }
.memo-form-todo { border-color: #16a34a !important; background: rgba(22,163,74,0.06) !important; box-shadow: 0 4px 14px rgba(22,163,74,0.12); }
.memo-form-memo { border-color: #d97706 !important; background: rgba(217,119,6,0.07) !important; box-shadow: 0 4px 14px rgba(217,119,6,0.12); }

.io-pending-row {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr) 56px 72px 20px;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
}
.io-pending-row .list-row-main { min-width: 0; }
.io-pick-slot { display: flex; align-items: center; justify-content: center; }
.io-qty-col { text-align: center; white-space: nowrap; line-height: 1.2; }
.io-qty-num { display: block; font-size: 16px; font-weight: 700; color: var(--primary); }
.io-qty-label { display: block; font-size: 11px; color: var(--muted); }
.io-badge-slot { display: flex; align-items: center; justify-content: center; min-height: 24px; }
.io-table-scroll { overflow-x: auto; margin: 0 -2px; }
.io-qty-table.io-io-table { table-layout: fixed; width: 100%; min-width: 560px; }
.io-outbound-table { min-width: 820px; }
.io-qty-table.io-io-table .col-po { width: 108px; max-width: 108px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.io-qty-table.io-io-table .col-model { width: 120px; max-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.io-qty-table.io-io-table .col-num { width: 56px; }
.io-qty-table.io-io-table .col-input { width: 80px; }
.io-qty-table.io-io-table .col-action { width: 72px; }
.io-qty-table.io-io-table .col-flag { width: 64px; }
.io-qty-table.io-io-table th.io-num,
.io-qty-table.io-io-table td.io-num { text-align: center; }
.io-qty-table.io-io-table input { width: 100%; max-width: 72px; box-sizing: border-box; }

.io-combine-bar { display:flex; align-items:center; gap:10px; margin:0 0 12px; padding:10px 12px; background:#eef6ff; border:1px solid #c9e2ff; border-radius:8px; flex-wrap:wrap; }
.io-combine-bar .order-act-btn.primary:disabled { opacity:0.45; cursor:not-allowed; }
.io-pick-slot input[type=checkbox] { width:16px; height:16px; cursor:pointer; }
