:root {
  color-scheme: light;
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  color: #1f2937;
  background: #f5f7f9;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: #f3f5f7;
}

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

.op-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  padding: 1.5rem 2rem;
  background: #ffffff;
  border-bottom: 1px solid #e5e7eb;
}

.brand-row {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  flex: 1 1 auto;
  min-width: 0;
}

.brand-label,
.brand-subtitle {
  min-width: 0;
}

.logout-btn {
  flex-shrink: 0;
  white-space: nowrap;
}

.brand-badge {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: #0f5132;
  color: white;
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 1.1rem;
}

.brand-label {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 700;
  letter-spacing: 0.08em;
}

.brand-subtitle {
  margin: 0;
  font-size: 0.85rem;
  color: #4b5563;
}

.logout-btn {
  border: 1px solid #1f8a3e;
  background: #eef8ef;
  color: #1f4726;
  padding: 0.7rem 1rem;
  border-radius: 999px;
  cursor: pointer;
}

.login-main,
.op-main {
  min-height: 100vh;
  display: grid;
}

.op-main {
  align-content: start;
}

.login-main {
  gap: 1.75rem;
  padding: 2rem 1.5rem;
  place-items: center;
  background: #f3f5f7;
}

.op-main {
  gap: 0.25rem;
  padding: 1.75rem 1.5rem 2.5rem;
}

.workflow-panel {
  margin-top: 0;
}

.catalog-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1rem;
  margin-top: 1.5rem;
}

.catalog-card {
  background: white;
  border-radius: 24px;
  padding: 1.25rem 1.3rem;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.08);
  display: grid;
  gap: 0.75rem;
}

.catalog-card-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.catalog-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.45rem 0.75rem;
  border-radius: 999px;
  background: #eef8ef;
  color: #0f5132;
  font-size: 0.85rem;
  font-weight: 700;
}

.catalog-item {
  display: grid;
  grid-template-columns: 6rem 1fr;
  gap: 0.5rem;
  align-items: center;
}

.catalog-input {
  width: 100%;
  padding: 0.75rem 0.85rem;
  border: 1px solid #cbd5e1;
  border-radius: 14px;
  background: white;
  color: #0f172a;
  font-size: 0.95rem;
}

.catalog-card-actions {
  display: flex;
  gap: 0.75rem;
  justify-content: flex-end;
  flex-wrap: wrap;
  margin-top: 1rem;
}

.catalog-label {
  color: #64748b;
  font-size: 0.9rem;
}

.edit-panel {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 20px;
  padding: 1.5rem;
  margin-top: 1.5rem;
}

.edit-search {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.edit-search-label {
  display: grid;
  gap: 0.5rem;
  width: min(100%, 420px);
}

.edit-search-row {
  display: flex;
  gap: 0.75rem;
}

.edit-form {
  margin-top: 1.5rem;
}

.edit-form-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}

.edit-form-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.edit-form .catalog-input {
  margin-top: 0.35rem;
}

.edit-form .catalog-input[readonly] {
  background: #f1f5f9;
  color: #475569;
}

@media (max-width: 1024px) {
  .edit-form-grid {
    grid-template-columns: 1fr;
  }
}

.catalog-card strong {
  font-size: 1rem;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1rem;
}

.summary-card {
  background: white;
  border-radius: 18px;
  padding: 1.35rem 1.25rem;
  height: 120px;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.08);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

@media (min-width: 1025px) {
  .op-main {
    gap: 1rem;
  }

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

.summary-title {
  display: block;
  margin-bottom: 1rem;
  color: #475569;
  font-size: 0.92rem;
}

.summary-value {
  display: block;
  font-size: 2.4rem;
  color: #0f5132;
}

.workflow-panel {
  background: #ffffff;
  border-radius: 24px;
  padding: 1.5rem;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.08);
}

.workflow-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.workflow-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.workflow-header h2 {
  margin: 0;
  font-size: 1.25rem;
}

.workflow-text {
  margin: 0.4rem 0 0;
  color: #64748b;
}

.btn {
  border: 1px solid transparent;
  border-radius: 999px;
  padding: 0.8rem 1.15rem;
  cursor: pointer;
  transition: transform 0.15s ease, background-color 0.15s ease;
}

.btn:hover {
  transform: translateY(-1px);
}

.btn.primary {
  background: #0f5132;
  color: white;
  border-color: #0f5132;
}

.btn.secondary {
  background: white;
  color: #0f5132;
  border-color: #d1fae5;
}

.btn.ghost {
  background: transparent;
  color: #334155;
  border-color: transparent;
}

.order-form {
  margin-top: 1.5rem;
  padding: 1.5rem;
  border-radius: 20px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
}

.hidden {
  display: none;
}

.form-grid {
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.form-grid label {
  display: grid;
  gap: 0.5rem;
  font-size: 0.95rem;
  color: #334155;
}

label.full-width {
  grid-column: 1 / -1;
}

input,
textarea,
select {
  width: 100%;
  padding: 0.85rem 1rem;
  border: 1px solid #cbd5e1;
  border-radius: 14px;
  background: white;
  color: #0f172a;
}

.login-card {
  width: min(520px, 100%);
  background: white;
  border-radius: 28px;
  padding: 2rem;
  box-shadow: 0 30px 60px rgba(15, 23, 42, 0.08);
}

.login-header h1 {
  margin: 0 0 0.5rem;
  font-size: 1.8rem;
}

.login-header p {
  margin: 0;
  color: #64748b;
}

.login-form {
  display: grid;
  gap: 1rem;
  margin-top: 1.5rem;
}

.login-error {
  color: #b91c1c;
  min-height: 1.25rem;
  margin: 0;
}

.login-note {
  margin-top: 1.5rem;
  color: #475569;
  font-size: 0.92rem;
}

.login-form label {
  display: grid;
  gap: 0.5rem;
  font-size: 0.95rem;
  color: #334155;
}

textarea {
  resize: vertical;
}

.product-section {
  margin-top: 1.5rem;
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.order-lines {
  display: grid;
  gap: 1rem;
  margin-top: 1rem;
}

.order-line {
  display: grid;
  gap: 1rem;
  grid-template-columns: 2fr 1fr auto;
  align-items: end;
}

.order-line label {
  margin: 0;
}

.order-line .actions {
  display: grid;
  gap: 0.5rem;
}

.order-line .remove-line {
  height: 3rem;
  border-color: #f8d7da;
  background: #fff1f2;
  color: #b91c1c;
}

.form-actions {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
  margin-top: 1.5rem;
}

.table-card {
  margin: 1.75rem -1.5rem 0;
  width: calc(100% + 3rem);
  box-sizing: border-box;
}

.table-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.orders-table {
  width: 100%;
  table-layout: fixed;
  border-collapse: separate;
  border-spacing: 0 0.5rem;
  min-width: 100%;
}

.orders-table th,
.orders-table td {
  padding: 1rem 0.5rem;
  text-align: left;
  vertical-align: top;
  white-space: normal;
  font-size: 0.90rem;
  min-width: 90px;
}

.orders-table th:nth-child(1),
.orders-table td:nth-child(1) {
  width: 110px;
}

.orders-table th:nth-child(2),
.orders-table td:nth-child(2) {
  width: 110px;
}

.orders-table th:nth-child(3),
.orders-table td:nth-child(3),
.orders-table th:nth-child(4),
.orders-table td:nth-child(4),
.orders-table th:nth-child(5),
.orders-table td:nth-child(5),
.orders-table th:nth-child(6),
.orders-table td:nth-child(6),
.orders-table th:nth-child(9),
.orders-table td:nth-child(9) {
  width: 110px;
}

.orders-table th:nth-child(7),
.orders-table td:nth-child(7) {
  min-width: 180px;
  width: 210px;
  max-width: 280px;
  overflow-wrap: anywhere;
}

.orders-table th:nth-child(8),
.orders-table td:nth-child(8) {
  min-width: 120px;
  width: 140px;
}

.orders-table th:nth-child(10),
.orders-table td:nth-child(10) {
  min-width: 120px;
  width: 120px;
  max-width: 240px;
}

.orders-table td:last-child {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  justify-content: flex-end;
}

.orders-table td:last-child .btn,
.orders-table td:last-child .start-select-label {
  flex: 0 0 auto;
  white-space: nowrap;
}

.orders-table th {
  background: #f8fafc;
  color: #475569;
  font-weight: 700;
}

.orders-table tbody tr:nth-child(odd) {
  background: #ffffff;
}

.orders-table tbody tr:nth-child(even) {
  background: #f8fafc;
}

/* Highlight completed orders */
.orders-table tbody tr.order-done {
  background-color: #e6fff0;
  color: #02320a;
}

.orders-table tbody tr.order-done td {
  border-top: 1px solid rgba(2,50,10,0.06);
}

.start-by-select {
  min-width: 30px;
}

.form-actions .btn {
  min-width: 140px;
}

.orders-table td:last-child {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}

.orders-table td:last-child .btn,
.orders-table td:last-child .start-select-label {
  flex: 0 1 auto;
  white-space: nowrap;
}

@media (max-width: 1200px) {
  .op-main {
    padding: 1.25rem 1.2rem 1.8rem;
  }

  .summary-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .workflow-header {
    flex-direction: column;
    align-items: stretch;
  }

  .form-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .order-line {
    grid-template-columns: 1.4fr 0.9fr auto;
  }

  input,
  textarea,
  select,
  .btn {
    min-height: 3rem;
  }
}

@media (min-width: 768px) and (max-width: 1024px) {
  .op-main {
    padding: 1.25rem 1rem 1.6rem;
  }

  .op-header {
    padding: 1rem 1rem;
  }

  .workflow-header {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
  }

  .form-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .summary-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .section-header {
    flex-wrap: wrap;
    gap: 0.75rem;
  }

  .order-line {
    grid-template-columns: 1.4fr 0.9fr auto;
  }

  .orders-table th,
  .orders-table td {
    padding: 0.85rem 0.75rem;
  }

  .table-card {
    margin-top: 1.25rem;
  }

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

  .form-actions {
    gap: 0.75rem;
  }
}

@media (max-width: 1024px) {
  .summary-grid,
  .form-grid,
  .catalog-grid {
    grid-template-columns: 1fr;
  }

  .order-line {
    grid-template-columns: 1fr;
  }

  .workflow-header,
  .section-header,
  .form-actions {
    gap: 0.75rem;
  }

  .section-header {
    flex-direction: column;
    align-items: stretch;
  }

  .order-line .actions {
    justify-content: flex-end;
  }
}

@media (max-width: 768px) {
  .op-header,
  .workflow-panel,
  .order-form,
  .table-card,
  .catalog-card {
    border-radius: 0;
    padding-left: 1rem;
    padding-right: 1rem;
  }

  .op-main {
    padding: 1rem 0.75rem 1.5rem;
  }

  .order-line {
    grid-template-columns: 1fr;
  }

  .orders-table th,
  .orders-table td {
    padding: 0.9rem 0.7rem;
  }

  .start-by-select,
  .form-actions .btn {
    width: 100%;
  }

  .form-actions {
    flex-direction: column;
    align-items: stretch;
  }
}

