:root{
  --bg:#ffffff;
  --card:#ffffff;
  --text:#0f172a; /* slate-900 */
  --muted:#64748b; /* slate-500 */
  --accent:#2563eb; /* blue-600 */
  --accent-700:#1d4ed8; /* blue-700 */
  --ok:#16a34a; /* green-600 */
  --warn:#f59e0b; /* amber-500 */
  --danger:#ef4444; /* red-500 */
  --border:#e5e7eb; /* gray-200 */
  --shadow:0 6px 16px rgba(2,6,23,.06);
}

*{box-sizing:border-box}
html,body{margin:0;padding:0}
body, body.bg-gray-950{background:var(--bg)!important;color:var(--text)!important;font:14px/1.5 system-ui,Segoe UI,Roboto}

a{color:var(--accent);text-decoration:none}
a:hover{text-decoration:underline}

.container{max-width:100%;margin:12px auto;padding:0 24px}

.header{display:flex;align-items:center;justify-content:space-between;gap:12px;margin:10px 0 16px}
.header .title{font-size:20px;font-weight:700}
.header .nav{display:flex;flex-wrap:wrap;gap:8px;overflow-x:auto;padding-bottom:4px;-webkit-overflow-scrolling:touch}

.card{background:var(--card);border:1px solid var(--border);border-radius:12px;padding:16px;box-shadow:var(--shadow)}

.row{display:flex;gap:12px;align-items:flex-start}
.col{flex:1;min-width:0}

input.input,select,textarea{width:100%;padding:10px 12px;background:#fff;border:1px solid var(--border);color:var(--text);border-radius:10px;outline:none}
input.input:focus,select:focus,textarea:focus{border-color:var(--accent);box-shadow:0 0 0 3px rgba(37,99,235,.15)}

label{display:block;margin:8px 0 6px;color:#0f172a}

.btn{padding:8px 12px;border-radius:10px;border:1px solid var(--border);background:#f8fafc;color:var(--text);cursor:pointer}
.btn:hover{background:#f1f5f9}
.btn.primary{background:var(--accent);border-color:var(--accent);color:#fff}
.btn.green{background:var(--ok);border-color:var(--ok);color:#fff}
.btn.danger{background:var(--danger);border-color:var(--danger);color:#fff}

.badge{display:inline-block;padding:6px 10px;border-radius:999px;background:#eff6ff;border:1px solid #bfdbfe;color:#1d4ed8;font-size:13px;white-space:nowrap}

.toolbar{display:flex;gap:8px;align-items:center;justify-content:space-between;margin:0 0 12px;flex-wrap:wrap}


.table{width:100%;border-collapse:collapse;background:#fff;border:1px solid var(--border);border-radius:12px;overflow:hidden;table-layout:fixed}
.table th{background:#f8fafc;text-align:left;color:#334155}
.table th,.table td{padding:12px 10px;border-bottom:1px solid var(--border);vertical-align:middle}
.table td,.table th{word-break:break-word}
.table th:nth-child(1),.table td:nth-child(1){width:84px}
.table th:nth-child(3),.table td:nth-child(3){width:120px;text-align:right}
.table th:nth-child(4),.table td:nth-child(4){width:220px}
.table th:nth-child(5),.table td:nth-child(5){width:180px;white-space:nowrap}


.grid{display:grid;gap:12px}
.grid.cols-2{grid-template-columns:2fr 1fr}
.grid.cols-3{grid-template-columns:1.5fr 1fr 1fr}

.list-images{display:grid;grid-template-columns:repeat(auto-fill,minmax(128px,1fr));gap:12px}
.image-card{border:1px dashed #cbd5e1;border-radius:10px;padding:8px;background:#fff}
.image-card img{width:100%;height:120px;object-fit:cover;border-radius:8px;border:1px solid var(--border)}

.hint{color:var(--muted);font-size:12px}
.right{margin-left:auto}
.flex{display:flex;gap:8px;align-items:center;flex-wrap:wrap}
hr{border:0;border-top:1px solid var(--border);margin:12px 0}

.ai-box{background:#f8fafc;border:1px solid var(--border);border-radius:10px;padding:10px;max-height:380px;overflow:auto}
.ai-box .ai-item{padding:8px;border:1px dashed #bfdbfe;background:#eff6ff;border-radius:8px;margin:6px 0;cursor:pointer}

.thumb{width:64px;height:64px;border-radius:8px;border:1px solid var(--border);object-fit:cover;background:#fff}

/* Responsive */
@media (max-width: 1024px){
  .grid.cols-2{grid-template-columns:1fr}
  .grid.cols-3{grid-template-columns:1fr}
  .row{flex-wrap:wrap}
  .header{flex-direction:column;align-items:flex-start}
  .header .nav{justify-content:flex-start}
}

@media (max-width: 640px){
  .container{max-width:100%;margin:12px auto;padding:0 24px}
  .badge{font-size:12px;padding:5px 8px}
  .btn{padding:10px 12px}
  .table{display:block;overflow-x:auto;-webkit-overflow-scrolling:touch;white-space:nowrap}
  .thumb{width:56px;height:56px}
}

/* Modal detail table override */
.md-table{table-layout:auto}
.md-table td,.md-table th{white-space:nowrap}

/* Variants sub-table */
.table.variants{table-layout:auto;border:0;border-radius:0}
.table.variants th:nth-child(1),.table.variants td:nth-child(1){width:auto}
.table.variants th:nth-child(2),.table.variants td:nth-child(2){width:140px;text-align:right}
.table.variants th:nth-child(3),.table.variants td:nth-child(3){width:120px;text-align:right}
.table.variants th,.table.variants td{padding:8px 10px}

/* Orders Container */
.orders-container {
  padding: 0;
  background: transparent;
  border: 0;
  box-shadow: none;
}

.orders-table {
  background: transparent;
  border: 0;
  table-layout: auto;
}

.orders-table thead {
  display: none;
}

.orders-table tbody tr {
  border: 0;
}

.orders-table tbody td {
  padding: 0 0 16px 0;
  border: 0;
}

/* Desktop Order Card */
.order-card-desktop {
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.order-card-header-desktop {
  background: linear-gradient(to right, #f9fafb, #fff);
  padding: 16px 20px;
  border-bottom: 1px solid #e5e7eb;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
}

.order-customer-info {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
}

.order-customer-info svg {
  color: #3b82f6;
  flex-shrink: 0;
}

.customer-name {
  font-size: 15px;
  font-weight: 600;
  color: #111827;
}

.customer-phone {
  font-size: 13px;
  color: #6b7280;
  margin-top: 2px;
}

.order-meta {
  display: flex;
  align-items: center;
  gap: 12px;
}

.order-id-badge {
  background: #eff6ff;
  color: #2563eb;
  font-size: 13px;
  font-weight: 600;
  padding: 6px 12px;
  border-radius: 6px;
  white-space: nowrap;
}

.order-date {
  font-size: 13px;
  color: #6b7280;
  white-space: nowrap;
}

.order-card-body {
  display: grid;
  grid-template-columns: 1fr 280px 140px;
  gap: 20px;
  padding: 20px;
  align-items: start;
}

.order-items-col {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.order-item {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 12px;
  background: #f9fafb;
  border-radius: 8px;
  border: 1px solid #e5e7eb;
}

.order-item .item-img {
  width: 80px;
  height: 80px;
  object-fit: cover;
  border-radius: 6px;
  flex-shrink: 0;
  border: 1px solid #d1d5db;
  background: #fff;
}

.order-item .item-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.order-item .item-name {
  font-size: 14px;
  font-weight: 500;
  color: #111827;
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  word-break: break-word;
  max-width: 100%;
}

.order-item .item-variant {
  font-size: 13px;
  color: #6b7280;
  line-height: 1.3;
}

.order-item .item-price-qty {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 4px;
}

.order-item .item-price {
  font-size: 15px;
  font-weight: 600;
  color: #dc2626;
}

.order-item .item-qty {
  font-size: 13px;
  color: #6b7280;
}

.order-details-col {
  background: #f9fafb;
  padding: 16px;
  border-radius: 8px;
  border: 1px solid #e5e7eb;
}

.detail-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0;
  font-size: 13px;
  gap: 12px;
}

.detail-row:not(:last-child) {
  border-bottom: 1px dashed #e5e7eb;
}

.detail-row .label {
  color: #6b7280;
  white-space: nowrap;
}

.detail-row .value {
  color: #111827;
  font-weight: 500;
  text-align: right;
  word-break: break-all;
}

.detail-row .price-total {
  color: #dc2626;
  font-weight: 700;
  font-size: 16px;
}

.detail-row .tracking-code {
  font-family: 'Courier New', monospace;
  font-size: 12px;
  background: #eff6ff;
  padding: 4px 8px;
  border-radius: 4px;
}

.order-actions-col {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.order-actions-col .btn {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 16px;
  font-size: 14px;
  font-weight: 500;
  border-radius: 8px;
  white-space: nowrap;
}

.order-actions-col .btn svg {
  flex-shrink: 0;
}

.order-actions-col .btn-view {
  background: #3b82f6;
  color: white;
  border-color: #3b82f6;
}

.order-actions-col .btn-view:hover {
  background: #2563eb;
}

/* Mobile Order Card */
.order-row-mobile {
  display: none;
}

.order-card-mobile {
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.order-card-header {
  background: linear-gradient(to right, #f9fafb, #fff);
  padding: 14px 16px;
  border-bottom: 1px solid #e5e7eb;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.order-customer {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 600;
  color: #111827;
  flex: 1;
  min-width: 0;
}

.order-customer svg {
  flex-shrink: 0;
  color: #3b82f6;
}

.order-customer .phone {
  color: #6b7280;
  font-weight: 400;
  font-size: 13px;
}

.order-id {
  font-size: 12px;
  color: #2563eb;
  font-weight: 600;
  background: #eff6ff;
  padding: 4px 10px;
  border-radius: 6px;
  white-space: nowrap;
}

.order-card-items {
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.order-card-footer {
  padding: 14px 16px;
  background: #f9fafb;
  border-top: 1px solid #e5e7eb;
}

.order-info-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 0;
  font-size: 13px;
  gap: 12px;
}

.order-info-row .label {
  color: #6b7280;
  white-space: nowrap;
}

.order-info-row .value {
  color: #111827;
  font-weight: 500;
  text-align: right;
  word-break: break-all;
}

.order-info-row .value.price {
  color: #dc2626;
  font-weight: 700;
  font-size: 16px;
}

.order-actions {
  display: flex;
  gap: 10px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px dashed #e5e7eb;
}

.order-actions .btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 11px 12px;
  font-size: 13px;
  font-weight: 500;
  border-radius: 8px;
}

.order-actions .btn svg {
  flex-shrink: 0;
}

.order-actions .btn-view {
  background: #3b82f6;
  color: white;
  border-color: #3b82f6;
}

.order-actions .btn-view:hover {
  background: #2563eb;
}

/* Responsive */
@media (max-width: 1024px) {
  .order-card-body {
    grid-template-columns: 1fr 240px 120px;
    gap: 16px;
    padding: 16px;
  }
}

@media (max-width: 768px) {
  /* Hide desktop view */
  .order-row-desktop {
    display: none !important;
  }
  
  /* Show mobile view */
  .order-row-mobile {
    display: table-row !important;
  }
  
  .order-row-mobile td {
    padding: 0 0 12px 0 !important;
    border: 0 !important;
  }
  
  /* Container adjustments */
  .orders-container {
    padding: 0;
    margin: 0 -24px;
  }
  
  .orders-table {
    width: 100%;
    display: table;
  }
  
  .toolbar {
    border-radius: 0;
    margin-left: -24px;
    margin-right: -24px;
    padding: 12px 16px;
    margin-bottom: 12px;
  }
  
  /* Mobile card full width */
  .order-card-mobile {
    width: 100%;
    max-width: 100%;
    margin: 0;
    border-radius: 0;
    border-left: 0;
    border-right: 0;
  }
  
  /* Fix item images on mobile */
  .order-card-mobile .order-item {
    padding: 10px;
  }
  
  .order-card-mobile .item-img {
    width: 70px;
    height: 70px;
  }
  
  .order-card-mobile .item-name {
    font-size: 13px;
    -webkit-line-clamp: 2 !important;
    max-height: 2.6em;
  }
  
  .order-card-mobile .item-variant {
    font-size: 12px;
  }
  
  .order-card-mobile .item-price {
    font-size: 14px;
  }
  
  .order-card-mobile .item-qty {
    font-size: 12px;
  }
  
  /* Customer header responsive */
  .order-card-header {
    flex-wrap: nowrap;
  }
  
  .order-customer {
    flex-wrap: wrap;
  }
  
  .order-customer .phone {
    flex-basis: 100%;
    margin-left: 24px;
  }
}

@media (max-width: 480px) {
  /* Ultra compact for small phones */
  .order-card-mobile .item-img {
    width: 60px;
    height: 60px;
  }
  
  .order-card-mobile .item-name {
    font-size: 12px;
    -webkit-line-clamp: 2 !important;
    max-height: 2.4em;
  }
  
  .order-card-mobile .item-variant,
  .order-card-mobile .item-price,
  .order-card-mobile .item-qty {
    font-size: 11px;
  }
  
  .order-card-header {
    padding: 12px 14px;
  }
  
  .order-card-items {
    padding: 12px 14px;
  }
  
  .order-card-footer {
    padding: 12px 14px;
  }
  
  .order-customer {
    font-size: 13px;
  }
  
  .order-id {
    font-size: 11px;
    padding: 4px 8px;
  }
}

/* Mobile order actions buttons */
.order-actions .btn-print {
  background: #3b82f6;
  color: white;
  border-color: #3b82f6;
}

.order-actions .btn-print:hover {
  background: #2563eb;
}

.order-actions .btn-cancel {
  background: #f59e0b;
  color: white;
  border-color: #f59e0b;
}

.order-actions .btn-cancel:hover {
  background: #d97706;
}

.order-actions .btn-delete {
  background: #ef4444;
  color: white;
  border-color: #ef4444;
}

.order-actions .btn-delete:hover {
  background: #dc2626;
}

/* Desktop order actions buttons */
.order-actions-col .btn-print {
  background: #3b82f6;
  color: white;
  border-color: #3b82f6;
}

.order-actions-col .btn-print:hover {
  background: #2563eb;
}

.order-actions-col .btn-cancel {
  background: #f59e0b;
  color: white;
  border-color: #f59e0b;
}

.order-actions-col .btn-cancel:hover {
  background: #d97706;
}

.order-actions-col .btn-delete {
  background: #ef4444;
  color: white;
  border-color: #ef4444;
}

.order-actions-col .btn-delete:hover {
  background: #dc2626;
}

/* Force no horizontal scroll on mobile */
@media (max-width: 768px) {
  html, body {
    max-width: 100vw;
    overflow-x: hidden !important;
  }
  
  #adminSidebar {
    max-width: 260px;
  }
  
  .admin-main-content {
    max-width: 100vw;
    overflow-x: hidden !important;
  }
  
  .order-card-mobile,
  .order-card-header,
  .order-card-items,
  .order-card-footer {
    max-width: 100vw !important;
    overflow-x: hidden !important;
  }
  
  .order-item {
    max-width: calc(100vw - 32px) !important;
  }
  
  .order-item .item-name,
  .order-item .item-variant {
    max-width: calc(100vw - 140px) !important;
  }
  
  .order-info-row {
    max-width: 100%;
  }
  
  .order-info-row .value {
    max-width: 55%;
    font-size: 12px;
  }
}
