/* Generic Inventory System — modern stylesheet
   Replaces the legacy 2006 table/BGCOLOR/FONT markup. */

:root {
  --bg:            #f4f6f8;
  --surface:       #ffffff;
  --surface-2:     #f8fafc;
  --border:        #dfe3e8;
  --border-strong: #c3cad2;
  --text:          #1f2933;
  --text-dim:      #64707d;
  --text-faint:    #97a1ac;

  --brand:         #1f4e79;
  --brand-600:     #17506f;
  --brand-100:     #e7eef4;

  --accent:        #0f766e;
  --accent-100:    #d9f2ef;

  --ok:            #1b7a3d;
  --ok-100:        #e2f3e7;
  --warn:          #92600a;
  --warn-100:      #fdf1d9;
  --danger:        #b3261e;
  --danger-100:    #fbe6e4;

  --radius:        8px;
  --radius-sm:     5px;
  --shadow:        0 1px 2px rgba(16,24,40,.06), 0 1px 3px rgba(16,24,40,.1);
  --shadow-lg:     0 4px 12px rgba(16,24,40,.1);

  --mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, "Liberation Mono", monospace;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 var(--sans);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.wrap {
  width: 100%;
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 20px;
}

main.wrap { flex: 1 0 auto; padding-bottom: 40px; }

a { color: var(--brand-600); }
a:hover { color: var(--brand); }

/* ---------- top bar ---------- */

.topbar {
  background: var(--brand);
  color: #fff;
  box-shadow: var(--shadow);
  position: sticky;
  top: 0;
  z-index: 20;
}

.topbar-inner {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 20px;
  display: flex;
  align-items: center;
  gap: 24px;
  min-height: 56px;
  flex-wrap: wrap;
}

/* The brand is a link, so it is tinted grey at rest and brightens to white on
   hover — the same rest/hover relationship as the nav items. Every state is
   listed explicitly because the global `a:hover` rule would otherwise set
   dark brand-blue text, which is unreadable on the dark top bar. */
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  font-weight: 600;
  color: rgba(255, 255, 255, .72);
  transition: color .12s;
}

.brand:hover,
.brand:active {
  color: #fff;
  text-decoration: none;
}

.brand:focus-visible,
.brand:focus {
  color: #fff;
  text-decoration: none;
}

.brand:hover .brand-mark {
  background: rgba(255, 255, 255, .26);
  border-color: rgba(255, 255, 255, .42);
  color: #fff;
}

.brand:focus-visible {
  outline: 2px solid rgba(255, 255, 255, .7);
  outline-offset: 3px;
  border-radius: 4px;
}

.brand-mark {
  font-family: var(--mono);
  font-size: 13px;
  letter-spacing: .08em;
  background: rgba(255,255,255,.16);
  border: 1px solid rgba(255,255,255,.28);
  border-radius: 4px;
  padding: 4px 8px;
}

.brand-text { font-size: 15px; white-space: nowrap; }

.mainnav {
  display: flex;
  gap: 2px;
  flex-wrap: wrap;
  margin-right: auto;
}

.mainnav a {
  /* Inactive is deliberately a dull grey-white so it reads as "not here";
     hover jumps to full white, and the current page gets a solid pill plus
     underline so the three states are unmistakable at a glance. */
  color: rgba(255, 255, 255, .62);
  text-decoration: none;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 500;
  border-bottom: 2px solid transparent;
  transition: background .12s, color .12s, border-color .12s;
}

.mainnav a:hover {
  background: rgba(255, 255, 255, .14);
  color: #fff;
  border-bottom-color: rgba(255, 255, 255, .55);
}

.mainnav a:focus-visible {
  outline: 2px solid rgba(255, 255, 255, .75);
  outline-offset: 2px;
  color: #fff;
}

.mainnav a.is-active {
  background: rgba(255, 255, 255, .2);
  color: #fff;
  font-weight: 700;
  border-bottom-color: #fff;
}

.logoutform { display: flex; align-items: center; gap: 12px; margin: 0; }

.who { display: flex; flex-direction: column; line-height: 1.25; text-align: right; }
.who-name { font-size: 14px; font-weight: 600; }
.who-bins { font-size: 12px; color: rgba(255,255,255,.7); font-variant-numeric: tabular-nums; }

/* ---------- headings ---------- */

.pagehead {
  font-size: 22px;
  font-weight: 650;
  margin: 26px 0 18px;
  letter-spacing: -.01em;
}

h2 { font-size: 16px; font-weight: 650; margin: 0 0 12px; }
h3 { font-size: 14px; font-weight: 650; margin: 0 0 10px; color: var(--text-dim); text-transform: uppercase; letter-spacing: .04em; }

/* ---------- cards ---------- */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 18px;
  overflow: hidden;
}

.card-head {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.card-head h2, .card-head h3 { margin: 0; }

.card-body { padding: 16px; }

.grid { display: grid; gap: 18px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0,1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0,1fr)); }

.cols-main {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 18px;
  align-items: start;
}

@media (max-width: 1080px) {
  .grid-2, .grid-3 { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .cols-main { grid-template-columns: 1fr; }
}
@media (max-width: 620px) {
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
}

/* ---------- forms ---------- */

.field { margin-bottom: 14px; }

.field > label,
.label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-dim);
  margin-bottom: 5px;
}

input[type=text], input[type=password], input[type=number],
input[type=search], input[type=email], select, textarea {
  width: 100%;
  padding: 8px 10px;
  font: inherit;
  font-size: 14px;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  transition: border-color .12s, box-shadow .12s;
}

textarea { resize: vertical; min-height: 74px; font-family: var(--mono); font-size: 13px; }

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

input:disabled, select:disabled { background: var(--surface-2); color: var(--text-faint); }

.field-row { display: flex; gap: 12px; flex-wrap: wrap; }
.field-row > .field { flex: 1 1 160px; }

.hint { font-size: 12px; color: var(--text-faint); margin-top: 4px; }
.hint-warn { color: var(--warn); }

/* ---------- datasheet link ---------- */

/* Screen-reader-only text. Kept off-screen rather than removed so assistive
   tech still announces that the link opens a new tab. */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

/* Icon sitting beside the URL field on the bin editor. */
.input-with-action {
  display: flex;
  align-items: center;
  gap: 8px;
}
.input-with-action input { flex: 1 1 auto; min-width: 0; }

/* Styled as a real button (border + background + generous padding) so it is
   obviously clickable, not a stray glyph. */
.ds-link {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  flex: 0 0 auto;
  color: var(--brand-600);
  text-decoration: none;
  border: 1px solid var(--brand-600);
  border-radius: var(--radius-sm);
  padding: 8px 13px;
  background: var(--brand-100);
  font-size: 14px;
  font-weight: 600;
  line-height: 1.2;
  white-space: nowrap;
  transition: background .12s, color .12s, border-color .12s, box-shadow .12s;
}

.ds-link:hover {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
  text-decoration: none;
  box-shadow: 0 1px 4px rgba(31, 78, 121, .3);
}

.ds-link:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}

/* The glyph inherits the text colour via currentColor. */
.icon-datasheet {
  width: 18px;
  height: 18px;
  display: block;
  flex: 0 0 auto;
}

/* In a table row the button is slightly more compact, but keeps its label and
   border so it still reads as a control. */
.ds-cell .ds-link {
  padding: 5px 10px 5px 8px;
  font-size: 13px;
  gap: 6px;
}
.ds-cell .icon-datasheet { width: 16px; height: 16px; }

.ds-none {
  flex: 0 0 auto;
  color: var(--text-faint);
  padding: 8px 12px;
  text-align: center;
  min-width: 34px;
}

/* ---------- buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 14px;
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  line-height: 1.2;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  transition: background .12s, border-color .12s, color .12s;
}

.btn:hover { background: var(--surface-2); border-color: var(--text-faint); }

.btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-600); border-color: var(--brand-600); color: #fff; }

.btn-accent { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-accent:hover { background: #0b5f58; border-color: #0b5f58; color: #fff; }

.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-danger:hover { background: #8f1e18; border-color: #8f1e18; color: #fff; }

.btn-ghost { background: transparent; border-color: rgba(255,255,255,.4); color: #fff; }
.btn-ghost:hover { background: rgba(255,255,255,.14); color: #fff; }

.btn-sm { padding: 5px 10px; font-size: 13px; }
.btn-block { width: 100%; }

.btn-row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }

/* ---------- tables ---------- */

.tablewrap { overflow-x: auto; }

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

/* Column widths are left to the browser's auto layout, which tends to starve
   the short label columns (Group, Location) and wrap two-word names onto two
   lines. Giving them a minimum width pushes the wrapping onto Description,
   which is the one column that reads fine over multiple lines.
   .tablewrap already scrolls horizontally if the total exceeds the card. */
table.data col.c-idx      { width: 34px; }
table.data col.c-bin      { width: 5.5%; min-width: 64px; }
table.data col.c-group    { width: 12%;  min-width: 134px; }  /* "Dispensing Tip" */
table.data col.c-location { width: 9%;   min-width: 104px; }
table.data col.c-qty      { width: 5%;   min-width: 46px; }
table.data col.c-vendor   { width: 13%;  min-width: 180px; }  /* "Spark Fun Electronics" */
table.data col.c-pn       { width: 14%;  min-width: 196px; }  /* 23-char part numbers */
table.data col.c-link     { width: 118px; }

table.data th, table.data td {
  padding: 8px 12px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

table.data thead th {
  background: var(--surface-2);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--text-dim);
  white-space: nowrap;
  border-bottom: 1px solid var(--border-strong);
  position: sticky;
  top: 0;
}

table.data thead th a { color: var(--text-dim); text-decoration: none; }
table.data thead th a:hover { color: var(--brand); text-decoration: underline; }

table.data tbody tr:hover { background: var(--brand-100); }
table.data tbody tr:last-child td { border-bottom: none; }

table.data td.num, table.data th.num { text-align: right; font-variant-numeric: tabular-nums; }
table.data td.nowrap { white-space: nowrap; }

/* zebra striping kept from the old system, but subtle */
table.data tbody tr:nth-child(even) { background: var(--surface-2); }
table.data tbody tr:nth-child(even):hover { background: var(--brand-100); }

.idx { color: var(--text-faint); font-variant-numeric: tabular-nums; font-size: 12px; }

.bin-code, .qty { font-family: var(--mono); font-size: 13px; }
.bin-code { font-weight: 700; letter-spacing: .02em; }

.qty { display: inline-block; text-align: right; min-width: 3.5ch; }
.qty-neg { color: var(--danger); font-weight: 700; }

/* ---------- pills / badges ---------- */

.pill {
  display: inline-block;
  padding: 2px 8px;
  font-size: 12px;
  font-weight: 600;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text-dim);
  white-space: nowrap;
}

.pill-ok     { background: var(--ok-100);     border-color: #b9e0c6; color: var(--ok); }
.pill-warn   { background: var(--warn-100);   border-color: #f0d9a8; color: var(--warn); }
.pill-danger { background: var(--danger-100); border-color: #f0c2be; color: var(--danger); }

/* ---------- stats ---------- */

.stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
}

.stat-label { font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--text-dim); font-weight: 700; }
.stat-value { font-size: 30px; font-weight: 700; font-variant-numeric: tabular-nums; margin-top: 4px; line-height: 1.1; }
.stat-sub   { font-size: 12px; color: var(--text-faint); margin-top: 2px; }

/* ---------- flash messages ---------- */

.flash {
  padding: 11px 14px;
  border-radius: var(--radius-sm);
  margin-bottom: 18px;
  font-size: 14px;
  border: 1px solid;
}

.flash-ok   { background: var(--ok-100);     border-color: #b9e0c6; color: #14532b; }
.flash-warn { background: var(--warn-100);   border-color: #f0d9a8; color: #6b4608; }
.flash-err  { background: var(--danger-100); border-color: #f0c2be; color: #7d1a14; }

/* ---------- login ---------- */

body.login-page {
  background: linear-gradient(160deg, #1f4e79 0%, #2c3e50 100%);
  align-items: center;
  justify-content: center;
  display: flex;
  padding: 24px;
}

.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--surface);
  border-radius: 12px;
  box-shadow: 0 12px 40px rgba(0,0,0,.28);
  overflow: hidden;
}

.login-head {
  padding: 26px 28px 20px;
  text-align: center;
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
}

.login-head .brand-mark { background: var(--brand); color: #fff; border-color: var(--brand); }
.login-head h1 { font-size: 17px; margin: 12px 0 2px; font-weight: 650; }
.login-head p { margin: 0; font-size: 13px; color: var(--text-dim); }
.login-body { padding: 24px 28px 28px; }

/* ---------- misc ---------- */

.empty {
  padding: 34px 20px;
  text-align: center;
  color: var(--text-faint);
  font-size: 14px;
}

.muted  { color: var(--text-dim); }
.faint  { color: var(--text-faint); }
.mono   { font-family: var(--mono); }
.small  { font-size: 13px; }
.center { text-align: center; }
.right  { text-align: right; }
.mt     { margin-top: 16px; }
.nowrap { white-space: nowrap; }

.kv { display: grid; grid-template-columns: 130px 1fr; gap: 6px 14px; font-size: 14px; }
.kv dt { color: var(--text-dim); font-weight: 600; }
.kv dd { margin: 0; word-break: break-word; }

.foot {
  border-top: 1px solid var(--border);
  background: var(--surface);
  padding: 14px 0;
  font-size: 12px;
  color: var(--text-faint);
}
.foot .wrap { display: flex; gap: 8px; }
.foot .dot { color: var(--border-strong); }

.searchbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; }
.searchbar > * { flex: 0 0 auto; }
.searchbar .grow { flex: 1 1 220px; }

.resultcount { font-size: 13px; color: var(--text-dim); margin-bottom: 10px; }

/* ---------- print (project reports / pick lists) ---------- */

@media print {
  .topbar, .foot, .btn, .btn-row, form[action*="adjust"], .noprint { display: none !important; }
  body { background: #fff; font-size: 11pt; }
  .card { box-shadow: none; border-color: #999; break-inside: avoid; }
  main.wrap { max-width: none; padding: 0; }
  table.data thead th { position: static; }
}
