* { box-sizing: border-box; }
body { font-family: system-ui, sans-serif; margin: 0; background: #f5f6f8; color: #222; }
nav { display: flex; gap: 1rem; align-items: center; background: #1f3a5f; color: #fff; padding: .6rem 1rem; }
nav a { color: #cfe0f5; text-decoration: none; white-space: nowrap; }
nav a:hover { color: #fff; }
nav .spacer { flex: 1; }
main { max-width: 1100px; margin: 1.5rem auto; padding: 0 1rem; }
h1 { font-size: 1.4rem; }
table { width: 100%; border-collapse: collapse; background: #fff; }
th, td { text-align: left; padding: .5rem .6rem; border-bottom: 1px solid #e3e6ea; }
th { background: #eef1f5; }
tr:hover td { background: #f4f8fd; }
a.button, button { display: inline-block; background: #1f6feb; color: #fff; border: 0; padding: .45rem .9rem; border-radius: 4px; text-decoration: none; cursor: pointer; font-size: .9rem; }
a.button.secondary { background: #6a737d; }
form.stack label { display: block; margin: .8rem 0 .2rem; font-weight: 600; }
input[type=text], input[type=password], input[type=number], input[type=date], input[type=email], select, textarea {
  width: 100%; max-width: 420px; padding: .45rem; border: 1px solid #c4c9d0; border-radius: 4px;
}
.error { background: #fde8e8; color: #9b1c1c; padding: .6rem .8rem; border-radius: 4px; margin-bottom: 1rem; }
.success { background: #e6f6e6; color: #1a7f37; padding: .6rem .8rem; border-radius: 4px; margin-bottom: 1rem; }
.toolbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: .8rem; gap: 1rem; }
.badge { padding: .15rem .5rem; border-radius: 10px; font-size: .8rem; background: #e3e6ea; }
.badge.confirmed { background: #d0e7ff; }
.nav-logo { height: 28px; vertical-align: middle; margin-right: 4px; }
.badge.preorder { background: #e7d9ff; }
.badge.shipped { background: #fff3cd; }
.badge.invoiced { background: #d4edda; }
.badge.cancelled { background: #f8d7da; }
.login-box { max-width: 360px; margin: 8vh auto; background: #fff; padding: 2rem; border-radius: 8px; box-shadow: 0 2px 8px rgba(0,0,0,.08); }

/* Layout helpers */
.cols { display: grid; grid-template-columns: 1fr 1fr; gap: 1.5rem; align-items: start; }
@media (max-width: 800px) { .cols { grid-template-columns: 1fr; } }
.card { background: #fff; border: 1px solid #e3e6ea; border-radius: 8px; padding: 1rem; margin-bottom: 1rem; }
.notice { background: #e6f6e6; color: #1a7f37; padding: .6rem .8rem; border-radius: 4px; margin-bottom: 1rem; }
.error-text { color: #9b1c1c; font-weight: 600; }
.big { font-size: 1.15rem; }
.inline-form { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; margin-bottom: 1rem; }
.inline-form input, .inline-form select { width: auto; }
.perm-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: .4rem; }
.perm-box { display: flex; gap: .4rem; align-items: center; background: #f4f6f9; padding: .4rem .6rem; border-radius: 4px; }

/* Warehouse mobile UI */
.wh-menu { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: .8rem; }
.wh-tile { display: block; background: #1f6feb; color: #fff; text-align: center; padding: 1.4rem .5rem; border-radius: 8px; text-decoration: none; font-size: 1.1rem; font-weight: 600; }
.wh-tile:hover { background: #1a5fd0; }
.wh-form input, .wh-form select { font-size: 1.15rem; padding: .7rem; }
.wh-form button { font-size: 1.15rem; padding: .7rem 1.2rem; width: 100%; margin-top: .6rem; }
.pick-card { background: #fff; border: 1px solid #e3e6ea; border-left: 5px solid #1f6feb; border-radius: 6px; padding: .8rem 1rem; margin-bottom: .8rem; }
.pick-card.done { border-left-color: #1a7f37; opacity: .65; }

/* Dispatch / driver */
.route-card { background: #fff; border: 1px solid #e3e6ea; border-radius: 8px; padding: 1rem; margin-bottom: 1rem; }
.sig-form { margin-top: .6rem; }
.sigpad { border: 2px dashed #c4c9d0; border-radius: 6px; background: #fff; touch-action: none; width: 100%; max-width: 480px; height: 160px; }

/* Item photos */
.photo-grid { display: flex; flex-wrap: wrap; gap: .8rem; }
.photo-card { background: #fff; border: 1px solid #e3e6ea; border-radius: 6px; padding: .4rem; text-align: center; }
.photo-card img { max-width: 140px; max-height: 140px; display: block; }

/* Customer portal */
.portal-nav { background: #14532d; }
.portal-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 1rem; }
.product-card { background: #fff; border: 1px solid #e3e6ea; border-radius: 8px; padding: .8rem; display: flex; flex-direction: column; gap: .4rem; }
.product-card img { width: 100%; height: 130px; object-fit: cover; border-radius: 6px; background: #f0f2f5; }
.product-card .price { font-weight: 700; font-size: 1.05rem; }
.buy-again { display: flex; gap: .8rem; overflow-x: auto; padding-bottom: .5rem; }
.buy-again .product-card { min-width: 170px; }
.cart-badge { background: #f0b429; color: #222; border-radius: 10px; padding: .1rem .5rem; font-weight: 700; }

/* Invoice / statement documents + print */
.invoice-doc { background: #fff; padding: 1.5rem; border: 1px solid #e3e6ea; border-radius: 8px; margin-bottom: 1.5rem; }
.inv-head { display: flex; justify-content: space-between; gap: 2rem; margin-bottom: 1rem; }
@media print {
  nav, .no-print, h1 { display: none !important; }
  body { background: #fff; }
  main { max-width: none; margin: 0; }
  .invoice-doc { border: 0; padding: 0; }
  tr:hover td { background: transparent; }
}
