* { box-sizing: border-box; }
html, body { max-width: 100%; overflow-x: hidden; }
body { font-family: Arial, Helvetica, sans-serif; background: #f5f6f8; margin: 0; color: #222; }
header { background: #1a2b3c; color: #fff; padding: 14px 24px; display: flex; justify-content: space-between; align-items: center; }
header a { color: #fff; text-decoration: none; margin-left: 16px; }
main { max-width: 1000px; margin: 24px auto; padding: 0 16px; }
h1 { font-size: 22px; }
.card { background: #fff; border-radius: 8px; padding: 16px; margin-bottom: 16px; box-shadow: 0 1px 3px rgba(0,0,0,0.08); }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 8px; border-bottom: 1px solid #eee; font-size: 14px; }
input, select, button, textarea { font-size: 14px; padding: 8px; margin: 4px 0; }
input[type=text], input[type=email], input[type=password], input[type=number], select, textarea { width: 100%; border: 1px solid #ccc; border-radius: 4px; }
button, .btn { background: #1a2b3c; color: #fff; border: none; border-radius: 4px; padding: 10px 16px; cursor: pointer; display: inline-block; }
button:hover, .btn:hover { background: #33475b; }
.qty-input { width: 60px; }
.error { color: #b00020; }
.muted { color: #666; font-size: 13px; }
.flex { display: flex; gap: 12px; flex-wrap: wrap; }
.flex > div { flex: 1; min-width: 200px; }
.dash-section { margin-bottom: 28px; }
.dash-section h2 { font-size: 15px; color: #666; text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 10px; }
.dash-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; }
.dash-btn {
  display: block; background: #fff; border: 1px solid #e2e2e2; border-radius: 10px;
  padding: 16px; text-decoration: none; color: #1a2b3c; font-weight: 600; font-size: 14px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06); position: relative; transition: box-shadow 0.15s, transform 0.15s;
}
.dash-btn:hover { box-shadow: 0 3px 10px rgba(0,0,0,0.12); transform: translateY(-1px); background: #f8fafc; }
.dash-btn .dash-btn-badge {
  position: absolute; top: -8px; right: -8px; background: #b00020; color: #fff;
  border-radius: 10px; padding: 2px 8px; font-size: 11px; font-weight: 700;
}
.tab-row { display: flex; gap: 8px; margin-bottom: 16px; border-bottom: 1px solid #e2e2e2; }
.tab-row a { padding: 8px 14px; text-decoration: none; color: #666; border-bottom: 2px solid transparent; font-weight: 600; font-size: 14px; }
.tab-row a.active { color: #1a2b3c; border-bottom-color: #1a2b3c; }

/* Mobile optimization */
@media (max-width: 640px) {
  header { flex-direction: column; align-items: flex-start; gap: 8px; padding: 12px 16px; }
  header div { margin-left: 0; display: flex; flex-wrap: wrap; gap: 4px 14px; }
  header a { margin-left: 0; }
  main { padding: 0 12px; margin: 16px auto; }
  h1 { font-size: 19px; }
  .card { padding: 12px; }
  .flex { flex-direction: column; }
  .flex > div { min-width: 0; }
  .dash-grid { grid-template-columns: 1fr 1fr; gap: 8px; }
  .dash-btn { padding: 12px; font-size: 13px; }

  /* Wide tables scroll horizontally, contained within their own box — not the whole page */
  .card { overflow-x: hidden; }
  table { display: block; width: 100%; max-width: 100%; overflow-x: auto; white-space: nowrap; -webkit-overflow-scrolling: touch; }
  th, td { font-size: 13px; }

  /* Keep the last column (usually an action button like Remove) pinned on screen while the rest scrolls */
  table th:last-child, table td:last-child {
    position: sticky;
    right: 0;
    background: #fff;
    box-shadow: -4px 0 6px -4px rgba(0,0,0,0.15);
  }

  /* Stack any .btn link full-width instead of squeezing them side by side */
  .btn { display: block !important; width: 100%; text-align: center; margin-bottom: 8px; box-sizing: border-box; }

  /* Bigger, easier-to-tap buttons and inputs on touch screens */
  button, .btn { padding: 12px 16px; font-size: 15px; }
  input, select, textarea { font-size: 16px; padding: 10px; } /* 16px prevents iOS auto-zoom on focus */
  .qty-input { width: 70px; }

  /* Catalog on a phone: each product is its own card (name, details, price, Add) instead of a table you have to scroll sideways */
  .catalog-table, .catalog-table tbody { display: block; overflow: visible; white-space: normal; }
  .catalog-table thead { display: none; }
  .catalog-table tr { display: flex; flex-wrap: wrap; align-items: center; gap: 2px 8px; position: relative; padding: 10px 0; border-bottom: 1px solid #eee; }
  .catalog-table.has-photos tr { padding-left: 72px; min-height: 64px; }
  .catalog-table td { display: block; padding: 0; border: 0; white-space: normal; position: static; box-shadow: none; background: none; }
  .catalog-table td:last-child { position: static; box-shadow: none; background: none; }
  .catalog-table td.c-photo { position: absolute; left: 0; top: 10px; }
  .catalog-table td.c-name { order: 1; flex: 1 0 100%; font-weight: 600; font-size: 15px; }
  .catalog-table td.c-meta { order: 2; font-size: 12px; color: #667; }
  .catalog-table td.c-meta:not(:empty)::after { content: " \00b7"; }
  .catalog-table td.c-last::after { content: none !important; }
  .catalog-table td.c-price { order: 3; flex: 1 0 100%; margin-top: 4px; }
  .catalog-table td.c-add { order: 4; flex: 1 0 100%; margin-top: 6px; }
  .catalog-table td[colspan] { flex: 1 0 100%; }

  /* Cart on a phone: each item is a small card so price, line total and Remove are all visible without scrolling sideways */
  .cart-table, .cart-table tbody { display: block; overflow: visible; white-space: normal; }
  .cart-table thead { display: none; }
  .cart-table tr { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 14px; padding: 10px 0; border-bottom: 1px solid #eee; }
  .cart-table td, .cart-table td:last-child { display: block; padding: 0; border: 0; position: static; box-shadow: none; background: none; white-space: normal; font-size: 13px; }
  .cart-table td:nth-child(1) { flex: 1 0 100%; font-weight: 600; font-size: 15px; }
  .cart-table td:nth-child(2) { color: #667; }
  .cart-table td:nth-child(3)::before { content: "Qty "; color: #667; }
  .cart-table td:nth-child(4)::before { content: "Price "; color: #667; }
  .cart-table td:nth-child(5) { margin-left: auto; font-weight: 700; font-size: 15px; }
  .cart-table td:nth-child(6) { flex: 1 0 100%; }
  .cart-table td[colspan] { flex: 1 0 100%; }
}
