/* NFI Catalog -- deliberately dense and plain. This is a working tool for
   people doing bulk data entry, so readability and hit-targets beat decoration. */

:root {
  --bg: #f6f7f9;
  --panel: #ffffff;
  --ink: #1a1d21;
  --ink-soft: #5b6470;
  --line: #dfe3e8;
  --line-strong: #c6ccd4;
  --accent: #1b6ec2;
  --accent-soft: #e8f1fb;
  --dirty: #fff4d6;
  --dirty-line: #e0b64a;
  --danger: #b3261e;
  --danger-soft: #fdecea;
  --warn: #8a5a00;
  --warn-soft: #fff6e5;
  --ok: #1e7a41;
  --row-h: 30px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0; height: 100%;
  font-family: var(--font);
  font-size: 13px; color: var(--ink); background: var(--bg);
}

.hidden { display: none !important; }
.spacer { flex: 1; }
.muted { color: var(--ink-soft); }
.warn { color: var(--warn); }

/* ------------------------------------------------------------- sign in */
.login-wrap {
  height: 100%; display: flex; align-items: center; justify-content: center;
}
.login-card {
  background: var(--panel); padding: 32px; border-radius: 10px;
  border: 1px solid var(--line); width: 340px;
  box-shadow: 0 4px 24px rgba(0,0,0,.06);
}
.login-card h1 { margin: 0 0 4px; font-size: 20px; }
.login-card p { margin: 0 0 20px; font-size: 13px; }
.login-card label { display: block; margin-bottom: 14px; font-weight: 600; }
.login-card input {
  width: 100%; margin-top: 5px; padding: 9px 10px; font-size: 14px;
  border: 1px solid var(--line-strong); border-radius: 6px; font-weight: 400;
}
.login-card button { width: 100%; padding: 10px; font-size: 14px; }

/* -------------------------------------------------------------- chrome */
#app { display: flex; flex-direction: column; height: 100%; }

.topbar {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 12px; background: var(--panel);
  border-bottom: 1px solid var(--line); flex: none;
}
.brand { font-weight: 700; font-size: 14px; margin-right: 6px; white-space: nowrap; }
.searchbox { flex: 0 1 320px; }
.searchbox input {
  width: 100%; padding: 6px 10px; font-size: 13px;
  border: 1px solid var(--line-strong); border-radius: 6px;
}
.filter, select {
  padding: 6px 8px; font-size: 13px; border: 1px solid var(--line-strong);
  border-radius: 6px; background: #fff; color: var(--ink);
}
.chk { display: flex; align-items: center; gap: 5px; white-space: nowrap; color: var(--ink-soft); }

button {
  font-family: inherit; font-size: 13px; padding: 6px 12px; cursor: pointer;
  border-radius: 6px; border: 1px solid var(--line-strong); background: #fff;
  color: var(--ink);
}
button:hover:not(:disabled) { background: #f0f2f5; }
button:disabled { opacity: .5; cursor: not-allowed; }
button.primary {
  background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600;
}
button.primary:hover:not(:disabled) { background: #175ea3; }
button.ghost { background: transparent; }
button.small { padding: 4px 9px; font-size: 12px; }
button.icon { padding: 5px 9px; }
button.danger { color: var(--danger); border-color: #e6b4b0; }

.pill {
  display: inline-block; min-width: 18px; padding: 0 5px; margin-left: 4px;
  background: rgba(255,255,255,.28); border-radius: 9px; font-size: 11px;
  text-align: center;
}
.badge {
  padding: 3px 9px; border-radius: 5px; font-size: 12px;
  background: var(--warn-soft); color: var(--warn); border: 1px solid #f0d9a8;
}

.statusbar {
  display: flex; align-items: center; gap: 14px; padding: 5px 12px;
  background: var(--panel); border-bottom: 1px solid var(--line);
  font-size: 12px; color: var(--ink-soft); flex: none;
}

.bulkbar {
  display: flex; align-items: center; gap: 8px; padding: 7px 12px;
  background: var(--accent-soft); border-bottom: 1px solid #bcd8f2; flex: none;
}
.bulkbar input, .bulkbar select { padding: 4px 8px; font-size: 13px;
  border: 1px solid var(--line-strong); border-radius: 5px; }

/* ---------------------------------------------------------------- grid */
.gridwrap { flex: 1; position: relative; overflow: hidden; display: flex; flex-direction: column; }

.grid-header {
  display: flex; background: #eef1f4; border-bottom: 2px solid var(--line-strong);
  flex: none; overflow: hidden; position: relative; z-index: 3;
}
.grid-scroll { flex: 1; overflow: auto; position: relative; }
#grid-sizer { position: relative; }
#grid-rows { position: absolute; top: 0; left: 0; right: 0; }

.hcell, .cell {
  flex: none; padding: 0 7px; overflow: hidden; text-overflow: ellipsis;
  white-space: nowrap; border-right: 1px solid var(--line);
  line-height: var(--row-h); height: var(--row-h);
}
.hcell {
  font-weight: 600; font-size: 12px; cursor: pointer; user-select: none;
  display: flex; align-items: center; gap: 4px;
}
.hcell:hover { background: #e3e8ee; }
.hcell .sort { color: var(--accent); font-size: 10px; }
.hcell .info {
  color: var(--ink-soft); font-weight: 400; cursor: help; font-size: 11px;
}

.row { display: flex; border-bottom: 1px solid var(--line);
  background: var(--panel); position: absolute; left: 0; right: 0; }
.row:hover { background: #f4f8fd; }
.row.selected { background: var(--accent-soft); }
.row.selected:hover { background: #dbeafb; }

.cell.num { text-align: right; font-variant-numeric: tabular-nums; }
.cell.mono { font-family: var(--mono); font-size: 12px; }
.cell.editable { cursor: cell; }
.cell.editable:hover { box-shadow: inset 0 0 0 1px var(--accent); }
.cell.dirty { background: var(--dirty); box-shadow: inset 2px 0 0 var(--dirty-line); }
.cell.readonly { color: var(--ink-soft); background: #fafbfc; }
.cell.lowstock { color: var(--danger); font-weight: 600; }
.cell.untracked { color: var(--ink-soft); font-style: italic; }

.cell input, .cell select {
  width: 100%; height: calc(var(--row-h) - 4px); border: 2px solid var(--accent);
  border-radius: 3px; padding: 0 4px; font: inherit; font-size: 13px;
  background: #fff; outline: none;
}

.frozen { position: sticky; left: 0; z-index: 2; box-shadow: 2px 0 4px rgba(0,0,0,.05); }
.row .frozen { background: inherit; }
.grid-header .frozen { background: #eef1f4; }

.selcell {
  flex: none; width: 30px; text-align: center; line-height: var(--row-h);
  height: var(--row-h); border-right: 1px solid var(--line);
}

.empty { padding: 40px; text-align: center; color: var(--ink-soft); }

/* --------------------------------------------------------------- modal */
.modal {
  position: fixed; inset: 0; background: rgba(20,24,28,.45);
  display: flex; align-items: center; justify-content: center; z-index: 50;
}
.modal-card {
  background: var(--panel); border-radius: 10px; width: 560px;
  max-height: 86vh; display: flex; flex-direction: column;
  box-shadow: 0 12px 48px rgba(0,0,0,.25);
}
.modal-card.wide { width: 900px; }
.modal-card header, .modal-card footer {
  display: flex; align-items: center; gap: 8px; padding: 14px 18px;
}
.modal-card header { border-bottom: 1px solid var(--line); }
.modal-card footer { border-top: 1px solid var(--line); }
.modal-card h2 { margin: 0; font-size: 16px; }
.modal-body { padding: 18px; overflow: auto; }

.diff-summary { display: flex; gap: 20px; flex-wrap: wrap; margin-bottom: 16px; }
.stat { background: #f4f6f8; border: 1px solid var(--line); border-radius: 8px;
  padding: 10px 14px; min-width: 110px; }
.stat .n { font-size: 21px; font-weight: 700; }
.stat .l { font-size: 11px; color: var(--ink-soft); text-transform: uppercase;
  letter-spacing: .04em; }

table.diff { width: 100%; border-collapse: collapse; font-size: 12.5px; }
table.diff th {
  text-align: left; padding: 6px 8px; border-bottom: 2px solid var(--line-strong);
  position: sticky; top: 0; background: var(--panel); font-size: 11px;
  text-transform: uppercase; letter-spacing: .04em; color: var(--ink-soft);
}
table.diff td { padding: 5px 8px; border-bottom: 1px solid var(--line); }
table.diff tr:hover { background: #f7f9fb; }
.was { color: var(--danger); text-decoration: line-through; opacity: .75; }
.now { color: var(--ok); font-weight: 600; }
.sku { font-family: var(--mono); font-size: 12px; }

.notice {
  padding: 10px 12px; border-radius: 7px; margin-bottom: 14px; font-size: 13px;
  border: 1px solid;
}
.notice.info { background: var(--accent-soft); border-color: #bcd8f2; }
.notice.warn { background: var(--warn-soft); border-color: #f0d9a8; color: var(--warn); }
.notice.error { background: var(--danger-soft); border-color: #f0c4c0; color: var(--danger); }

.error { color: var(--danger); font-size: 12.5px; margin-bottom: 10px; }

.settings-row {
  display: flex; align-items: center; gap: 10px; padding: 8px 0;
  border-bottom: 1px solid var(--line);
}
.settings-row:last-child { border-bottom: 0; }
.settings-row label { min-width: 140px; font-weight: 600; }
.settings-row input { flex: 1; padding: 6px 8px; border: 1px solid var(--line-strong);
  border-radius: 5px; font: inherit; }
h3.section { font-size: 13px; margin: 20px 0 8px; text-transform: uppercase;
  letter-spacing: .05em; color: var(--ink-soft); }

.toast {
  position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%);
  background: #22262b; color: #fff; padding: 10px 18px; border-radius: 7px;
  z-index: 100; font-size: 13px; box-shadow: 0 4px 18px rgba(0,0,0,.3);
  max-width: 70vw;
}
.toast.err { background: var(--danger); }

/* ------------------------------------------------------------ sheet tabs */
.tabs {
  display: flex; gap: 2px; padding: 0 12px; background: var(--panel);
  border-bottom: 1px solid var(--line); flex: none; overflow-x: auto;
}
.tab {
  border: 0; border-bottom: 3px solid transparent; border-radius: 0;
  background: transparent; padding: 9px 15px; font-size: 13px; font-weight: 600;
  color: var(--ink-soft); white-space: nowrap; display: flex; align-items: center;
  gap: 6px;
}
.tab:hover { background: #f2f4f7; }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); }
.tabcount {
  font-weight: 400; font-size: 11px; color: var(--ink-soft);
  background: #eef1f4; padding: 1px 6px; border-radius: 8px;
}
.tab.active .tabcount { background: var(--accent-soft); color: var(--accent); }

.filters { display: flex; gap: 6px; align-items: center; }

/* Read-only header cells read as inert, so nobody hunts for an edit cursor. */
.hcell.ro { color: var(--ink-soft); font-weight: 500; }

/* Rows worth noticing: reference data nothing uses, or a row that cannot
   produce a price. */
.row.unused .cell { color: var(--ink-soft); }
.row.unused .cell.mono { opacity: .7; }
.row.problem { background: var(--warn-soft); }
.row.problem:hover { background: #fdefd6; }
