/* =========================================================================
   Hardware Shop POS — Design System
   Direction: a working shop floor, not a SaaS dashboard. Kraft-paper tags,
   pegboard walls, stamped ink numbers, hazard-stripe accents used sparingly.
   ========================================================================= */

@import url('https://fonts.googleapis.com/css2?family=Big+Shoulders+Display:wght@600;700;800;900&family=IBM+Plex+Sans:wght@400;500;600;700&family=IBM+Plex+Mono:wght@400;500;600&display=swap');

:root {
  --ink: #1B1712;
  --ink-soft: #55503f;
  --paper: #EDE4CF;
  --paper-deep: #E3D8BE;
  --panel: #F8F2E2;
  --panel-raised: #FFFBF2;
  --line: #C9BC9C;
  --line-strong: #a89a76;
  --rust: #BF4E1E;
  --rust-dark: #8f3a15;
  --rust-tint: #f0c8ac;
  --steel: #33505E;
  --steel-dark: #223740;
  --brass: #C08A25;
  --brass-tint: #f2dca4;
  --forest: #3C5B3A;
  --forest-tint: #cfe0c8;
  --danger: #9C2B21;
  --shadow-hard: 4px 4px 0 rgba(27, 23, 18, 0.18);
  --shadow-soft: 0 2px 10px rgba(27, 23, 18, 0.12);
  --radius-tag: 6px;
  --font-display: 'Big Shoulders Display', sans-serif;
  --font-body: 'IBM Plex Sans', sans-serif;
  --font-mono: 'IBM Plex Mono', monospace;
}

* { box-sizing: border-box; }
html, body { height: 100%; }

body {
  margin: 0;
  font-family: var(--font-body);
  color: var(--ink);
  background-color: var(--paper);
  background-image:
    radial-gradient(circle at 1px 1px, rgba(27,23,18,0.05) 1px, transparent 0);
  background-size: 22px 22px;
  position: relative;
  min-height: 100vh;
}

/* grain overlay */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 999;
  opacity: 0.05;
  mix-blend-mode: multiply;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='120' height='120'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/></filter><rect width='100%25' height='100%25' filter='url(%23n)'/></svg>");
}

a { color: inherit; }
h1, h2, h3, h4 { font-family: var(--font-display); font-weight: 800; letter-spacing: 0.01em; margin: 0; text-transform: uppercase; }
p { margin: 0 0 0.6em; line-height: 1.5; }
.mono { font-family: var(--font-mono); }

/* ---------------------------------------------------------------------- */
/* Layout shell                                                           */
/* ---------------------------------------------------------------------- */
.app-shell {
  display: grid;
  grid-template-columns: 240px 1fr;
  min-height: 100vh;
}
@media (max-width: 860px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidenav { position: sticky; top: 0; z-index: 40; }
}

.sidenav {
  background:
    radial-gradient(circle at 20px 24px, rgba(255,255,255,0.06) 2px, transparent 2.4px),
    var(--steel-dark);
  background-size: 40px 40px, auto;
  color: #EFE7D8;
  padding: 22px 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 22px;
  border-right: 3px solid var(--ink);
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
}
.brand-mark {
  width: 34px; height: 34px;
  background: var(--rust);
  border: 2px solid var(--ink);
  border-radius: 3px;
  display: flex; align-items: center; justify-content: center;
  transform: rotate(-4deg);
  box-shadow: var(--shadow-hard);
  flex: none;
}
.brand-mark svg { width: 20px; height: 20px; }
.brand-text { font-family: var(--font-display); font-weight: 900; font-size: 1.25rem; line-height: 1; text-transform: uppercase; letter-spacing: 0.03em; }
.brand-text small { display: block; font-family: var(--font-mono); font-size: 0.6rem; font-weight: 500; letter-spacing: 0.12em; color: var(--brass-tint); text-transform: uppercase; margin-top: 2px; }

.nav-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.nav-list a {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px 10px 14px;
  border-radius: 4px;
  text-decoration: none;
  font-weight: 600;
  font-size: 0.92rem;
  color: #d9d0ba;
  border: 1px solid transparent;
  position: relative;
}
.nav-list a::before {
  content: "";
  width: 6px; height: 6px; border-radius: 50%;
  background: #7c8f96;
  border: 1px solid rgba(0,0,0,0.3);
  flex: none;
}
.nav-list a:hover { background: rgba(255,255,255,0.06); }
.nav-list a.active {
  background: var(--rust);
  color: #fff;
  border-color: var(--ink);
  box-shadow: var(--shadow-hard);
}
.nav-list a.active::before { background: #fff; }

.sidenav-footer { margin-top: auto; display: flex; flex-direction: column; gap: 10px; }
.who-tag {
  background: var(--panel-raised);
  color: var(--ink);
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius-tag);
  padding: 8px 10px;
  font-size: 0.78rem;
}
.who-tag .role-pill { font-family: var(--font-mono); text-transform: uppercase; font-size: 0.62rem; letter-spacing: 0.08em; color: var(--rust-dark); font-weight: 700; }

.btn-logout {
  background: transparent;
  border: 1px solid #56606a;
  color: #d9d0ba;
  padding: 9px 12px;
  border-radius: 4px;
  font-family: var(--font-body);
  font-weight: 600;
  cursor: pointer;
  font-size: 0.85rem;
}
.btn-logout:hover { border-color: var(--rust); color: #fff; }

main.content { padding: 28px 32px 60px; max-width: 1280px; }
@media (max-width: 640px) { main.content { padding: 18px 16px 48px; } }

.page-head {
  display: flex; align-items: flex-end; justify-content: space-between; gap: 16px;
  margin-bottom: 24px; flex-wrap: wrap;
  border-bottom: 3px solid var(--ink);
  padding-bottom: 14px;
}
.page-head h1 { font-size: 2rem; }
.page-head .eyebrow { font-family: var(--font-mono); font-size: 0.72rem; letter-spacing: 0.14em; text-transform: uppercase; color: var(--rust-dark); font-weight: 600; display: block; margin-bottom: 4px; }
.page-head-actions { display: flex; gap: 10px; flex-wrap: wrap; }

/* ---------------------------------------------------------------------- */
/* Buttons & inputs                                                       */
/* ---------------------------------------------------------------------- */
.btn {
  font-family: var(--font-body);
  font-weight: 700;
  font-size: 0.86rem;
  padding: 10px 18px;
  border-radius: 4px;
  border: 2px solid var(--ink);
  background: var(--panel-raised);
  color: var(--ink);
  cursor: pointer;
  box-shadow: var(--shadow-hard);
  transition: transform 0.08s ease;
  text-decoration: none;
  display: inline-flex; align-items: center; gap: 8px;
}
.btn:active { transform: translate(2px, 2px); box-shadow: 0 0 0 rgba(0,0,0,0); }
.btn-primary { background: var(--rust); color: #fff; }
.btn-steel { background: var(--steel); color: #fff; }
.btn-ghost { background: transparent; box-shadow: none; }
.btn-danger { background: var(--danger); color: #fff; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn.small { padding: 6px 12px; font-size: 0.76rem; }

label { display: block; font-weight: 600; font-size: 0.8rem; margin-bottom: 6px; color: var(--ink-soft); text-transform: uppercase; letter-spacing: 0.04em; }
input, select, textarea {
  width: 100%;
  font-family: var(--font-body);
  font-size: 0.95rem;
  padding: 10px 12px;
  border: 2px solid var(--line-strong);
  border-radius: 4px;
  background: var(--panel-raised);
  color: var(--ink);
}
input:focus, select:focus, textarea:focus {
  outline: 3px solid var(--brass-tint);
  outline-offset: 0;
  border-color: var(--rust);
}
.field { margin-bottom: 14px; }
.field-row { display: grid; gap: 14px; grid-template-columns: 1fr 1fr; }
@media (max-width: 560px) { .field-row { grid-template-columns: 1fr; } }

/* ---------------------------------------------------------------------- */
/* Cards / tags                                                           */
/* ---------------------------------------------------------------------- */
.panel {
  background: var(--panel);
  border: 2px solid var(--ink);
  border-radius: var(--radius-tag);
  box-shadow: var(--shadow-hard);
  padding: 20px;
}

.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 16px; margin-bottom: 26px; }
.kpi-card {
  background: var(--panel-raised);
  border: 2px solid var(--ink);
  border-radius: var(--radius-tag);
  padding: 16px 18px;
  position: relative;
  box-shadow: var(--shadow-hard);
  clip-path: polygon(0 0, calc(100% - 14px) 0, 100% 14px, 100% 100%, 0 100%);
}
.kpi-card::after {
  content: "";
  position: absolute; top: 8px; right: 8px;
  width: 8px; height: 8px; border-radius: 50%;
  border: 1.5px solid var(--ink);
  background: var(--paper);
}
.kpi-label { font-family: var(--font-mono); font-size: 0.68rem; text-transform: uppercase; letter-spacing: 0.1em; color: var(--ink-soft); margin-bottom: 8px; }
.kpi-value { font-family: var(--font-display); font-weight: 900; font-size: 2.1rem; line-height: 1; color: var(--ink); }
.kpi-value.rust { color: var(--rust-dark); }
.kpi-value.forest { color: var(--forest); }
.kpi-sub { font-size: 0.76rem; color: var(--ink-soft); margin-top: 6px; }

/* ---------------------------------------------------------------------- */
/* Tables                                                                  */
/* ---------------------------------------------------------------------- */
.table-wrap { overflow-x: auto; border: 2px solid var(--ink); border-radius: var(--radius-tag); background: var(--panel-raised); }
table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
thead th {
  text-align: left; font-family: var(--font-mono); font-size: 0.68rem; text-transform: uppercase;
  letter-spacing: 0.08em; color: var(--paper); background: var(--steel-dark);
  padding: 10px 14px; white-space: nowrap;
}
tbody td { padding: 10px 14px; border-top: 1px solid var(--line); vertical-align: middle; }
tbody tr:hover { background: rgba(191, 78, 30, 0.06); }
tbody tr:nth-child(even) { background: rgba(27,23,18,0.02); }
td.num, th.num { text-align: right; font-family: var(--font-mono); }

.badge {
  display: inline-flex; align-items: center; gap: 6px;
  font-family: var(--font-mono); font-size: 0.68rem; text-transform: uppercase; letter-spacing: 0.06em;
  padding: 3px 9px; border-radius: 20px; border: 1.5px solid currentColor; font-weight: 600;
}
.badge-ok { color: var(--forest); background: var(--forest-tint); }
.badge-low { color: var(--rust-dark); background: var(--rust-tint); }
.badge-warn { color: var(--brass); background: var(--brass-tint); }
.badge-off { color: var(--ink-soft); background: var(--line); border-color: var(--line-strong); }

/* hazard stripe, used sparingly for critical alerts only */
.hazard-strip {
  background: repeating-linear-gradient(135deg, var(--brass) 0 14px, var(--ink) 14px 28px);
  height: 8px; border-radius: 4px; margin-bottom: 14px;
}

/* ---------------------------------------------------------------------- */
/* Login / setup screen                                                    */
/* ---------------------------------------------------------------------- */
.auth-wrap {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
  background:
    linear-gradient(var(--steel-dark), var(--steel-dark)),
    repeating-linear-gradient(180deg, rgba(255,255,255,0.035) 0 3px, transparent 3px 26px);
  background-blend-mode: normal;
}
.auth-card {
  width: 100%; max-width: 400px;
  background: var(--panel-raised);
  border: 3px solid var(--ink);
  border-radius: 8px;
  box-shadow: 8px 8px 0 rgba(0,0,0,0.35);
  padding: 30px 28px 26px;
}
.auth-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 22px; }
.auth-title { font-family: var(--font-display); font-weight: 900; font-size: 1.6rem; text-transform: uppercase; }
.auth-title small { display: block; font-family: var(--font-mono); font-size: 0.68rem; color: var(--ink-soft); letter-spacing: 0.1em; }
.auth-error { background: var(--rust-tint); border: 1.5px solid var(--rust-dark); color: var(--rust-dark); padding: 10px 12px; border-radius: 4px; font-size: 0.85rem; margin-bottom: 14px; display: none; }
.auth-toggle { margin-top: 18px; text-align: center; font-size: 0.82rem; color: var(--ink-soft); }
.auth-toggle button { background: none; border: none; color: var(--rust-dark); font-weight: 700; cursor: pointer; text-decoration: underline; padding: 0; font-size: inherit; }

/* ---------------------------------------------------------------------- */
/* POS / sale screen                                                       */
/* ---------------------------------------------------------------------- */
.pos-grid { display: grid; grid-template-columns: 1.5fr 1fr; gap: 20px; align-items: start; }
@media (max-width: 960px) { .pos-grid { grid-template-columns: 1fr; } }

.product-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.product-tag {
  background: var(--panel-raised);
  border: 2px solid var(--ink);
  border-radius: 4px;
  padding: 12px;
  cursor: pointer;
  text-align: left;
  font-family: var(--font-body);
  box-shadow: var(--shadow-hard);
  position: relative;
}
.product-tag:hover { background: var(--brass-tint); }
.product-tag:disabled { opacity: 0.4; cursor: not-allowed; }
.product-tag .p-name { font-weight: 700; font-size: 0.88rem; display: block; margin-bottom: 4px; }
.product-tag .p-sku { font-family: var(--font-mono); font-size: 0.66rem; color: var(--ink-soft); display: block; margin-bottom: 8px; }
.product-tag .p-price { font-family: var(--font-mono); font-weight: 700; color: var(--rust-dark); font-size: 1rem; }
.product-tag .p-stock { position: absolute; top: 8px; right: 8px; font-family: var(--font-mono); font-size: 0.62rem; }

.cart-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; max-height: 360px; overflow-y: auto; }
.cart-item { display: flex; align-items: center; justify-content: space-between; gap: 8px; border-bottom: 1px dashed var(--line-strong); padding-bottom: 8px; }
.cart-item .ci-name { font-weight: 600; font-size: 0.85rem; }
.cart-item .ci-meta { font-family: var(--font-mono); font-size: 0.72rem; color: var(--ink-soft); }
.qty-control { display: flex; align-items: center; gap: 6px; }
.qty-control button { width: 24px; height: 24px; border-radius: 3px; border: 2px solid var(--ink); background: var(--panel); cursor: pointer; font-weight: 700; line-height: 1; }
.cart-total-row { display: flex; justify-content: space-between; align-items: baseline; margin-top: 16px; padding-top: 14px; border-top: 3px solid var(--ink); }
.cart-total-row .ct-label { font-family: var(--font-mono); text-transform: uppercase; font-size: 0.75rem; }
.cart-total-row .ct-value { font-family: var(--font-display); font-size: 2rem; font-weight: 900; color: var(--rust-dark); }

/* ---------------------------------------------------------------------- */
/* Modal                                                                    */
/* ---------------------------------------------------------------------- */
.modal-backdrop { position: fixed; inset: 0; background: rgba(23,20,15,0.55); display: none; align-items: center; justify-content: center; z-index: 100; padding: 20px; }
.modal-backdrop.open { display: flex; }
.modal { width: 100%; max-width: 480px; background: var(--panel-raised); border: 3px solid var(--ink); border-radius: 8px; box-shadow: 10px 10px 0 rgba(0,0,0,0.3); padding: 24px; max-height: 90vh; overflow-y: auto; }
.modal h2 { font-size: 1.3rem; margin-bottom: 16px; }
.modal-close { position: absolute; }

/* ---------------------------------------------------------------------- */
/* Toast                                                                    */
/* ---------------------------------------------------------------------- */
#toast-root { position: fixed; bottom: 20px; right: 20px; display: flex; flex-direction: column; gap: 10px; z-index: 200; }
.toast { background: var(--ink); color: var(--paper); padding: 12px 16px; border-radius: 4px; font-size: 0.85rem; box-shadow: var(--shadow-hard); border: 2px solid var(--ink); max-width: 320px; }
.toast.error { background: var(--danger); border-color: var(--rust-dark); }
.toast.success { background: var(--forest); border-color: #274a26; }

/* ---------------------------------------------------------------------- */
/* Misc                                                                     */
/* ---------------------------------------------------------------------- */
.empty-state { text-align: center; padding: 40px 20px; color: var(--ink-soft); }
.empty-state h3 { margin-bottom: 8px; }
.divider { height: 2px; background: var(--line); margin: 22px 0; border: none; }
.helper-text { font-size: 0.78rem; color: var(--ink-soft); margin-top: -8px; margin-bottom: 14px; }
.section-title { font-size: 1.15rem; margin-bottom: 14px; }
.flex-between { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
@media (max-width: 900px) { .two-col { grid-template-columns: 1fr; } }
.bar-chart { display: flex; align-items: flex-end; gap: 6px; height: 160px; padding-top: 10px; }
.bar-chart .bar { flex: 1; background: var(--rust); border: 2px solid var(--ink); border-radius: 3px 3px 0 0; min-height: 3px; position: relative; }
.bar-chart .bar-label { position: absolute; bottom: -20px; left: 50%; transform: translateX(-50%) rotate(0deg); font-family: var(--font-mono); font-size: 0.6rem; color: var(--ink-soft); white-space: nowrap; }
.loading-row { text-align: center; padding: 30px; color: var(--ink-soft); font-family: var(--font-mono); font-size: 0.8rem; }
