:root {
  --bg: #f5f4ef;
  --card: #ffffff;
  --text: #24231f;
  --muted: #6f6b62;
  --line: #e4dfd6;
  --accent: #2f5d50;
  --accent-dark: #24493f;
  --accent-soft: #e6f0ec;
  --accent2: #d8b35c;
  --danger: #b4473f;
  --danger-soft: #fde9e7;
  --warning: #8f6200;
  --warning-soft: #fff3d7;
  --shadow: 0 10px 30px rgba(36, 35, 31, .07);
}

* { box-sizing: border-box; }
html { min-width: 320px; }
body {
  margin: 0;
  min-width: 320px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.45;
}
button, input, select { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .58; }
button:focus-visible, input:focus-visible { outline: 3px solid rgba(47, 93, 80, .28); outline-offset: 2px; }

.top {
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(255, 255, 255, .95);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
}
.wrap { width: min(1120px, 100%); margin: 0 auto; padding: 18px; }
.top-inner { display: flex; justify-content: space-between; gap: 14px; align-items: center; }
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand-mark, .login-mark {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  width: 38px;
  height: 38px;
  border-radius: 12px;
  color: #fff;
  background: var(--accent);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .04em;
}
.brand h1 { margin: 0; font-size: 18px; line-height: 1.1; }
.brand small { display: block; margin-top: 4px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 60vw; }

h1, h2, h3, p { overflow-wrap: anywhere; }
h2 { margin: 0; font-size: clamp(24px, 4vw, 34px); line-height: 1.1; }
h3 { margin: 0 0 5px; font-size: 17px; line-height: 1.25; }
.muted { color: var(--muted); }
.eyebrow { margin: 0 0 6px; color: var(--accent); font-size: 12px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
.page-heading { margin: 12px 0 22px; }
.page-heading p { margin: 8px 0 0; max-width: 720px; }

.card, .item {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow);
}
.card { padding: 18px; }
.item { padding: 15px; box-shadow: none; }
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 14px; }
.metric-grid { margin-bottom: 20px; }
.metric { display: flex; flex-direction: column; gap: 3px; }
.metric-value { color: var(--accent); font-size: 31px; font-weight: 800; line-height: 1; }
.metric-label { color: var(--muted); font-size: 13px; }
.row { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; }
.between { justify-content: space-between; }

.btn {
  min-height: 44px;
  border: 0;
  border-radius: 12px;
  padding: 10px 15px;
  background: var(--accent);
  color: #fff;
  font-weight: 750;
  transition: background .15s ease, transform .15s ease;
}
.btn:hover:not(:disabled) { background: var(--accent-dark); }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn.secondary { background: #eeeae1; color: var(--text); }
.btn.compact { min-height: 40px; padding: 8px 12px; }
.btn.full { width: 100%; margin-top: 18px; }

.input, .qty {
  min-height: 46px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  color: var(--text);
}
.input { width: 100%; padding: 11px 13px; }
.qty { width: 92px; padding: 9px 10px; text-align: center; }
.field-label { display: block; margin: 0 0 6px; color: var(--muted); font-size: 12px; font-weight: 750; }
.inline-label { margin: 0; }
.field-label:not(.inline-label) { margin-top: 14px; }
.check-label { display: inline-flex; align-items: center; gap: 6px; min-height: 44px; color: var(--muted); font-size: 13px; }
.check-label input { width: 18px; height: 18px; accent-color: var(--accent); }
.search-wrap { margin-bottom: 16px; }

.tabs {
  display: flex;
  gap: 8px;
  margin: 4px 0 18px;
  padding: 2px 0 8px;
  overflow-x: auto;
  scrollbar-width: thin;
  -webkit-overflow-scrolling: touch;
}
.tab {
  flex: 0 0 auto;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 9px 14px;
  background: #fff;
  color: var(--text);
  font-weight: 700;
  white-space: nowrap;
}
.tab.active { border-color: var(--accent); background: var(--accent); color: #fff; }

.list { display: flex; flex-direction: column; gap: 12px; }
.product-card, .demand-product, .unit-shipment, .progress-card { overflow: hidden; }
.product-heading, .section-title { gap: 12px; margin-bottom: 14px; }
.variant-list, .unit-demand-list { display: flex; flex-direction: column; gap: 8px; }
.variant-row, .unit-demand, .shipment-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: #fcfbf8;
}
.variant-info, .shipment-info { min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.variant-actions { display: flex; align-items: center; justify-content: flex-end; flex-wrap: wrap; gap: 8px; }
.badge {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  width: fit-content;
  border-radius: 999px;
  padding: 4px 9px;
  background: #efeae1;
  color: #655f55;
  font-size: 12px;
  font-weight: 750;
  white-space: nowrap;
}
.badge.priority { background: var(--warning-soft); color: var(--warning); }
.priority-dot { display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; background: var(--warning-soft); color: var(--warning); font-size: 13px; }

.info-card { display: flex; gap: 12px; align-items: flex-start; margin-top: 18px; background: var(--accent-soft); border-color: #cfe2da; }
.info-card h3 { margin-bottom: 4px; }
.info-card p { margin: 0; }
.info-icon { display: grid; place-items: center; flex: 0 0 auto; width: 27px; height: 27px; border-radius: 50%; background: var(--accent); color: #fff; font-weight: 800; }
.status-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-top: 16px; }
.status-grid > div { display: flex; flex-direction: column; gap: 3px; padding: 10px; border-radius: 12px; background: var(--bg); }
.status-grid span { color: var(--muted); font-size: 11px; }
.status-grid strong { font-size: 21px; }
.pending-note { margin: 12px 0 0; padding-top: 11px; border-top: 1px solid var(--line); color: var(--muted); }
.warning-note { margin-top: 8px; padding: 10px; border-radius: 10px; background: var(--warning-soft); color: var(--warning); font-size: 13px; }
.success-note { margin-top: 8px; padding: 10px; border-radius: 10px; background: var(--accent-soft); color: var(--accent-dark); font-size: 13px; }
.shipment-actions { display: flex; flex-direction: column; gap: 8px; min-width: min(100%, 280px); }
.authorization-card { background: #fcfbf8; }
.authorization-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-top: 14px; }
.authorization-grid > div { display: flex; flex-direction: column; gap: 3px; padding: 10px; border-radius: 12px; background: var(--bg); }
.authorization-grid span { color: var(--muted); font-size: 11px; }
.authorization-grid strong { font-size: 20px; }
.authorization-actions { justify-content: flex-start; margin-top: 12px; }
.badge.success { background: var(--accent-soft); color: var(--accent-dark); }
.badge.danger { background: var(--danger-soft); color: #8a2923; }
.demand-variant { margin-top: 10px; padding: 12px; border-top: 1px solid var(--line); }
.demand-variant > .row { margin-bottom: 8px; }

.login-page { min-height: 100vh; display: grid; place-items: center; padding-top: 8vh; padding-bottom: 8vh; }
.login { width: min(100%, 430px); }
.login-mark { width: 50px; height: 50px; margin-bottom: 20px; border-radius: 16px; font-size: 15px; }
.login h1 { margin: 0 0 7px; font-size: 32px; }
.login > .muted { margin: 0 0 20px; }
.login form { display: flex; flex-direction: column; }
.error, .error-panel { border-color: #f0c5c1; background: var(--danger-soft); color: #8a2923; }
.error { padding: 11px; border-radius: 11px; margin: 12px 0; }
.error-panel p { margin: 6px 0 14px; }
.flash-region { min-height: 0; }
.flash { margin: 0 0 14px; padding: 11px 13px; border-radius: 11px; font-weight: 650; }
.flash.success { background: var(--accent-soft); color: var(--accent-dark); }
.flash.error { background: var(--danger-soft); color: #8a2923; }
.flash.warning { background: var(--warning-soft); color: var(--warning); }
.loading { display: flex; align-items: center; gap: 10px; color: var(--muted); }
.spinner { width: 18px; height: 18px; border: 3px solid #d8e4df; border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.empty { padding: 20px 4px; color: var(--muted); text-align: center; }
.unit-choice { display: flex; flex-direction: column; align-items: flex-start; gap: 7px; text-align: left; cursor: pointer; }
.unit-choice span { color: var(--accent); font-size: 13px; font-weight: 700; }
.admin-card { display: flex; flex-direction: column; gap: 10px; }
.admin-card .input { margin-bottom: 1px; }

@media (max-width: 700px) {
  .wrap { padding: 14px; }
  .top-inner { padding-top: 12px; padding-bottom: 12px; }
  .brand h1 { font-size: 16px; }
  .brand small { max-width: 52vw; font-size: 11px; }
  .card { border-radius: 15px; padding: 15px; }
  .page-heading { margin-bottom: 18px; }
  .metric-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
  .metric { padding: 12px; }
  .tabs { flex-wrap: wrap; overflow-x: visible; }
  .tab { flex: 1 1 calc(50% - 8px); min-width: 0; white-space: normal; line-height: 1.2; }
  .metric-value { font-size: 25px; }
  .metric-label { font-size: 11px; }
  .variant-row, .unit-demand, .shipment-row { align-items: stretch; flex-direction: column; }
  .variant-actions { justify-content: flex-start; }
  .shipment-row .variant-actions { justify-content: space-between; }
  .shipment-row .variant-actions .btn { flex: 1 1 180px; }
  .shipment-actions { width: 100%; }
  .authorization-grid { grid-template-columns: repeat(2, 1fr); }
  .status-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 420px) {
  .top-inner { align-items: flex-start; }
  .brand { align-items: flex-start; }
  .brand-mark { width: 34px; height: 34px; border-radius: 10px; }
  .brand h1 { max-width: 45vw; }
  .brand small { white-space: normal; }
  .metric-grid { grid-template-columns: 1fr; }
  .metric { flex-direction: row; align-items: baseline; justify-content: space-between; }
  .metric-value { font-size: 24px; }
  .variant-actions { width: 100%; }
  .variant-actions .qty { flex: 0 0 86px; }
  .variant-actions .btn { flex: 1 1 120px; }
  .shipment-row .variant-actions { display: grid; grid-template-columns: auto 1fr; }
  .shipment-row .variant-actions .inline-label { grid-column: 1 / -1; }
  .shipment-row .variant-actions .btn { grid-column: 1 / -1; width: 100%; }
}
