/* ===========================================================
   MaaK · Inventory — brand-matched styles
   Matches maakhq.com: dark nav, white canvas, green accent,
   Inter body, JetBrains Mono for data/labels.
=========================================================== */

/* Import MaaK fonts (Playfair Display for headings, Inter for body) */
@import url('https://fonts.googleapis.com/css2?family=Playfair+Display:wght@400;500;600;700;800&family=Inter:wght@300;400;500;600;700&family=JetBrains+Mono:wght@400;500;600&display=swap');

:root {
  /* Primary brand (MaaK orange) */
  --primary-DEFAULT: #f97316; /* main orange */
  --primary-600: #f97316;
  --primary-500: #fb923c;
  --primary-50:  #fff7ed;
  --primary-700: #ea580c;

  /* retain existing palette but align accent with MaaK */
  --ink:        #0b0c0b;
  --ink-soft:   #5a6360;
  --paper:      #ffffff;
  --surface:    #f7f8f7;
  --line:       #e4e7e4;
  --line-soft:  #f0f2f0;
  --accent:     var(--primary-500);
  --accent-dark:var(--primary-600);
  --accent-ink: #3b2b1a;
  --accent-dim: #fff7ed;
  --danger:     #e03e3e;
  --danger-dim: #fdeaea;
  --warn:       #c07a10;
  --warn-dim:   #fdf0d6;
  --nav-bg:     #0b0c0b;
  --nav-border: #1a1d1a;

  --font-body: 'Inter', system-ui, sans-serif;
  --font-heading: 'Playfair Display', serif;
  --font-mono: 'JetBrains Mono', 'SFMono-Regular', monospace;

  --r-sm: 6px;
  --r-md: 10px;
  --r-lg: 16px;
  --shadow: 0 4px 20px -4px rgba(11,12,11,0.14);
  --shadow-lg: 0 16px 40px -12px rgba(11,12,11,0.22);
}

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }

body {
  background: var(--surface);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

/* Headings use the Playfair Display brand font */
h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-heading);
  color: var(--ink);
}

/* Utility classes for primary brand color */
.text-primary { color: var(--primary-DEFAULT) !important; }
.bg-primary { background-color: var(--primary-DEFAULT) !important; }
.border-primary { border-color: var(--primary-DEFAULT) !important; }

.dropdown-menu {
  display: none;
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 160ms ease, transform 160ms ease;
}

.dropdown-menu.active {
  display: block;
  opacity: 1;
  transform: translateY(0);
}

/* Small helper for gradient accents as used in MaaK template */
.gradient-primary { background: linear-gradient(135deg, var(--primary-50) 0%, var(--primary-500) 100%); }

a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; }
img { max-width: 100%; }

/* ─── NAV ─── */
.topbar {
  background: var(--nav-bg);
  border-bottom: 1px solid var(--nav-border);
  position: sticky;
  top: 0;
  z-index: 100;
}
.topbar__inner {
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 28px;
  height: 60px;
  display: flex;
  align-items: center;
  gap: 28px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-right: auto;
}
.brand img {
  height: 26px;
  width: auto;
  filter: brightness(0) invert(1);
}
.brand__name {
  color: #ffffff;
  font-weight: 700;
  font-size: 15px;
  letter-spacing: 0.01em;
}
.brand__mark {
  width: 28px; height: 28px;
  background: var(--accent);
  color: var(--accent-ink);
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 14px;
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.modnav {
  display: flex;
  gap: 2px;
}
.modnav__link {
  color: #9fa89e;
  font-size: 13.5px;
  font-weight: 500;

/* Product card small styles (matches MaaK header) */
.product-card { transition: all .12s ease; }
.product-card:hover { transform: translateY(-2px); }
.product-card .w-10 { flex-shrink:0 }
  padding: 7px 14px;
  border-radius: var(--r-sm);
  transition: color .15s, background .15s;
}
.modnav__link:hover { color: #fff; background: #1a1d1a; }
.modnav__link.is-active {
  color: var(--accent-ink);
  background: var(--accent);
  font-weight: 600;
}
.topbar__cta {
  margin-left: 6px;
}

/* ─── BUTTONS ─── */
.btn {
  font-family: inherit;
  font-size: 13.5px;
  font-weight: 600;
  border-radius: var(--r-sm);
  padding: 9px 18px;
  border: 1.5px solid transparent;
  cursor: pointer;
  transition: all .15s ease;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 7px;
}
.btn:active { transform: translateY(1px); }

.btn--primary {
  background: linear-gradient(135deg, var(--primary-500), var(--primary-600));
  color: #ffffff;
  border-color: transparent;
  box-shadow: 0 12px 22px rgba(249, 115, 22, 0.18);
}
.btn--primary:hover {
  background: linear-gradient(135deg, var(--primary-600), var(--primary-700));
  border-color: transparent;
  color: #ffffff;
}

.btn--dark {
  background: var(--ink);
  color: #fff;
  border-color: var(--ink);
}
.btn--dark:hover { background: #1c201c; }

.btn--outline {
  background: transparent;
  color: var(--ink);
  border-color: var(--line);
}
.btn--outline:hover { border-color: var(--ink); }

.btn--ghost {
  background: transparent;
  color: var(--ink-soft);
  border-color: transparent;
}
.btn--ghost:hover { color: var(--ink); background: var(--line-soft); }

.topbar .btn--ghost { color: #9fa89e; }
.topbar .btn--ghost:hover { color: #fff; background: #1a1d1a; }

.btn--sm { padding: 7px 13px; font-size: 12.5px; }
.btn--icon {
  width: 34px; height: 34px; padding: 0;
  justify-content: center;
}

/* ─── SHELL ─── */
.shell {
  max-width: 1280px;
  margin: 0 auto;
  padding: 40px 28px 80px;
}

/* ─── PAGE HEAD ─── */
.pagehead {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  flex-wrap: wrap;
  margin-bottom: 32px;
}
.eyebrow {
  font-family: var(--font-mono);
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-soft);
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 6px;
}
.eyebrow__dot { color: var(--accent); }
.pagehead__title {
  font-size: 28px;
  font-weight: 800;
  letter-spacing: -0.02em;
  margin: 0 0 6px;
  line-height: 1.15;
}
.pagehead__sub {
  margin: 0;
  color: var(--ink-soft);
  font-size: 14px;
}
.pagehead__actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }

/* ─── STATS ─── */
.stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1px;
  background: var(--line);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  overflow: hidden;
  margin-bottom: 30px;
}
.stat {
  background: var(--paper);
  padding: 20px 22px;
}
.stat__label {
  font-family: var(--font-mono);
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-soft);
  margin-bottom: 6px;
}
.stat__value {
  font-size: 26px;
  font-weight: 800;
  letter-spacing: -0.02em;
}
.stat__value.alert { color: var(--danger); }
.stat__delta {
  font-size: 12px;
  color: var(--ink-soft);
  margin-top: 2px;
}

/* ─── TABS ─── */
.tabs {
  display: flex;
  border-bottom: 1.5px solid var(--line);
  margin-bottom: 20px;
}
.tabs__btn {
  background: none;
  border: none;
  font-size: 14px;
  font-weight: 600;
  color: var(--ink-soft);
  padding: 10px 18px 10px 0;
  margin-right: 20px;
  border-bottom: 2px solid transparent;
  position: relative;
  top: 1.5px;
  cursor: pointer;
  transition: color .15s;
}
.tabs__btn:hover { color: var(--ink); }
.tabs__btn.is-active {
  color: var(--ink);
  border-bottom-color: var(--accent);
}

/* ─── TOOLBAR ─── */
.toolbar {
  display: flex;
  gap: 10px;
  margin-bottom: 16px;
  flex-wrap: wrap;
  align-items: center;
}
.search {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--paper);
  border: 1.5px solid var(--line);
  border-radius: var(--r-sm);
  padding: 0 12px;
  flex: 1;
  max-width: 300px;
  min-width: 200px;
  transition: border-color .15s;
}
.search:focus-within { border-color: var(--accent); }
.search svg { color: var(--ink-soft); flex-shrink: 0; }
.search input {
  border: none; outline: none; background: none;
  font-size: 13.5px; padding: 9px 0; width: 100%;
  color: var(--ink); font-family: inherit;
}
.select {
  border: 1.5px solid var(--line);
  border-radius: var(--r-sm);
  background: var(--paper);
  font-size: 13px;
  padding: 9px 10px;
  color: var(--ink);
  font-family: inherit;
  outline: none;
  transition: border-color .15s;
}
.select:focus { border-color: var(--accent); }

/* ─── TABLE ─── */
.tablewrap {
  border: 1.5px solid var(--line);
  border-radius: var(--r-md);
  overflow: hidden;
  background: var(--paper);
}
.datatable {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}
.datatable thead th {
  text-align: left;
  font-family: var(--font-mono);
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-soft);
  background: var(--surface);
  border-bottom: 1.5px solid var(--line);
  padding: 12px 16px;
  white-space: nowrap;
}
.datatable tbody td {
  padding: 13px 16px;
  border-bottom: 1px solid var(--line-soft);
  vertical-align: middle;
}
.datatable tbody tr:last-child td { border-bottom: none; }
.datatable tbody tr { transition: background .1s; }
.datatable tbody tr:hover { background: #f6faf7; }

.cell-name { font-weight: 600; font-size: 14px; }
.cell-sku {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--ink-soft);
  margin-top: 2px;
}
.cell-qty { font-weight: 700; font-family: var(--font-mono); }
.cell-qty.low { color: var(--danger); }

/* ─── BADGE ─── */
.badge {
  display: inline-flex;
  align-items: center;
  font-size: 11px;
  font-weight: 700;
  padding: 3px 9px;
  border-radius: 999px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-family: var(--font-mono);
}
.badge--active   { background: var(--accent-dim); color: var(--accent-ink); }
.badge--inactive { background: var(--warn-dim);   color: var(--warn); }
.badge--archived { background: var(--line-soft);  color: var(--ink-soft); }

/* ─── TAGS ─── */
.tagrow { display: flex; gap: 5px; flex-wrap: wrap; }
.tag {
  font-size: 11px;
  font-family: var(--font-mono);
  background: var(--line-soft);
  color: var(--ink-soft);
  padding: 2px 8px;
  border-radius: 999px;
}

/* ─── LOCATION CARDS ─── */
.cardgrid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(270px, 1fr));
  gap: 14px;
}
.loccard {
  background: var(--paper);
  border: 1.5px solid var(--line);
  border-radius: var(--r-md);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  transition: box-shadow .2s, border-color .2s;
}
.loccard:hover { box-shadow: var(--shadow); border-color: #cdd4cc; }
.loccard__head { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.loccard__name { font-weight: 700; font-size: 15px; }
.loccard__code { font-family: var(--font-mono); font-size: 11.5px; color: var(--ink-soft); margin-top: 2px; }
.loccard__meta { font-size: 13px; color: var(--ink-soft); display: flex; flex-direction: column; gap: 3px; }
.loccard__foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-top: 12px;
  border-top: 1px solid var(--line-soft);
  margin-top: auto;
}
.loccard__stat { font-family: var(--font-mono); font-size: 11px; color: var(--ink-soft); text-transform: uppercase; letter-spacing: 0.04em; }
.loccard__statval { font-weight: 800; font-size: 18px; letter-spacing: -0.01em; }

/* ─── STATE SCREENS ─── */
[hidden] {
  display: none !important;
}
.state {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 10px;
  padding: 64px 20px;
  color: var(--ink-soft);
}
.state__icon { font-size: 36px; opacity: .4; }
.state__title { font-weight: 700; font-size: 16px; color: var(--ink); margin: 0; }
.state__body { margin: 0; font-size: 13.5px; max-width: 340px; line-height: 1.6; }
.spinner {
  width: 24px; height: 24px;
  border-radius: 50%;
  border: 2.5px solid var(--line);
  border-top-color: var(--accent);
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ─── TOASTS ─── */
.toasts {
  position: fixed;
  bottom: 22px; right: 22px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 999;
}
.toast {
  background: var(--ink);
  color: #f5f7f5;
  font-size: 13px;
  padding: 12px 18px;
  border-radius: var(--r-sm);
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  gap: 10px;
  animation: toast-in .2s ease-out;
  max-width: 320px;
}
.toast__dot { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); flex-shrink: 0; }
.toast--error .toast__dot { background: var(--danger); }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ─── FOOTER ─── */
.footbar {
  max-width: 1280px;
  margin: 0 auto;
  padding: 20px 28px 40px;
  border-top: 1.5px solid var(--line);
  display: flex;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  font-size: 12.5px;
  color: var(--ink-soft);
}
.footbar__mono { font-family: var(--font-mono); font-size: 11.5px; }

/* ─── ADD PAGE LAYOUT ─── */
.add-shell {
  max-width: 800px;
  margin: 0 auto;
  padding: 40px 28px 80px;
}
.add-card {
  background: var(--paper);
  border: 1.5px solid var(--line);
  border-radius: var(--r-lg);
  padding: 32px 36px;
}
.add-card__head {
  padding-bottom: 24px;
  margin-bottom: 28px;
  border-bottom: 1.5px solid var(--line-soft);
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}
.add-card__title {
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.02em;
  margin: 6px 0 0;
}

/* ─── FORM ─── */
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.field--full { grid-column: 1 / -1; }
.field__label {
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
}
.req { color: var(--danger); }
.field input,
.field select,
.field textarea {
  font-family: inherit;
  font-size: 13.5px;
  padding: 10px 12px;
  border: 1.5px solid var(--line);
  border-radius: var(--r-sm);
  background: var(--paper);
  color: var(--ink);
  outline: none;
  transition: border-color .15s, box-shadow .15s;
  resize: vertical;
}
.field input:focus,
.field select:focus,
.field textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-dim);
}
.field input.upper { text-transform: uppercase; }
.field--invalid input,
.field--invalid select,
.field--invalid textarea {
  border-color: var(--danger);
}
.field input:disabled {
  background: var(--surface);
  color: var(--ink-soft);
}

.toggle-row { display: flex; align-items: center; gap: 10px; padding: 10px 0; }
.toggle-row input[type="checkbox"] {
  width: 16px; height: 16px;
  accent-color: var(--accent);
  cursor: pointer;
}
.toggle-row label { font-size: 13.5px; cursor: pointer; }

/* tag chip input */
.chipfield {
  border: 1.5px solid var(--line);
  border-radius: var(--r-sm);
  padding: 8px 10px;
  background: var(--paper);
  transition: border-color .15s;
}
.chipfield:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-dim); }
.chipfield__chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chipfield__chips:not(:empty) { margin-bottom: 6px; }
.chip {
  display: inline-flex; align-items: center; gap: 5px;
  background: var(--accent-dim);
  color: var(--accent-ink);
  font-size: 12px; font-weight: 600;
  padding: 3px 6px 3px 10px;
  border-radius: 999px;
}
.chip__rm {
  background: none; border: none; cursor: pointer;
  color: var(--accent-ink); font-size: 14px; line-height: 1; padding: 0 1px;
}
.chip__input {
  border: none; outline: none; width: 100%;
  font-size: 13px; padding: 4px 2px; background: none; font-family: inherit;
}

/* section divider */
.form-section {
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--ink-soft);
  padding: 8px 0 14px;
  border-top: 1px solid var(--line-soft);
  margin-top: 8px;
  grid-column: 1 / -1;
}
.form-section:first-child { border-top: none; padding-top: 0; margin-top: 0; }

.form-error {
  color: var(--danger);
  background: var(--danger-dim);
  font-size: 13px;
  font-weight: 500;
  padding: 10px 14px;
  border-radius: var(--r-sm);
  margin-top: 18px;
  display: none;
}
.form-error.show { display: block; }

.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 28px;
  padding-top: 20px;
  border-top: 1.5px solid var(--line-soft);
}

/* back link */
.back-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13.5px;
  font-weight: 500;
  color: var(--ink-soft);
  margin-bottom: 24px;
  transition: color .15s;
}
.back-link:hover { color: var(--ink); }
.back-link svg { width: 16px; height: 16px; }

/* ─── RESPONSIVE ─── */
@media (max-width: 768px) {
  .topbar__inner { padding: 0 16px; gap: 16px; }
  .shell, .add-shell { padding: 24px 16px 60px; }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .form-grid { grid-template-columns: 1fr; }
  .field--full { grid-column: auto; }
  .pagehead { align-items: flex-start; flex-direction: column; gap: 14px; }
  .tablewrap { overflow-x: auto; }
  .datatable { min-width: 680px; }
  .add-card { padding: 22px 18px; }
  .modnav { display: none; }
}

@media (max-width: 480px) {
  .stats { grid-template-columns: 1fr 1fr; }
}

/* Focus */
a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  .spinner { animation: none; }
  .toast { animation: none; }
}