/*
 * Slate + amber theme. The old variable names (--blue-*) are kept because they're
 * referenced throughout — they now mean "primary scale," not literally blue. If this
 * theme sticks, a rename pass (--primary-*) would be the cleanup; and the longer-term
 * plan is making the accent per-yard configurable from Settings.
 */
:root {
  --white: #ffffff;
  --page-bg: #f3f4f6;
  --panel: #ffffff;
  --border: #cbd5e1;
  --border-light: #e2e8f0;

  --text: #111827;
  --muted: #55606e;

  --blue-900: #0f172a;   /* deep slate — headers, topbar */
  --blue-800: #1e293b;   /* slate — headings, table headers */
  --blue-700: #b45309;   /* amber-dark — hovers, emphasized text */
  --blue-600: #d97706;   /* amber — primary actions, active nav */
  --blue-500: #f59e0b;   /* amber-light — logo, highlights */
  --blue-100: #fbe9c9;   /* amber tint — focus rings, timeline fill */
  --blue-50: #faf5eb;    /* pale amber — subtle backgrounds */

  --navy: #0f172a;

  --amber: #b45309;

  --red-600: #c62828;
  --red-50: #fdecea;
  --red-200: #f2b8b0;

  --radius: 10px;
  --shadow: 0 1px 3px rgba(15, 23, 42, 0.08), 0 1px 2px rgba(15, 23, 42, 0.06);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  background: var(--page-bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.45;
}

header.topbar {
  background: var(--blue-900);
  color: white;
  padding: 14px 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: 0 2px 6px rgba(15, 23, 42, 0.3);
  position: sticky;
  top: 0;
  z-index: 10;
}

header.topbar h1 {
  font-size: 19px;
  margin: 0;
  font-weight: 700;
  letter-spacing: 0.01em;
  display: flex;
  align-items: center;
  gap: 9px;
}

header.topbar h1 svg { display: block; flex-shrink: 0; }

header.topbar nav {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}

header.topbar nav a {
  color: #cbd5e1;
  text-decoration: none;
  padding: 7px 12px;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 600;
}

header.topbar nav a:hover { background: rgba(255, 255, 255, 0.12); color: white; }
header.topbar nav a.active { background: var(--blue-600); color: white; }

main {
  max-width: 1150px;
  margin: 0 auto;
  padding: 28px 24px 60px;
}

h2 { margin-top: 0; font-size: 22px; color: var(--blue-900); }
h3 { color: var(--blue-800); }

.panel {
  background: var(--panel);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  padding: 22px;
  margin-bottom: 22px;
  box-shadow: var(--shadow);
}

label {
  display: block;
  font-size: 13px;
  font-weight: 700;
  color: var(--muted);
  margin-bottom: 5px;
  margin-top: 14px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

label.inline-label {
  display: inline;
  font-weight: 500;
  text-transform: none;
  letter-spacing: normal;
  color: var(--text);
  font-size: 14px;
  margin: 0;
}

input[type=text], input[type=number], input[type=email], input[type=tel], input[type=password], select, textarea {
  width: 100%;
  padding: 9px 11px;
  border: 1.5px solid var(--border);
  border-radius: 6px;
  font-size: 14px;
  font-family: inherit;
  background: white;
  color: var(--text);
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--blue-600);
  box-shadow: 0 0 0 3px var(--blue-100);
}

button, a.primary, a.secondary, a.ghost, a.danger {
  cursor: pointer;
  font-family: inherit;
  font-size: 14px;
  font-weight: 700;
  border-radius: 6px;
  border: 1.5px solid transparent;
  padding: 9px 18px;
  transition: background 0.1s ease;
  display: inline-block;
  text-decoration: none;
  text-align: center;
  box-sizing: border-box;
}

button.primary, a.primary { background: var(--blue-600); color: white; }
button.primary:hover, a.primary:hover { background: var(--blue-700); }
button.secondary, a.secondary { background: white; color: var(--blue-700); border-color: var(--blue-600); }
button.secondary:hover, a.secondary:hover { background: var(--blue-50); }
button.ghost, a.ghost { background: transparent; color: var(--muted); border-color: var(--border); }
button.ghost:hover, a.ghost:hover { background: var(--blue-50); color: var(--blue-700); }
button.danger, a.danger { background: white; color: var(--red-600); border-color: var(--red-200); }
button.danger:hover, a.danger:hover { background: var(--red-50); }
button:disabled { opacity: 0.5; cursor: not-allowed; }

.row { display: flex; gap: 14px; }
.row > * { flex: 1; }

.item-row {
  display: grid;
  grid-template-columns: 2fr 1fr 40px;
  gap: 10px;
  align-items: end;
  margin-top: 10px;
}

.item-group {
  padding-bottom: 10px;
  margin-bottom: 4px;
  border-bottom: 1px dashed var(--border-light);
}

/* --- Customer hero --- */
.hero {
  background: linear-gradient(135deg, var(--blue-900) 0%, var(--blue-700) 60%, var(--blue-600) 100%);
  color: white;
  border-radius: var(--radius);
  padding: 46px 28px;
  text-align: center;
  margin-bottom: 22px;
  box-shadow: 0 4px 14px rgba(15, 23, 42, 0.3);
}

.hero h2 {
  color: white;
  font-size: 28px;
  margin: 0 0 10px;
}

.hero p {
  color: #cbd5e1;
  font-size: 15.5px;
  max-width: 520px;
  margin: 0 auto 24px;
}

/* Doubled selector on purpose: .cta-primary is defined later in this file, and at equal
   specificity it was silently overriding the hero variant — leaving an amber button on an
   amber gradient. */
.cta-primary.cta-hero {
  background: white;
  color: var(--blue-800);
  font-size: 16px;
  padding: 14px 32px;
}

.cta-primary.cta-hero:hover { background: var(--blue-50); color: var(--blue-900); }

/* --- Staff dashboard --- */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 14px;
  margin-bottom: 22px;
}

.stat-card {
  display: block;
  background: var(--panel);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  padding: 16px 18px;
  box-shadow: var(--shadow);
  text-decoration: none;
  color: var(--text);
  transition: border-color 0.1s ease, transform 0.1s ease;
}

a.stat-card:hover { border-color: var(--blue-600); transform: translateY(-1px); }

.stat-label {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}

.stat-value {
  font-size: 26px;
  font-weight: 800;
  color: var(--blue-900);
  margin-top: 4px;
  line-height: 1.1;
}

.stat-value.stat-warn { color: var(--amber, #b3781c); }
.stat-value.stat-bad { color: var(--red-600); }

/* --- Customer landing + tracking --- */
.cta-primary, .cta-secondary {
  display: inline-block;
  font-weight: 700;
  font-size: 15px;
  text-decoration: none;
  border-radius: 8px;
  padding: 13px 26px;
  border: 1.5px solid transparent;
}

.cta-primary { background: var(--blue-600); color: white; }
.cta-primary:hover { background: var(--blue-700); }
.cta-secondary {
  background: white;
  color: var(--blue-700);
  border-color: var(--blue-600);
  font-size: 14px;
  padding: 10px 18px;
}
.cta-secondary:hover { background: var(--blue-50); }

.track-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  text-decoration: none;
  color: var(--text);
  margin-bottom: 10px;
}

.track-card:hover { border-color: var(--blue-600); background: var(--blue-50); }

.track-steps {
  list-style: none;
  padding: 0;
  margin: 18px 0 0;
}

.track-step {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 0;
  position: relative;
  font-size: 14.5px;
}

/* Connector line between dots */
.track-step:not(:last-child)::after {
  content: "";
  position: absolute;
  left: 7px;
  top: 30px;
  bottom: -9px;
  width: 2px;
  background: var(--border-light);
}

.track-dot {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 2px solid var(--border);
  background: white;
  flex-shrink: 0;
  z-index: 1;
}

.track-step.done { color: var(--text); }
.track-step.done .track-dot { background: var(--blue-600); border-color: var(--blue-600); }
.track-step.done:not(:last-child)::after { background: var(--blue-600); }

.track-step.current { color: var(--blue-900); font-weight: 700; }
.track-step.current .track-dot {
  background: var(--blue-600);
  border-color: var(--blue-100);
  box-shadow: 0 0 0 4px var(--blue-100);
}

.track-step.todo { color: var(--muted); }

/* --- Delivery window picker --- */
.slot-btn {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  width: 100%;
  max-width: 420px;
  margin-bottom: 8px;
  background: white;
  border: 1.5px solid var(--border);
  color: var(--text);
  text-align: left;
  font-weight: 600;
}

.slot-btn:hover:not(:disabled) { border-color: var(--blue-600); background: var(--blue-50); }
.slot-btn.selected { border-color: var(--blue-600); background: var(--blue-100); color: var(--blue-900); }
.slot-btn.full { opacity: 0.5; }
.slot-btn .slot-cap { font-weight: 500; font-size: 12.5px; color: var(--muted); }
.slot-btn.selected .slot-cap { color: var(--blue-800); }

.photo-upload-btn {
  display: block;
  margin-top: 5px;
  padding: 5px 8px;
  font-size: 11px;
  font-weight: 700;
  text-align: center;
  color: var(--blue-700);
  background: white;
  border: 1.5px solid var(--blue-600);
  border-radius: 6px;
  cursor: pointer;
}

.photo-upload-btn:hover { background: var(--blue-50); }

.tile.out-of-stock { opacity: 0.45; cursor: not-allowed; }
.tile.out-of-stock:hover { border-color: var(--border); box-shadow: none; }

/* --- Product photos --- */
.product-thumb {
  display: block;
  width: 96px;
  height: 64px;
  object-fit: cover;
  border-radius: 6px;
  border: 1px solid var(--border-light);
  background: var(--blue-50);
}

.thumb-empty {
  width: 96px;
  height: 64px;
  border-radius: 6px;
  border: 1px dashed var(--border);
  background: var(--blue-50);
  color: var(--muted);
  font-size: 11px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* --- Category-first browse (customer order page) --- */
.tile-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 14px;
  margin-top: 12px;
}

.tile {
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  background: white;
  padding: 0;
  overflow: hidden;
  cursor: pointer;
  text-align: left;
  font-family: inherit;
  transition: border-color 0.1s ease, box-shadow 0.1s ease;
}

.tile:hover { border-color: var(--blue-600); box-shadow: var(--shadow); }

.tile img, .tile .tile-noimg {
  display: block;
  width: 100%;
  height: 110px;
  object-fit: cover;
  background: var(--blue-50);
}

.tile .tile-noimg {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  font-size: 12px;
}

.tile-body { padding: 10px 12px; }
.tile-name { font-weight: 700; font-size: 14px; color: var(--text); line-height: 1.3; }
.tile-meta { font-size: 12.5px; color: var(--muted); margin-top: 3px; }
.tile-price { font-weight: 700; color: var(--blue-700); font-size: 14px; margin-top: 5px; }
.tile-price .was { color: var(--muted); font-weight: 500; text-decoration: line-through; margin-left: 5px; font-size: 12px; }

.browse-crumb {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 10px 0 0;
  font-size: 14px;
  color: var(--muted);
}

.cart-line {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border-light);
}

.cart-line:last-child { border-bottom: none; }
.cart-line .cart-name { flex: 1; font-size: 14px; }
.cart-line .cart-qty { width: 90px; }
.cart-line .cart-sub { width: 90px; text-align: right; font-weight: 700; font-size: 14px; }

.cart-total {
  display: flex;
  justify-content: space-between;
  padding-top: 10px;
  margin-top: 6px;
  border-top: 2px solid var(--blue-100);
  font-weight: 800;
  font-size: 16px;
  color: var(--blue-900);
}

.item-group:last-child { border-bottom: none; }

.error-box {
  background: var(--red-50);
  border: 1.5px solid var(--red-200);
  color: var(--red-600);
  padding: 11px 14px;
  border-radius: 8px;
  margin-top: 14px;
  font-size: 14px;
  font-weight: 600;
}

.success-box {
  background: var(--blue-50);
  border: 1.5px solid var(--blue-100);
  color: var(--blue-900);
  padding: 11px 14px;
  border-radius: 8px;
  margin-top: 14px;
  font-size: 14px;
  font-weight: 600;
}

.pile-group { margin-bottom: 28px; }
.pile-group h3 {
  font-size: 14px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--blue-800);
  border-bottom: 2px solid var(--blue-100);
  padding-bottom: 8px;
  margin-bottom: 12px;
}

.card {
  background: var(--panel);
  border: 1px solid var(--border-light);
  border-left: 5px solid var(--blue-600);
  border-radius: var(--radius);
  padding: 16px 18px;
  margin-bottom: 14px;
  box-shadow: var(--shadow);
}

.card.delivery { border-left-color: var(--navy); border-left-style: dashed; }

.badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 4px 10px;
  border-radius: 12px;
  color: white;
  background: var(--blue-600);
}

.badge.delivery { background: var(--navy); }
.badge.status {
  background: var(--blue-50);
  color: var(--blue-800);
  border: 1px solid var(--blue-100);
  margin-left: 8px;
}

.card-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
}

.card .meta { color: var(--muted); font-size: 13.5px; margin: 8px 0 0; }
.card .items { font-size: 14px; margin: 10px 0; padding-left: 20px; }
.card .items li { margin-bottom: 3px; }
.card .address {
  font-size: 13.5px;
  background: var(--blue-50);
  color: var(--blue-900);
  padding: 8px 10px;
  border-radius: 6px;
  margin-top: 8px;
  font-weight: 600;
}

.card-actions { margin-top: 12px; display: flex; gap: 8px; flex-wrap: wrap; }

.columns {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 18px;
}

.column h3 {
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--blue-800);
  border-bottom: 2px solid var(--blue-100);
  padding-bottom: 8px;
}

.empty {
  color: var(--muted);
  font-style: italic;
  font-size: 14px;
  padding: 14px;
  text-align: center;
  background: var(--blue-50);
  border-radius: 8px;
  border: 1px dashed var(--border);
}

.dispatch-form { display: flex; gap: 8px; margin-top: 12px; align-items: end; }
.dispatch-form > div { flex: 1; }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

thead th {
  text-align: left;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--blue-800);
  background: var(--blue-50);
  padding: 10px 12px;
  border-bottom: 2px solid var(--blue-100);
}

tbody td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border-light);
  color: var(--text);
}

tbody tr:hover { background: var(--blue-50); cursor: default; }
tbody tr.clickable:hover { cursor: pointer; }

.pill {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  padding: 3px 9px;
  border-radius: 10px;
  background: var(--blue-100);
  color: var(--blue-900);
}

.pill.inactive { background: #e6e9ef; color: var(--muted); }

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

.toolbar .filters { display: flex; gap: 10px; flex-wrap: wrap; }
.toolbar input[type=text] { min-width: 220px; width: auto; }
.toolbar select { width: auto; }

.detail-panel {
  border-top: 1px solid var(--border-light);
  margin-top: 10px;
  padding-top: 10px;
  font-size: 13.5px;
}

.timeline { list-style: none; padding: 0; margin: 8px 0 0; }
.timeline li {
  padding: 6px 0 6px 18px;
  border-left: 2px solid var(--blue-100);
  position: relative;
  color: var(--muted);
}
.timeline li::before {
  content: "";
  position: absolute;
  left: -5px;
  top: 10px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--blue-600);
}
.timeline li strong { color: var(--text); }

@media (max-width: 900px) {
  .columns { grid-template-columns: 1fr; }
  header.topbar { flex-direction: column; align-items: flex-start; gap: 10px; }
}
