* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --bg-1: #f8fafc;
  --bg-2: #e6f4f1;
  --surface: rgba(255, 255, 255, 0.92);
  --text-main: #0f172a;
  --text-muted: #475569;
  --border: #dbe5ef;
  --primary: #0f766e;
  --primary-strong: #115e59;
  --accent: #f97316;
  --danger: #dc2626;
  --danger-strong: #b91c1c;
  --shadow: 0 24px 50px rgba(15, 23, 42, 0.12);
}

body {
  font-family: "Trebuchet MS", "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at 12% 20%, rgba(249, 115, 22, 0.16), transparent 40%),
    radial-gradient(circle at 88% 80%, rgba(15, 118, 110, 0.18), transparent 45%),
    linear-gradient(145deg, var(--bg-1) 0%, var(--bg-2) 100%);
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  color: var(--text-main);
}

.container {
  width: 100%;
  max-width: 1280px;
  padding: 26px;
}

.auth-container {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 92vh;
}

.auth-card {
  background: var(--surface);
  backdrop-filter: blur(4px);
  padding: 36px;
  border-radius: 18px;
  box-shadow: var(--shadow);
  border: 1px solid rgba(255, 255, 255, 0.65);
  width: 100%;
  max-width: 420px;
}

.auth-card h1 {
  margin-bottom: 24px;
  text-align: center;
  font-size: 30px;
  letter-spacing: 0.5px;
}

.auth-card form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.auth-card input,
.management-toolbar input,
.editor-form input,
.editor-form select,
.editor-form textarea {
  padding: 12px 13px;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 14px;
  background: #ffffff;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.auth-card input:focus,
.management-toolbar input:focus,
.editor-form input:focus,
.editor-form select:focus,
.editor-form textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.16);
}

button {
  border: none;
  cursor: pointer;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 3px solid rgba(15, 118, 110, 0.25);
  outline-offset: 2px;
}

.primary-btn,
.auth-card button {
  background: linear-gradient(135deg, var(--primary) 0%, #0d9488 100%);
  color: #fff;
  border-radius: 10px;
  padding: 11px 16px;
  font-weight: 700;
  transition: transform 0.18s ease, filter 0.18s ease;
}

.primary-btn:hover,
.auth-card button:hover {
  transform: translateY(-1px);
  filter: brightness(1.03);
}

.primary-btn:disabled,
.secondary-btn:disabled,
.action-btn:disabled,
.logout-btn:disabled,
.row-btn:disabled,
.auth-card button:disabled {
  opacity: 0.65;
  cursor: not-allowed;
  transform: none;
  filter: none;
}

.secondary-btn {
  background: #e2e8f0;
  color: #1e293b;
  border-radius: 10px;
  padding: 10px 14px;
  font-weight: 700;
}

.secondary-btn:hover {
  background: #cbd5e1;
}

.error {
  color: var(--danger);
  font-size: 14px;
  margin-top: 8px;
  text-align: center;
}

.dashboard {
  background: var(--surface);
  border-radius: 22px;
  box-shadow: var(--shadow);
  border: 1px solid rgba(255, 255, 255, 0.65);
  padding: 28px;
  animation: fade-slide 0.4s ease;
}

@keyframes fade-slide {
  from {
    opacity: 0;
    transform: translateY(10px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
  border-bottom: 1px solid #d8e4ee;
  padding-bottom: 16px;
}

.header h1 {
  font-size: 30px;
  font-weight: 800;
}

.ops-strip {
  display: flex;
  gap: 14px;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 18px;
  padding: 10px 12px;
  border: 1px solid #dbe5ef;
  border-radius: 12px;
  background: #f8fafc;
  color: #334155;
  font-size: 12px;
}

.health-dot {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border-radius: 999px;
  padding: 3px 10px;
  font-weight: 700;
}

.health-dot.online {
  color: #166534;
  background: #dcfce7;
}

.health-dot.offline {
  color: #991b1b;
  background: #fee2e2;
}

.logout-btn {
  padding: 10px 20px;
  background: var(--danger);
  color: white;
  border-radius: 10px;
  font-weight: 700;
}

.logout-btn:hover {
  background: var(--danger-strong);
}

.stats-container {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 16px;
  margin-bottom: 28px;
}

.stat-card {
  background: #ffffff;
  border: 1px solid #d8e4ee;
  border-radius: 14px;
  padding: 18px;
  text-align: center;
  box-shadow: 0 5px 16px rgba(15, 23, 42, 0.05);
}

.stat-card h3 {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.stat-value {
  font-size: 30px;
  font-weight: 800;
  color: var(--primary);
}

.action-buttons {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 10px;
  border-top: 1px solid #d8e4ee;
  padding-top: 18px;
}

.action-btn {
  flex: 1;
  min-width: 150px;
  padding: 12px;
  background: #1e293b;
  color: white;
  border-radius: 10px;
  font-weight: 700;
  transition: background 0.2s ease;
}

.action-btn:hover {
  background: #0f172a;
}

.management-panel {
  margin-top: 24px;
  border-top: 1px solid #d8e4ee;
  padding-top: 18px;
}

.management-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

.management-header h2 {
  font-size: 24px;
}

.panel-header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.close-panel-btn {
  padding: 10px 14px;
  background: #475569;
  color: white;
  border-radius: 10px;
}

.close-panel-btn:hover {
  background: #334155;
}

.management-toolbar {
  display: flex;
  gap: 12px;
  margin-bottom: 12px;
  align-items: center;
  flex-wrap: wrap;
  position: relative;
}

.management-toolbar input {
  flex: 1;
  min-width: 220px;
}

.column-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  min-width: 240px;
  max-width: 320px;
  padding: 12px;
  background: #ffffff;
  border: 1px solid #dbe5ef;
  border-radius: 14px;
  box-shadow: 0 20px 40px rgba(15, 23, 42, 0.16);
  z-index: 5;
  display: grid;
  gap: 8px;
}

.column-menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 10px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  font-size: 13px;
  color: #0f172a;
}

.column-menu-item input {
  width: 15px;
  height: 15px;
}

.order-filter-bar {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.filter-chip {
  padding: 8px 12px;
  border-radius: 999px;
  border: 1px solid #dbe5ef;
  background: #ffffff;
  color: #334155;
  font-size: 12px;
  font-weight: 700;
  transition: all 0.18s ease;
}

.filter-chip:hover {
  background: #f8fafc;
  border-color: #bfdbfe;
}

.filter-chip.active {
  background: #0f766e;
  color: #fff;
  border-color: #0f766e;
}

.bulk-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
  padding: 10px;
  border: 1px solid #d5e4f0;
  border-radius: 10px;
  background: #f8fbff;
  flex-wrap: wrap;
}

.bulk-actions span {
  font-weight: 700;
  color: #334155;
}

.bulk-actions select {
  min-width: 170px;
  padding: 7px 10px;
  border-radius: 8px;
  border: 1px solid #cddbeb;
}

.management-message {
  margin-bottom: 12px;
  color: #0b3f47;
  font-size: 14px;
  background: #d7f4f1;
  border: 1px solid #98dfd7;
  border-radius: 8px;
  padding: 10px;
}

.management-message.error {
  color: #7f1d1d;
  background: #fee2e2;
  border-color: #fecaca;
}

.management-message.success {
  color: #14532d;
  background: #dcfce7;
  border-color: #bbf7d0;
}

.management-panel[aria-busy="true"] .table-wrapper {
  opacity: 0.72;
}

.management-message:not(.error):not(.success) {
  color: #1d4ed8;
  background: #dbeafe;
  border-color: #bfdbfe;
}

.table-wrapper {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #ffffff;
}

.management-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 860px;
}

.management-table th,
.management-table td {
  border-bottom: 1px solid #edf2f7;
  padding: 14px 12px;
  text-align: left;
  font-size: 13px;
  vertical-align: top;
}

.management-table th {
  background: #f8fafc;
  color: #0f172a;
  position: sticky;
  top: 0;
  z-index: 1;
}

.management-table tbody tr:nth-child(even) {
  background: #fcfdff;
}

.management-table tbody tr:hover {
  background: #f0f9ff;
}

.table-product-image {
  width: 52px;
  height: 52px;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid #e2e8f0;
  display: block;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 92px;
  padding: 5px 12px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  text-transform: capitalize;
  background: #e2e8f0;
  color: #1e293b;
  white-space: nowrap;
  line-height: 1;
}

.status-badge.pending {
  background: #ffedd5;
  color: #9a3412;
}

.status-badge.approved,
.status-badge.paid,
.status-badge.delivered,
.status-badge.assigned {
  background: #dcfce7;
  color: #166534;
}

.status-badge.rejected,
.status-badge.cancelled {
  background: #fee2e2;
  color: #991b1b;
}

.row-actions {
  display: flex;
  gap: 8px;
}

.row-expand-btn {
  width: 28px;
  height: 28px;
  border-radius: 999px;
  background: #e2e8f0;
  color: #0f172a;
  font-weight: 800;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.row-expand-btn:hover {
  background: #cbd5e1;
}

.expanded-order-row td {
  background: #f8fbff;
  border-bottom: 1px solid #dbe5ef;
}

.expanded-order-panel {
  display: grid;
  gap: 14px;
  padding: 4px 4px 10px;
}

.expanded-order-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.expanded-order-grid div {
  background: #ffffff;
  border: 1px solid #dbe5ef;
  border-radius: 12px;
  padding: 10px 12px;
}

.expanded-order-grid span {
  display: block;
  font-size: 11px;
  color: #64748b;
  font-weight: 700;
  margin-bottom: 4px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.expanded-order-grid strong {
  font-size: 13px;
  color: #0f172a;
  word-break: break-word;
}

.expanded-order-grid .expanded-wide {
  grid-column: 1 / -1;
}

.expanded-items-block {
  background: #ffffff;
  border: 1px solid #dbe5ef;
  border-radius: 12px;
  padding: 12px;
}

.expanded-items-block h4 {
  font-size: 14px;
  margin-bottom: 10px;
  color: #0f172a;
}

.expanded-item-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 0;
  border-top: 1px solid #edf2f7;
  font-size: 12px;
}

.expanded-item-row:first-of-type {
  border-top: none;
}

.expanded-item-row strong {
  display: block;
  color: #0f172a;
}

.expanded-item-row span {
  display: block;
  color: #64748b;
  margin-top: 2px;
}

.expanded-empty {
  color: #64748b;
  font-size: 12px;
}

.order-details-cell {
  display: grid;
  gap: 10px;
  max-width: 430px;
}

.od-meta-line {
  display: flex;
  gap: 12px;
  align-items: baseline;
}

.od-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.2px;
  color: #64748b;
  min-width: 56px;
}

.od-value {
  color: #0f172a;
  font-size: 12px;
  line-height: 1.35;
  word-break: break-word;
}

.od-items-wrap {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 4px;
}

.od-item-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: #f8fafc;
  border: 1px solid #dbe5ef;
  border-radius: 999px;
  padding: 5px 12px;
  font-size: 11px;
}

.od-item-name {
  font-weight: 700;
  color: #1e293b;
}

.od-size {
  background: #dcfce7;
  color: #166534;
  border-radius: 999px;
  padding: 1px 6px;
  font-weight: 700;
  font-size: 10px;
}

.od-item-qty {
  color: #475569;
  font-weight: 700;
}

.od-more,
.od-empty {
  font-size: 11px;
  color: #64748b;
}

.row-checkbox {
  width: 16px;
  height: 16px;
}

.row-btn {
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 12px;
  font-weight: 700;
  min-height: 36px;
}

.row-btn.edit {
  background: #dbeafe;
  color: #1d4ed8;
}

.row-btn.edit:hover {
  background: #bfdbfe;
}

.row-btn.delete {
  background: #fee2e2;
  color: #b91c1c;
}

.row-btn.delete:hover {
  background: #fecaca;
}

.editor-modal {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 20;
}

.editor-card {
  width: 100%;
  max-width: 640px;
  background: #ffffff;
  border-radius: 16px;
  box-shadow: var(--shadow);
  padding: 18px;
  max-height: 90vh;
  overflow-y: auto;
}

  min-height: 40px;
.editor-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

  .action-btn,
  .primary-btn,
  .secondary-btn,
  .row-btn,
  .filter-chip,
  .close-panel-btn,
  .logout-btn {
    min-height: 40px;
  }

  .row-expand-btn {
    width: 34px;
    height: 34px;
  }

.editor-header h3 {
  font-size: 22px;
}

.close-editor-btn {

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation: none !important;
    transition: none !important;
    scroll-behavior: auto !important;
  }
}
  background: #e2e8f0;
  color: #1e293b;
  width: 34px;
  height: 34px;
  border-radius: 8px;
  font-size: 16px;
  font-weight: 700;
}

.editor-form {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.editor-form .field-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.editor-form .field-group.full {
  grid-column: 1 / -1;
}

.editor-form label {
  font-size: 13px;
  color: var(--text-muted);
  font-weight: 700;
}

.editor-form textarea {
  min-height: 92px;
  resize: vertical;
}

.image-preview-wrap {
  margin-top: 12px;
  border: 1px dashed #9db6ce;
  border-radius: 10px;
  padding: 10px;
  background: #f8fafc;
}

.image-preview-wrap p {
  font-size: 13px;
  color: #475569;
  margin-bottom: 8px;
  font-weight: 700;
}

#image-preview {
  width: 100%;
  max-height: 240px;
  object-fit: contain;
  border-radius: 8px;
  border: 1px solid #dbe5ef;
  background: #fff;
}

.field-checkbox {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 100%;
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px;
}

.editor-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 14px;
}

.editor-actions .primary-btn:disabled {
  background: #94a3b8;
}

.editor-actions .secondary-btn:disabled {
  background: #cbd5e1;
}

.pagination {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 12px;
}

#pagination-info {
  font-weight: 700;
  color: #475569;
}

.audit-panel {
  margin-top: 16px;
  border: 1px solid #dbe5ef;
  border-radius: 12px;
  padding: 12px;
  background: #f8fafc;
}

.audit-panel h3 {
  font-size: 16px;
  margin-bottom: 8px;
}

#audit-log-list {
  list-style: none;
  display: grid;
  gap: 6px;
  max-height: 180px;
  overflow-y: auto;
}

#audit-log-list li {
  font-size: 13px;
  color: #334155;
  padding: 8px;
  border-radius: 8px;
  background: #ffffff;
  border: 1px solid #e2e8f0;
}

#management-table-body tr td {
  word-break: break-word;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (max-width: 900px) {
  .container {
    padding: 14px;
  }

  .dashboard {
    padding: 18px;
  }

  .header {
    flex-direction: column;
    gap: 12px;
    align-items: flex-start;
  }

  .header h1 {
    font-size: 24px;
  }

  .ops-strip {
    font-size: 11px;
  }

  .management-toolbar {
    flex-direction: column;
  }

  .bulk-actions {
    flex-direction: column;
    align-items: flex-start;
  }

  .pagination {
    justify-content: space-between;
  }

  .editor-form {
    grid-template-columns: 1fr;
  }

  .column-menu {
    position: static;
    min-width: 100%;
  }

  .expanded-order-grid {
    grid-template-columns: 1fr 1fr;
  }

  .order-details-cell {
    max-width: 300px;
  }

  .od-meta-line {
    flex-direction: column;
    gap: 2px;
  }

  .od-label {
    min-width: auto;
  }
}

@media (max-width: 560px) {
  .management-table {
    min-width: 620px;
  }

  .order-details-cell {
    max-width: 260px;
  }

  .auth-card {
    padding: 24px;
  }

  .auth-card h1 {
    font-size: 24px;
  }

  .stat-value {
    font-size: 24px;
  }

  .action-buttons {
    flex-direction: column;
  }

  .expanded-order-grid {
    grid-template-columns: 1fr;
  }
}
