:root {
  --bg: #f4f6f8;
  --panel: #ffffff;
  --line: #d9e0e7;
  --text: #1f2a37;
  --muted: #667085;
  --primary: #126b5d;
  --primary-2: #0f766e;
  --danger: #b42318;
  --warn: #b54708;
  --ok: #067647;
  --blue: #175cd3;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Microsoft YaHei", "PingFang SC", "Noto Sans CJK SC", Arial, sans-serif;
}

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

.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, #eef7f4 0%, #f5f7fb 48%, #fff7ed 100%);
}

.login-box {
  width: 420px;
  max-width: calc(100vw - 32px);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 28px;
  box-shadow: 0 18px 45px rgba(16, 24, 40, .12);
}

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

.brand-mark {
  width: 44px;
  height: 44px;
  border-radius: 8px;
  background: var(--primary);
  color: #fff;
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 20px;
}

.brand h1 {
  margin: 0;
  font-size: 20px;
  line-height: 1.35;
}

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

.field { margin-bottom: 14px; }
.field label {
  display: block;
  margin-bottom: 6px;
  font-size: 14px;
  color: #344054;
}

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

textarea { min-height: 76px; resize: vertical; }
input:focus, select:focus, textarea:focus {
  outline: 2px solid rgba(18, 107, 93, .18);
  border-color: var(--primary);
}

.btn {
  border: 0;
  border-radius: 6px;
  padding: 9px 14px;
  cursor: pointer;
  background: #e5e7eb;
  color: #111827;
  white-space: nowrap;
  transition: transform .16s ease, box-shadow .16s ease, background-color .16s ease, border-color .16s ease;
}
.btn.primary { background: var(--primary); color: #fff; }
.btn.submit { background: var(--blue); color: #fff; }
.btn.approve { background: var(--ok); color: #fff; }
.btn.reject, .btn.danger { background: var(--danger); color: #fff; }
.btn.warn { background: var(--warn); color: #fff; }
.btn.ghost { background: #fff; border: 1px solid var(--line); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn:not(:disabled):hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(15, 23, 42, .12);
}
.btn:not(:disabled):active {
  transform: translateY(0);
  box-shadow: none;
}
a.btn { text-decoration: none; display: inline-block; }
a.card { text-decoration: none; }

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

.sidebar {
  background: #16202a;
  color: #dce5ee;
  overflow: auto;
}

.side-head {
  padding: 18px 16px;
  border-bottom: 1px solid rgba(255,255,255,.08);
}
.side-head strong { display: block; color: #fff; font-size: 17px; }
.side-head span { display: block; color: #b8c4d1; font-size: 12px; margin-top: 4px; }

.menu { padding: 10px 8px 24px; }
.menu-group { margin: 7px 0; }
.menu-title {
  width: 100%;
  border: 0;
  background: transparent;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 9px 10px;
  font-size: 13px;
  color: #9fb0c0;
  cursor: pointer;
  text-align: left;
  transition: color .16s ease, background-color .16s ease;
}
.menu-title.active,
.menu-title:hover {
  color: #fff;
}
.menu a {
  display: block;
  color: #eaf0f6;
  text-decoration: none;
  padding: 9px 12px;
  border-radius: 6px;
  font-size: 14px;
  margin: 2px 0;
  background: rgba(255,255,255,.06);
  transition: background-color .18s ease, transform .18s ease;
}
.menu a:hover, .menu a.active { background: rgba(255,255,255,.11); transform: translateX(2px); }
.menu .child { padding-left: 12px; }
.menu-items { padding-bottom: 4px; }
.home-link {
  display: block;
  color: #fff;
  text-decoration: none;
  padding: 10px 12px;
  border-radius: 6px;
  margin: 4px 0 10px;
  background: rgba(255,255,255,.12);
}

.main {
  min-width: 0;
  display: grid;
  grid-template-rows: 58px minmax(0, 1fr);
}

.topbar {
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 18px;
}

.topbar h2 {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
}

.user-box {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 14px;
}

.content {
  overflow: auto;
  padding: 18px;
}

.toolbar {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
  margin-bottom: 14px;
}
.toolbar .search { max-width: 260px; }

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  margin-bottom: 16px;
  animation: panelIn .22s ease both;
}

.panel h3 {
  margin: 0 0 14px;
  font-size: 16px;
}

.cards {
  display: grid;
  grid-template-columns: repeat(5, minmax(150px, 1fr));
  gap: 12px;
}

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  min-height: 86px;
  transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease;
}
.card:hover {
  transform: translateY(-2px);
  border-color: rgba(18, 107, 93, .24);
  box-shadow: 0 12px 26px rgba(15, 23, 42, .08);
}
.card .label { color: var(--muted); font-size: 13px; }
.card .value { margin-top: 8px; font-size: 22px; font-weight: 700; }

.quick {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.home-module { padding: 18px; }
.module-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}
.module-head h3 { margin: 0; }
.module-head span {
  color: var(--muted);
  font-size: 13px;
}
.overview-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(180px, 1fr));
  gap: 12px;
}
.metric-column {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfe;
  padding: 12px;
}
.metric-column h4 {
  margin: 0 0 10px;
  font-size: 15px;
}
.metric-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 9px 0;
  border-top: 1px solid #edf1f5;
}
a.metric-line {
  color: inherit;
  text-decoration: none;
}
.metric-line.clickable {
  margin: 0 -8px;
  padding: 9px 8px;
  border-radius: 6px;
}
.metric-line.clickable:hover {
  background: #eef7f4;
}
.metric-line span {
  color: var(--muted);
  font-size: 13px;
}
.metric-line strong {
  font-size: 15px;
  text-align: right;
}
.segmented {
  display: inline-flex;
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
  margin-bottom: 14px;
}
.segmented button {
  border: 0;
  border-radius: 6px;
  padding: 8px 14px;
  background: transparent;
  color: #475467;
  cursor: pointer;
}
.segmented button.active {
  background: #fff;
  color: var(--primary);
  box-shadow: 0 1px 3px rgba(16, 24, 40, .12);
}
.home-action-panel {
  border-top: 1px solid #eef2f6;
  padding-top: 14px;
}
.empty-inline {
  color: var(--muted);
  font-size: 14px;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(15, 23, 42, .38);
  backdrop-filter: blur(4px);
  animation: fadeIn .16s ease both;
}
.modern-modal {
  width: min(560px, calc(100vw - 32px));
  max-height: calc(100vh - 40px);
  background: #fff;
  border: 1px solid rgba(203, 213, 225, .8);
  border-radius: 10px;
  box-shadow: 0 24px 70px rgba(15, 23, 42, .22);
  overflow: hidden;
  animation: modalPop .18s cubic-bezier(.2,.9,.2,1) both;
  display: flex;
  flex-direction: column;
}
.modal-backdrop.closing {
  animation: fadeOut .14s ease both;
}
.modal-backdrop.closing .modern-modal {
  animation: modalDrop .14s ease both;
}
.form-modal {
  width: min(820px, calc(100vw - 48px));
}
.modern-modal > form {
  min-height: 0;
  display: flex;
  flex-direction: column;
}
.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
}
.modal-head h3 {
  margin: 0;
  font-size: 17px;
}
.modal-close {
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: 6px;
  background: #f2f4f7;
  color: #475467;
  cursor: pointer;
  font-size: 22px;
  line-height: 1;
}
.modal-body {
  padding: 18px;
  overflow: auto;
  min-height: 0;
}
.modal-text {
  margin: 0 0 12px;
  color: #344054;
  line-height: 1.65;
}
.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 14px 18px 18px;
  border-top: 1px solid #edf1f5;
  background: #fff;
}
.detail-grid {
  display: grid;
  gap: 8px;
}
.detail-line {
  display: grid;
  grid-template-columns: 110px minmax(0, 1fr);
  gap: 12px;
  padding: 8px 0;
  border-bottom: 1px solid #edf1f5;
}
.detail-line span {
  color: var(--muted);
}
.detail-line strong {
  font-weight: 600;
  word-break: break-word;
}

.inline-form {
  display: grid;
  grid-template-columns: minmax(220px, 360px) auto;
  gap: 10px;
  align-items: center;
  margin-bottom: 12px;
}

.option-panel table input {
  max-width: 420px;
}

.option-category-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(120px, 1fr));
  gap: 10px;
  margin-bottom: 16px;
}

.option-category {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  min-height: 54px;
  padding: 12px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  text-decoration: none;
}

.option-category span {
  font-weight: 700;
}

.option-category strong {
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
}

.option-category.active {
  border-color: var(--primary);
  background: #eef7f4;
}

.option-table table {
  min-width: 560px;
}

.unit-input {
  display: grid;
  grid-template-columns: minmax(92px, 1fr) 34px;
  align-items: center;
}

.unit-input input {
  border-radius: 6px 0 0 6px;
}

.unit-input span {
  height: 40px;
  display: grid;
  place-items: center;
  border: 1px solid #cbd5e1;
  border-left: 0;
  border-radius: 0 6px 6px 0;
  background: #f8fafc;
  color: var(--muted);
}

.edit-table table {
  min-width: 1180px;
}

.wide-table table {
  min-width: 1880px;
}

.permission-section {
  border: 1px solid var(--line);
  border-radius: 8px;
  margin-bottom: 12px;
  background: #fff;
}
.filter-field {
  display: inline-grid;
  grid-template-columns: auto minmax(180px, 260px);
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 13px;
}

.permission-section summary {
  cursor: pointer;
  padding: 12px 14px;
  font-weight: 700;
  color: var(--text);
}

.permission-section .permission-grid {
  padding: 0 12px 12px;
}

.permission-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(150px, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.check-item {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 9px 10px;
  background: #fff;
  font-size: 14px;
}

.check-item input {
  width: auto;
  margin-right: 6px;
}

.grid-form {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 12px;
}
.form-modal .grid-form {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}
.form-modal .field {
  min-width: 0;
}
.form-modal input,
.form-modal select,
.form-modal textarea {
  min-width: 0;
}
.grid-form .wide { grid-column: span 2; }
.grid-form .full { grid-column: 1 / -1; }

.raw-inbound-head {
  display: grid;
  grid-template-columns: 1.05fr 1fr .9fr .9fr 1fr;
  gap: 10px;
  align-items: end;
}

.raw-inbound-head .field label {
  font-size: 13px;
}

.raw-inbound-head input,
.raw-inbound-head select {
  padding: 8px 9px;
}

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

table {
  border-collapse: collapse;
  width: 100%;
  min-width: 920px;
  font-size: 13px;
}
th, td {
  border-bottom: 1px solid #edf1f5;
  padding: 9px 10px;
  text-align: left;
  vertical-align: top;
  white-space: nowrap;
}
th {
  background: #f8fafc;
  color: #344054;
  font-weight: 700;
  position: sticky;
  top: 0;
}
tr:hover td { background: #fbfdff; }
tr {
  transition: background-color .16s ease;
}

.tag {
  display: inline-block;
  border-radius: 999px;
  padding: 3px 8px;
  font-size: 12px;
  background: #eef2f6;
  color: #344054;
}
.tag.ok { background: #dcfae6; color: #067647; }
.tag.warn { background: #fef0c7; color: #b54708; }
.tag.danger { background: #fee4e2; color: #b42318; }

.message {
  margin: 10px 0;
  padding: 10px 12px;
  border-radius: 6px;
  background: #eff8ff;
  color: #175cd3;
  border: 1px solid #b2ddff;
}
.message.error {
  background: #fef3f2;
  color: #b42318;
  border-color: #fecdca;
}

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

.split {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(360px, .45fr);
  gap: 16px;
}

.qr-img {
  width: 180px;
  height: 180px;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.today-row td {
  color: #b42318;
  background: #fff4f2;
}

.low-yield-row td {
  color: #d92d20;
  background: #fff5f5;
  font-weight: 600;
}

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

.role-picker-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 10px;
  display: grid;
  gap: 10px;
  transition: border-color .18s ease, box-shadow .18s ease, transform .18s ease;
}

.role-picker-item.active {
  border-color: rgba(18, 107, 93, .5);
  box-shadow: 0 10px 24px rgba(18, 107, 93, .11);
}

.role-picker-item.fixed {
  background: #f8fafc;
}

.role-picker-main {
  border: 0;
  background: transparent;
  padding: 0;
  text-align: left;
  cursor: pointer;
  color: var(--text);
}

.role-picker-main:disabled {
  cursor: default;
}

.role-picker-main strong {
  display: block;
  font-size: 16px;
  margin-bottom: 4px;
}

.role-picker-main span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.role-picker-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.single-permission-form {
  max-width: 1180px;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes fadeOut {
  from { opacity: 1; }
  to { opacity: 0; }
}

@keyframes modalPop {
  from { opacity: 0; transform: translateY(10px) scale(.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes modalDrop {
  from { opacity: 1; transform: translateY(0) scale(1); }
  to { opacity: 0; transform: translateY(8px) scale(.985); }
}

@keyframes panelIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.report-raw-yield table th:first-child,
.report-raw-yield table td:first-child {
  width: 92px;
  max-width: 92px;
  white-space: nowrap;
}

@media (max-width: 1100px) {
  .app-shell { grid-template-columns: 220px minmax(0, 1fr); }
  .cards { grid-template-columns: repeat(3, minmax(150px, 1fr)); }
  .grid-form { grid-template-columns: repeat(2, minmax(160px, 1fr)); }
  .form-modal .grid-form { grid-template-columns: 1fr; }
  .split { grid-template-columns: 1fr; }
  .permission-grid { grid-template-columns: repeat(2, minmax(150px, 1fr)); }
}

@media (max-width: 680px) {
  .grid-form,
  .form-modal .grid-form {
    grid-template-columns: 1fr;
  }
  .grid-form .wide {
    grid-column: 1 / -1;
  }
  .modal-backdrop {
    padding: 12px;
  }
  .form-modal {
    width: calc(100vw - 24px);
  }
}
