:root {
  --bg: #f4f0e6;
  --panel: #fffdf6;
  --panel-2: #fff8e6;
  --line: #e1c982;
  --line-soft: #efe2b8;
  --ink: #3d2a18;
  --muted: #816a4d;
  --gold: #c99b22;
  --gold-dark: #95670d;
  --green: #2f9b62;
  --red: #c94b37;
  --blue: #2e74a6;
  --shadow: 0 18px 48px rgba(108, 73, 28, .12);
  --radius: 10px;
  --font: "Microsoft YaHei UI", "Microsoft YaHei", "PingFang SC", "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

html,
body {
  height: 100%;
  width: 100%;
  max-width: 100%;
}

body {
  margin: 0;
  color: var(--ink);
  font-family: var(--font);
  font-size: 14px;
  background:
    radial-gradient(circle at 18% 0%, rgba(255, 221, 115, .28), transparent 28%),
    linear-gradient(135deg, #fff9e7 0%, #f4f0e6 48%, #efe4d5 100%);
  overflow: hidden;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  height: 100vh;
  width: 100%;
  min-width: 0;
  display: grid;
  grid-template-rows: auto 1fr;
  gap: 14px;
  padding: 14px;
}

.top-bar {
  display: grid;
  grid-template-columns: auto minmax(520px, 1fr) auto;
  align-items: center;
  gap: 18px;
  min-height: 72px;
  padding: 12px 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background:
    linear-gradient(180deg, rgba(255,255,255,.72), transparent 70%),
    var(--panel);
  box-shadow: var(--shadow);
  min-width: 0;
  max-width: 100%;
}

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

.brand-mark {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 8px;
  border: 1px solid rgba(255,255,255,.8);
  background: linear-gradient(180deg, #f5d466, #bd7a18);
  color: #fff9d7;
  font-weight: 900;
  box-shadow: inset 0 1px rgba(255,255,255,.55), 0 8px 20px rgba(149, 103, 13, .2);
}

.brand h1 {
  margin: 0;
  font-size: 22px;
  line-height: 1.15;
  color: #6c3d16;
}

.brand p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.top-controls {
  display: grid;
  grid-template-columns: minmax(220px, 300px) minmax(160px, 220px) auto;
  align-items: end;
  gap: 12px;
  min-width: 0;
}

.control,
.field {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.control span,
.field span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

input[type="text"],
input[type="number"],
input[type="date"],
select {
  width: 100%;
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 252, 241, .92);
  color: var(--ink);
  padding: 7px 10px;
  outline: none;
}

input:focus,
select:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(201, 155, 34, .18);
}

input[type="radio"],
input[type="checkbox"] {
  width: 15px;
  height: 15px;
  margin: 0;
  accent-color: var(--gold);
}

.switch-line {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 36px;
  padding: 0 12px;
  border: 1px solid var(--line-soft);
  border-radius: 999px;
  background: #fff8e6;
  color: #68481e;
  font-weight: 800;
  white-space: nowrap;
}

.top-actions,
.toolbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  justify-content: flex-end;
}

.btn {
  min-height: 36px;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 0 14px;
  font-weight: 900;
  color: #fff;
}

.btn-refresh {
  background: linear-gradient(180deg, #d9b84c, #b07d17);
  border-color: #9f7116;
}

.btn-reset,
.btn-dialog-cancel {
  background: #8c8a82;
  border-color: #77756f;
}

.btn-save,
.btn-dialog-confirm {
  background: linear-gradient(180deg, #4bbb7a, #24844f);
  border-color: #1f7445;
}

.btn-quick-pass {
  background: linear-gradient(180deg, #ef9b45, #c7651f);
  border-color: #ad5318;
}

.workspace {
  min-height: 0;
  min-width: 0;
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr);
  gap: 14px;
}

.sidebar {
  min-height: 0;
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 253, 246, .92);
  box-shadow: var(--shadow);
}

.sidebar-content {
  height: 100%;
  overflow: auto;
  padding: 12px;
}

.sidebar-section {
  border: 1px solid var(--line-soft);
  border-radius: 9px;
  background: rgba(255, 255, 255, .68);
  padding: 12px;
  margin-bottom: 12px;
}

.sidebar-section h4 {
  margin: -2px 0 10px;
  color: #7a541c;
  font-size: 13px;
}

.field-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.field {
  margin-bottom: 10px;
}

.sidebar-section .field:last-child {
  margin-bottom: 0;
}

.choice-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.choice-grid label,
.choice-row label {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 32px;
  padding: 6px 8px;
  border: 1px solid var(--line-soft);
  border-radius: 7px;
  background: #fffaf0;
  color: #584025;
  font-weight: 700;
}

.choice-grid .wide {
  grid-column: 1 / -1;
}

.choice-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 10px;
}

.helper p {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.65;
}

.content-body {
  min-width: 0;
  max-width: 100%;
  min-height: 0;
}

.table-card {
  min-width: 0;
  height: 100%;
  min-height: 0;
  display: grid;
  grid-template-rows: auto auto 1fr;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.table-toolbar {
  min-height: 46px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 14px;
  border-bottom: 1px solid var(--line-soft);
  background: linear-gradient(180deg, #fff9e5, #fff6db);
}

.table-summary {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 12px;
  min-width: 0;
}

.table-toolbar strong {
  display: inline-flex;
  color: #6c3d16;
  font-size: 16px;
  line-height: 1.2;
}

#totalInfo {
  display: inline-flex;
  color: var(--muted);
  font-size: 12px;
}

.audit-stats {
  color: #7d551d;
  font-size: 12px;
  font-weight: 800;
}

.last-submit {
  margin: 8px 12px 0;
  padding: 8px 10px;
  border: 1px solid #ecd79d;
  border-radius: 8px;
  background: #fff8dc;
  color: #75511d;
  font-size: 12px;
  font-weight: 800;
}

.last-submit.hidden {
  display: none;
}

.table-wrapper {
  min-height: 0;
  min-width: 0;
  display: grid;
  grid-template-rows: 1fr auto;
}

.table-scroll {
  min-height: 0;
  min-width: 0;
  overflow: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
  min-width: 1120px;
}

thead {
  position: sticky;
  top: 0;
  z-index: 5;
  background: #f1df9d;
  box-shadow: 0 1px 0 var(--line);
}

th,
td {
  padding: 10px 12px;
  border-bottom: 1px solid #eee4c4;
  text-align: left;
  vertical-align: top;
}

th {
  color: #5b421e;
  font-size: 13px;
}

tbody tr:nth-child(even) {
  background: #fffaf0;
}

tbody tr:hover {
  background: #fff2ca;
}

.risk-row {
  background: #fff2e8 !important;
}

.risk-row:hover {
  background: #ffe5d5 !important;
}

.info-cell {
  color: #4b3720;
  font-size: 13px;
  line-height: 1.55;
}

.item-name {
  color: var(--blue);
  font-weight: 900;
}

.price-val {
  color: #c65e1b;
  font-weight: 900;
}

.risk-badge {
  display: inline-flex;
  max-width: 100%;
  margin-top: 6px;
  padding: 3px 7px;
  border: 1px solid #e6a178;
  border-radius: 999px;
  background: #fff0e4;
  color: #ad4d1b;
  font-size: 12px;
  font-weight: 900;
  line-height: 1.4;
}

.role-name-link {
  color: var(--blue);
  text-decoration: underline;
  cursor: pointer;
}

.role-name-link:hover {
  color: #184e73;
}

.audit-group,
.audit-head-group {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.audit-group label,
.audit-head-group label {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 28px;
  padding: 4px 7px;
  border-radius: 999px;
  background: #fffaf0;
  border: 1px solid var(--line-soft);
  color: #604522;
  font-weight: 800;
}

.th-with-filter {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.btn-name-filter {
  width: 22px;
  height: 22px;
  padding: 0;
  border: 1px solid #d3bd7e;
  border-radius: 6px;
  background: #fff8df;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.btn-name-filter:hover,
.btn-name-filter.active {
  background: #fce9a9;
  border-color: var(--gold);
}

.icon-filter {
  width: 0;
  height: 0;
  border-left: 4px solid transparent;
  border-right: 4px solid transparent;
  border-top: 6px solid #8a6d3b;
  transform: translateY(1px);
}

.pager-bar {
  min-height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px 12px;
  border-top: 1px solid var(--line-soft);
  background: #fffaf0;
}

.pager-bar .controls {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  justify-content: center;
  gap: 7px;
  color: var(--muted);
  font-size: 12px;
}

.pager-bar button {
  min-height: 30px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fffdf6;
  color: #5d4037;
  padding: 0 10px;
  font-weight: 800;
}

#inputPage,
#pageSizeSelect {
  width: auto;
  min-height: 30px;
  padding: 4px 7px;
  font-size: 12px;
}

#inputPage {
  width: 66px;
}

.op-mask,
.dialog-mask {
  position: fixed;
  inset: 0;
  background: rgba(40, 28, 16, .42);
  z-index: 9998;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 18px;
}

.dialog-mask.active {
  display: flex;
}

.op-mask-box,
.dialog-card,
.name-filter-popup {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: 0 18px 48px rgba(35, 25, 16, .22);
}

.op-mask-box {
  min-width: 190px;
  padding: 16px 18px;
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 900;
}

.op-spinner {
  width: 18px;
  height: 18px;
  border: 2px solid var(--line-soft);
  border-top-color: var(--gold);
  border-radius: 50%;
  animation: op-spin .8s linear infinite;
}

@keyframes op-spin {
  to { transform: rotate(360deg); }
}

.dialog-card {
  width: min(440px, calc(100vw - 32px));
  padding: 18px;
}

.dialog-title {
  margin-bottom: 14px;
  color: #7a541c;
  font-size: 17px;
  font-weight: 900;
}

.dialog-row {
  display: grid;
  grid-template-columns: 82px 1fr;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
}

.dialog-row label {
  color: var(--muted);
  font-weight: 800;
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.name-filter-popup {
  position: fixed;
  z-index: 9997;
  width: min(340px, calc(100vw - 24px));
  max-height: min(440px, calc(100vh - 24px));
  display: none;
  overflow: hidden;
}

.name-filter-popup.active {
  display: block;
}

.name-filter-head {
  min-height: 38px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 0 10px;
  border-bottom: 1px solid var(--line-soft);
  background: #fff2c8;
  color: #70501d;
  font-weight: 900;
}

.name-filter-clear {
  min-height: 26px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fffdf6;
  color: #70501d;
  padding: 0 9px;
  font-weight: 800;
}

.name-filter-list {
  max-height: 390px;
  overflow: auto;
  padding: 8px;
}

.name-filter-item {
  width: 100%;
  margin-bottom: 6px;
  padding: 7px 9px;
  border: 1px solid var(--line-soft);
  border-radius: 7px;
  background: #fffaf0;
  color: var(--ink);
  text-align: left;
}

.name-filter-item:hover,
.name-filter-item.active {
  border-color: var(--gold);
  background: #fce9a9;
  font-weight: 900;
}

.name-filter-empty {
  padding: 10px;
  color: var(--muted);
}

@media (max-width: 1100px) {
  body {
    overflow: auto;
    overflow-x: hidden;
  }

  .app-shell {
    height: auto;
    min-height: 100vh;
    overflow-x: hidden;
  }

  .top-bar {
    grid-template-columns: 1fr;
    align-items: stretch;
    min-width: 0;
  }

  .top-controls {
    grid-template-columns: 1fr 1fr;
  }

  .top-actions {
    justify-content: flex-start;
  }

  .workspace {
    grid-template-columns: 1fr;
    min-width: 0;
  }

  .sidebar {
    max-height: none;
  }

  .table-card {
    min-height: 680px;
  }
}

@media (max-width: 680px) {
  .app-shell {
    display: flex;
    flex-direction: column;
    width: 100vw;
    max-width: 100vw;
    padding: 10px;
    gap: 10px;
  }

  .top-bar,
  .workspace,
  .sidebar,
  .content-body,
  .table-card {
    width: calc(100% - 10px);
    max-width: 100%;
  }

  .top-controls,
  .field-grid,
  .choice-grid {
    grid-template-columns: 1fr;
    min-width: 0;
  }

  .brand h1 {
    font-size: 20px;
  }

  .toolbar-actions,
  .top-actions {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    width: 100%;
    min-width: 0;
  }

  .btn {
    width: 100%;
    min-width: 0;
  }

  .table-toolbar {
    align-items: stretch;
    flex-direction: column;
  }

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