
  * { box-sizing: border-box; }
  html, body { margin: 0; padding: 0; }
  body {
    font-family: 'Courier New', Courier, monospace;
    font-size: 12px;
    background: #fff;
    color: #000;
    -webkit-user-select: none;
    user-select: none;
  }

  .toolbar {
    position: sticky; top: 0; z-index: 30;
    background: #fff; padding: 10px 14px;
    border-bottom: 1px solid #ccc;
    display: flex; gap: 10px; align-items: center; flex-wrap: wrap;
  }
  .toolbar input, .toolbar select, .toolbar button {
    font-family: inherit; font-size: 13px;
    padding: 6px 10px;
    border: 1px solid #aaa; border-radius: 3px;
    background: #fff;
  }
  .toolbar input { width: 320px; }
  .toolbar button { cursor: pointer; background: #4285f4; color: #fff; border: none; }
  .toolbar button:hover { background: #3367d6; }
  .toolbar button.secondary { background: #eee; color: #333; }
  .toolbar button.secondary:hover { background: #ddd; }

  #userInfo {
    margin-left: auto; color: #666; font-size: 11px;
    -webkit-user-select: text; user-select: text;
  }

  .menu-wrap { position: relative; }
  .menu-popup {
    position: absolute; top: 100%; right: 0; margin-top: 4px;
    background: #fff; border: 1px solid #aaa; border-radius: 3px;
    padding: 8px; min-width: 220px; max-height: 460px; overflow-y: auto;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15); z-index: 40;
  }
  .menu-popup label {
    display: block; padding: 4px 4px; font-size: 12px; cursor: pointer;
    border-radius: 2px;
  }
  .menu-popup label:hover { background: #f0f5ff; }
  .menu-popup input { margin-right: 8px; vertical-align: middle; }
  .menu-actions {
    display: flex; gap: 6px; padding-top: 6px; margin-top: 6px;
    border-top: 1px solid #eee;
  }
  .menu-actions button {
    flex: 1; font-size: 11px; padding: 4px 6px;
  }

  #message { padding: 4px 14px; min-height: 20px; font-size: 12px; }
  .msg-err  { color: #c00; }
  .msg-ok   { color: #060; }
  .msg-info { color: #444; }

  table { border-collapse: collapse; width: 100%; table-layout: auto; }
  thead th {
    background: #efefef; padding: 6px 8px; border: 1px solid #ccc;
    position: sticky; top: 58px; z-index: 10;
    font-weight: bold; text-align: left; font-size: 11px;
  }
  tbody td {
    padding: 3px 8px; border: 1px solid #d6d6d6;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    max-width: 360px;
  }
  tbody tr:nth-child(even) td { background: #f7faff; }
  tbody td.oem { background: #fff8d8; }
  tbody tr:nth-child(even) td.oem { background: #fff3c4; }

  /* Multi-line collapsible cells (Programm., Special func., Vehicles) */
  tbody td.multi {
    white-space: normal;
    vertical-align: top;
    overflow: hidden;
    text-overflow: clip;
    max-width: 360px;
    cursor: pointer;
    position: relative;
    padding-bottom: 18px; /* space for "show more" badge */
  }
  /* Vehicles column (display index 9 = nth-child 10) — needs more width so car names don't wrap */
  thead th:nth-child(10),
  tbody td:nth-child(10) { min-width: 240px; }
  tbody td.multi:nth-child(10) { max-width: 280px; }
  tbody td.multi .clamp {
    white-space: pre-line;
    line-height: 1.4em;
    max-height: 4.2em; /* exactly 3 lines */
    overflow: hidden;
  }
  tbody td.multi.expanded {
    padding-bottom: 18px;
  }
  tbody td.multi.expanded .clamp {
    max-height: none;
    overflow: visible;
  }
  tbody td.multi .more {
    position: absolute; left: 6px; bottom: 2px;
    font-size: 10px; font-weight: bold;
    background: #4285f4; color: #fff;
    padding: 1px 8px; border-radius: 3px;
    cursor: pointer; user-select: none;
    box-shadow: 0 1px 2px rgba(0,0,0,0.15);
  }
  tbody td.multi .more:hover { background: #3367d6; }

  tr.group-header td {
    background: #b8b8b8 !important;
    font-weight: bold; text-align: center; font-size: 13px;
    padding: 10px; letter-spacing: 1px;
  }
  tr.match-highlight td { background: #ffe66e !important; }

  tbody td.photo-cell {
    text-align: center; padding: 2px;
  }
  tbody td.photo-cell .thumb {
    width: 50px; height: 38px;
    object-fit: cover; cursor: zoom-in;
    border: 1px solid #ccc; border-radius: 2px;
    vertical-align: middle;
    display: inline-block;
  }
  #imgPreview {
    position: fixed; z-index: 200;
    background: #fff; padding: 4px;
    border: 1px solid #888; border-radius: 4px;
    box-shadow: 0 6px 20px rgba(0,0,0,0.30);
    pointer-events: none;
  }
  #imgPreview img {
    display: block; max-width: 360px; max-height: 270px;
  }
  #imgPreview .caption {
    font-size: 11px; color: #444; padding: 2px 4px 0;
    text-align: center;
  }

  thead th.filterable { cursor: pointer; user-select: none; }
  thead th.filterable:hover { background: #e0e7ff; }
  thead th.filterable .filter-icon {
    font-size: 9px; color: #999; margin-left: 4px;
  }
  thead th.filterable.has-filter { background: #d0deff; }
  thead th.filterable.has-filter .filter-icon { color: #1a4cd6; font-weight: bold; }

  #columnFilterPopup {
    position: absolute; display: none; z-index: 50;
    background: #fff; border: 1px solid #aaa; border-radius: 3px;
    padding: 6px; min-width: 180px; max-height: 380px; overflow-y: auto;
    box-shadow: 0 4px 12px rgba(0,0,0,0.18);
  }
  #columnFilterPopup label {
    display: block; padding: 3px 4px; font-size: 12px;
    cursor: pointer; border-radius: 2px;
  }
  #columnFilterPopup label:hover { background: #f0f5ff; }
  #columnFilterPopup input { margin-right: 6px; vertical-align: middle; }
  #columnFilterPopup .popup-actions {
    border-top: 1px solid #eee; padding-top: 6px; margin-top: 6px;
  }
  #columnFilterPopup button {
    width: 100%; font-size: 11px; padding: 4px 6px;
    background: #eee; color: #333; border: 1px solid #ccc;
    border-radius: 2px; cursor: pointer;
  }
  #columnFilterPopup button:hover { background: #ddd; }

  #loading { text-align: center; padding: 60px; color: #666; font-size: 14px; }

  body { display: flex; flex-direction: column; height: 100dvh; }
  .toolbar { position: relative; flex: 0 0 auto; }
  .table-scroll { flex: 1; overflow: auto; min-height: 0; }
  thead th { top: 0; }
  #message { flex: 0 0 auto; }
  .toolbar input { user-select: text; -webkit-user-select: text; }
  button:disabled { opacity: .55; cursor: wait; }
  .photo-cell img { background: #f7f7f7; }
  @media (max-width: 640px) {
    .toolbar { padding: 8px; gap: 6px; }
    .toolbar input[type=text] { width: 100%; }
    #userInfo { margin-left: 0; width: 100%; }
    .toolbar select { max-width: 100%; }
  }
