/* LATEST UPDATE TOOLS — design tokens
   Palette: charcoal shop-floor background, safety-orange accent (hazard signage),
   steel-blue for BTC/crypto elements, mono type for prices/addresses/order IDs
   (the "spec plate" numbers), condensed grotesk for headers (stenciled tool-tag feel). */

:root {
  --bg: #1b1d1f;
  --surface: #232628;
  --surface-raised: #2a2d30;
  --border: #3a3f42;
  --text: #ededed;
  --text-dim: #9aa0a6;
  --accent: #ff6a13;
  --accent-dim: #c85510;
  --steel: #4fa8d8;
  --ok: #4cae6d;
  --danger: #e5484d;
  --font-display: "Oswald", "Arial Narrow", sans-serif;
  --font-body: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-mono: "IBM Plex Mono", "SF Mono", Consolas, monospace;
  --radius: 3px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.5;
}

body {
  background-image:
    linear-gradient(var(--border) 1px, transparent 1px),
    linear-gradient(90deg, var(--border) 1px, transparent 1px);
  background-size: 48px 48px;
  background-position: -1px -1px;
  background-attachment: fixed;
  background-color: var(--bg);
  opacity: 1;
}
body::before {
  content: "";
}

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

h1, h2, h3, h4 {
  font-family: var(--font-display);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-weight: 600;
  margin: 0 0 0.5em;
}

.mono { font-family: var(--font-mono); }

button, input, textarea, select {
  font-family: inherit;
  font-size: inherit;
}

button {
  cursor: pointer;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; }
}

/* --- Layout shell --- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 24px;
  background: var(--surface);
  border-bottom: 3px solid var(--accent);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-display);
  font-size: 22px;
  letter-spacing: 0.06em;
  color: var(--text);
}
.brand .bolt {
  width: 10px; height: 10px;
  background: var(--accent);
  transform: rotate(45deg);
  flex: none;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 18px;
}

.cart-btn {
  position: relative;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
  padding: 8px 14px;
  border-radius: var(--radius);
  font-family: var(--font-mono);
  font-size: 14px;
}
.cart-btn:hover { border-color: var(--accent); }
.cart-count {
  position: absolute;
  top: -8px; right: -8px;
  background: var(--accent);
  color: #1b1d1f;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  min-width: 18px;
  height: 18px;
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
}

.container {
  max-width: 1180px;
  margin: 0 auto;
  padding: 32px 24px 80px;
}

/* --- Hero --- */
.hero {
  padding: 56px 24px 40px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(180deg, rgba(255,106,19,0.06), transparent 70%);
}
.hero-inner { max-width: 1180px; margin: 0 auto; }
.hero .eyebrow {
  font-family: var(--font-mono);
  color: var(--accent);
  font-size: 13px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  margin-bottom: 10px;
}
.hero h1 {
  font-size: clamp(32px, 5vw, 52px);
  margin-bottom: 12px;
  color: var(--text);
}
.hero p {
  color: var(--text-dim);
  max-width: 560px;
  font-size: 16px;
}
.hero .btc-note {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-top: 18px;
  padding: 8px 14px;
  border: 1px solid var(--steel);
  border-radius: var(--radius);
  color: var(--steel);
  font-family: var(--font-mono);
  font-size: 13px;
}

/* --- Product grid: "spec plate" tags --- */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 20px;
  margin-top: 28px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  position: relative;
  transition: border-color 0.15s ease, transform 0.15s ease;
}
.card:hover { border-color: var(--accent); transform: translateY(-2px); }

.card .rivet {
  position: absolute;
  top: 10px; left: 10px;
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--border);
  box-shadow: 0 0 0 2px var(--bg);
  z-index: 2;
}

.card-img {
  width: 100%;
  aspect-ratio: 4 / 3;
  background: var(--surface-raised) center/cover no-repeat;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-dim);
  font-family: var(--font-mono);
  font-size: 12px;
  border-bottom: 1px dashed var(--border);
}

.card-body {
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
}

.card-title {
  font-family: var(--font-display);
  font-size: 16px;
  letter-spacing: 0.02em;
  text-transform: none;
}

.card-desc {
  color: var(--text-dim);
  font-size: 13px;
  flex: 1;
}

.card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 8px;
}

.price {
  font-family: var(--font-mono);
  font-size: 16px;
  color: var(--accent);
  font-weight: 700;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 16px;
  border-radius: var(--radius);
  border: 1px solid var(--accent);
  background: var(--accent);
  color: #1b1d1f;
  font-weight: 700;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.btn:hover { background: var(--accent-dim); border-color: var(--accent-dim); }
.btn.secondary {
  background: transparent;
  color: var(--text);
  border-color: var(--border);
}
.btn.secondary:hover { border-color: var(--text-dim); }
.btn.steel {
  background: var(--steel);
  border-color: var(--steel);
  color: #10222c;
}
.btn.danger {
  background: transparent;
  border-color: var(--danger);
  color: var(--danger);
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn.small { padding: 6px 10px; font-size: 12px; }
.btn.block { width: 100%; }

/* --- Cart drawer --- */
.overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.55);
  z-index: 50;
  display: none;
}
.overlay.open { display: block; }

.drawer {
  position: fixed;
  top: 0; right: 0;
  height: 100%;
  width: min(420px, 100%);
  background: var(--surface);
  border-left: 1px solid var(--border);
  z-index: 51;
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 0.2s ease;
}
.drawer.open { transform: translateX(0); }

.drawer-header {
  padding: 18px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.drawer-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px 20px;
}
.drawer-footer {
  padding: 18px 20px;
  border-top: 1px solid var(--border);
}

.cart-line {
  display: flex;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px dashed var(--border);
}
.cart-line img {
  width: 56px; height: 56px;
  object-fit: cover;
  border-radius: var(--radius);
  background: var(--surface-raised);
  flex: none;
}
.cart-line-info { flex: 1; }
.cart-line-title { font-size: 14px; margin-bottom: 4px; }
.qty-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 6px;
}
.qty-controls button {
  width: 24px; height: 24px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text);
}
.qty-controls .qty-val { font-family: var(--font-mono); min-width: 20px; text-align: center; }
.remove-link { color: var(--danger); font-size: 12px; background: none; border: none; padding: 0; margin-top: 6px; cursor: pointer; }

.cart-total-row {
  display: flex;
  justify-content: space-between;
  font-family: var(--font-mono);
  font-size: 18px;
  margin-bottom: 14px;
}

/* --- Forms --- */
.field { margin-bottom: 16px; }
.field label {
  display: block;
  font-size: 13px;
  color: var(--text-dim);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.field input, .field textarea, .field select {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 10px 12px;
  border-radius: var(--radius);
}
.field input:focus, .field textarea:focus, .field select:focus {
  border-color: var(--accent);
  outline: none;
}
.field textarea { resize: vertical; min-height: 80px; }
.hint { color: var(--text-dim); font-size: 12px; margin-top: 4px; }

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
}

/* --- Order / payment box --- */
.order-box {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
}
@media (max-width: 720px) {
  .order-box { grid-template-columns: 1fr; }
}

.btc-panel {
  background: var(--surface);
  border: 1px solid var(--steel);
  border-radius: var(--radius);
  padding: 20px;
  text-align: center;
}
.btc-panel .label {
  font-family: var(--font-mono);
  color: var(--steel);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-bottom: 10px;
}
.btc-address {
  font-family: var(--font-mono);
  font-size: 13px;
  word-break: break-all;
  background: var(--bg);
  border: 1px dashed var(--border);
  padding: 10px;
  border-radius: var(--radius);
  margin: 12px 0;
}
#qrcode { display: flex; justify-content: center; margin: 16px 0; background: #fff; padding: 10px; border-radius: var(--radius); width: fit-content; margin-left: auto; margin-right: auto; }

.status-badge {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 4px 10px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
}
.status-pending_payment { color: var(--text-dim); }
.status-awaiting_confirmation { color: var(--accent); border-color: var(--accent); }
.status-paid, .status-completed { color: var(--ok); border-color: var(--ok); }
.status-shipped { color: var(--steel); border-color: var(--steel); }
.status-disputed, .status-refunded { color: var(--danger); border-color: var(--danger); }

/* --- Chat --- */
.chat-log {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: 320px;
  overflow-y: auto;
  padding: 14px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 12px;
}
.chat-msg {
  max-width: 80%;
  padding: 8px 12px;
  border-radius: var(--radius);
  font-size: 14px;
}
.chat-msg.customer {
  align-self: flex-end;
  background: var(--accent-dim);
  color: #fff;
}
.chat-msg.admin {
  align-self: flex-start;
  background: var(--surface-raised);
  border: 1px solid var(--border);
}
.chat-msg .meta {
  display: block;
  font-family: var(--font-mono);
  font-size: 10px;
  opacity: 0.7;
  margin-top: 4px;
}
.chat-input-row { display: flex; gap: 8px; }
.chat-input-row input { flex: 1; }

/* --- Admin --- */
.admin-shell { display: flex; min-height: 100vh; }
.admin-nav {
  width: 220px;
  flex: none;
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 20px 0;
}
.admin-nav .brand { padding: 0 20px 20px; border-bottom: 1px solid var(--border); margin-bottom: 10px; }
.admin-nav button {
  display: flex;
  width: 100%;
  text-align: left;
  padding: 12px 20px;
  background: none;
  border: none;
  color: var(--text-dim);
  font-family: var(--font-mono);
  font-size: 13px;
  border-left: 3px solid transparent;
}
.admin-nav button.active {
  color: var(--text);
  border-left-color: var(--accent);
  background: var(--surface-raised);
}
.admin-main { flex: 1; padding: 32px; max-width: 1000px; }

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
.table th, .table td {
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
}
.table th {
  font-family: var(--font-mono);
  text-transform: uppercase;
  font-size: 11px;
  color: var(--text-dim);
  letter-spacing: 0.05em;
}
.table tr:hover td { background: var(--surface-raised); }

.tag-list { display: flex; flex-wrap: wrap; gap: 8px; }

.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-dim);
}
.empty-state h3 { color: var(--text); margin-bottom: 8px; }

.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--surface-raised);
  border: 1px solid var(--accent);
  color: var(--text);
  padding: 12px 20px;
  border-radius: var(--radius);
  font-size: 14px;
  z-index: 100;
  display: none;
}
.toast.show { display: block; }

.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.6);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 60;
  padding: 20px;
}
.modal-overlay.open { display: flex; }
.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  max-width: 520px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  padding: 24px;
}

.flex-between { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.text-dim { color: var(--text-dim); }
.small { font-size: 13px; }
