:root {
  --bg: #f4f6ee;
  --surface: #ffffff;
  --surface-2: #fafbf6;
  --surface-3: #eef4e2;
  --ink: #20261d;
  --muted: #68705f;
  --muted-2: #8a927f;
  --line: #dfe5d5;
  --line-strong: #cbd6bd;
  --brand: #6f8f3d;
  --brand-dark: #3f5e20;
  --brand-soft: #eef5df;
  --accent: #b86a2d;
  --danger: #aa3d31;
  --warning-bg: #fff4d8;
  --warning-line: #df9f22;
  --added-bg: #eaf6e9;
  --removed-bg: #fdecea;
  --changed-bg: #fff6dd;
  --shadow-sm: 0 6px 16px rgba(52, 64, 42, 0.07);
  --shadow-md: 0 16px 38px rgba(52, 64, 42, 0.11);
  --radius: 10px;
  --radius-lg: 14px;
  font-family: "Microsoft YaHei", "PingFang SC", Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    linear-gradient(180deg, rgba(111, 143, 61, 0.1), rgba(244, 246, 238, 0) 330px),
    var(--bg);
}

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

button {
  cursor: pointer;
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  font-size: clamp(28px, 4vw, 42px);
  line-height: 1.05;
  letter-spacing: 0;
}

h2 {
  font-size: clamp(22px, 3vw, 32px);
  line-height: 1.15;
}

h3 {
  margin-bottom: 10px;
  font-size: 20px;
  line-height: 1.2;
}

main {
  padding: 22px clamp(14px, 4vw, 48px) 48px;
}

.hidden {
  display: none !important;
}

.view {
  display: none;
}

.active-view {
  display: block;
}

.eyebrow {
  margin-bottom: 6px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0;
  text-transform: uppercase;
}

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

.small {
  font-size: 13px;
  line-height: 1.5;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 30;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 18px;
  border-bottom: 1px solid rgba(111, 143, 61, 0.18);
  padding: 14px clamp(14px, 4vw, 48px);
  background: rgba(250, 251, 246, 0.95);
  backdrop-filter: blur(12px);
}

.brand-block {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 16px;
}

.shop-logo {
  width: 214px;
  height: 64px;
  border: 1px solid #5f7d32;
  border-radius: 10px;
  background: #6f8f3d url("./assets/ru-meet-logo-avocado.png") center / contain no-repeat;
  box-shadow: var(--shadow-sm);
}

.shop-logo::before,
.shop-logo.has-image::before {
  content: "";
}

.top-actions,
.button-row,
.staff-tools {
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
}

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

.nav-button,
.primary-button,
.secondary-button,
.ghost-button,
.tab-button,
.date-filter-button,
.compact-button {
  min-height: 40px;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 0 14px;
  font-weight: 800;
  line-height: 1;
  transition: background 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease;
}

.nav-button,
.secondary-button {
  color: var(--ink);
  border-color: var(--line);
  background: #fff;
}

.nav-button.active,
.primary-button {
  color: #fff;
  border-color: var(--brand-dark);
  background: var(--brand-dark);
}

.ghost-button {
  color: var(--muted);
  border-color: var(--line);
  background: #fff;
}

.danger-button {
  color: var(--danger);
  border-color: #efc8bd;
  background: #fff7f3;
}

.nav-button:hover,
.primary-button:hover,
.secondary-button:hover,
.ghost-button:hover,
.tab-button:hover,
.date-filter-button:hover {
  box-shadow: var(--shadow-sm);
}

.nav-button:active,
.primary-button:active,
.secondary-button:active,
.ghost-button:active,
.tab-button:active,
.date-filter-button:active {
  transform: translateY(1px);
}

.full-button {
  width: 100%;
  margin-top: 9px;
}

.compact-button {
  min-height: 32px;
  padding-inline: 10px;
}

.input-control,
.category-select,
.unit-input,
.sort-input,
.draft-controls input,
.draft-controls textarea {
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 11px;
  color: var(--ink);
  background: #fff;
  outline: none;
}

textarea.input-control,
.draft-controls textarea {
  padding-block: 10px;
  line-height: 1.5;
}

.input-control:focus,
.category-select:focus,
.unit-input:focus,
.sort-input:focus,
.draft-controls input:focus,
.draft-controls textarea:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(111, 143, 61, 0.16);
}

.file-control {
  padding: 8px;
}

.reset-admin-form {
  grid-column: 1 / -1;
  margin-top: 8px;
  border-top: 1px solid var(--line);
  padding-top: 14px;
}

.admin-security-panel {
  margin-top: 18px;
  border-top: 1px solid var(--line);
  padding-top: 18px;
}

.credential-form {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.credential-form button {
  justify-self: start;
}

.field-label {
  display: block;
  margin: 10px 0 5px;
  color: var(--ink);
  font-size: 13px;
  font-weight: 900;
}

.backup-label {
  margin-top: 13px;
}

.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

/* Staff view: mobile-first production list */
#staffView {
  max-width: 1240px;
  margin: 0 auto;
}

#staffView .section-heading {
  position: sticky;
  top: 93px;
  z-index: 20;
  border: 1px solid rgba(111, 143, 61, 0.2);
  border-radius: var(--radius-lg);
  padding: 12px;
  background: rgba(250, 251, 246, 0.96);
  box-shadow: var(--shadow-md);
  backdrop-filter: blur(10px);
}

#staffView .section-heading h2 {
  font-size: clamp(22px, 3vw, 30px);
}

.staff-filter-toggle {
  display: none;
}

.staff-tools {
  align-items: center;
  justify-content: flex-end;
}

.date-filter {
  display: flex;
  flex-wrap: nowrap;
  gap: 7px;
  overflow-x: auto;
  margin: 0 0 12px;
  border: 1px solid rgba(111, 143, 61, 0.2);
  border-radius: var(--radius-lg);
  padding: 8px;
  background: rgba(250, 251, 246, 0.96);
  scrollbar-width: none;
}

#staffView .date-filter {
  position: sticky;
  top: 176px;
  z-index: 19;
  backdrop-filter: blur(10px);
}

.date-filter::-webkit-scrollbar {
  display: none;
}

.date-filter-button {
  flex: 0 0 auto;
  min-width: 78px;
  color: var(--muted);
  border-color: var(--line);
  background: #fff;
}

.date-filter-button span,
.date-filter-button strong,
.date-filter-button small {
  display: block;
}

.date-filter-button strong {
  margin-top: 2px;
  color: var(--ink);
  font-size: 13px;
}

.date-filter-button small {
  margin-top: 2px;
  color: var(--muted);
  font-size: 11px;
}

.date-filter-button.active {
  color: #fff;
  border-color: var(--brand-dark);
  background: var(--brand-dark);
}

.date-filter-button.active strong,
.date-filter-button.active small {
  color: #fff;
}

.filter-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
  border: 1px solid rgba(111, 143, 61, 0.18);
  border-radius: var(--radius);
  padding: 9px 10px;
  color: var(--brand-dark);
  background: rgba(238, 245, 223, 0.8);
  font-size: 13px;
  font-weight: 900;
}

.connection-status {
  display: flex;
  align-items: center;
  gap: 9px;
  margin-bottom: 12px;
  border: 1px solid rgba(111, 143, 61, 0.24);
  border-radius: var(--radius);
  padding: 9px 11px;
  color: var(--brand-dark);
  background: rgba(238, 245, 223, 0.88);
  font-size: 13px;
}

.connection-status > span:last-child {
  display: grid;
  min-width: 0;
  gap: 1px;
}

.connection-status strong,
.connection-status small {
  overflow-wrap: anywhere;
}

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

.connection-dot {
  flex: 0 0 auto;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--brand);
  box-shadow: 0 0 0 4px rgba(111, 143, 61, 0.14);
}

.connection-checking .connection-dot {
  background: var(--warning-line);
  box-shadow: 0 0 0 4px rgba(223, 159, 34, 0.14);
}

.connection-offline,
.connection-error {
  border-color: rgba(170, 61, 49, 0.42);
  color: #7d2c24;
  background: var(--removed-bg);
}

.connection-offline .connection-dot,
.connection-error .connection-dot {
  background: var(--danger);
  box-shadow: 0 0 0 4px rgba(170, 61, 49, 0.13);
}

.change-notice {
  margin-bottom: 14px;
  border: 1px solid var(--warning-line);
  border-radius: var(--radius-lg);
  padding: 13px 14px;
  background: var(--warning-bg);
  box-shadow: 0 10px 24px rgba(184, 106, 45, 0.1);
}

.notice-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 6px;
}

.change-notice strong {
  display: block;
}

.change-notice ul {
  display: grid;
  gap: 4px;
  margin: 8px 0 0;
  padding-left: 18px;
}

.notice-action {
  margin-top: 10px;
}

.read-badge {
  flex: 0 0 auto;
  border-radius: 999px;
  padding: 4px 9px;
  font-size: 12px;
  font-weight: 900;
}

.read-badge.unread {
  color: #fff;
  background: var(--accent);
}

.read-badge.read {
  color: var(--brand-dark);
  background: var(--brand-soft);
}

.staff-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 8px;
  margin-bottom: 12px;
}

.staff-summary-card,
.summary-tile {
  border: 1px solid rgba(111, 143, 61, 0.18);
  border-radius: var(--radius);
  padding: 11px 12px;
  background: #fff;
  min-width: 0;
}

.staff-summary-card span,
.summary-tile span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.staff-summary-card strong,
.summary-tile strong {
  display: block;
  margin-top: 3px;
  color: var(--brand-dark);
  font-size: 23px;
  line-height: 1.15;
  overflow-wrap: anywhere;
}

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

.draft-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(190px, 1fr));
  align-items: start;
  gap: 10px;
  overflow-x: auto;
  padding-bottom: 3px;
}

.day-column {
  min-width: 0;
  border: 1px solid rgba(111, 143, 61, 0.18);
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: #fff;
  box-shadow: var(--shadow-sm);
}

.draft-grid .day-column {
  min-width: 190px;
}

.day-header {
  position: sticky;
  top: 0;
  z-index: 4;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 5px 10px;
  border-bottom: 1px solid var(--line);
  padding: 12px;
  background: linear-gradient(180deg, #f1f7e8, #fff);
}

.day-header strong {
  font-size: 16px;
}

.day-total,
.day-header .event-note {
  grid-column: 1 / -1;
  color: var(--brand-dark);
  font-size: 13px;
  font-weight: 900;
}

.day-body {
  background: #fff;
}

.day-toggle-button {
  min-height: 32px;
  border: 1px solid rgba(111, 143, 61, 0.22);
  border-radius: 8px;
  padding: 0 9px;
  color: var(--brand-dark);
  background: #fff;
  font-weight: 900;
}

.collapsed-day .day-body {
  display: none;
}

.staff-category-section {
  border-bottom: 1px solid var(--line);
}

.staff-category-section:last-child {
  border-bottom: 0;
}

.staff-category-heading {
  position: sticky;
  top: 236px;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  border-bottom: 1px solid rgba(111, 143, 61, 0.16);
  padding: 9px 14px;
  background: #f7faef;
}

.staff-category-heading strong {
  font-size: 15px;
}

.staff-category-heading span {
  color: var(--brand-dark);
  font-size: 13px;
  font-weight: 900;
}

.plan-item {
  display: grid;
  grid-template-columns: 62px minmax(0, 1fr);
  gap: 12px;
  border-bottom: 1px solid var(--line);
  padding: 12px 14px;
  background: #fff;
}

.plan-item:last-child {
  border-bottom: 0;
}

.plan-item:hover,
.draft-card:hover,
.product-row:hover,
.analytics-row:hover,
.event-row:hover,
.history-row:hover {
  background: #fbfcf7;
}

.product-img {
  width: 62px;
  height: 62px;
  border: 1px solid var(--line);
  border-radius: 9px;
  object-fit: cover;
  background: var(--surface-3);
}

.product-name {
  display: block;
  color: var(--ink);
  font-weight: 900;
  line-height: 1.3;
}

.sku-text {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.category-badge,
.change-pill {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  min-height: 23px;
  margin-top: 5px;
  border: 1px solid rgba(111, 143, 61, 0.24);
  border-radius: 999px;
  padding: 3px 8px;
  color: var(--brand-dark);
  background: var(--brand-soft);
  font-size: 12px;
  font-weight: 900;
}

#staffView .plan-item .category-badge {
  display: none;
}

.quantity-line {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 8px;
  margin-top: 9px;
  border: 1px solid rgba(111, 143, 61, 0.2);
  border-radius: 9px;
  padding: 8px 10px;
  background: #fbfcf7;
}

.quantity-line span:first-child {
  color: var(--muted);
  font-size: 12px;
}

.quantity-line span:last-child {
  color: var(--brand-dark);
  font-size: 22px;
  font-weight: 900;
}

.note-text,
.change-text,
.event-note {
  margin-top: 6px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.change-text {
  color: var(--accent);
  font-weight: 900;
}

.change-added {
  background: var(--added-bg);
}

.change-removed {
  background: var(--removed-bg);
  opacity: 0.88;
}

.change-quantity_changed,
.change-note_changed {
  background: var(--changed-bg);
}

/* Admin command center */
.admin-login {
  max-width: 1260px;
  margin: 0 auto;
}

.admin-login {
  border: 1px solid rgba(111, 143, 61, 0.2);
  border-radius: var(--radius-lg);
  padding: 18px;
  background: #fff;
  box-shadow: var(--shadow-md);
}

.login-form {
  display: grid;
  grid-template-columns: repeat(3, minmax(160px, 1fr));
  gap: 10px;
  margin-top: 14px;
}

.admin-message,
.toast {
  margin-bottom: 12px;
  border-radius: var(--radius);
  padding: 11px 13px;
  color: #fff;
  background: var(--brand-dark);
}

.admin-panel {
  width: calc(100vw - 24px);
  max-width: none;
  margin-inline: calc(50% - 50vw + 12px);
  border: 1px solid rgba(111, 143, 61, 0.18);
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: #fff;
  box-shadow: var(--shadow-md);
}

.admin-panel > .section-heading {
  position: relative;
  z-index: 2;
  margin: 0;
  border-bottom: 1px solid var(--line);
  padding: 16px 18px;
  background: linear-gradient(90deg, #eef5df, #fff 62%);
}

.admin-layout {
  display: grid;
  grid-template-columns: 282px minmax(0, 1fr);
  min-height: 620px;
}

.admin-layout.is-side-collapsed {
  grid-template-columns: 0 minmax(0, 1fr);
}

.side-panel {
  max-height: calc(100vh - 170px);
  overflow: auto;
  border-right: 1px solid var(--line);
  padding: 14px;
  background: #fbfcf7;
  scrollbar-width: thin;
}

.side-panel.is-collapsed {
  position: relative;
  z-index: 12;
  width: 0;
  min-width: 0;
  border-right: 0;
  padding: 0;
  overflow: visible;
}

.side-panel.is-collapsed .collapsible-body,
.side-panel.is-collapsed h3,
.side-panel.is-collapsed .field-label,
.side-panel.is-collapsed .input-control,
.side-panel.is-collapsed .full-button,
.side-panel.is-collapsed .csv-import-guide,
.side-panel.is-collapsed .csv-import-report,
.side-panel.is-collapsed .template-actions {
  display: none !important;
}

.side-panel.is-collapsed .panel-collapse-toggle {
  position: sticky;
  top: 12px;
  left: 0;
  width: 42px;
  min-width: 42px;
  min-height: 128px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 5px;
  background: #fff;
  box-shadow: var(--shadow-sm);
  writing-mode: vertical-rl;
  transform: translateX(8px);
}

.side-panel.is-collapsed .panel-collapse-toggle strong {
  writing-mode: horizontal-tb;
}

.work-panel {
  min-width: 0;
  padding: 14px;
  background: linear-gradient(180deg, rgba(238, 245, 223, 0.42), rgba(255, 255, 255, 0) 230px), #fff;
}

.admin-layout.is-side-collapsed .work-panel {
  padding-left: 56px;
}

.admin-workflow-rail {
  display: grid;
  grid-template-columns: repeat(5, minmax(126px, 1fr));
  gap: 8px;
  margin-bottom: 12px;
  border: 1px solid rgba(111, 143, 61, 0.2);
  border-radius: var(--radius-lg);
  padding: 8px;
  background: #f7faef;
}

.workflow-step {
  display: grid;
  grid-template-columns: 30px 1fr;
  align-items: center;
  gap: 2px 8px;
  min-height: 66px;
  border: 1px solid rgba(111, 143, 61, 0.18);
  border-radius: var(--radius);
  padding: 8px 10px;
  color: var(--ink);
  background: #fff;
  text-align: left;
}

.workflow-step span {
  grid-row: 1 / 3;
  display: inline-grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 999px;
  color: var(--brand-dark);
  background: var(--brand-soft);
  font-size: 13px;
  font-weight: 900;
}

.workflow-step strong {
  font-size: 14px;
}

.workflow-step small {
  color: var(--muted);
  font-size: 11px;
}

.workflow-step.done {
  background: #f3f8e8;
}

.workflow-step.active {
  border-color: var(--brand);
  box-shadow: inset 0 0 0 1px rgba(111, 143, 61, 0.22);
}

.workflow-step.warning {
  border-color: var(--warning-line);
  background: var(--warning-bg);
  box-shadow: inset 0 0 0 1px rgba(223, 159, 34, 0.2);
}

.workflow-step.warning span {
  color: #fff;
  background: var(--warning-line);
}

.workflow-step.active span,
.workflow-step.publish-step:hover span {
  color: #fff;
  background: var(--brand-dark);
}

.tabs {
  position: relative;
  top: auto;
  z-index: 16;
  display: flex;
  flex-wrap: nowrap;
  gap: 8px;
  overflow-x: auto;
  margin: 0 -14px 14px;
  border-bottom: 1px solid var(--line);
  padding: 10px 14px;
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(10px);
  scrollbar-width: none;
}

.tabs::-webkit-scrollbar {
  display: none;
}

.tab-button {
  flex: 0 0 auto;
  border-color: var(--line);
  border-radius: 999px;
  color: var(--ink);
  background: #fff;
}

.tab-button.active {
  color: #fff;
  border-color: var(--brand-dark);
  background: var(--brand-dark);
}

.admin-tab {
  display: none;
}

.active-admin-tab {
  display: block;
}

.panel-heading {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 13px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 13px;
}

.panel-heading::after {
  content: "";
  position: absolute;
  left: 0;
  bottom: -1px;
  width: 64px;
  height: 2px;
  border-radius: 999px;
  background: var(--brand);
}

.panel-heading h3 {
  margin-bottom: 4px;
}

.summary-strip {
  display: grid;
  grid-template-columns: repeat(8, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 12px;
}

.summary-strip .summary-tile {
  min-height: 82px;
}

.summary-strip .summary-tile strong {
  font-size: 21px;
}

.summary-strip .summary-tile:last-child strong {
  font-size: 16px;
  line-height: 1.2;
}

.publish-note-panel,
.preflight-panel,
.category-form,
.event-form,
.draft-filter-bar {
  border: 1px solid rgba(111, 143, 61, 0.2);
  border-radius: var(--radius-lg);
  padding: 12px;
  background: #fff;
}

.publish-note-panel,
.preflight-panel {
  margin-bottom: 12px;
}

.publish-note-input {
  width: 100%;
  min-height: 82px;
  resize: vertical;
}

.draft-filter-bar {
  position: sticky;
  top: 214px;
  z-index: 15;
  display: grid;
  grid-template-columns: minmax(130px, 180px) minmax(130px, 180px) minmax(180px, 1fr) auto auto;
  gap: 8px;
  margin-bottom: 12px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: var(--shadow-sm);
  backdrop-filter: blur(10px);
}

.toggle-line {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  width: fit-content;
  min-height: 32px;
  border-radius: 999px;
  padding: 3px 10px 3px 6px;
  color: var(--muted);
  background: var(--surface-2);
  font-size: 13px;
  font-weight: 900;
}

.collapse-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  min-height: 36px;
  border: 0;
  padding: 0;
  color: var(--ink);
  background: transparent;
  text-align: left;
  font-weight: 900;
}

.collapse-toggle strong {
  flex: 0 0 auto;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px 10px;
  color: var(--muted);
  background: #fff;
  font-size: 12px;
}

.collapsible-body {
  margin-top: 8px;
}

.is-collapsed .collapsible-body {
  display: none;
}

.change-preview {
  margin-bottom: 8px;
}

.change-preview-card,
.validation-item {
  border-radius: var(--radius);
  padding: 11px 12px;
}

.change-preview-card {
  border: 1px solid var(--warning-line);
  background: var(--warning-bg);
}

.change-preview-card ul {
  display: grid;
  gap: 4px;
  margin: 8px 0 0;
  padding-left: 18px;
}

.validation-panel {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 8px;
}

.validation-item {
  border: 1px solid var(--line);
  background: var(--surface-2);
}

.validation-ok {
  border-color: #bcd9bd;
  background: #edf8ef;
}

.validation-warning {
  border-color: var(--warning-line);
  background: var(--warning-bg);
}

.validation-danger {
  border-color: #df9288;
  background: var(--removed-bg);
}

.draft-card {
  border-bottom: 1px solid var(--line);
  background: #fff;
}

.draft-card .plan-item {
  padding: 10px;
}

.draft-controls {
  display: grid;
  grid-template-columns: 84px minmax(0, 1fr);
  gap: 7px;
  margin-top: 9px;
}

.draft-controls input {
  text-align: center;
  color: var(--brand-dark);
  font-size: 18px;
  font-weight: 900;
}

.draft-controls textarea {
  min-height: 40px;
  resize: vertical;
}

.category-form {
  display: grid;
  grid-template-columns: minmax(160px, 1fr) auto;
  gap: 8px;
  margin-bottom: 12px;
}

.category-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 8px;
  margin-bottom: 12px;
}

.category-card {
  border: 1px solid rgba(111, 143, 61, 0.18);
  border-radius: var(--radius);
  padding: 10px 12px;
  background: linear-gradient(180deg, rgba(238, 245, 223, 0.75), #fff);
}

.product-list,
.analytics-list,
.history-list,
.event-list {
  display: grid;
  gap: 0;
  border: 1px solid rgba(111, 143, 61, 0.2);
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: #fff;
  box-shadow: var(--shadow-sm);
}

.product-row,
.analytics-row,
.event-row,
.history-row {
  display: grid;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid var(--line);
  padding: 12px;
  background: #fff;
}

.product-row:last-child,
.analytics-row:last-child,
.event-row:last-child,
.history-row:last-child {
  border-bottom: 0;
}

.product-row {
  grid-template-columns: 58px minmax(220px, 1fr) minmax(132px, 170px) minmax(178px, auto);
}

.product-row .product-img,
.analytics-row .product-img {
  width: 58px;
  height: 58px;
}

.product-controls {
  display: grid;
  grid-template-columns: minmax(78px, 110px) minmax(76px, 90px);
  gap: 8px;
}

.category-select,
.unit-input,
.sort-input,
.image-url-input {
  width: 100%;
}

.image-url-input {
  min-height: 34px;
  margin-top: 8px;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 6px 8px;
  color: var(--ink);
  background: #fff;
  font-size: 12px;
}

.history-meta {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.analytics-row {
  grid-template-columns: 58px minmax(200px, 1fr) minmax(180px, 250px) minmax(250px, 0.9fr);
}

.sales-quality-band {
  margin-bottom: 12px;
  border-block: 1px solid var(--line);
  padding: 14px 2px;
}

.sales-quality-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.sales-quality-heading > div {
  display: grid;
  gap: 3px;
}

.quality-kicker {
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

.quality-status {
  flex: none;
  border: 1px solid currentColor;
  border-radius: 999px;
  padding: 4px 9px;
  font-size: 12px;
  font-weight: 900;
}

.quality-ok {
  color: var(--brand-dark);
  background: var(--brand-soft);
}

.quality-warning {
  color: #8a5a00;
  background: #fff6df;
}

.quality-danger {
  color: #a4372a;
  background: #fff0ed;
}

.sales-quality-metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1px;
  margin-top: 12px;
  background: var(--line);
}

.sales-quality-metrics > div {
  display: grid;
  gap: 2px;
  min-width: 0;
  padding: 10px;
  background: var(--surface-2);
}

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

.sales-quality-metrics strong {
  color: var(--brand-dark);
  font-size: 18px;
}

.sales-quality-note {
  margin-top: 10px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.spark-bars {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  align-items: end;
  gap: 4px;
  height: 60px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 8px 8px 0;
  background: var(--surface-2);
}

.spark-bar {
  min-height: 4px;
  border-radius: 4px 4px 0 0;
  background: linear-gradient(180deg, var(--brand), var(--brand-dark));
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(56px, 1fr));
  gap: 7px;
}

.metric-cell {
  border: 1px solid rgba(111, 143, 61, 0.18);
  border-radius: 8px;
  padding: 8px;
  background: #fbfcf7;
}

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

.metric-cell strong {
  display: block;
  margin-top: 2px;
  color: var(--brand-dark);
  font-size: 17px;
}

.trend-up {
  color: var(--brand-dark);
}

.trend-down {
  color: var(--accent);
}

.event-form {
  display: grid;
  grid-template-columns: minmax(130px, 160px) minmax(170px, 1fr) minmax(90px, 120px) minmax(160px, 1fr) auto;
  gap: 8px;
  margin-bottom: 12px;
}

.event-row {
  grid-template-columns: minmax(118px, 150px) minmax(180px, 1fr) minmax(78px, auto) auto;
}

.event-multiplier {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 62px;
  min-height: 38px;
  border-radius: 999px;
  color: var(--brand-dark);
  background: var(--brand-soft);
  font-size: 18px;
  font-weight: 900;
}

.status-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 10px;
}

.status-card {
  border: 1px solid rgba(111, 143, 61, 0.22);
  border-radius: var(--radius-lg);
  padding: 12px;
  background: linear-gradient(180deg, rgba(238, 245, 223, 0.75), #fff);
  box-shadow: var(--shadow-sm);
}

.status-card div {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.status-card span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 900;
}

.status-card strong {
  color: var(--brand-dark);
  font-size: 22px;
}

.status-card p {
  margin-top: 8px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.status-ok {
  border-color: #bcd9bd;
}

.status-warning {
  border-color: var(--warning-line);
}

.status-danger {
  border-color: #df9288;
}

.history-row {
  grid-template-columns: minmax(260px, 1fr) minmax(260px, auto);
}

.history-row > div:first-child strong {
  font-size: 16px;
}

.history-changes {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 6px;
}

.empty-state {
  border: 1px dashed rgba(111, 143, 61, 0.36);
  border-radius: var(--radius-lg);
  padding: 24px;
  color: var(--muted);
  background: rgba(238, 245, 223, 0.5);
  text-align: center;
}

.template-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 9px;
}

.csv-import-guide {
  display: grid;
  gap: 5px;
  margin: -2px 0 10px;
  border: 1px solid rgba(111, 143, 61, 0.18);
  border-radius: var(--radius);
  padding: 10px;
  background: var(--brand-soft);
  font-size: 12px;
  line-height: 1.45;
}

.csv-import-guide strong {
  color: var(--brand-dark);
}

.csv-import-report {
  display: grid;
  gap: 8px;
  margin-top: 12px;
  border: 1px solid rgba(185, 111, 66, 0.3);
  border-radius: var(--radius);
  padding: 10px;
  background: var(--warning-bg);
  font-size: 12px;
  line-height: 1.45;
}

.csv-import-report:empty {
  display: none;
}

.csv-import-report strong {
  color: var(--accent);
}

.csv-import-report span,
.csv-import-report p {
  color: var(--muted);
}

.csv-import-report dl {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  margin: 0;
}

.csv-import-report dl div {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 7px;
  background: var(--surface);
}

.csv-import-report dt {
  color: var(--muted);
  font-size: 11px;
}

.csv-import-report dd {
  margin: 2px 0 0;
  color: var(--brand-dark);
  font-size: 16px;
  font-weight: 900;
}

.csv-import-report ul {
  margin: 0;
  padding-left: 18px;
  color: var(--ink);
}

.csv-next-step {
  display: grid;
  gap: 4px;
  border: 1px solid rgba(111, 143, 61, 0.22);
  border-radius: var(--radius);
  padding: 9px;
  background: var(--brand-soft);
}

.csv-next-step strong {
  color: var(--brand-dark);
}

.csv-report-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.import-history {
  margin-top: 12px;
  border-top: 1px solid var(--line);
  padding-top: 10px;
}

.import-history ul {
  display: grid;
  gap: 6px;
  margin-top: 8px;
}

.import-history li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  border-left: 3px solid var(--brand-soft);
  padding-left: 8px;
}

.import-history-copy {
  display: grid;
  min-width: 0;
  gap: 2px;
}

.import-history span,
.import-history small {
  overflow-wrap: anywhere;
}

.import-history small {
  color: var(--muted);
  font-size: 11px;
}

.import-rollback-button {
  flex: 0 0 auto;
}

@media (max-width: 520px) {
  .import-history li {
    align-items: stretch;
    flex-direction: column;
  }

  .import-rollback-button {
    width: 100%;
  }
}

.meta-list dd {
  overflow-wrap: anywhere;
}

.data-import-card {
  display: grid;
  gap: 4px;
  margin: 8px 0 12px;
  border-left: 4px solid var(--brand);
  padding: 9px 10px;
  background: var(--brand-soft);
}

.data-import-card strong {
  color: var(--brand-dark);
  font-size: 13px;
}

.data-import-card span {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.data-import-card.import-demo {
  border-left-color: var(--accent);
  background: #fff3eb;
}

.csv-import-report .compact-button {
  min-height: 32px;
  padding: 0 10px;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(31, 38, 31, 0.44);
  backdrop-filter: blur(6px);
}

.modal-panel {
  width: min(760px, 100%);
  max-height: 86vh;
  overflow: auto;
  border-radius: var(--radius-lg);
  background: #fff;
  box-shadow: 0 24px 80px rgba(31, 38, 31, 0.24);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid var(--line);
  padding: 16px;
  background: linear-gradient(90deg, rgba(238, 245, 223, 0.9), #fff);
}

.modal-content {
  display: grid;
  gap: 10px;
  padding: 16px;
}

.modal-content section {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  background: var(--surface-2);
}

.modal-content p {
  color: var(--muted);
  line-height: 1.7;
}

.back-to-top-button {
  position: fixed;
  right: 18px;
  bottom: 86px;
  z-index: 55;
  min-width: 58px;
  min-height: 42px;
  border: 1px solid rgba(111, 143, 61, 0.26);
  border-radius: 999px;
  color: #fff;
  background: var(--brand-dark);
  font-weight: 900;
  box-shadow: var(--shadow-md);
}

@media (max-width: 1180px) {
  .draft-grid {
    grid-template-columns: repeat(4, minmax(210px, 1fr));
  }

  .draft-grid .day-column {
    min-width: 210px;
  }

  .analytics-row {
    grid-template-columns: 58px minmax(180px, 1fr) minmax(190px, 240px);
  }

  .analytics-row .metric-grid {
    grid-column: 2 / -1;
  }
}

@media (max-width: 900px) {
  .app-header {
    grid-template-columns: 1fr;
    align-items: stretch;
  }

  .brand-block {
    grid-template-columns: auto minmax(0, 1fr);
  }

  .top-actions {
    width: 100%;
  }

  .top-actions .nav-button,
  .top-actions .secondary-button,
  .top-actions .ghost-button {
    flex: 1 1 0;
  }

  .admin-panel > .section-heading,
  .tabs,
  .draft-filter-bar {
    position: static;
  }

  .admin-layout,
  .admin-layout.is-side-collapsed {
    grid-template-columns: 1fr;
  }

  .side-panel {
    max-height: none;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .side-panel.is-collapsed {
    display: block;
  }

  .side-panel.is-collapsed .panel-collapse-toggle {
    writing-mode: horizontal-tb;
    min-height: 42px;
    width: 100%;
  }

  .work-panel {
    padding: 12px;
  }

  .admin-workflow-rail {
    display: flex;
    overflow-x: auto;
    margin-inline: -12px;
    border-inline: 0;
    border-radius: 0;
    scrollbar-width: none;
  }

  .admin-workflow-rail::-webkit-scrollbar {
    display: none;
  }

  .workflow-step {
    flex: 0 0 152px;
  }

  .tabs {
    margin-inline: -12px;
    padding-inline: 12px;
  }

  .draft-grid {
    grid-template-columns: 1fr;
    overflow: visible;
  }

  .draft-grid .day-column {
    min-width: 0;
  }

  .draft-filter-bar {
    grid-template-columns: 1fr 1fr;
  }

  .draft-filter-bar #draftSearchInput,
  .draft-filter-bar #resetDraftFiltersButton {
    grid-column: 1 / -1;
  }

  .product-row {
    grid-template-columns: 58px minmax(0, 1fr);
  }

  .product-row .category-select,
  .product-row .product-controls,
  .analytics-row .spark-bars,
  .analytics-row .metric-grid,
  .history-changes {
    grid-column: 1 / -1;
  }

  .analytics-row,
  .event-row,
  .history-row {
    grid-template-columns: 1fr;
  }

  .event-form,
  .category-form {
    grid-template-columns: 1fr;
  }

  .history-changes {
    justify-content: flex-start;
  }
}

@media (max-width: 720px) {
  .admin-panel {
    width: calc(100vw - 20px);
    margin-inline: calc(50% - 50vw + 10px);
  }

  .credential-form {
    grid-template-columns: 1fr;
  }

  .credential-form button {
    width: 100%;
  }
  body {
    padding-bottom: 82px;
  }

  .sales-quality-metrics {
    grid-template-columns: 1fr 1fr;
  }

  .app-header {
    position: sticky;
    gap: 10px;
    padding: 9px 10px;
  }

  .brand-block {
    gap: 10px;
  }

  .shop-logo {
    width: 136px;
    height: 44px;
  }

  h1 {
    font-size: 22px;
  }

  main {
    padding: 10px 10px 32px;
  }

  #staffView .section-heading {
    top: 62px;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: start;
    gap: 10px;
    margin-bottom: 10px;
    padding: 10px;
  }

  #staffView .section-heading > div:first-child {
    min-width: 0;
  }

  #staffView .section-heading h2 {
    font-size: 21px;
  }

  .staff-filter-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 38px;
  }

  #staffView .staff-filter-toggle {
    grid-column: 2;
    grid-row: 1;
  }

  #staffView .staff-tools {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }

  #staffView:not(.staff-filters-open) .staff-tools {
    display: none;
  }

  #staffView.staff-filters-open .staff-tools {
    display: grid;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 9px;
    background: #fff;
  }

  #staffWeekSelect,
  #staffSearchInput,
  #resetStaffFiltersButton {
    grid-column: 1 / -1;
  }

  .change-only-toggle {
    justify-content: center;
  }

  #printPlanButton,
  #exportPlanButton {
    position: fixed;
    z-index: 50;
    bottom: max(12px, env(safe-area-inset-bottom));
    width: calc(50% - 18px);
    min-height: 52px;
    box-shadow: var(--shadow-md);
  }

  #printPlanButton {
    left: 12px;
  }

  #exportPlanButton {
    right: 12px;
  }

  #staffView .date-filter {
    top: 139px;
    margin-inline: -10px;
    border-inline: 0;
    border-radius: 0;
    padding-inline: 10px;
  }

  .date-filter-button {
    min-width: 74px;
    padding-inline: 10px;
  }

  .filter-summary {
    align-items: stretch;
  }

  .connection-status {
    margin-inline: 0;
    padding: 10px 11px;
  }

  .change-notice {
    max-height: 260px;
    overflow: auto;
    padding: 12px;
  }

  .change-notice ul {
    max-height: 150px;
    overflow: auto;
    padding-right: 4px;
  }

  .notice-heading {
    align-items: flex-start;
  }

  .staff-summary {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    margin-inline: -10px;
    padding: 0 10px 3px;
    scrollbar-width: none;
  }

  .staff-summary::-webkit-scrollbar {
    display: none;
  }

  .staff-summary-card {
    flex: 0 0 112px;
    padding: 9px 10px;
  }

  .staff-summary-card strong {
    font-size: 19px;
  }

  .day-column {
    border-radius: var(--radius-lg);
  }

  .day-header {
    top: 0;
    padding: 12px;
  }

  .staff-category-heading {
    position: static;
    padding: 8px 12px;
  }

  .plan-item {
    grid-template-columns: 56px minmax(0, 1fr);
    gap: 10px;
    padding: 11px;
  }

  .product-img {
    width: 56px;
    height: 56px;
  }

  .quantity-line {
    padding: 8px 9px;
  }

  .quantity-line span:last-child {
    font-size: 20px;
  }

  .admin-panel {
    border-radius: var(--radius-lg);
  }

  .admin-panel > .section-heading {
    display: grid;
    gap: 10px;
    padding: 12px;
  }

  .admin-panel > .section-heading .button-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    width: 100%;
  }

  .summary-strip,
  .status-grid,
  .validation-panel {
    grid-template-columns: 1fr 1fr;
  }

  .summary-tile strong {
    font-size: 19px;
  }

  .publish-note-panel,
  .preflight-panel,
  .draft-filter-bar,
  .category-form,
  .event-form {
    padding: 10px;
  }

  .draft-filter-bar {
    grid-template-columns: 1fr;
  }

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

  .login-form {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 460px) {
  .top-actions {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .top-actions .nav-button,
  .top-actions .secondary-button,
  .top-actions .ghost-button {
    min-width: 0;
    padding-inline: 8px;
  }

  .summary-strip,
  .status-grid,
  .validation-panel,
  .metric-grid {
    grid-template-columns: 1fr;
  }

  .shop-logo {
    width: 126px;
    height: 42px;
  }

  .product-img {
    width: 50px;
    height: 50px;
  }

  .plan-item {
    grid-template-columns: 50px minmax(0, 1fr);
  }

  .quantity-line {
    grid-template-columns: 1fr;
    gap: 2px;
  }
}

@media print {
  @page {
    size: A4 portrait;
    margin: 10mm;
  }

  body {
    padding: 0;
    color: #111;
    background: #fff;
  }

  .app-header,
  .top-actions,
  .staff-tools,
  .date-filter,
  .connection-status,
  .filter-summary,
  #adminView,
  .back-to-top-button,
  .day-toggle-button,
  .change-notice.read-collapsed,
  .change-notice .small {
    display: none !important;
  }

  main {
    padding: 0;
  }

  #staffView,
  .active-view {
    display: block !important;
  }

  #staffView .section-heading {
    position: static;
    border: 0;
    padding: 0 0 8px;
    box-shadow: none;
  }

  .change-notice {
    break-inside: avoid;
    margin-bottom: 8px;
    padding: 8px;
    box-shadow: none;
  }

  .staff-summary {
    display: none;
  }

  .plan-grid {
    gap: 0;
  }

  .day-column {
    break-after: page;
    border: 1px solid #bbb;
    border-radius: 0;
    box-shadow: none;
  }

  .day-column:last-child {
    break-after: auto;
  }

  .day-header,
  .staff-category-heading {
    position: static;
    background: #f4f4f4;
  }

  .plan-item {
    break-inside: avoid;
    grid-template-columns: 42px 1fr;
    padding: 6px;
  }

  .product-img {
    width: 42px;
    height: 42px;
  }

  .quantity-line {
    border: 0;
    padding: 0;
    background: transparent;
  }
}
