/* South Jewels OS - visual design.
   Palette: deep navy ink + warm gold accent on a soft warm-grey canvas.
   Gold is decorative (rings, rules, active states); body-size text never uses the light golds. */

:root {
  --navy-950: #0a1424;
  --navy-900: #0f1c33;
  --navy-800: #182a49;
  --navy-700: #243a5e;

  --gold-50: #fbf6ea;
  --gold-100: #f4e8c8;
  --gold-300: #dcbb78;
  --gold-500: #c39a4b;
  --gold-600: #a97f2f;
  --gold-700: #8a6420; /* 5.3:1 on white - safe for text */

  --bg: #f6f5f2;
  --surface: #ffffff;
  --surface-2: #faf9f6;
  --text: #141c2b;
  --muted: #5a6475;
  --border: #e6e3dc;
  --border-soft: #eeece6;

  --danger-bg: #fdeceb;
  --danger-text: #9b1c1c;
  --stale-bg: #fff4e5;
  --stale-text: #8a4b00;
  --stale-border: #efc48c;

  --series-1: #3468c9; /* Kalaiyarasi */
  --series-2: #d69a2d; /* Nithya */
  --grid: #e4e1d9;

  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 18px;

  --shadow-xs: 0 1px 2px rgba(15, 28, 51, 0.05);
  --shadow-sm: 0 1px 3px rgba(15, 28, 51, 0.08), 0 1px 2px rgba(15, 28, 51, 0.04);
  --shadow-md: 0 12px 32px -8px rgba(15, 28, 51, 0.16), 0 2px 6px rgba(15, 28, 51, 0.05);

  --ring: 0 0 0 4px rgba(195, 154, 75, 0.25);
  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;

  color-scheme: light;
}

* { box-sizing: border-box; }

/* Keeps `hidden` working on elements that also set their own display (e.g. the pager). */
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--font);
  font-size: 0.9375rem;
  line-height: 1.55;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

h1 {
  margin: 0 0 0.35rem;
  font-size: 1.65rem;
  font-weight: 650;
  letter-spacing: -0.02em;
  line-height: 1.2;
  color: var(--navy-900);
}

.muted { color: var(--muted); margin: 0; }

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

/* ---------- Logo ---------- */
/* The JPG has generous white margins; crop to the artwork so it reads at nav size. */
.logo {
  display: block;
  height: auto;
  aspect-ratio: 1999 / 524;
  object-fit: cover;
  object-position: 50% 74%;
  mix-blend-mode: multiply;
  user-select: none;
}

/* ---------- Forms & buttons ---------- */
label {
  display: block;
  margin: 1.1rem 0 0.4rem;
  font-size: 0.85rem;
  font-weight: 550;
  color: var(--navy-800);
}

input, select {
  width: 100%;
  min-height: 44px;
  padding: 0.6rem 0.85rem;
  font: inherit;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: var(--shadow-xs);
  transition: border-color 0.15s, box-shadow 0.15s;
}
input:hover, select:hover { border-color: #d3cfc4; }
input:focus, select:focus { outline: none; border-color: var(--gold-600); box-shadow: var(--ring); }

select {
  min-width: 11rem;
  padding-right: 2.2rem;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5l5 5 5-5' fill='none' stroke='%235a6475' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.85rem center;
}

button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  min-height: 40px;
  padding: 0.5rem 1.05rem;
  font: inherit;
  font-weight: 550;
  color: #fff;
  background: var(--navy-900);
  border: 1px solid var(--navy-900);
  border-radius: 10px;
  box-shadow: var(--shadow-xs), inset 0 1px 0 rgba(255, 255, 255, 0.08);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, box-shadow 0.15s, transform 0.05s;
}
button:hover { background: var(--navy-700); border-color: var(--navy-700); }
button:active { transform: translateY(1px); }
button:disabled { opacity: 0.45; cursor: default; transform: none; }

button.secondary {
  color: var(--navy-900);
  background: var(--surface);
  border-color: var(--border);
  box-shadow: var(--shadow-xs);
}
button.secondary:hover { background: var(--surface-2); border-color: #d3cfc4; }
button.secondary:disabled:hover { background: var(--surface); border-color: var(--border); }

.alert {
  margin: 1.25rem 0 0;
  padding: 0.7rem 0.9rem;
  font-size: 0.875rem;
  color: var(--danger-text);
  background: var(--danger-bg);
  border: 1px solid #f5c9c6;
  border-radius: 10px;
}

/* ---------- Sign-in page ---------- */
body.auth { min-height: 100vh; background: var(--bg); }

.auth-shell { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); min-height: 100vh; }

.auth-aside {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding: 3.5rem;
  overflow: hidden;
  color: #fff;
  background:
    radial-gradient(60% 45% at 78% 22%, rgba(195, 154, 75, 0.16), transparent 70%),
    linear-gradient(160deg, var(--navy-800), var(--navy-950) 70%);
}
.auth-aside::before { /* fine gold rule down the seam */
  content: "";
  position: absolute;
  inset: 0 0 0 auto;
  width: 3px;
  background: linear-gradient(180deg, transparent, var(--gold-500) 30%, var(--gold-300) 60%, transparent);
  opacity: 0.7;
}
.auth-gem {
  position: absolute;
  top: 14%;
  right: 10%;
  width: min(58%, 400px);
  height: auto;
  color: var(--gold-300);
  opacity: 0.5;
}
.auth-tagline { position: relative; max-width: 26rem; }
.auth-tagline strong {
  display: block;
  margin-bottom: 0.6rem;
  font-size: 1.85rem;
  font-weight: 650;
  line-height: 1.2;
  letter-spacing: -0.02em;
}
.auth-tagline span { color: rgba(255, 255, 255, 0.72); font-size: 1rem; }
.auth-rule { display: block; width: 44px; height: 3px; margin-bottom: 1.25rem; border-radius: 2px; background: var(--gold-500); }

.auth-main {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem 1.25rem;
  background:
    radial-gradient(60% 40% at 50% 0%, rgba(195, 154, 75, 0.1), transparent 70%),
    var(--bg);
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
}
.login-card { width: 100%; max-width: 420px; padding: 2.5rem 2.25rem 2.25rem; }
.login-card .logo { width: 240px; max-width: 100%; margin: 0 auto 1.75rem; }
.login-head { text-align: center; }
.login-head h1 { font-size: 1.4rem; margin-bottom: 0.2rem; }
.login-card form { margin-top: 0.75rem; }
.login-card button { width: 100%; min-height: 46px; margin-top: 1.6rem; font-size: 0.95rem; }

/* ---------- Top navigation ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(255, 255, 255, 0.92);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow-xs);
  -webkit-backdrop-filter: saturate(1.4) blur(10px);
  backdrop-filter: saturate(1.4) blur(10px);
}
.topbar::before { /* gold hairline across the top */
  content: "";
  display: block;
  height: 3px;
  background: linear-gradient(90deg, var(--gold-600), var(--gold-300) 50%, var(--gold-600));
}
.topbar-inner {
  display: flex;
  align-items: center;
  gap: 2rem;
  max-width: 1280px;
  margin: 0 auto;
  padding: 0.6rem 1.5rem;
}
.brand-link { display: block; flex: none; margin-left: -8px; border-radius: 6px; }
.brand-link .logo { height: 44px; width: auto; }

.topnav { display: flex; gap: 0.25rem; }
.topnav a {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.85rem;
  color: var(--muted);
  font-weight: 550;
  text-decoration: none;
  border-radius: 9px;
  transition: color 0.15s, background 0.15s;
}
.topnav a svg { flex: none; width: 17px; height: 17px; }
.topnav a:hover { color: var(--navy-900); background: var(--bg); }
.topnav a[aria-current="page"] { color: var(--navy-900); background: var(--gold-50); box-shadow: inset 0 0 0 1px var(--gold-100); }
.topnav a[aria-current="page"] svg { color: var(--gold-700); }

.topbar-user { display: flex; align-items: center; gap: 0.85rem; margin-left: auto; min-width: 0; }
.topbar-user form { margin: 0; }
#user-info { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 0.85rem; }
.topbar-user button { min-height: 36px; padding: 0.35rem 0.8rem; font-size: 0.85rem; }
.topbar-user button svg { display: none; width: 18px; height: 18px; }

/* ---------- Page layout ---------- */
.content { max-width: 960px; margin: 0 auto; padding: 2rem 1.5rem 3rem; }
.content.wide { max-width: 1280px; }
.content > h1 + .muted { margin-bottom: 0.25rem; max-width: 46rem; }

/* ---------- Enquiries dashboard ---------- */
.tiles {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 1rem;
  margin: 1.25rem 0 1.5rem;
}

button.tile {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: flex-start;
  gap: 0.2rem;
  padding: 1.1rem 1.25rem 1.15rem;
  overflow: hidden;
  text-align: left;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-xs);
  transition: border-color 0.15s, box-shadow 0.15s, transform 0.15s;
}
button.tile:hover { background: var(--surface); border-color: var(--gold-300); box-shadow: var(--shadow-sm); transform: translateY(-1px); }
button.tile:active { transform: none; }
button.tile[aria-pressed="true"] { border-color: var(--gold-500); box-shadow: var(--ring), var(--shadow-sm); }
button.tile[aria-pressed="true"]::before { /* selected marker */
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 3px;
  background: linear-gradient(90deg, var(--gold-600), var(--gold-300));
}
button.tile:focus-visible { outline: 2px solid var(--gold-600); outline-offset: 2px; }
.tile-label {
  order: -1;
  font-size: 0.75rem;
  font-weight: 650;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}
.tile-count {
  font-size: 2.1rem;
  font-weight: 700;
  line-height: 1.1;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
  color: var(--navy-900);
}
.tile-hint { font-weight: 500; letter-spacing: 0; text-transform: none; }
button.tile-stale { background: linear-gradient(180deg, #fffaf1, var(--stale-bg)); border-color: var(--stale-border); }
button.tile-stale:hover { background: linear-gradient(180deg, #fffaf1, var(--stale-bg)); }
.tile-stale .tile-count, .tile-stale .tile-label { color: var(--stale-text); }

.filters { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 0.85rem 1rem; margin-bottom: 1.25rem; }
.filters label { margin-top: 0; }

.notice {
  margin: 1rem 0;
  padding: 2.25rem 1.5rem;
  text-align: center;
  color: var(--muted);
  background: var(--surface);
  border: 1px dashed #d3cfc4;
  border-radius: var(--radius);
}
.notice-error { color: var(--danger-text); background: var(--danger-bg); border: 1px solid #f5c9c6; }

.table-wrap {
  overflow-x: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}
table.enquiries { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
table.enquiries th, table.enquiries td {
  padding: 0.85rem 1rem;
  text-align: left;
  vertical-align: top;
  border-bottom: 1px solid var(--border-soft);
}
table.enquiries th {
  padding-block: 0.7rem;
  font-size: 0.72rem;
  font-weight: 650;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  white-space: nowrap;
  color: var(--muted);
  background: var(--surface-2);
  border-bottom-color: var(--border);
}
table.enquiries tbody tr { transition: background 0.12s; }
table.enquiries tbody tr:hover { background: var(--surface-2); }
table.enquiries tbody tr:last-child td { border-bottom: 0; }
table.enquiries tr.is-stale td:first-child { box-shadow: inset 4px 0 0 var(--stale-border); }
table.enquiries a { color: var(--navy-800); font-weight: 500; text-decoration: underline; text-decoration-color: var(--gold-300); text-underline-offset: 3px; }
table.enquiries a:hover { color: var(--gold-700); text-decoration-color: var(--gold-600); }
.nowrap { white-space: nowrap; }
.strong { font-weight: 600; color: var(--navy-900); }
td.notes { min-width: 12rem; max-width: 22rem; overflow-wrap: anywhere; color: var(--muted); }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.15rem 0.6rem;
  font-size: 0.75rem;
  font-weight: 600;
  line-height: 1.5;
  border-radius: 999px;
  background: #eceff3;
  color: #374151;
}
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: 0.75; }
.badge + .badge { margin-left: 0.35rem; }
.badge-new { background: #e4eefc; color: #1e4f91; }
.badge-contacted { background: #ece9fb; color: #4a3fa8; }
.badge-converted { background: #dff3e4; color: #1d6b34; }
.badge-lost { background: #eceff3; color: #4b5563; }
.badge-stale { background: var(--stale-bg); color: var(--stale-text); border: 1px solid var(--stale-border); }

.pager { display: flex; align-items: center; justify-content: center; gap: 1rem; margin-top: 1.25rem; }

/* ---------- Team activity ---------- */
.s1 { --series: var(--series-1); }
.s2 { --series: var(--series-2); }

.segmented {
  display: inline-flex;
  gap: 2px;
  padding: 3px;
  background: #ebe9e3;
  border-radius: 12px;
}
.segmented button {
  min-height: 36px;
  color: var(--muted);
  background: transparent;
  border: 0;
  border-radius: 9px;
  box-shadow: none;
  font-weight: 550;
}
.segmented button:hover { color: var(--navy-900); background: rgba(255, 255, 255, 0.55); }
.segmented button[aria-pressed="true"] { color: var(--navy-900); background: var(--surface); box-shadow: var(--shadow-sm); font-weight: 650; }
.segmented button:focus-visible { outline: 2px solid var(--gold-600); outline-offset: 1px; }

.panel {
  margin-bottom: 1.5rem;
  padding: 1.4rem 1.6rem 1.6rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}
.panel h2 { margin: 0 0 0.15rem; font-size: 1.05rem; font-weight: 650; letter-spacing: -0.01em; color: var(--navy-900); }
.panel-note { margin-top: 1rem; }
#content { transition: opacity 0.15s; }
#content.is-loading { opacity: 0.55; }

.legend { display: flex; flex-wrap: wrap; gap: 0.35rem 1.25rem; margin: 0.85rem 0 1rem; padding: 0; list-style: none; font-size: 0.875rem; }
.legend li { display: flex; align-items: center; gap: 0.45rem; font-weight: 500; }
.swatch { display: inline-block; width: 12px; height: 12px; border-radius: 4px; background: var(--series); flex: none; }

.bars { display: flex; flex-direction: column; gap: 0.5rem; }
.bar-row {
  display: grid;
  grid-template-columns: 8rem 1fr;
  align-items: center;
  gap: 0.75rem;
  padding: 0.35rem 0.6rem;
  border-radius: 10px;
  transition: background 0.12s;
}
.bar-row:hover { background: var(--surface-2); }
.bar-row:focus-visible { outline: 2px solid var(--gold-600); outline-offset: 1px; }
.bar-name { font-weight: 550; overflow-wrap: anywhere; }
/* The axis: every bar grows from this one baseline. Padding leaves room for the value at the longest bar's tip. */
.bar-area { padding-right: 3.5rem; border-left: 1px solid var(--grid); }
.bar-line { display: flex; align-items: center; gap: 0.5rem; white-space: nowrap; }
.bar {
  flex: none;
  height: 26px;
  background: var(--series);
  border-radius: 0 6px 6px 0; /* square at the baseline, rounded at the data end */
}
.bar-value { flex: none; font-weight: 650; font-variant-numeric: tabular-nums; color: var(--navy-900); }

.splits { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 1.5rem; margin-top: 1rem; }
.split-head { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; margin-bottom: 0.45rem; }
.split-name { font-weight: 600; color: var(--navy-900); }
.split-bar { display: flex; gap: 2px; height: 14px; }
.seg { min-width: 4px; }
.seg:first-child { border-radius: 6px 0 0 6px; }
.seg:last-child { border-radius: 0 6px 6px 0; }
.seg:only-child { border-radius: 6px; }
.seg-enquiry, .swatch-enquiry { background: var(--series); }
.seg-production, .swatch-production { background: var(--series); opacity: 0.55; }
.seg-empty { flex: 1; background: var(--grid); }
.seg[data-tip]:hover { filter: brightness(1.08); }
.split-key { display: flex; flex-wrap: wrap; gap: 0.25rem 1.25rem; margin-top: 0.55rem; font-size: 0.875rem; color: var(--muted); }
.key-item { display: inline-flex; align-items: center; gap: 0.4rem; }
.key-item strong { color: var(--text); font-weight: 600; }

.tooltip {
  position: absolute;
  z-index: 30;
  pointer-events: none;
  max-width: 18rem;
  padding: 0.5rem 0.75rem;
  font-size: 0.82rem;
  color: #fff;
  background: var(--navy-900);
  border-radius: 10px;
  box-shadow: var(--shadow-md);
}
.tip-value { font-weight: 650; }
.tip-label { color: rgba(255, 255, 255, 0.72); }

/* ---------- Stock & Demand ---------- */
.stock-filters { margin: 1rem 0 0.75rem; }
.stock-filters .grow { flex: 1 1 16rem; }
.stock-filters select { min-width: 13rem; }
table.report.stock { min-width: 640px; }
table.stock tr.row-alert td { background: #fffafa; }
table.stock td .badge { white-space: nowrap; }
table.stock td .cover { margin-left: 0.5rem; font-size: 0.8rem; white-space: nowrap; }

/* ---------- Tablet & phone ---------- */
@media (max-width: 900px) {
  .auth-shell { grid-template-columns: 1fr; }
  .auth-aside { display: none; }
  .auth-main { min-height: 100vh; }
}

@media (max-width: 760px) {
  /* Top bar: logo + user on the first row, navigation tabs on a full-width second row. */
  .topbar-inner { flex-wrap: wrap; gap: 0.5rem 0.75rem; padding: 0.55rem 1rem 0.6rem; }
  .brand-link .logo { height: 38px; }
  .topbar-user { order: 2; flex: 1; justify-content: flex-end; gap: 0.6rem; }
  .topnav {
    order: 3;
    flex: 1 0 100%;
    gap: 0.35rem;
    padding: 0.35rem;
    background: var(--bg);
    border-radius: 12px;
  }
  .topnav a { flex: 1; justify-content: center; padding: 0.55rem 0.5rem; font-size: 0.875rem; }
  .topnav a[aria-current="page"] { background: var(--surface); box-shadow: var(--shadow-sm); }
  .topbar-user button { width: 40px; min-height: 40px; padding: 0; }
  .topbar-user button svg { display: block; }
  .topbar-user button span { display: none; }

  .content { padding: 1.25rem 1rem 2.5rem; }
  h1 { font-size: 1.4rem; }

  /* Three compact tiles side by side instead of three tall stacked ones. */
  .tiles { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0.5rem; margin: 1rem 0 1.25rem; }
  button.tile { justify-content: space-between; padding: 0.8rem 0.75rem 0.85rem; }
  .tile-count { font-size: 1.6rem; }
  .tile-label { font-size: 0.66rem; letter-spacing: 0.04em; }
  .tile-hint { display: block; }

  .filters { display: grid; grid-template-columns: 1fr 1fr; gap: 0.75rem; }
  .filters > div { min-width: 0; }
  select { min-width: 0; font-size: 1rem; }
  #clear-filters, .filters > .segmented { grid-column: 1 / -1; }
  input { font-size: 1rem; }

  /* Enquiry table becomes one card per enquiry. Labels come from the column position. */
  .table-wrap { overflow: visible; background: none; border: 0; border-radius: 0; box-shadow: none; }
  table.enquiries, table.enquiries tbody { display: block; }
  table.enquiries thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  table.enquiries tbody { display: grid; gap: 0.75rem; }
  table.enquiries tbody tr {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    padding: 1rem 1rem 0.5rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
  }
  table.enquiries tbody tr:hover { background: var(--surface); }
  table.enquiries tr.is-stale { border-left: 4px solid var(--stale-border); }
  table.enquiries tr.is-stale td:first-child { box-shadow: none; }
  table.enquiries td, table.enquiries tbody tr:last-child td {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 1rem;
    grid-column: 1 / -1;
    min-width: 0;
    padding: 0.6rem 0;
    text-align: right;
    white-space: normal;
    border-bottom: 0;
    border-top: 1px solid var(--border-soft);
    overflow-wrap: anywhere;
  }
  table.enquiries td:empty { display: none; }
  table.enquiries td::before {
    flex: none;
    text-align: left;
    font-size: 0.7rem;
    font-weight: 650;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--muted);
  }
  /* Customer and status form the card header, so they carry no label or divider. */
  table.enquiries td:nth-child(2) { order: 1; padding: 0 0 0.4rem; border-top: 0; font-size: 1.02rem; text-align: left; }
  table.enquiries td:nth-child(7) { order: 2; justify-content: flex-start; flex-wrap: wrap; gap: 0.35rem; padding: 0 0 0.75rem; border-top: 0; }
  table.enquiries td:nth-child(7) .badge + .badge { margin-left: 0; }
  table.enquiries td:nth-child(3) { order: 3; }
  table.enquiries td:nth-child(6) { order: 4; }
  table.enquiries td:nth-child(4) { order: 5; }
  table.enquiries td:nth-child(5) { order: 6; }
  table.enquiries td:nth-child(1) { order: 7; }
  table.enquiries td:nth-child(8) { order: 8; flex-direction: column; gap: 0.25rem; text-align: left; }
  table.enquiries td:nth-child(1)::before { content: "Received"; }
  table.enquiries td:nth-child(3)::before { content: "Phone"; }
  table.enquiries td:nth-child(4)::before { content: "Area"; }
  table.enquiries td:nth-child(5)::before { content: "Source"; }
  table.enquiries td:nth-child(6)::before { content: "Enquired about"; }
  table.enquiries td:nth-child(8)::before { content: "Notes"; }
  table.enquiries td:nth-child(2)::before, table.enquiries td:nth-child(7)::before { content: none; }
  td.notes { min-width: 0; max-width: none; }

  .pager { justify-content: space-between; gap: 0.5rem; }
  .pager .muted { font-size: 0.8rem; text-align: center; }

  /* Team activity */
  .panel { padding: 1.1rem 1rem 1.25rem; }
  .bar-row { grid-template-columns: 5.5rem 1fr; }
  .bar-area { padding-right: 3rem; }
  .segmented { display: flex; width: 100%; }
  .segmented button { flex: 1; white-space: nowrap; }

  .login-card { padding: 2rem 1.4rem 1.75rem; }
}

@media (max-width: 400px) {
  #user-info { max-width: 8.5rem; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}

/* ---------- Sales & Products report ---------- */
.report-controls { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 0.85rem 1rem; margin: 1.25rem 0; }
.report-status { display: flex; align-items: center; gap: 0.75rem; margin-left: auto; }
.report-status .muted { font-size: 0.85rem; }
.custom-range { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 0.75rem; }
.custom-range label { margin-top: 0; }
.custom-range input { width: auto; min-width: 10.5rem; }

.progress { margin: 1rem 0; padding: 1.5rem; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-xs); }
.progress-track { height: 8px; overflow: hidden; background: #ebe9e3; border-radius: 999px; }
.progress-fill { width: 4%; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--gold-600), var(--gold-300)); transition: width 0.4s ease; }
.progress p { margin-top: 0.7rem; font-size: 0.875rem; }

.panel-head { display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between; gap: 0.75rem 1rem; }
.panel-head .segmented { flex: none; }

.scroll-x { margin-top: 1rem; overflow-x: auto; border: 1px solid var(--border-soft); border-radius: var(--radius-sm); }
table.report { width: 100%; min-width: 600px; border-collapse: collapse; font-size: 0.9rem; }
table.report th, table.report td { padding: 0.7rem 0.9rem; text-align: left; vertical-align: middle; border-bottom: 1px solid var(--border-soft); }
table.report th {
  padding-block: 0.6rem;
  font-size: 0.72rem;
  font-weight: 650;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  white-space: nowrap;
  color: var(--muted);
  background: var(--surface-2);
  border-bottom-color: var(--border);
}
table.report tbody tr:last-child td { border-bottom: 0; }
table.report tbody tr:hover td { background: var(--surface-2); }
table.report .num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
table.report .rank { width: 2.75rem; padding-right: 0.25rem; text-align: right; color: var(--muted); font-variant-numeric: tabular-nums; }
/* The product name stays put while wide tables scroll sideways on a phone. */
table.report .product-col { position: sticky; left: 0; background: var(--surface); min-width: 11rem; }
table.report th.product-col { background: var(--surface-2); }
.product { display: flex; flex-direction: column; }
.sku { font-size: 0.75rem; color: var(--muted); }
.loss { color: var(--danger-text); }

.margin { display: inline-flex; align-items: center; justify-content: flex-end; }
.meter { display: inline-block; width: 64px; height: 6px; margin-left: 0.6rem; overflow: hidden; background: #ebe9e3; border-radius: 999px; }
.meter i { display: block; height: 100%; background: var(--gold-500); border-radius: inherit; }

.badge-danger { background: var(--danger-bg); color: var(--danger-text); border: 1px solid #f5c9c6; }
button.more { margin-top: 0.9rem; }
.missing { margin-top: 1rem; font-size: 0.875rem; color: var(--muted); }
.missing summary { cursor: pointer; }
.missing ul { margin: 0.5rem 0 0; padding-left: 1.25rem; columns: 2 16rem; }

.chips { display: flex; flex-wrap: wrap; gap: 0.75rem; margin: 1rem 0; padding: 0; list-style: none; }
.chip { display: flex; flex-direction: column; min-width: 12rem; padding: 0.8rem 1.1rem; background: var(--surface-2); border: 1px solid var(--border-soft); border-radius: var(--radius-sm); }
.chip-label { font-size: 0.72rem; font-weight: 650; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }
.chip-value { font-size: 1.4rem; font-weight: 700; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; color: var(--navy-900); }
.chip .muted { font-size: 0.8rem; }

.cust-list { display: grid; gap: 0.5rem; }
details.cust { background: var(--surface); border: 1px solid var(--border-soft); border-radius: var(--radius-sm); }
details.cust[open] { border-color: var(--border); box-shadow: var(--shadow-xs); }
details.cust summary { display: flex; flex-wrap: wrap; align-items: center; gap: 0.4rem 0.75rem; padding: 0.75rem 1rem; cursor: pointer; list-style: none; }
details.cust summary::-webkit-details-marker { display: none; }
details.cust summary::before { content: "›"; width: 0.8rem; font-size: 1.2rem; line-height: 1; color: var(--muted); transition: transform 0.15s; }
details.cust[open] summary::before { transform: rotate(90deg); }
.cust-name { flex: 1 1 10rem; min-width: 0; overflow-wrap: anywhere; }
.cust-total { margin-left: auto; font-weight: 650; font-variant-numeric: tabular-nums; white-space: nowrap; color: var(--navy-900); }
.cust-invoices { display: grid; gap: 0.5rem; margin: 0; padding: 0.15rem 1rem 0.9rem 2.55rem; list-style: none; }
.cust-invoices li { display: flex; flex-wrap: wrap; align-items: center; gap: 0.3rem 0.9rem; font-size: 0.875rem; }

@media (max-width: 760px) {
  .report-controls { display: grid; grid-template-columns: minmax(0, 1fr); gap: 0.75rem; } /* minmax(0, ...) lets the column shrink below its content */
  .report-controls .segmented button, .panel-head .segmented button { min-width: 0; padding-inline: 0.4rem; }
  .report-status { margin-left: 0; justify-content: space-between; }
  .custom-range { display: grid; grid-template-columns: 1fr 1fr; }
  .custom-range input { width: 100%; min-width: 0; }
  .custom-range button { grid-column: 1 / -1; }
  .panel-head .segmented { width: 100%; }
  .chip { flex: 1 1 100%; }
  .topnav a svg { display: none; } /* three tabs need the room */
}

@media (max-width: 400px) {
  .report-controls .segmented button { font-size: 0.85rem; }
}

@media (max-width: 760px) {
  .stock-filters .grow { flex-basis: 100%; grid-column: 1 / -1; }
  .stock-filters select { min-width: 0; }
  /* Each product becomes a card: name on top, then Available / On hand / Sold side by side, then the demand signal. */
  #table-wrap { overflow: visible; border: 0; border-radius: 0; }
  table.report.stock, table.stock tbody { display: block; min-width: 0; }
  table.stock thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  table.stock tbody { display: grid; gap: 0.6rem; }
  table.stock tr { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0.5rem 0.75rem; padding: 0.8rem 0.9rem; background: var(--surface); border: 1px solid var(--border-soft); border-radius: var(--radius-sm); }
  table.stock tr.row-alert { background: #fffafa; border-color: #f5c9c6; }
  table.stock td, table.stock tr.row-alert td, table.stock tbody tr:hover td { display: block; padding: 0; border: 0; background: none; text-align: left; }
  table.stock td.product-col { position: static; grid-column: 1 / -1; min-width: 0; }
  table.stock td.num::before { content: attr(data-label); display: block; margin-bottom: 0.1rem; font-size: 0.68rem; font-weight: 650; letter-spacing: 0.05em; text-transform: uppercase; color: var(--muted); }
  table.stock td.num { font-size: 1.05rem; }
  table.stock td[data-label="Demand"] { grid-column: 1 / -1; }
  table.stock td .cover { display: block; margin: 0.3rem 0 0 0.2rem; }
}

@media (max-width: 480px) {
  .stock-filters { grid-template-columns: minmax(0, 1fr); } /* half-width dropdowns cut their labels off */
}
