:root {
  color-scheme: light;
  --ink: #173121;
  --muted: #69796f;
  --line: #e5dccd;
  --paper: #fffaf1;
  --panel: #ffffff;
  --green: #2d6a4f;
  --green-2: #e8f1e9;
  --orange: #e2953b;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--paper);
  color: var(--ink);
  display: grid;
  grid-template-columns: 280px 1fr;
}

button,
input {
  font: inherit;
}

.sidebar {
  background: #173121;
  color: white;
  padding: 32px 26px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.eyebrow {
  color: #b7cfbd;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  margin: 0 0 8px;
  text-transform: uppercase;
}

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

h1 {
  font-size: 34px;
  line-height: 1.05;
  margin-bottom: 28px;
}

h2 {
  font-size: 28px;
  margin-bottom: 6px;
}

h3 {
  font-size: 18px;
  margin-bottom: 0;
}

.stat {
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 8px;
  padding: 18px;
}

.admin-nav {
  display: grid;
  gap: 10px;
}

.admin-nav button {
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.16);
  color: white;
  text-align: left;
}

.admin-nav button.active {
  background: white;
  color: var(--green);
}

.stat span {
  display: block;
  font-size: 32px;
  font-weight: 800;
}

.stat small {
  color: #c5d9cb;
}

.workspace {
  padding: 28px;
  min-width: 0;
}

.toolbar,
.panel-head,
.actions,
.preview-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.toolbar {
  margin-bottom: 22px;
}

.toolbar p,
.preview-row p {
  color: var(--muted);
  margin-bottom: 0;
}

.content-grid {
  display: grid;
  grid-template-columns: minmax(340px, 0.9fr) minmax(420px, 1.1fr);
  gap: 22px;
  align-items: start;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
}

.panel-head {
  margin-bottom: 16px;
}

.panel-head input {
  max-width: 220px;
}

label,
fieldset {
  display: grid;
  gap: 8px;
  color: #314439;
  font-size: 13px;
  font-weight: 700;
  margin: 0 0 14px;
}

fieldset {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
}

legend {
  padding: 0 6px;
}

input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px 13px;
  color: var(--ink);
  background: white;
}

input:focus {
  border-color: var(--green);
  outline: 3px solid rgba(45, 106, 79, 0.12);
}

button {
  border: 0;
  border-radius: 8px;
  padding: 12px 16px;
  background: var(--green);
  color: white;
  cursor: pointer;
  font-weight: 800;
}

button[type="button"] {
  background: var(--green-2);
  color: var(--green);
}

button:disabled {
  cursor: wait;
  opacity: 0.7;
}

.two-columns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

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

.category-choices label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-weight: 700;
}

.category-choices input {
  width: auto;
}

.product-list {
  display: grid;
  gap: 10px;
  max-height: calc(100vh - 180px);
  overflow: auto;
  padding-right: 4px;
}

.customer-list {
  display: grid;
  gap: 14px;
}

.customer-grid {
  display: grid;
  grid-template-columns: minmax(420px, 1.1fr) minmax(340px, 0.9fr);
  gap: 22px;
  align-items: start;
}

.all-order-list {
  display: grid;
  gap: 12px;
  max-height: calc(100vh - 190px);
  overflow: auto;
  padding-right: 4px;
}

.customer-card {
  background: white;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
}

.customer-card.selected {
  border-color: var(--green);
  background: #f7fbf7;
}

.customer-top,
.customer-phone-row,
.customer-meta,
.address-list,
.order-list {
  display: grid;
  gap: 10px;
}

.customer-top {
  grid-template-columns: 1fr auto;
  align-items: start;
}

.customer-phone-row {
  grid-template-columns: 1fr auto;
  align-items: center;
  margin-top: 8px;
}

.client-title,
.client-link {
  background: transparent;
  color: var(--green);
  padding: 0;
  text-align: left;
}

.client-title h3 {
  color: var(--ink);
}

.client-link {
  font-size: 16px;
  font-weight: 900;
}

.customer-actions {
  display: flex;
  gap: 8px;
}

.customer-actions button {
  padding: 8px 11px;
  font-size: 12px;
}

.customer-top h3 {
  margin-bottom: 4px;
}

.customer-top p,
.customer-phone-row p,
.customer-meta,
.address-card p,
.order-card p,
.full-order-card p {
  color: var(--muted);
  margin-bottom: 0;
}

.customer-meta {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin: 14px 0;
}

.address-card,
.order-card,
.full-order-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fffdf8;
}

.full-order-card {
  display: grid;
  gap: 12px;
}

.full-order-head {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 16px;
  align-items: start;
}

.order-total {
  text-align: right;
}

.order-total strong {
  display: block;
}

.order-total span {
  color: var(--muted);
  font-size: 12px;
}

.order-detail-grid {
  display: grid;
  grid-template-columns: minmax(160px, 0.7fr) minmax(220px, 1.3fr);
  gap: 12px;
}

.order-items {
  display: grid;
  gap: 6px;
}

.order-item-row {
  display: grid;
  grid-template-columns: minmax(140px, 1fr) minmax(70px, auto) minmax(60px, auto) minmax(90px, auto);
  gap: 10px;
  align-items: center;
  border-top: 1px solid var(--line);
  padding-top: 7px;
  color: var(--muted);
  font-size: 13px;
}

.order-item-row span:first-child {
  color: var(--ink);
  font-weight: 800;
}

.empty-items {
  color: var(--muted);
  font-size: 13px;
}

.customer-section-title {
  color: var(--ink);
  font-size: 13px;
  font-weight: 800;
  margin: 16px 0 8px;
  text-transform: uppercase;
}

.product-card {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  color: var(--ink);
  padding: 12px;
  display: grid;
  grid-template-columns: 56px 1fr;
  gap: 12px;
  text-align: left;
}

.product-card.active {
  border-color: var(--green);
  background: #f5fbf6;
}

.product-card img,
.preview-row img {
  width: 56px;
  height: 56px;
  object-fit: contain;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #faf6ed;
}

.product-card strong {
  display: block;
  margin-bottom: 3px;
}

.product-card span {
  color: var(--muted);
  display: block;
  font-size: 13px;
  font-weight: 600;
}

.pill {
  background: #fff0da;
  border-radius: 999px;
  color: #9c5a12;
  font-size: 12px;
  font-weight: 800;
  padding: 6px 10px;
}

.preview-row {
  align-items: flex-start;
  justify-content: flex-start;
  margin-bottom: 16px;
}

.preview-row img {
  width: 84px;
  height: 84px;
}

.message {
  min-height: 22px;
  color: var(--green);
  font-weight: 700;
  margin-bottom: 12px;
}

.message.error {
  color: #b42318;
}

.category-list {
  display: grid;
  gap: 8px;
  max-height: calc(100vh - 180px);
  overflow: auto;
  padding-right: 4px;
}

.category-row {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  color: var(--ink);
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  text-align: left;
  gap: 12px;
  font-weight: 400;
}

.category-row.active {
  border-color: var(--green);
  background: #f5fbf6;
}

.category-row strong {
  display: block;
  font-size: 15px;
}

.category-row span {
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
}

button.danger {
  background: #fef3f2;
  color: #b42318;
}

button.danger:hover {
  background: #fee4e2;
}

.affected-panel {
  background: #fffbf0;
  border: 1px solid #f5c36a;
  border-radius: 8px;
  padding: 14px;
  margin-bottom: 14px;
}

.affected-panel > p {
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 10px;
}

.affected-product-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  margin-bottom: 8px;
}

.affected-product-item:last-child {
  margin-bottom: 0;
}

.affected-product-item span {
  font-weight: 700;
  font-size: 14px;
}

.affected-product-item button {
  font-size: 12px;
  padding: 6px 12px;
  flex-shrink: 0;
}

.category-right-column {
  display: flex;
  flex-direction: column;
  gap: 18px;
  min-width: 0;
}

.category-products-list {
  display: grid;
  gap: 8px;
  max-height: 420px;
  overflow-y: auto;
  padding-right: 4px;
}

.cat-product-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  overflow: hidden;
}

.cat-product-main {
  display: grid;
  grid-template-columns: 48px 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 12px;
}

.cat-product-main img {
  width: 48px;
  height: 48px;
  object-fit: contain;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #faf6ed;
}

.cat-product-info strong {
  display: block;
  font-size: 14px;
  margin-bottom: 3px;
}

.cat-product-info span {
  color: var(--muted);
  font-size: 12px;
  display: block;
}

.cat-product-actions {
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-items: stretch;
}

.cat-product-actions button {
  padding: 7px 12px;
  font-size: 12px;
  white-space: nowrap;
}

.cat-transfer-form {
  border-top: 1px solid var(--line);
  background: #fafaf8;
  padding: 12px;
}

.cat-transfer-form > label {
  margin: 0 0 8px;
  font-size: 13px;
  font-weight: 700;
  color: #314439;
  display: grid;
  gap: 6px;
}

.cat-transfer-form select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  color: var(--ink);
  background: white;
  font: inherit;
  cursor: pointer;
}

.cat-transfer-form select:focus {
  border-color: var(--green);
  outline: 3px solid rgba(45, 106, 79, 0.12);
}

.cat-transfer-actions {
  display: flex;
  gap: 8px;
}

.cat-transfer-actions button {
  font-size: 13px;
  padding: 8px 14px;
}

dialog {
  border: none;
  border-radius: 12px;
  padding: 0;
  width: min(600px, 90vw);
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.25);
}

dialog::backdrop {
  background: rgba(23, 49, 33, 0.5);
}

.modal-inner {
  padding: 26px;
}

.modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 22px;
}

.modal-header h2 {
  margin-bottom: 6px;
  font-size: 22px;
}

.modal-header > button {
  background: var(--green-2);
  color: var(--green);
  padding: 8px 13px;
  font-size: 18px;
  line-height: 1;
  flex-shrink: 0;
}

@media (max-width: 980px) {
  body {
    display: block;
  }

  .sidebar {
    display: grid;
    grid-template-columns: 1fr 120px 120px 120px;
    align-items: end;
  }

  .content-grid {
    grid-template-columns: 1fr;
  }

  .customer-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .sidebar,
  .two-columns {
    grid-template-columns: 1fr;
  }

  .toolbar,
  .panel-head,
  .actions,
  .customer-top,
  .customer-phone-row,
  .customer-meta,
  .full-order-head,
  .order-detail-grid,
  .order-item-row {
    align-items: stretch;
    grid-template-columns: 1fr;
    flex-direction: column;
  }

  .panel-head input {
    max-width: none;
  }
}
