:root {
  --bg-1: #fffaf0;
  --bg-2: #ffffff;
  --accent: #fcd34d;
  --accent-strong: #f59e0b;
  --text-primary: #1f2937;
  --text-muted: #4b5563;
  --error: #dc2626;
  --success: #16a34a;
  --card: rgba(255, 255, 255, 0.95);
  --border: rgba(0, 0, 0, 0.08);
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.14);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: clamp(12px, 3vw, 32px);
  font-family: "Arial", "Helvetica Neue", sans-serif;
  background:
    radial-gradient(circle at 18% 20%, rgba(252, 211, 77, 0.25) 0, transparent 34%),
    radial-gradient(circle at 78% 12%, rgba(239, 68, 68, 0.18) 0, transparent 30%),
    linear-gradient(135deg, var(--bg-1), var(--bg-2));
  color: var(--text-primary);
  overflow-x: hidden;
  font-size: 15px;
}

.container {
  width: 100%;
  max-width: 1300px;
  margin: 0 auto;
  display: grid;
  gap: 16px;
}

.panel {
  width: 90%;
  max-width: 1300px;
  margin: 0 auto;
  background: var(--card);
  border: 1px solid var(--border);
  backdrop-filter: blur(8px);
  border-radius: 18px;
  padding: 24px;
  box-shadow: var(--shadow);
  transition: transform 200ms ease, border-color 200ms ease;
}

#login-card {
  max-width: 520px;
}

.panel:hover {
  transform: translateY(-2px);
  border-color: rgba(245, 158, 11, 0.4);
}

h1 {
  margin: 0 0 8px;
  font-size: 26px;
  letter-spacing: 0.2px;
}

.subhead {
  margin: 0 0 20px;
  color: var(--text-muted);
  font-size: 15px;
}

label {
  display: block;
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--text-primary);
}

.label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 15px;
  font-weight: 700;
}

.label .icon {
  font-size: 18px;
  line-height: 1;
}

input,
select,
textarea {
  width: 100%;
  max-width: 100%;
  padding: 12px 14px;
  min-height: 44px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-primary);
  font-size: 16px;
  transition: border-color 150ms ease, box-shadow 150ms ease;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: rgba(245, 158, 11, 0.6);
  box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.18);
}

.field {
  margin-bottom: 12px;
  width: 100%;
  display: flex;
  flex-direction: column;
}

.address-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.address-row input {
  flex: 1;
}

.retail-btn {
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px dashed var(--border);
  background: rgba(245, 158, 11, 0.12);
  color: var(--text-primary);
  font-weight: 700;
  cursor: pointer;
  min-width: 90px;
}

.retail-btn.active {
  background: rgba(22, 163, 74, 0.14);
  border-color: rgba(22, 163, 74, 0.5);
}

.is-hidden {
  display: none;
}

.price-row {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.price-row > .calculated-price,
.price-row > .total-badge,
.price-row > .price-field,
.price-row > input {
  flex: 1 1 0;
  min-width: 160px;
}

.calculated-price {
  white-space: nowrap;
  padding: 10px 12px;
  border: 1px dashed var(--border);
  border-radius: 10px;
  background: rgba(245, 158, 11, 0.08);
  color: var(--text-primary);
  font-weight: 700;
  min-width: 120px;
  text-align: center;
}

.total-badge {
  background: rgba(22, 163, 74, 0.12);
  border-color: rgba(22, 163, 74, 0.4);
}

.price-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 160px;
  flex: 1 1 0;
}

.price-label {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-muted);
}

#boxPrice,
#deliveryPrice,
#finalPrice {
  min-width: 140px;
}

button {
  padding: 12px 14px;
  border: none;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--accent), var(--accent-strong));
  color: #7c2d12;
  font-weight: 700;
  font-size: 15px;
  cursor: pointer;
  transition: transform 120ms ease, box-shadow 120ms ease;
  box-shadow: 0 10px 26px rgba(245, 158, 11, 0.35);
}

button:hover {
  transform: translateY(-1px);
  box-shadow: 0 14px 30px rgba(245, 158, 11, 0.45);
}

button:active {
  transform: translateY(0);
}

.checkboxes {
  display: grid;
  gap: 6px 12px;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
}

.checkboxes label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  color: var(--text-primary);
}

.checkboxes input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--accent-strong);
}

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

.extras-row {
  display: grid;
  grid-template-columns: 1fr 80px;
  align-items: center;
  gap: 10px;
  font-size: 14px;
  color: var(--text-primary);
}

.extras-row input[type="number"] {
  width: 100%;
}

.extra-price {
  color: var(--text-muted);
  font-weight: 700;
  font-size: 13px;
  margin-left: 6px;
}

.removed-sections {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px;
  margin: 12px 0;
}

.removed-sections h3 {
  margin: 0 0 8px;
  font-size: 15px;
}

.option-list {
  display: grid;
  gap: 8px;
}

.option-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.04);
  gap: 10px;
}

.option-row label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  margin: 0;
}

.option-row input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--accent-strong);
}

.option-qty {
  width: 70px;
}

.option-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  font-size: 12px;
  font-weight: 700;
}

.option-icon.icon-remove {
  background: rgba(220, 38, 38, 0.12);
  color: #b91c1c;
}

.option-icon.icon-add {
  background: rgba(22, 163, 74, 0.12);
  color: #15803d;
}

.status {
  margin-top: 12px;
  padding: 10px 12px;
  border-radius: 10px;
  font-size: 14px;
  line-height: 1.4;
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid rgba(245, 158, 11, 0.3);
  display: none;
}

.status.success {
  display: block;
  border-color: rgba(22, 163, 74, 0.4);
  color: var(--success);
}

.status.error {
  display: block;
  border-color: rgba(220, 38, 38, 0.4);
  color: var(--error);
}

.modal {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.modal[hidden] {
  display: none;
}

.modal.open {
  display: flex;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(2px);
}

.modal-content {
  position: relative;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 18px;
  width: min(520px, 92vw);
  box-shadow: var(--shadow);
  z-index: 1;
}

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

.modal-header h2 {
  margin: 0;
  font-size: 18px;
}

.modal-actions {
  margin-top: 14px;
  display: flex;
  justify-content: flex-end;
}

.order-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  margin-top: 12px;
}

.order-grid .field {
  min-width: 0;
  width: 100%;
}

.order-grid .full {
  grid-column: 1 / -1;
}

.table-wrap {
  margin-top: 16px;
  overflow: visible;
  border: 1px solid var(--border);
  border-radius: 12px;
  width: 100%;
  max-width: 100%;
}

table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  min-width: 0;
  table-layout: auto;
  font-size: 11.5px;
}

.table-wrap col {
  width: auto !important;
}

thead {
  background: transparent;
}

th,
td {
  padding: 8px 8px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  font-size: inherit;
  white-space: normal;
  overflow: visible;
  text-overflow: clip;
  line-height: 1.2;
  vertical-align: middle;
}

th {
  color: var(--text-muted);
  font-weight: 700;
  font-size: inherit;
  background: rgba(255, 255, 255, 0.85);
  border-bottom: none;
}

thead tr {
  border-radius: 14px;
}

thead th:first-child {
  border-top-left-radius: 14px;
  border-bottom-left-radius: 14px;
}

thead th:last-child {
  border-top-right-radius: 14px;
  border-bottom-right-radius: 14px;
}

tr:last-child td {
  border-bottom: none;
}

/* allow controlled wrapping for select columns */
td:nth-child(3),
td:nth-child(5),
td:nth-child(6) {
  white-space: normal;
  overflow: visible;
  text-overflow: clip;
  word-break: break-word;
}

.actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.head-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

#logout {
  margin-left: auto;
}

.text-button {
  background: rgba(252, 211, 77, 0.16);
  color: var(--text-primary);
  box-shadow: none;
  padding: 10px 12px;
  border: 1px solid rgba(252, 211, 77, 0.35);
}

.text-button:disabled,
.text-button.disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.field > .text-button,
.field > button {
  width: 100%;
  justify-content: center;
  text-align: center;
}

.edit-actions {
  display: flex;
  gap: 8px;
  justify-content: center;
}

.edit-actions button {
  width: auto;
  min-width: 0;
  flex: 0 0 auto;
}

#order-form .field.full button[type="submit"] {
  width: 100%;
  max-width: 420px;
  min-width: 0;
  padding-inline: 16px;
  margin: 0 auto;
  display: block;
}

.btn-danger {
  background: linear-gradient(135deg, #f87171, #ef4444);
  color: #fff;
  border: none;
  box-shadow: 0 10px 24px rgba(239, 68, 68, 0.2);
}

.btn-secondary {
  background: #ffffff;
  color: var(--text-primary);
  border: 1px solid var(--border);
  box-shadow: none;
}

/* smaller action buttons inside table */
.table-action-btn {
  padding: 4px 8px;
  font-size: 11px;
  border-radius: 6px;
  box-shadow: none;
  min-height: 0;
}

.table-action-btn + .table-action-btn {
  margin-left: 4px;
}

.row-deleted {
  background: rgba(220, 38, 38, 0.08);
  color: #991b1b;
}

.modal.open .modal-content {
  animation: pop 160ms ease;
}

@keyframes pop {
  from {
    transform: scale(0.98);
    opacity: 0.8;
  }
  to {
    transform: scale(1);
    opacity: 1;
  }
}

/* Breakpoints */
@media (max-width: 1024px) {
  body {
    padding: clamp(12px, 4vw, 24px);
  }
  h1 {
    font-size: 24px;
  }
  .actions {
    gap: 10px;
  }
}

@media (max-width: 768px) {
  .panel {
    padding: 18px;
  }

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

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

  .actions .text-button,
  .actions button {
    width: 100%;
  }

  #order-form .field.full button[type="submit"] {
    width: 100%;
  }

  th,
  td {
    padding: 6px 6px;
    font-size: 11.5px;
  }
}

@media (max-width: 480px) {
  body {
    padding: 12px;
  }

  h1 {
    font-size: 22px;
  }

  th,
  td {
    padding: 5px 5px;
    font-size: 10.5px;
  }
}
