:root {
  --ink: #17201d;
  --muted: #66736e;
  --line: #dfe6e2;
  --surface: #ffffff;
  --canvas: #f4f7f5;
  --green: #145c43;
  --green-dark: #0d4633;
  --green-soft: #e5f2ec;
  --amber: #bd7426;
  --red: #a23d3d;
  --shadow: 0 18px 55px rgba(24, 45, 37, 0.09);
  font-family: "Segoe UI", "Microsoft YaHei UI", system-ui, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  color: var(--ink);
  background: var(--canvas);
}

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

button { cursor: pointer; }

.hidden { display: none !important; }

.auth-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 32px;
  background:
    radial-gradient(circle at 15% 15%, rgba(20, 92, 67, 0.14), transparent 34%),
    radial-gradient(circle at 86% 78%, rgba(189, 116, 38, 0.12), transparent 28%),
    #eef3f0;
}

.auth-card {
  width: min(440px, 100%);
  padding: 42px;
  border: 1px solid rgba(255, 255, 255, 0.8);
  border-radius: 24px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
}

.auth-card h1 {
  margin: 6px 0 8px;
  font-size: 30px;
  letter-spacing: -0.03em;
}

.brand-mark {
  position: relative;
  width: 58px;
  height: 46px;
  margin-bottom: 24px;
}

.drop {
  position: absolute;
  width: 28px;
  height: 34px;
  border-radius: 55% 45% 52% 48% / 65% 45% 55% 35%;
  transform: rotate(30deg);
  opacity: 0.88;
}

.drop-cyan { left: 0; top: 8px; background: #1b9aaa; }
.drop-magenta { left: 16px; top: 0; background: #c13c68; }
.drop-yellow { left: 30px; top: 10px; background: #e5a832; }

.eyebrow {
  margin: 0 0 6px;
  color: var(--green);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.16em;
}

.muted, small { color: var(--muted); }

.form-hint {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
}

.stack {
  display: grid;
  gap: 18px;
  margin-top: 28px;
}

label {
  display: grid;
  gap: 7px;
  color: #35423d;
  font-size: 13px;
  font-weight: 700;
}

input, select, textarea {
  width: 100%;
  padding: 11px 13px;
  border: 1px solid #ccd6d1;
  border-radius: 9px;
  color: var(--ink);
  background: #fff;
  outline: none;
  transition: border-color 120ms ease, box-shadow 120ms ease;
}

input:focus, select:focus, textarea:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(20, 92, 67, 0.12);
}

.button {
  padding: 10px 16px;
  border: 1px solid transparent;
  border-radius: 9px;
  font-weight: 750;
}

.button.primary {
  color: #fff;
  background: var(--green);
}

.button.primary:hover { background: var(--green-dark); }

.button.secondary {
  color: var(--green);
  border-color: #c8d6d0;
  background: #fff;
}

.button:disabled, .mini-button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.notice {
  padding: 12px 14px;
  border-radius: 9px;
  color: #6f4a1d;
  background: #fff3df;
  font-size: 13px;
}

.error {
  min-height: 20px;
  margin-bottom: 0;
  color: var(--red);
  font-size: 13px;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 248px 1fr;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 24px 16px;
  color: #eff7f3;
  background: #173e31;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 0 8px 26px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
}

.sidebar-brand strong, .sidebar-brand small { display: block; }
.sidebar-brand small { margin-top: 3px; color: #a9c5b9; }

.mini-mark {
  width: 34px;
  height: 34px;
  border-radius: 10px 15px 10px 15px;
  background: linear-gradient(135deg, #4f9e7d 0 50%, #e0a44f 50%);
  transform: rotate(5deg);
}

nav {
  display: grid;
  gap: 6px;
  margin-top: 24px;
  min-height: 0;
  overflow-y: auto;
}

.nav-item {
  padding: 11px 13px;
  border: 0;
  border-radius: 8px;
  color: #cfe0d9;
  text-align: left;
  background: transparent;
}

.nav-item:hover, .nav-item.active {
  color: #fff;
  background: rgba(255, 255, 255, 0.12);
}

.sidebar-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: auto;
  padding: 18px 8px 0;
  border-top: 1px solid rgba(255, 255, 255, 0.12);
  flex: 0 0 auto;
}

.sidebar-footer strong, .sidebar-footer small { display: block; }
.sidebar-footer small { margin-top: 3px; color: #a9c5b9; }

.text-button {
  border: 0;
  color: #d9e7e1;
  background: transparent;
}

.content { min-width: 0; padding: 32px 38px 56px; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 28px;
}

.topbar h2 { margin: 0; font-size: 27px; }

.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 11px;
  border: 1px solid #cbe0d7;
  border-radius: 999px;
  color: var(--green);
  background: var(--green-soft);
  font-size: 12px;
  font-weight: 700;
}

.status-badge i {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #2f9a70;
  box-shadow: 0 0 0 4px rgba(47, 154, 112, 0.13);
}

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

.metric-card, .panel {
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
  box-shadow: 0 6px 24px rgba(26, 49, 40, 0.04);
}

.metric-card { padding: 22px; }
.metric-card span, .metric-card small { display: block; }
.metric-card span { color: var(--muted); font-size: 13px; }
.metric-card strong { display: block; margin: 10px 0 4px; font-size: 27px; }

.panel { padding: 22px; }
.panel-header { margin-bottom: 20px; }
.panel-header h3 { margin: 0; font-size: 19px; }
.panel-header.split {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 20px;
}

.workflow {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.workflow li { display: flex; gap: 11px; align-items: center; }
.workflow li > span {
  display: grid;
  flex: 0 0 34px;
  height: 34px;
  place-items: center;
  border-radius: 50%;
  color: var(--green);
  background: var(--green-soft);
  font-weight: 800;
}
.workflow strong, .workflow small { display: block; }
.workflow small { margin-top: 3px; }

.inline-form, .button-row {
  display: flex;
  align-items: center;
  gap: 9px;
}

.inline-form input { width: auto; min-width: 150px; }

.audit-filter {
  display: grid;
  grid-template-columns:
    minmax(150px, 0.9fr)
    minmax(190px, 1.15fr)
    minmax(190px, 1.15fr)
    minmax(120px, 0.65fr)
    auto;
  gap: 12px;
  align-items: end;
  margin-bottom: 16px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--canvas);
}

.audit-filter label {
  display: grid;
  gap: 7px;
}

.audit-filter label > span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.audit-filter-actions,
.pagination {
  display: flex;
  align-items: center;
  gap: 9px;
}

.result-summary {
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 13px;
}

.pagination {
  justify-content: flex-end;
  margin-top: 16px;
}

.pagination span {
  min-width: 120px;
  color: var(--muted);
  text-align: center;
}

.pagination strong { color: var(--ink); }

.two-column {
  display: grid;
  grid-template-columns: minmax(320px, 0.85fr) minmax(380px, 1.15fr);
  gap: 18px;
}

.management-layout {
  grid-template-columns: minmax(420px, 0.9fr) minmax(500px, 1.1fr);
}

.user-layout {
  grid-template-columns: minmax(300px, 0.65fr) minmax(620px, 1.35fr);
}

.dashboard-panels {
  align-items: start;
  margin: 18px 0;
}

.compact-stack { margin-top: 0; gap: 14px; }

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.component-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.text-action {
  padding: 3px;
  border: 0;
  color: var(--green);
  background: transparent;
  font-weight: 750;
}

.component-list {
  display: grid;
  gap: 9px;
}

.component-row {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) 130px 32px;
  gap: 8px;
}

.row-remove {
  border: 0;
  border-radius: 8px;
  color: var(--red);
  background: #f9eeee;
  font-size: 20px;
}

.inventory-panel { margin: 18px 0; }
.inventory-operations { margin-bottom: 18px; }

.inventory-notice {
  margin-bottom: 16px;
}

.inventory-form {
  align-items: end;
  flex-wrap: wrap;
}

.inventory-form > input { min-width: 140px; width: auto; flex: 1; }
.inventory-form input[type="number"] { max-width: 170px; }

.color-label {
  display: flex;
  align-items: center;
  gap: 7px;
  white-space: nowrap;
}

.package-label {
  min-width: 150px;
}

.package-label input[type="number"] {
  width: 150px;
}

.color-label input[type="color"] {
  width: 48px;
  height: 42px;
  padding: 4px;
}

.color-chip {
  display: inline-block;
  width: 13px;
  height: 13px;
  margin-right: 7px;
  border: 1px solid rgba(0, 0, 0, 0.16);
  border-radius: 50%;
  vertical-align: -1px;
  background: var(--chip);
}

.action-cell {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.mini-button {
  padding: 6px 9px;
  border: 1px solid var(--green);
  border-radius: 7px;
  color: #fff;
  background: var(--green);
  font-size: 12px;
  font-weight: 700;
}

.secondary-mini {
  color: var(--green);
  border-color: #c8d6d0;
  background: #fff;
}

.danger-mini {
  color: var(--red);
  border-color: #e3c4c4;
  background: #fff;
}

.download-link {
  display: inline-block;
  text-decoration: none;
}

.backup-list { margin-top: 18px; }
.report-production-panel { margin-top: 18px; }

.state-pill {
  display: inline-block;
  padding: 4px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 750;
}

.active-pill { color: var(--green); background: var(--green-soft); }
.inactive-pill { color: var(--muted); background: #eef1ef; }

.actual-usage-input { min-width: 145px; padding: 7px 9px; }
.compact-empty { min-height: 120px; }

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

.recipe-summary-row {
  transition: background 120ms ease;
}

.recipe-summary-row:hover,
.recipe-summary-row.expanded {
  background: #f4f8f6;
}

.recipe-toggle {
  display: inline-grid;
  width: 27px;
  height: 27px;
  margin-right: 7px;
  place-items: center;
  border: 1px solid #c8d6d0;
  border-radius: 7px;
  color: var(--green);
  background: #fff;
  vertical-align: middle;
}

.recipe-toggle span {
  font-size: 21px;
  line-height: 1;
  transform: rotate(0);
  transition: transform 120ms ease;
}

.recipe-toggle[aria-expanded="true"] span {
  transform: rotate(90deg);
}

.recipe-detail-row > td {
  padding: 0 10px 16px 44px;
  background: #f4f8f6;
  white-space: normal;
}

.recipe-detail {
  overflow: hidden;
  border: 1px solid #d8e4de;
  border-radius: 10px;
  background: #fff;
}

.recipe-detail-heading {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 14px;
  border-bottom: 1px solid #e5ebe8;
  color: var(--green);
}

.recipe-component-header,
.recipe-detail-component {
  display: grid;
  grid-template-columns: 54px minmax(140px, 1.4fr) minmax(100px, 1fr) 120px 90px;
  gap: 12px;
  align-items: center;
  padding: 9px 14px;
}

.recipe-component-header {
  color: var(--muted);
  background: #fafcfb;
  font-size: 11px;
  font-weight: 750;
}

.recipe-detail-component + .recipe-detail-component {
  border-top: 1px solid #edf1ef;
}

.recipe-detail-component code {
  color: var(--muted);
}

.recipe-detail-loading {
  padding: 18px;
  color: var(--muted);
  text-align: center;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

th, td {
  padding: 12px 10px;
  border-bottom: 1px solid #edf1ef;
  text-align: left;
  white-space: nowrap;
}

th {
  color: var(--muted);
  font-size: 11px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.empty-state {
  display: grid;
  min-height: 240px;
  place-items: center;
  border: 1px dashed #cdd8d3;
  border-radius: 10px;
  color: var(--muted);
  background: #fafcfb;
}

.result-total {
  display: flex;
  justify-content: space-between;
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
  font-weight: 800;
}

body.modal-open {
  overflow: hidden;
}

.modal-backdrop {
  position: fixed;
  z-index: 1000;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(12, 28, 22, 0.52);
  backdrop-filter: blur(6px);
}

.system-modal {
  position: relative;
  width: min(480px, 100%);
  padding: 30px;
  border: 1px solid rgba(255, 255, 255, 0.72);
  border-radius: 20px;
  background: var(--surface);
  box-shadow: 0 28px 90px rgba(8, 28, 20, 0.28);
  animation: modal-enter 160ms ease-out;
}

.system-modal h3 {
  margin: 0;
  font-size: 23px;
  letter-spacing: -0.025em;
}

.modal-close {
  position: absolute;
  top: 18px;
  right: 18px;
  display: grid;
  width: 34px;
  height: 34px;
  padding: 0;
  place-items: center;
  border: 0;
  border-radius: 9px;
  color: var(--muted);
  background: #f1f5f3;
  font-size: 23px;
  line-height: 1;
}

.modal-close:hover {
  color: var(--ink);
  background: #e7eeea;
}

.modal-symbol {
  display: grid;
  width: 48px;
  height: 48px;
  margin-bottom: 20px;
  place-items: center;
  border-radius: 15px;
  color: var(--green);
  background: var(--green-soft);
  font-size: 23px;
  font-weight: 850;
}

.modal-kicker {
  margin-bottom: 7px;
}

.modal-message {
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.7;
  white-space: pre-line;
}

.modal-input-wrap {
  margin-top: 20px;
}

.modal-input-wrap input {
  padding: 13px 14px;
  border-radius: 11px;
  font-size: 15px;
}

.modal-error {
  min-height: 19px;
  margin: 8px 0 0;
  color: var(--red);
  font-size: 12px;
  font-weight: 650;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.modal-actions .button {
  min-width: 94px;
  padding: 11px 18px;
  border-radius: 10px;
}

.system-modal.danger .modal-symbol {
  color: var(--red);
  background: #f9eeee;
}

.system-modal.danger .modal-confirm {
  background: var(--red);
}

.system-modal.danger .modal-confirm:hover {
  background: #873131;
}

@keyframes modal-enter {
  from {
    opacity: 0;
    transform: translateY(8px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.toast {
  position: fixed;
  z-index: 1100;
  right: 24px;
  bottom: 24px;
  max-width: 360px;
  padding: 13px 16px;
  border-radius: 9px;
  color: #fff;
  background: #203c32;
  box-shadow: var(--shadow);
}

@media (max-width: 900px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; }
  nav { grid-template-columns: repeat(3, 1fr); }
  .sidebar-footer { margin-top: 18px; }
  .content { padding: 24px 18px 40px; }
  .card-grid, .workflow, .two-column { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .panel-header.split { align-items: stretch; flex-direction: column; }
  .inline-form { flex-wrap: wrap; }
  .audit-filter { grid-template-columns: 1fr 1fr; }
  .audit-filter-actions { grid-column: 1 / -1; }
  .recipe-component-header,
  .recipe-detail-component {
    grid-template-columns: 40px minmax(120px, 1fr) 90px;
  }
  .recipe-component-header span:nth-child(3),
  .recipe-detail-component code,
  .recipe-component-header span:nth-child(5),
  .recipe-detail-component span:nth-child(5) {
    display: none;
  }

  .modal-backdrop {
    padding: 16px;
  }

  .system-modal {
    padding: 24px;
    border-radius: 17px;
  }

  .modal-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 560px) {
  .audit-filter { grid-template-columns: 1fr; }
  .audit-filter-actions { grid-column: auto; }
  .audit-filter-actions .button { flex: 1; }
  .pagination { justify-content: space-between; }
}
