:root {
  color-scheme: light;
  --ink: #172026;
  --muted: #66737f;
  --line: #d9e0e5;
  --surface: #ffffff;
  --page: #f4f7f8;
  --accent: #0f766e;
  --accent-strong: #0b5f59;
  --warn: #b45309;
  --ok: #15803d;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--page);
  color: var(--ink);
  font-family: "Microsoft YaHei", "Segoe UI", Arial, sans-serif;
}

.auth-page {
  align-items: center;
  display: flex;
  flex-direction: column;
  gap: 14px;
  justify-content: center;
  min-height: 100vh;
  padding: 20px;
}

.auth-panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  max-width: 460px;
  padding: 24px;
  width: 100%;
}

.auth-tabs {
  display: grid;
  gap: 8px;
  grid-template-columns: 1fr 1fr;
  margin-bottom: 14px;
}

.auth-tabs button {
  background: #edf4f3;
  color: var(--accent-strong);
}

.auth-tabs button.active {
  background: var(--accent);
  color: white;
}

.auth-form {
  display: grid;
  gap: 10px;
}

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

.field {
  display: grid;
  gap: 6px;
}

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

.auth-form .field {
  width: 100%;
}

button {
  border: 0;
  border-radius: 6px;
  background: var(--accent);
  color: white;
  cursor: pointer;
  min-height: 42px;
  padding: 0 16px;
}

.file-field,
.upload-button {
  align-items: center;
  background: #edf4f3;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--accent-strong);
  cursor: pointer;
  display: inline-flex;
  font-weight: 700;
  justify-content: center;
  min-height: 42px;
  padding: 0 14px;
  text-align: center;
}

.file-field input,
.upload-button input {
  display: none;
}

.file-note {
  color: var(--muted);
  font-size: 14px;
}

.icp-footer {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.6;
  padding: 8px 0 4px;
  text-align: center;
}

.icp-footer a {
  color: var(--muted);
  text-decoration: none;
}

.icp-footer a:hover {
  color: var(--accent-strong);
  text-decoration: underline;
}

.supplement-note {
  background: #fff1f2;
  border: 1px solid #fb7185;
  border-left: 5px solid #e11d48;
  border-radius: 8px;
  color: #be123c;
  font-size: 15px;
  font-weight: 800;
  padding: 9px 12px;
}

.security-warning {
  background: #fff7ed;
  border: 1px solid #fb923c;
  border-left: 5px solid #ea580c;
  border-radius: 6px;
  color: #9a3412;
  font-size: 13px;
  font-weight: 800;
  margin: 8px 0 0;
  padding: 8px 10px;
}

button:hover {
  background: var(--accent-strong);
}

.ghost-button {
  background: #24323b;
  color: #d7e0e5;
  margin-top: 16px;
  width: 100%;
}

#app {
  display: grid;
  grid-template-columns: 260px 1fr;
  min-height: 100vh;
}

.sidebar {
  background: #172026;
  color: white;
  height: 100vh;
  overflow-y: auto;
  padding: 22px;
  position: sticky;
  top: 0;
}

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

.logo {
  align-items: center;
  display: flex;
  gap: 12px;
  margin-bottom: 18px;
}

.logo.large {
  margin-bottom: 22px;
}

.logo-mark {
  align-items: center;
  background: linear-gradient(135deg, #d72638 0%, #f8c14a 54%, #0f766e 100%);
  border-radius: 8px;
  color: #172026;
  display: inline-flex;
  flex-direction: column;
  font-weight: 800;
  height: 48px;
  justify-content: center;
  line-height: 1;
  width: 48px;
}

.logo-mark span {
  color: white;
  font-size: 20px;
}

.logo-mark i {
  color: white;
  font-size: 11px;
  font-style: normal;
  letter-spacing: 1px;
}

.logo-text strong {
  color: white;
  display: block;
  font-size: 15px;
  line-height: 1.25;
}

.auth-panel .logo-text strong {
  color: var(--ink);
}

.logo-text small,
.topbar p,
.section-title span,
.metric small,
.metric span,
.card span {
  color: var(--muted);
  display: block;
}

.sidebar .logo-text small {
  color: #bac6ce;
}

.user-chip {
  background: #24323b;
  border-radius: 6px;
  color: #d7e0e5;
  margin-bottom: 18px;
  padding: 10px 12px;
}

.company-chip,
.company-switcher {
  background: #101820;
  border: 1px solid #31434e;
  border-radius: 6px;
  color: #d7e0e5;
  display: grid;
  gap: 6px;
  margin-bottom: 16px;
  padding: 10px 12px;
}

.company-switcher span {
  color: #9fb0ba;
  font-size: 12px;
  font-weight: 700;
}

.company-switcher select {
  background: #24323b;
  border: 1px solid #3c505c;
  color: white;
  width: 100%;
}

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

nav button {
  background: transparent;
  color: #d7e0e5;
  text-align: left;
}

nav button.active,
nav button:hover {
  background: #24323b;
}

.workspace {
  align-content: start;
  display: grid;
  gap: 14px;
  min-width: 0;
  padding: 22px;
}

.open-tabs {
  align-items: end;
  background: #dfe7eb;
  border: 1px solid #cdd7dc;
  border-radius: 8px 8px 0 0;
  display: flex;
  gap: 2px;
  min-height: 42px;
  overflow-x: auto;
  overflow-y: hidden;
  padding: 6px 8px 0;
  position: sticky;
  top: 0;
  z-index: 5;
}

.browser-tab {
  align-items: center;
  background: #edf2f4;
  border: 1px solid #c8d3d9;
  border-bottom: 0;
  border-radius: 8px 8px 0 0;
  color: var(--muted);
  cursor: pointer;
  display: inline-flex;
  flex: 0 0 136px;
  gap: 8px;
  height: 34px;
  justify-content: space-between;
  max-width: 180px;
  padding: 0 8px 0 12px;
}

.browser-tab span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.browser-tab.active {
  background: var(--surface);
  color: var(--ink);
}

.tab-close {
  align-items: center;
  background: transparent;
  border-radius: 50%;
  color: var(--muted);
  display: inline-flex;
  flex: 0 0 22px;
  font-size: 18px;
  height: 22px;
  justify-content: center;
  line-height: 1;
  min-height: 22px;
  padding: 0;
  width: 22px;
}

.tab-close:hover {
  background: #d6e0e5;
  color: var(--ink);
}

.topbar,
.panel,
.metric,
.card,
.archive-item {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.topbar {
  align-items: center;
  display: flex;
  justify-content: space-between;
  min-height: 66px;
  padding: 10px 16px;
}

.topbar h1 {
  font-size: 24px;
  line-height: 1.1;
  margin: 0;
}

.topbar p {
  font-size: 12px;
  margin: 0 0 2px;
}

.quick-stats {
  display: flex;
  gap: 14px;
}

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

.actions button {
  min-height: 36px;
}

.toolbar {
  flex-wrap: nowrap;
  justify-content: flex-end;
  max-width: 620px;
}

.toolbar button {
  min-height: 34px;
  padding: 0 14px;
}

.toolbar input {
  flex: 0 1 280px;
  min-height: 34px;
  min-width: 260px;
  padding: 6px 10px;
  width: auto;
}

#saveStatus {
  color: var(--muted);
  font-size: 13px;
  min-width: 80px;
  text-align: right;
}

#saveStatus.ok {
  color: var(--ok);
}

#saveStatus.warn {
  color: var(--warn);
}

.search-results {
  border-top: 1px solid var(--line);
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  grid-column: 1 / -1;
  margin-top: 12px;
  padding-top: 12px;
  width: 100%;
}

.search-results span {
  background: #edf4f3;
  border-radius: 6px;
  color: var(--accent-strong);
  padding: 6px 10px;
}

.quick-stats span {
  border-left: 1px solid var(--line);
  font-size: 24px;
  font-weight: 800;
  min-width: 84px;
  padding-left: 14px;
}

.grid {
  display: grid;
  gap: 14px;
}

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

.metric {
  padding: 18px;
}

.metric.clickable {
  cursor: pointer;
  transition: transform 120ms ease, border-color 120ms ease;
}

.metric.clickable:hover {
  border-color: var(--accent);
  transform: translateY(-1px);
}

.metric strong {
  display: block;
  font-size: 34px;
  margin: 8px 0;
}

.panel {
  padding: 20px;
}

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

.section-title h2 {
  font-size: 22px;
  margin: 0;
}

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

.subsection-title h3 {
  font-size: 17px;
  margin: 0;
}

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

.customer-entry-section {
  background: #f5fbf7;
  border: 1px solid #cfe7d7;
  border-radius: 8px;
  margin-bottom: 20px;
  padding: 16px;
}

.customer-list-section {
  border-top: 2px solid var(--line);
  padding-top: 18px;
}

.title-tools {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
}

.compact-search {
  min-width: 220px;
}

#successToast {
  background: #0f766e;
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: 8px;
  box-shadow: 0 18px 40px rgba(15, 23, 42, 0.18);
  color: #fff;
  font-weight: 700;
  left: 50%;
  opacity: 0;
  padding: 10px 22px;
  pointer-events: none;
  position: fixed;
  top: 18px;
  transform: translate(-50%, -12px);
  transition: opacity 160ms ease, transform 160ms ease;
  z-index: 1000;
}

#successToast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

.form-grid {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  margin-bottom: 18px;
}

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

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

.form-group {
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 10px;
  grid-column: 1 / -1;
  padding: 12px;
}

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

.group-title button {
  min-height: 32px;
  padding: 0 12px;
}

.forex-section {
  background: #f5fbff;
}

.factory-section {
  background: #f6fbf7;
}

.customer-account-section {
  background: #f8fbf8;
}

.customer-fee-section {
  background: #fffaf0;
}

.other-fee-section {
  background: #fffaf0;
}

.forwarder-fee-section {
  background: #f7f4ff;
}

.document-item-section {
  background: #f8fbfb;
}

.forex-record {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(5, minmax(0, 1fr)) 72px;
}

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

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

.customer-bank-account.has-remove {
  grid-template-columns: repeat(3, minmax(0, 1fr)) 72px;
}

.customer-fee-standard {
  display: grid;
  gap: 10px;
  grid-template-columns: 1.2fr 1fr 1fr 1.4fr;
}

.customer-fee-standard.has-remove {
  grid-template-columns: 1.2fr 1fr 1fr 1.4fr 72px;
}

.other-fee-record {
  display: grid;
  gap: 10px;
  grid-template-columns: 2fr 1fr 72px;
}

.forwarder-fee-record {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(5, minmax(0, 1fr)) 72px;
}

.document-item-record {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(9, minmax(84px, 1fr)) 72px;
  overflow-x: auto;
}

.record-remove {
  align-self: end;
  background: #f8e8e7;
  color: #9b2f2a;
  min-height: 42px;
  padding: 0 10px;
}

.maintenance-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
}

.maintenance-tabs button {
  background: #f2f6f7;
  color: var(--muted);
  min-height: 36px;
  padding: 0 14px;
}

.maintenance-tabs button.active {
  background: var(--accent);
  color: #ffffff;
}

.maintenance-section,
.inline-editor {
  margin-top: 12px;
}

.inline-editor {
  border: 1px solid var(--line);
  border-radius: 8px;
  margin-bottom: 18px;
  padding: 12px;
}

.inline-editor summary {
  cursor: pointer;
  font-weight: 700;
}

input,
select,
textarea {
  background: #fbfcfd;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--ink);
  min-height: 42px;
  padding: 10px 12px;
  width: 100%;
}

.amount-input.foreign,
.amount-pill.foreign {
  background: #eaf4ff;
}

.amount-input.rmb,
.amount-pill.rmb {
  background: #fff4d6;
}

.amount-input.factory,
.amount-pill.factory {
  background: #eaf8ee;
}

.amount-pill {
  border-radius: 6px;
  display: inline-block;
  padding: 6px 8px;
}

.order-financial-lines {
  display: grid;
  gap: 6px;
  margin-top: 10px;
}

.money-line {
  align-items: center;
  background: #f6f8f9;
  border: 1px solid var(--line);
  border-radius: 6px;
  display: flex;
  justify-content: space-between;
  padding: 8px 10px;
}

.money-line.foreign {
  background: #eaf4ff;
}

.money-line.rmb,
.money-line.income {
  background: #fff4d6;
}

.money-line.outgoing {
  background: #f8e8e7;
}

.empty.compact {
  margin: 0;
  padding: 8px 0;
}

.receipt-row {
  align-items: stretch;
  display: grid;
  gap: 8px;
  grid-column: span 3;
  grid-template-columns: 96px 1fr;
}

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

.recognition-note {
  color: var(--muted);
  font-size: 13px;
  grid-column: span 3;
  margin: -4px 0 4px;
}

.archive-files {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}

.archive-files span {
  background: #edf4f3;
  border-radius: 6px;
  color: var(--accent-strong);
  padding: 6px 8px;
}

.archive-files button {
  min-height: 30px;
  padding: 0 10px;
}

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

details.card summary {
  cursor: pointer;
  list-style: none;
}

details.card summary::-webkit-details-marker {
  display: none;
}

.customer-stat-card summary {
  display: grid;
  gap: 4px;
}

.customer-stat-sections {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin-top: 14px;
}

.customer-stat-sections section {
  background: #f8fafb;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 12px;
}

.customer-stat-sections h3 {
  font-size: 15px;
  margin: 0 0 10px;
}

.customer-stat-sections p {
  align-items: center;
  border-top: 1px solid #e5eaee;
  display: flex;
  justify-content: space-between;
  margin: 0;
  padding: 8px 0;
}

.customer-stat-sections p:first-of-type {
  border-top: 0;
}

.customer-stat-sections p span {
  color: var(--muted);
  font-size: 13px;
}

.customer-stat-sections p strong {
  text-align: right;
}

.month-switch {
  align-items: center;
  color: var(--muted);
  display: flex;
  gap: 8px;
}

.compact-panel {
  padding-bottom: 12px;
  padding-top: 12px;
}

textarea {
  min-height: 84px;
  resize: vertical;
}

.table-wrap {
  overflow-x: auto;
}

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

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

th {
  color: var(--muted);
  font-weight: 600;
}

td small {
  color: var(--muted);
  display: block;
  margin-top: 4px;
}

.cards,
.archive-list {
  display: grid;
  gap: 12px;
}

.card,
.archive-item {
  padding: 16px;
}

.card > div:first-child {
  align-items: center;
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

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

dt {
  color: var(--muted);
  font-size: 13px;
}

dd {
  font-weight: 700;
  margin: 0;
}

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

.empty {
  color: var(--muted);
}

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

.roadmap p,
.archive-item p {
  margin: 0;
}

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

.ok {
  color: var(--ok);
}

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

  .sidebar {
    padding: 14px;
  }

  nav {
    display: flex;
    overflow-x: auto;
  }

  nav button {
    flex: 0 0 auto;
    text-align: center;
  }

  .workspace {
    padding: 14px;
  }

  .section-title {
    align-items: stretch;
    flex-direction: column;
  }

  .topbar {
    align-items: center;
    flex-direction: row;
    gap: 10px;
  }

  .actions {
    align-items: stretch;
    display: grid;
    grid-template-columns: 1fr;
  }

  .toolbar {
    align-items: center;
    display: flex;
    flex-wrap: nowrap;
  }

  .toolbar input {
    min-width: 0;
  }

  .browser-tab {
    flex-basis: 118px;
  }

  .quick-stats,
  .grid.three,
  .customer-stat-sections,
  .form-grid,
  .form-grid.tall,
  .form-grid.wide,
  .forex-record,
  .factory-record,
  .other-fee-record,
  .forwarder-fee-record,
  .receipt-row,
  dl {
    grid-template-columns: 1fr;
  }

  .receipt-row {
    grid-column: span 1;
  }

  .recognition-note {
    grid-column: span 1;
  }

  .quick-stats {
    display: grid;
  }

  .quick-stats span {
    border-left: 0;
    border-top: 1px solid var(--line);
    padding-left: 0;
    padding-top: 10px;
  }
}

@media print {
  .sidebar,
  .toolbar,
  nav,
  form,
  button,
  .actions {
    display: none !important;
  }

  #app {
    display: block;
  }

  .workspace {
    padding: 0;
  }

  .panel,
  .card,
  .archive-item,
  .metric,
  .topbar {
    border-color: #999;
    break-inside: avoid;
  }
}
