:root {
    --ne-bg: #f5f6f8;
    --ne-panel: #ffffff;
    --ne-ink: #1d2530;
    --ne-muted: #6b7480;
    --ne-accent: #1f5fa6;
    --ne-accent-dark: #174a82;
    --ne-border: #d9dee5;
    --ne-danger: #b3261e;
    --ne-ok: #1f7a3d;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: "Segoe UI", Roboto, Arial, sans-serif;
    background: var(--ne-bg);
    color: var(--ne-ink);
    font-size: 14px;
    line-height: 1.45;
}

a { color: var(--ne-accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.topbar {
    display: flex;
    align-items: center;
    gap: 24px;
    background: var(--ne-panel);
    border-bottom: 1px solid var(--ne-border);
    padding: 0 20px;
    height: 52px;
    position: relative;
    z-index: 100;
}
.brand a { font-weight: 600; font-size: 16px; color: var(--ne-ink); }
.mainnav { display: flex; gap: 16px; flex: 1; align-items: center; }
.mainnav a { color: var(--ne-muted); font-weight: 500; }
.mainnav a:hover { color: var(--ne-accent); text-decoration: none; }

/* Grouped dropdown menus */
.navgroup { position: relative; }
.navgroup-toggle {
    background: none;
    border: none;
    color: var(--ne-muted);
    font-weight: 500;
    font-size: 14px;
    cursor: pointer;
    padding: 0;
    font-family: inherit;
}
.navgroup-toggle:hover { color: var(--ne-accent); }
.navgroup-menu {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    /* Visual offset via transparent top padding (a "bridge"), NOT margin, so the
       cursor never crosses an un-hovered gap between toggle and menu. */
    padding-top: 8px;
    min-width: 180px;
}
.navgroup-menu-inner {
    background: var(--ne-panel);
    border: 1px solid var(--ne-border);
    border-radius: 6px;
    box-shadow: 0 6px 18px rgba(0,0,0,.08);
    padding: 6px 0;
}
/* Menu (and its transparent bridge) only exist in layout when the group is hovered
   or toggled open, so they never sit over and block page content while closed. */
.navgroup:hover .navgroup-menu,
.navgroup.open .navgroup-menu { display: block; }
.navgroup-menu a {
    display: block;
    padding: 8px 16px;
    color: var(--ne-ink);
    font-weight: 500;
}
.navgroup-menu a:hover { background: #f0f3f7; color: var(--ne-accent); text-decoration: none; }
.signout { margin-left: auto; display: flex; align-items: center; gap: 10px; color: var(--ne-muted); }
.signout button { background: none; border: 1px solid var(--ne-border); border-radius: 4px; padding: 4px 10px; cursor: pointer; }

.container { max-width: 1100px; margin: 24px auto; padding: 0 20px; }

h1 { font-size: 22px; margin: 0 0 16px; }
h2 { font-size: 17px; margin: 24px 0 10px; }

.panel {
    background: var(--ne-panel);
    border: 1px solid var(--ne-border);
    border-radius: 6px;
    padding: 18px;
    margin-bottom: 18px;
}
/* Remove the extra gap created by the first child's own top margin (e.g. h2/h3),
   which stacked on top of the panel padding and looked like excessive padding. */
.panel > :first-child { margin-top: 0; }
.panel > h2:first-child, .panel > h3:first-child { margin-top: 0; }

/* Product typeahead (speaker line picker) */
.typeahead-results {
    position: absolute; z-index: 30; left: 0; right: 0; top: 100%;
    background: #fff; border: 1px solid var(--ne-border); border-radius: 6px;
    max-height: 260px; overflow-y: auto; box-shadow: 0 6px 18px rgba(0,0,0,.12);
}
.typeahead-item { padding: 7px 10px; cursor: pointer; }
.typeahead-item:hover { background: #f0f4ff; }

/* Inline edit form on speaker rows */
.inline-edit { display: inline-flex; gap: 8px; align-items: center; margin-right: 8px; }

table { width: 100%; border-collapse: collapse; background: var(--ne-panel); }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--ne-border); }
th { color: var(--ne-muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .03em; }

.btn {
    display: inline-block;
    background: var(--ne-accent);
    color: #fff;
    border: none;
    border-radius: 4px;
    padding: 7px 14px;
    cursor: pointer;
    font-size: 14px;
}
.btn:hover { background: var(--ne-accent-dark); text-decoration: none; }
.btn-secondary { background: #eceff3; color: var(--ne-ink); }
.btn-danger { background: var(--ne-danger); }
.btn-sm { padding: 4px 9px; font-size: 13px; }

.actions { display: flex; gap: 8px; margin: 16px 0; flex-wrap: wrap; }
.row-actions { white-space: nowrap; }
.row-actions a, .row-actions button { margin-right: 8px; }

.form-group { margin-bottom: 14px; max-width: 520px; }
.form-group label { display: block; font-weight: 600; margin-bottom: 4px; }
.form-group input[type=text],
.form-group input[type=email],
.form-group input[type=password],
.form-group input[type=number],
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 7px 9px;
    border: 1px solid var(--ne-border);
    border-radius: 4px;
    font-size: 14px;
    background: #fff;
}
.form-group textarea { min-height: 90px; }

.checkbox-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 6px; max-width: 760px; }
.checkbox-list label { font-weight: 400; display: flex; gap: 8px; align-items: center; }
.readonly-value { margin: 2px 0 4px; padding: 7px 10px; background: #f3f3f3; border: 1px solid var(--ne-border, #e2e2e2); border-radius: 6px; font-weight: 600; }

/* Product filter bar */
.filter-bar { background: var(--ne-panel, #fff); border: 1px solid var(--ne-border, #e2e2e2); border-radius: 8px; padding: 14px 16px; margin: 12px 0 16px; }
.filter-row { display: flex; gap: 16px; flex-wrap: wrap; align-items: flex-end; }
.filter-field { margin-bottom: 12px; }
.filter-field > label { display: block; font-weight: 600; margin-bottom: 4px; }
.filter-grow { flex: 1 1 280px; }
.filter-grow input { width: 100%; box-sizing: border-box; }
.filter-actions { display: flex; gap: 10px; }
.brand-filter-input { width: 100%; max-width: 320px; box-sizing: border-box; margin-bottom: 6px; }
.checkbox-scroll { max-height: 180px; overflow-y: auto; border: 1px solid var(--ne-border, #e2e2e2); border-radius: 6px; padding: 8px 10px; display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 4px 14px; background: #fafafa; }
.checkbox-scroll .brand-item { font-weight: 400; display: flex; gap: 8px; align-items: center; }

/* Pager */
.pager { display: flex; gap: 8px; align-items: center; margin: 16px 0; flex-wrap: wrap; }
.pager-status { color: var(--ne-muted, #666); padding: 0 6px; }

.field-validation-error, .validation-summary-errors { color: var(--ne-danger); font-size: 13px; }
.text-muted { color: var(--ne-muted); }

.alert { padding: 10px 14px; border-radius: 4px; margin-bottom: 16px; }
.alert-ok { background: #e7f4ec; color: var(--ne-ok); border: 1px solid #b7dcc4; }
.alert-warn { background: #fdf4e3; color: #8a6d3b; border: 1px solid #f0dcae; }
.alert-error { background: #fbe9e8; color: var(--ne-danger); border: 1px solid #efc4c1; }
.alert-info { background: #e8f0f8; color: var(--ne-accent-dark); border: 1px solid #c3d7ec; }

.badge { display: inline-block; padding: 2px 8px; border-radius: 10px; font-size: 12px; background: #eceff3; color: var(--ne-muted); }
.badge-ok { background: #e7f4ec; color: var(--ne-ok); }
.badge-warn { background: #fdf2dc; color: #8a6d1a; }

.login-wrap { max-width: 380px; margin: 60px auto; }
.login-wrap .panel { padding: 24px; }
.footer { text-align: center; color: var(--ne-muted); padding: 24px; }

/* ---- Project room×product matrix ---- */
.matrix-scroll { overflow-x: auto; border: 1px solid var(--ne-border); border-radius: 6px; }
table.matrix { width: auto; min-width: 100%; border-collapse: collapse; background: var(--ne-panel); }
table.matrix th, table.matrix td { border: 1px solid var(--ne-border); padding: 6px 8px; }
table.matrix thead th { background: #f4f6f9; text-align: center; vertical-align: bottom; }
.matrix-section { text-align: center !important; white-space: nowrap; }
.matrix-prod { vertical-align: bottom; padding: 8px 4px; }
.matrix-partno {
    writing-mode: vertical-rl;
    transform: rotate(180deg);
    white-space: nowrap;
    font-size: 12px;
    line-height: 1.1;
    font-family: var(--ne-mono, ui-monospace, "Consolas", monospace);
    margin: 0 auto;
}
.matrix-qty { text-align: center; }
/* Derived modifier columns sit next to their base product, lightly shaded + italic code. */
.matrix-mod { background: var(--ne-mod-shade, #f3eefe); }
th.matrix-mod .matrix-partno { font-style: italic; color: var(--ne-mod-fg, #6b4fbb); }
/* Sticky first column so room names stay visible while scrolling right */
.matrix-roomhead, .matrix-roomcell {
    position: sticky; left: 0; z-index: 2; background: var(--ne-panel);
    white-space: nowrap; text-align: left;
}
table.matrix thead .matrix-roomhead { background: #f4f6f9; z-index: 3; }
.matrix-floor {
    display: inline-block; min-width: 30px; padding: 0 5px; margin-right: 4px;
    background: #eef2f7; border-radius: 3px; font-size: 11px; color: var(--ne-accent-dark);
}
.matrix-rowtotal { background: #f4f6f9; font-weight: 600; }
table.matrix tfoot td { background: #f4f6f9; }

/* ── Product listing: category sidebar layout (v2.5.0) ───────────────────── */
.product-layout { display: flex; gap: 18px; align-items: flex-start; }
.product-sidebar {
  flex: 0 0 280px; max-width: 280px;
  background: var(--ne-panel, #fff); border: 1px solid var(--ne-border, #e2e2e2);
  border-radius: 8px; padding: 12px; position: sticky; top: 12px;
  max-height: calc(100vh - 40px); overflow-y: auto;
}
.product-main { flex: 1 1 auto; min-width: 0; }
.cat-sidebar-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 8px; }
.cat-clear { font-size: .82rem; text-decoration: none; }
.cat-tree, .cat-children { list-style: none; margin: 0; padding: 0; }
.cat-children { padding-left: 14px; }
.cat-node { margin: 1px 0; }
.cat-row { display: flex; align-items: center; gap: 4px; border-radius: 5px; padding: 2px 4px; }
.cat-row:hover { background: #f3f5f8; }
.cat-row.cat-selected { background: #e6eef9; }
.cat-row.cat-selected > .cat-link { font-weight: 600; }
.cat-toggle { cursor: pointer; width: 16px; text-align: center; color: #888; font-size: .8rem; flex: 0 0 16px; user-select: none; }
.cat-toggle.cat-leaf { cursor: default; color: #bbb; }
.cat-link { flex: 1 1 auto; text-decoration: none; color: inherit; display: flex; justify-content: space-between; gap: 8px; align-items: baseline; min-width: 0; }
.cat-link > .cat-count { color: #8a8a8a; font-size: .78rem; flex: 0 0 auto; }
@media (max-width: 820px) {
  .product-layout { flex-direction: column; }
  .product-sidebar { position: static; max-width: none; flex-basis: auto; width: 100%; max-height: 320px; }
}
.cat-filter-note { font-size: .78rem; margin: 0 0 8px; padding: 0 4px; }

/* ── BOM quote-element sections (v2.9.0) ─────────────────────────────────── */
.bom-section-head td { background: #eef2f7; font-size: .95rem; padding-top: 10px; }
.bom-section-head.bom-unallocated td { background: #f7efef; }
.bom-subtotal td { background: #f7f9fb; border-top: 1px solid var(--ne-border, #e2e2e2); }
.bom-grandtotal td { background: #e9eef5; }

/* ── BOM allocate button + modal (v2.10.0) ───────────────────────────────── */
.bom-allocate-btn {
  border: 1px solid var(--ne-border, #d4d4d4); background: #fff; color: #4a6b8a;
  border-radius: 4px; cursor: pointer; font-size: .9rem; line-height: 1;
  padding: 1px 5px; margin-right: 6px; vertical-align: middle;
}
.bom-allocate-btn:hover { background: #eef2f7; border-color: #9bb3c9; }
.bom-modal {
  position: fixed; inset: 0; background: rgba(0,0,0,.35);
  display: flex; align-items: center; justify-content: center; z-index: 1000;
}
.bom-modal-box {
  background: #fff; border-radius: 8px; padding: 20px 22px; width: 420px; max-width: 92vw;
  box-shadow: 0 10px 40px rgba(0,0,0,.25);
}

/* ── Chips (selected categories etc.) (v2.13.0) ──────────────────────────── */
.chip-list { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  background: #eef2f7; border: 1px solid #d4dde6; border-radius: 14px;
  padding: 3px 6px 3px 12px; font-size: .86rem;
}
.chip-x {
  border: none; background: #cdd8e2; color: #33424f; border-radius: 50%;
  width: 18px; height: 18px; line-height: 1; cursor: pointer; font-size: .9rem; padding: 0;
}
.chip-x:hover { background: #b6c4d1; }

/* ── Project nav bar (v2.17.0) ───────────────────────────────────────────── */
.project-nav { margin-bottom: 16px; }
.project-nav .btn-active {
  background: #33424f; color: #fff; border-color: #33424f; pointer-events: none;
}

/* ── BOM labor-by-element + matrix requirement rows (v2.17.0) ────────────── */
.bom-labor-table { width: 100%; max-width: 760px; }
.bom-labor-table th, .bom-labor-table td { padding: 5px 8px; }
.bom-labor-table tfoot .bom-grandtotal th,
.bom-labor-table tfoot .bom-grandtotal td { border-top: 2px solid #33424f; }
.matrix-reqs { width: 100%; max-width: 760px; }
.matrix-reqs th, .matrix-reqs td { padding: 5px 8px; }

/* ── Locked key badge in import mapping (v2.19.0) ────────────────────────── */
.lock-badge {
  display: inline-block; margin-left: 8px; font-size: .72rem; font-weight: 600;
  color: #8a6d00; background: #fff6d8; border: 1px solid #ecd98a;
  border-radius: 10px; padding: 1px 8px;
}

/* ── Table action icon buttons (v2.20.0) ─────────────────────────────────── */
.row-actions .btn-sm {
  padding: 4px 7px; line-height: 0; display: inline-flex; align-items: center; justify-content: center;
}
.row-actions .btn-sm .icon { display: block; }
.icon { vertical-align: middle; }

/* ── Progress bar (mass import) (v2.21.0) ────────────────────────────────── */
.progress {
  width: 100%; max-width: 520px; height: 22px; background: #e9eef3;
  border: 1px solid #d4dde6; border-radius: 6px; overflow: hidden; margin: 4px 0 10px;
}
.progress-bar {
  height: 100%; background: #3d6cb9; color: #fff; font-size: .76rem; line-height: 22px;
  text-align: center; white-space: nowrap; transition: width .35s ease; min-width: 2px;
}
.progress-done { background: #2e8b57; }
.progress-mini {
  width: 120px; height: 12px; background: #e9eef3; border: 1px solid #d4dde6;
  border-radius: 4px; overflow: hidden; display: inline-block; vertical-align: middle; margin-right: 6px;
}
.progress-mini > span { display: block; height: 100%; background: #3d6cb9; }
.progress-mini.mini-done > span { background: #2e8b57; }


/* ── Mobile hamburger nav (v2.20.1) ──────────────────────────────────────── */
.nav-toggle { display: none; }
@media (max-width: 820px) {
  /* Let the bar grow when the menu opens, instead of the fixed 52px that made the
     menu spill over page content with no background. */
  .topbar { flex-wrap: wrap; height: auto; min-height: 52px; row-gap: 0; }
  .brand { order: 1; }

  /* Right cluster on the first row: compact sign-out, then the hamburger. */
  .signout { order: 2; margin-left: auto; gap: 6px; }
  .signout span { display: none; }            /* hide username on small screens to keep row 1 tidy */

  .nav-toggle {
    display: inline-flex; flex-direction: column; justify-content: center; gap: 5px;
    width: 44px; height: 38px; padding: 8px 10px; margin-left: 8px; order: 3;
    background: #fff; border: 1px solid var(--ne-border, #d4dde6); border-radius: 8px; cursor: pointer;
  }
  .nav-toggle span { display: block; height: 2px; width: 100%; background: var(--ne-ink, #33424f); border-radius: 2px; }

  /* The menu is its own full-width row (row 2), opaque, only shown when open. */
  .mainnav {
    order: 4; display: none; flex-direction: column; align-items: stretch; gap: 0;
    flex-basis: 100%; width: 100%; margin-top: 8px; padding: 2px 0 6px;
    background: var(--ne-panel); border-top: 1px solid var(--ne-border);
  }
  .mainnav.open { display: flex; }
  .mainnav > a, .navgroup > .navgroup-toggle {
    display: block; width: 100%; text-align: left; padding: 13px 4px; margin: 0;
    border-top: 1px solid #eef1f4; font-size: 15px;
  }

  /* Dropdown groups become inline accordions (no floating panel) */
  .navgroup { position: static; }
  .navgroup-menu { position: static; padding-top: 0; min-width: 0; }
  .navgroup-menu-inner { background: transparent; border: none; box-shadow: none; border-radius: 0; padding: 0 0 6px 14px; }
  .navgroup:hover .navgroup-menu { display: none; }
  .navgroup.open .navgroup-menu { display: block; }
  .navgroup-menu a { padding: 10px 6px; }
}
