:root {
  --font-sans: "Microsoft YaHei", "PingFang SC", "Noto Sans SC", Arial, sans-serif;
  --nav: #082b5f;
  --nav-2: #0b2f66;
  --nav-hover: rgba(255,255,255,.08);
  --primary: #1463ff;
  --primary-dark: #0f4fd6;
  --primary-soft: #eaf2ff;
  --bg: #f5f7fb;
  --panel: #ffffff;
  --line: #e5eaf3;
  --ink: #172033;
  --muted: #667085;
  --success: #12a150;
  --success-soft: #e8f7ef;
  --warning: #f59e0b;
  --warning-soft: #fff7e6;
  --danger: #e5484d;
  --danger-soft: #fff0f0;
  --gray-soft: #f2f4f7;
  --shadow: 0 10px 30px rgba(16, 24, 40, .08);
  --shadow-sm: 0 4px 14px rgba(16, 24, 40, .06);
  --radius: 16px;
}

* { box-sizing: border-box; }

html { background: var(--bg); }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.58;
  -webkit-font-smoothing: antialiased;
}

aside {
  position: fixed;
  inset: 0 auto 0 0;
  width: 276px;
  padding: 18px 14px;
  color: #fff;
  background:
    radial-gradient(circle at 28px 28px, rgba(20,99,255,.30), transparent 28%),
    linear-gradient(180deg, var(--nav-2) 0%, #061f49 100%);
  box-shadow: 8px 0 24px rgba(8,43,95,.18);
  overflow-y: auto;
  z-index: 10;
}

.brand,
.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 68px;
  padding: 8px 8px 18px;
  margin-bottom: 6px;
  border-bottom: 1px solid rgba(255,255,255,.10);
}

.sidebar-brand-logo {
  width: 48px;
  height: 48px;
  flex: 0 0 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 12px;
  background: #fff;
  overflow: hidden;
  box-shadow: 0 6px 18px rgba(0,0,0,.18);
}

.logo-img,
.sidebar-brand-logo img {
  display: block;
  width: 40px;
  height: 40px;
  max-width: 40px;
  max-height: 40px;
  object-fit: contain;
  object-position: center;
  flex-shrink: 0;
}

.brand strong,
.sidebar-brand strong {
  display: block;
  color: #fff;
  font-size: 15px;
  line-height: 1.2;
  font-weight: 800;
  letter-spacing: .01em;
}

.brand small,
.sidebar-brand small {
  display: block;
  margin-top: 3px;
  color: #b8c7df;
  font-size: 11px;
  font-weight: 600;
}

.sidebar-brand-text {
  min-width: 0;
}

nav { padding-bottom: 20px; }

.nav-label {
  margin: 17px 8px 6px;
  color: #9eb1cf;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .08em;
}

nav a,
.nav-disabled {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 40px;
  margin: 3px 0;
  padding: 9px 12px 9px 18px;
  border-radius: 10px;
  color: #dbe7f8;
  text-decoration: none;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: background .18s ease, color .18s ease, transform .18s ease;
}

nav a.sub { padding-left: 18px; }

nav a span,
.nav-disabled span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.menu-icon {
  width: 18px;
  height: 18px;
  flex: 0 0 18px;
  color: #a8c3e8;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.85;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: color .18s ease, transform .18s ease;
}

nav a:hover {
  background: var(--nav-hover);
  color: #fff;
}

nav a:hover .menu-icon {
  color: #ffffff;
}

nav a.active {
  color: #fff;
  background: linear-gradient(90deg, rgba(20,99,255,.95), rgba(20,99,255,.54));
  box-shadow: 0 8px 20px rgba(20,99,255,.25);
}

nav a.active .menu-icon {
  color: #ffffff;
}

nav a.active::before {
  content: "";
  position: absolute;
  left: 0;
  top: 9px;
  bottom: 9px;
  width: 4px;
  border-radius: 0 4px 4px 0;
  background: #ffffff;
}

.nav-disabled {
  opacity: .45;
  cursor: not-allowed;
}

.nav-disabled .menu-icon {
  color: #a8c3e8;
}

.nav-disabled::after {
  content: "预留";
  margin-left: auto;
  padding: 1px 6px;
  border: 1px solid rgba(255,255,255,.25);
  border-radius: 999px;
  font-size: 10px;
  color: #d7e4f7;
}

main {
  margin-left: 276px;
  min-height: 100vh;
  max-width: none;
  padding: 24px 28px 36px;
}

header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin: 0 0 22px;
  padding: 0;
  background: transparent;
}

.page-heading { min-width: 0; }

.breadcrumb {
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

h1 {
  margin: 0;
  color: var(--ink);
  font-size: 25px;
  line-height: 1.2;
  font-weight: 900;
  letter-spacing: -.02em;
}

h2 {
  margin: 0 0 12px;
  color: var(--ink);
  font-size: 18px;
  line-height: 1.35;
  font-weight: 900;
}

h3 {
  margin: 0 0 10px;
  color: var(--ink);
  font-size: 15px;
  line-height: 1.4;
  font-weight: 850;
}

small,
.hint,
.muted {
  color: var(--muted);
  font-size: 12px;
}

.userbox {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 7px 10px 7px 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255,255,255,.88);
  box-shadow: var(--shadow-sm);
  backdrop-filter: blur(8px);
}

.user-name {
  color: var(--ink);
  font-weight: 800;
}

.role-badge,
.badge,
.tag {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 24px;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
  line-height: 1;
  background: #e9efff;
  color: #2446a8;
}

.role-admin { background: #e9efff; color: #2446a8; }
.role-super_admin { background: #e9efff; color: #2446a8; }
.role-hefei_admin { background: #dcfce7; color: #047857; }
.role-hefei_operator { background: var(--success-soft); color: #087443; }
.role-shanghai_admin { background: #ede9fe; color: #5b21b6; }
.role-shanghai_operator { background: #f1eaff; color: #6034a6; }
.role-finance_viewer { background: var(--warning-soft); color: #a15c00; }
.role-finance_reviewer { background: var(--warning-soft); color: #a15c00; }

.card,
.panel,
.location,
.todo-card,
.permission-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: var(--shadow-sm);
}

.panel {
  margin-bottom: 18px;
  padding: 20px 22px;
}

.card {
  padding: 20px;
}

.card.accent {
  border-top: 0;
  position: relative;
  overflow: hidden;
}

.card.accent::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 4px;
  background: var(--primary);
}

.card:hover,
.todo-card:hover,
.location-card:hover {
  border-color: #c7d8fb;
  box-shadow: var(--shadow);
}

.cards,
.group-grid {
  gap: 16px;
}

.panel-title,
.section-title {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 16px;
  color: var(--muted);
}

.panel-title h2,
.section-title h2 {
  margin: 0 0 4px;
}

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

.metrics {
  gap: 16px;
}

.metrics strong,
.big,
.todo-card strong {
  display: block;
  color: var(--ink);
  font-size: 30px;
  line-height: 1.15;
  font-weight: 900;
  letter-spacing: -.03em;
}

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

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

.todo-card {
  display: block;
  padding: 16px;
  color: var(--ink);
  text-decoration: none;
}

.todo-card b,
.todo-card small,
.todo-card span {
  display: block;
}

.todo-card b {
  color: #344054;
  font-size: 13px;
}

.todo-card strong {
  margin: 7px 0 4px;
  color: var(--primary);
}

.quick-actions,
.filter,
.toolbar {
  display: flex;
  align-items: end;
  flex-wrap: wrap;
  gap: 10px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--panel);
}

.quick-actions {
  align-items: center;
}

button,
.button,
input,
select,
textarea {
  font: inherit;
  border-radius: 9px;
}

input,
select,
textarea {
  min-height: 40px;
  padding: 9px 11px;
  border: 1px solid #ccd6e5;
  background: #fff;
  color: var(--ink);
  transition: border-color .16s ease, box-shadow .16s ease;
}

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

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(20,99,255,.14);
}

label {
  display: flex;
  flex-direction: column;
  gap: 7px;
  color: #344054;
  font-weight: 800;
}

.form-grid {
  gap: 18px 20px;
  margin-top: 16px;
}

button,
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding: 9px 16px;
  border: 1px solid var(--primary);
  background: var(--primary);
  color: #fff;
  text-decoration: none;
  font-weight: 850;
  line-height: 1;
  cursor: pointer;
  box-shadow: 0 6px 16px rgba(20,99,255,.22);
  transition: background .16s ease, border-color .16s ease, box-shadow .16s ease, transform .16s ease;
}

button:hover,
.button:hover {
  border-color: var(--primary-dark);
  background: var(--primary-dark);
  box-shadow: 0 8px 18px rgba(20,99,255,.28);
}

.secondary {
  border-color: #cfd8e6;
  background: #fff;
  color: var(--primary);
  box-shadow: none;
}

.secondary:hover {
  border-color: #b8c9e6;
  background: var(--primary-soft);
  color: var(--primary-dark);
  box-shadow: none;
}

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

.danger:hover {
  border-color: #c9363b;
  background: #c9363b;
}

.link-button {
  min-height: auto;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--primary);
  box-shadow: none;
}

.link-button:hover {
  background: transparent;
  color: var(--primary-dark);
  box-shadow: none;
}

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

table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  background: #fff;
  font-size: 13px;
}

th,
td {
  min-height: 46px;
  padding: 12px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
}

th {
  background: #f8fafd;
  color: #475467;
  font-size: 12px;
  font-weight: 900;
  white-space: nowrap;
}

tbody tr:hover {
  background: #f8fbff;
}

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

.qty,
td.qty,
.numeric {
  text-align: right;
  font-size: 18px;
  font-weight: 900;
}

.tag.green,
.tag.success,
.tag.imported {
  background: var(--success-soft);
  color: #087443;
}

.tag.red,
.tag.error {
  background: var(--danger-soft);
  color: #b42318;
}

.tag.orange,
.tag.pending,
.tag.pending_confirm {
  background: var(--warning-soft);
  color: #b76e00;
}

.tag.gray,
.tag.skipped,
.tag.void {
  background: var(--gray-soft);
  color: #667085;
}

.tag.blue,
.tag.ready {
  background: var(--primary-soft);
  color: var(--primary-dark);
}

.alert {
  margin-bottom: 16px;
  padding: 12px 15px;
  border-radius: 12px;
  border: 1px solid transparent;
  font-weight: 800;
}

.alert.success,
.success {
  border-color: #bfe8d2;
  background: var(--success-soft);
  color: #087443;
}

.alert.error,
.error {
  border-color: #ffd0d0;
  background: var(--danger-soft);
  color: #b42318;
}

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

.empty::before {
  content: "— ";
}

.negative-balance {
  color: #d97706 !important;
  font-weight: 900;
}

.void {
  opacity: .58;
  color: #667085;
}

.void-help {
  margin: 0 0 12px;
  padding: 10px 12px;
  border: 1px solid #fed7aa;
  border-radius: 12px;
  background: #fffaf3;
  color: #8a4b05;
  font-size: 13px;
}

.transaction-row.void td {
  color: #98a2b3;
}

.transaction-row.void td:not(:last-child) {
  text-decoration: line-through;
  text-decoration-thickness: 1px;
  text-decoration-color: #98a2b3;
}

.transaction-row.reverse-row {
  background: #fffaf3;
}

.operation-name {
  display: block;
  color: var(--ink);
  font-weight: 850;
}

.transaction-row.void .operation-name {
  color: #98a2b3;
}

.relation-info,
.void-action-hint {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.void-action-hint {
  flex-basis: 100%;
  color: #9a3412;
}

form.inline .void-action-hint {
  margin-top: -3px;
}

.location {
  padding: 16px;
}

.location summary {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  cursor: pointer;
}

.location summary b {
  font-size: 15px;
}

.location summary strong {
  color: var(--primary);
  font-size: 24px;
  font-weight: 900;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 10px 0;
}

.chips span,
.type-summary span {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 5px 10px;
  border: 1px solid #dbe7fb;
  border-radius: 999px;
  background: #f7faff;
  color: #345071;
  font-size: 12px;
  font-weight: 750;
}

.factory-diff-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
}

.factory-diff-list div {
  padding: 14px;
  border: 1px solid #fed7aa;
  border-radius: 14px;
  background: #fffaf3;
}

.factory-diff-list b,
.factory-diff-list span {
  display: block;
}

.factory-diff-list strong {
  display: block;
  margin-top: 8px;
  font-size: 24px;
  line-height: 1;
}

.business-note,
.factory-note,
.source-note {
  margin: 10px 0 0;
  padding: 10px 12px;
  border: 1px solid #dbe7fb;
  border-radius: 12px;
  background: #f7faff;
  color: #47637f;
  font-size: 13px;
}

.factory-note {
  border-color: #fed7aa;
  background: #fffaf3;
}

.pallet-lines {
  padding: 14px;
  border: 1px dashed #cbd8ea;
  border-radius: 14px;
  background: #fbfdff;
}

.pallet-line {
  gap: 14px;
}

.import-steps {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 16px;
}

.import-steps span {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 7px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: #344054;
  font-weight: 850;
}

.import-warning {
  background: #fffaf3;
}

.receipt-paper {
  color: #111827;
  box-shadow: var(--shadow);
}

.receipt-paper > h1 {
  font-size: 28px;
  font-weight: 900;
  letter-spacing: .03em;
}

.receipt-paper th {
  color: #111827;
  background: #f3f6fb;
}

.print-actions {
  position: sticky;
  top: 12px;
  z-index: 2;
}

.permission-card {
  max-width: 620px;
  margin: 80px auto;
  padding: 26px;
  text-align: center;
}

.center-actions {
  justify-content: center;
}

.login-body {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(circle at 18% 12%, rgba(20,99,255,.36), transparent 28%),
    linear-gradient(135deg, #061f49 0%, var(--nav) 52%, #0c3a78 100%);
}

.login-card {
  width: min(460px, 94vw);
  display: grid;
  gap: 18px;
  padding: 34px;
  border: 1px solid rgba(255,255,255,.22);
  border-radius: 22px;
  background: rgba(255,255,255,.96);
  box-shadow: 0 28px 80px rgba(0,0,0,.28);
}

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

.login-brand-logo {
  width: 88px;
  height: 88px;
  flex: 0 0 88px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 18px;
  background: #fff;
  overflow: hidden;
  box-shadow: 0 8px 24px rgba(15, 35, 80, .12);
}

.login-logo,
.login-brand-logo img {
  display: block;
  width: 72px;
  height: 72px;
  max-width: 72px;
  max-height: 72px;
  object-fit: contain;
  object-position: center;
  flex-shrink: 0;
}

.login-brand h1 {
  margin: 0;
  font-size: 21px;
}

.login-brand p {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.login-card button {
  width: 100%;
  min-height: 44px;
}

@media print {
  body { background: #fff; }
  aside,
  header,
  .print-actions,
  .alert { display: none !important; }
  main {
    margin: 0 !important;
    padding: 0 !important;
    max-width: none !important;
  }
  .receipt-paper {
    border: 0;
    box-shadow: none;
  }
}

@media (max-width: 980px) {
  aside {
    position: static;
    width: auto;
    max-height: 46vh;
    border-radius: 0 0 18px 18px;
  }
  main {
    margin-left: 0;
    padding: 16px;
  }
  header {
    display: block;
  }
  .userbox {
    margin-top: 12px;
    border-radius: 14px;
  }
  .form-grid {
    grid-template-columns: 1fr;
  }
  .wide {
    grid-column: auto;
  }
}
