:root {
      --bg: #f5f7fa;
      --card: #ffffff;
      --text: #111827;
      --muted: #6b7280;
      --line: #d1d5db;
      --accent: #1f6f8b;
      --accent-dark: #155778;
      --warn-bg: #fff7ed;
      --warn-text: #9a3412;
      --ok-bg: #ecfdf5;
      --ok-text: #047857;
    }
    * { box-sizing: border-box; }
    body {
      margin: 0;
      font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
      background: var(--bg);
      color: var(--text);
      line-height: 1.35;
    }
    header {
      position: relative;
      background: #0f3045;
      color: white;
      padding: 18px 20px;
    }
    header h1 {
      margin: 0;
      font-size: 1.45rem;
      letter-spacing: 0.02em;
    }
    .version-small {
      font-size: 0.75rem;
      color: #cbd5e1;
      margin-bottom: 4px;
      font-weight: 600;
    }
    .version-badge {
      position: absolute;
      top: 10px;
      right: 16px;
      font-size: 0.78rem;
      color: #dbeafe;
      font-weight: 700;
      opacity: 0.95;
      white-space: nowrap;
    }
    header p {
      margin: 4px 0 0;
      color: #dbeafe;
      font-size: 0.95rem;
    }
    main {
      max-width: 1180px;
      margin: 18px auto 40px;
      padding: 0 14px;
    }
    .panel {
      background: var(--card);
      border: 1px solid var(--line);
      border-radius: 14px;
      padding: 16px;
      box-shadow: 0 6px 22px rgba(17, 24, 39, 0.06);
      margin-bottom: 14px;
    }
    .toolbar {
      align-items: center;
      display: grid;
      grid-template-columns: repeat(6, minmax(140px, 1fr));
      gap: 12px;
      align-items: end;
    }
    label {
      display: block;
      font-size: 0.82rem;
      font-weight: 650;
      color: #374151;
      margin-bottom: 4px;
    }
    input, select, textarea, button {
    }

    button.action {
      background: #1d4ed8; /* blue for actions */
      color: white;
    }

    button.action:hover {
      background: #1e40af;
    }

    button {
      font: inherit;
    }
    input, select, textarea {
      width: 100%;
      border: 1px solid var(--line);
      border-radius: 9px;
      padding: 8px 9px;
      background: white;
      color: var(--text);
    }
    textarea {
      min-height: 38px;
      resize: vertical;
    }
    button {
    }

    button.action {
      background: #1d4ed8; /* blue for actions */
      color: white;
    }

    button.action:hover {
      background: #1e40af;
    }

    button {
      border: 0;
      border-radius: 10px;
      padding: 9px 12px;
      background: var(--accent);
      color: white;
      font-weight: 700;
      cursor: pointer;
    }
    button:hover { background: var(--accent-dark); }
    button.secondary {
      background: #e5e7eb;
      color: #111827;
    }
    button.secondary:hover { background: #d1d5db; }
    button.danger {
      background: #b91c1c;
    }
    button.danger:hover { background: #991b1b; }
    .button-row {
      display: flex;
      gap: 8px;
      flex-wrap: nowrap;
      align-items: center;
    }
    .status {
      color: var(--muted);
      font-size: 0.9rem;
      margin-top: 10px;
    }
    .table-wrap {
      overflow-x: auto;
      border: 1px solid var(--line);
      border-radius: 12px;
      background: white;
    }
    table {
      border-collapse: collapse;
      width: 100%;
      min-width: 980px;
    }
    th, td {
      border-bottom: 1px solid var(--line);
      border-right: 1px solid var(--line);
      padding: 7px;
      vertical-align: top;
    }
    th:last-child, td:last-child { border-right: 0; }
    tr:last-child td { border-bottom: 0; }
    th {
      background: #eff6ff;
      text-align: left;
      font-size: 0.84rem;
      color: #1f2937;
      position: sticky;
      top: 0;
      z-index: 1;
    }
    td.entry {
      width: 72px;
      font-weight: 800;
      text-align: center;
      background: #f9fafb;
      color: #111827;
      padding-top: 13px;
    }
    .ack-header {
      width: 42px;
      min-width: 42px;
      max-width: 42px;
      text-align: center;
    }
    td.ack-cell {
      width: 42px;
      min-width: 42px;
      max-width: 42px;
      text-align: center;
      vertical-align: middle;
    }
    input.ack-check {
      width: 18px;
      height: 18px;
      cursor: pointer;
    }

    .stat-header {
      width: 52px;
      text-align: center;
    }
    td.member-state {
      display: flex;
      align-items: center;
      justify-content: center;
      width: 52px;
      min-width: 52px;
      max-width: 52px;
      font-size: 1.15rem;
      text-align: center;
      padding-top: 12px;
      font-weight: 900;
    }
    .known {
      background: var(--ok-bg);
      color: var(--ok-text);
    }
    .unknown {
      background: var(--warn-bg);
      color: var(--warn-text);
    }

    .regular {
      background: #e0f2fe;
      color: #075985;
    }
    .guest {
      background: var(--warn-bg);
      color: var(--warn-text);
    }
    .blank-state {
      background: #f9fafb;
      color: var(--muted);
    }
    .callsign { width: 135px; }
    .name { width: 155px; }
    .location { width: 160px; }
    .digital, .status-select { width: 110px; }
    .comments { min-width: 260px; }
    .small-note {
      font-size: 0.86rem;
      color: var(--muted);
      margin-top: 8px;
    }
    details summary {
      cursor: pointer;
      font-weight: 700;
      color: #1f2937;
    }
    .settings-grid {
      display: grid;
      grid-template-columns: 1fr auto;
      gap: 10px;
      margin-top: 12px;
      align-items: end;
    }
    .kbd {
      display: inline-block;
      border: 1px solid var(--line);
      border-bottom-width: 2px;
      border-radius: 5px;
      padding: 1px 5px;
      background: #fff;
      font-size: 0.8rem;
      color: #374151;
    }

    .ics309-meta {
      display: grid;
      grid-template-columns: 1.2fr 1fr 1fr;
      gap: 0;
      border: 1px solid #111827;
      border-bottom: 0;
      margin-top: 10px;
    }
    .ics309-meta div {
      border-right: 1px solid #111827;
      border-bottom: 1px solid #111827;
      padding: 6px 8px;
      min-height: 48px;
    }
    .ics309-meta div:nth-child(3n) { border-right: 0; }
    .ics309-label {
      display: block;
      font-size: 0.72rem;
      font-weight: 800;
      color: #374151;
      text-transform: uppercase;
      margin-bottom: 3px;
    }
    .ics309-value {
      font-size: 0.95rem;
      font-weight: 650;
    }


    .output-panel {
      display: none;
      margin-top: 12px;
      border: 1px solid var(--line);
      border-radius: 12px;
      padding: 12px;
      background: #ffffff;
    }
    .output-panel.open { display: block; }
    .output-panel h2 {
      margin: 0 0 8px;
      font-size: 1rem;
    }
    #generatedOutput {
      width: 100%;
      min-height: 260px;
      font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
      white-space: pre;
    }
    #printFrame {
      position: absolute;
      width: 0;
      height: 0;
      border: 0;
      visibility: hidden;
    }

    @media (max-width: 820px) {
      .toolbar, .settings-grid {
        grid-template-columns: 1fr;
      }
    }
    @media print {
      body { background: white; }
      header, .no-print { display: none; }
      main { margin: 0; max-width: none; padding: 0; }
      .panel { box-shadow: none; border: 0; padding: 0; }
      input, select, textarea { border: 0; padding: 0; }
      .member-state {
        color: #111827;
        background: white;
      }
    }
  
    /* v8d: keep DMR/WLK dropdown arrows readable */
    select.dmr,
    select.wlk {
      min-width: 64px;
      padding-right: 26px;
    }
    .dmr,
    .wlk {
      width: 72px;
      min-width: 72px;
    }

  
    /* v8g: print full logger table without cutting off Status/Comments */
    @page {
      size: letter landscape;
      margin: 0.35in;
    }

    @media print {
      body {
        background: white;
        font-size: 9px;
      }

      header {
        display: block !important;
        padding: 0;
        margin: 0 0 6px 0;
        background: white !important;
        color: black !important;
        border-bottom: 1px solid #111;
      }

      header h1 {
        font-size: 12px;
        text-align: center;
        margin: 0;
        color: black !important;
      }

      header p {
        display: none;
      }

      .no-print,
      .toolbar,
      .small-note,
      .output-panel {
        display: none !important;
      }

      main {
        margin: 0;
        max-width: none;
        padding: 0;
      }

      .panel {
        box-shadow: none;
        border: 0;
        padding: 0;
        margin: 0;
      }

      table {
        width: 100% !important;
        min-width: 0 !important;
        table-layout: fixed !important;
        font-size: 8.5px;
      }

      th, td {
        padding: 2px 3px !important;
        word-break: break-word;
      }

      input, select, textarea {
        border: 0 !important;
        padding: 0 !important;
        background: transparent !important;
        font-size: 8.5px !important;
        width: 100% !important;
        appearance: none;
        -webkit-appearance: none;
      }

      textarea {
        height: auto !important;
        min-height: 20px !important;
        resize: none !important;
        overflow: visible !important;
      }

      .entry { width: 5% !important; }
      .callsign { width: 11% !important; }
      .ack-header, .ack-cell { width: 4% !important; }
      .member-state { width: 5% !important; }
      .name { width: 12% !important; }
      .location { width: 14% !important; }
      .dmr, .wlk { width: 6% !important; }
      .status-select { width: 9% !important; }
      .comments { width: 28% !important; }

      .member-state {
        color: #111827 !important;
        background: white !important;
      }
    }

  
    /* v8j: hide dropdown arrow after selection to indicate completion */
    select.selection-complete {
      appearance: none;
      -webkit-appearance: none;
      -moz-appearance: none;
      background-image: none !important;
      padding-right: 8px !important;
    }


    /* v8k: hide native select arrows after selection */
    select.selection-complete {
      appearance: none !important;
      -webkit-appearance: none !important;
      -moz-appearance: none !important;
      background-image: none !important;
      padding-right: 8px !important;
    }
    select.selection-complete::-ms-expand {
      display: none !important;
    }

  
    /* v8m: keep comments compact but readable */
    textarea.comments {
      white-space: pre-wrap;
      overflow-wrap: anywhere;
      line-height: 1.25;
    }

  
    /* v8n: standardized button heights */
    button,
    .toolbar button,
    .action-button {
      min-height: 42px;
      height: 42px;
      padding: 6px 14px;
      display: inline-flex;
      align-items: center;
      justify-content: center;
      vertical-align: middle;
      line-height: 1.1;
      box-sizing: border-box;
      white-space: nowrap;
    }

  
    /* v8o: compact two-line toolbar buttons */
    button,
    .toolbar button,
    .action-button {
      min-height: 52px;
      height: 52px;
      min-width: 108px;
      max-width: 108px;
      padding: 4px 8px;
      display: inline-flex;
      flex-direction: column;
      align-items: center;
      justify-content: center;
      text-align: center;
      line-height: 1.05;
      white-space: normal;
      word-break: keep-all;
      box-sizing: border-box;
      gap: 2px;
      font-size: 0.92rem;
    }


    /* v8p: post-net checklist */
    .postnet-button {
      background: #991b1b !important;
      color: white !important;
      border-color: #7f1d1d !important;
    }

    .postnet-panel {
      display: none;
      margin-top: 10px;
      padding: 12px 14px;
      border: 2px solid #991b1b;
      border-radius: 10px;
      background: #fef2f2;
    }

    .postnet-panel.visible {
      display: block;
    }

    .postnet-panel h3 {
      margin-top: 0;
      margin-bottom: 10px;
      color: #7f1d1d;
    }

    .postnet-panel label {
      display: block;
      margin: 8px 0;
      font-size: 0.96rem;
    }

    .postnet-panel input[type="checkbox"] {
      margin-right: 8px;
      transform: scale(1.15);
    }


    /* v8r: lifecycle red buttons together */
    .postnet-button {
      background: #991b1b !important;
      color: white !important;
      border-color: #7f1d1d !important;
    }


    /* v8t: matching lifecycle red buttons */
    .lifecycle-button,
    .postnet-button,
    #clearBtn {
      background: #b91c1c !important;
      color: white !important;
      border-color: #991b1b !important;
    }

    .lifecycle-button:hover,
    .postnet-button:hover,
    #clearBtn:hover {
      background: #991b1b !important;
      border-color: #7f1d1d !important;
    }


    
    /* v8v: horizontal balanced toolbar rows */
    .button-row {
      display: flex;
      flex-direction: row;
      flex-wrap: nowrap;
      gap: 8px;
      align-items: stretch;
      margin-bottom: 8px;
    }

    .help-button,
    #quickStartBtn {
      background: #facc15 !important;
      color: #111827 !important;
      border-color: #ca8a04 !important;
      font-weight: 800;
    }

    .help-button:hover,
    #quickStartBtn:hover {
      background: #eab308 !important;
      border-color: #a16207 !important;
    }
    


    /* v8x: clean two-row workflow toolbar */
    .button-row {
      display: flex !important;
      flex-direction: row !important;
      flex-wrap: nowrap !important;
      gap: 8px !important;
      align-items: stretch !important;
      margin: 8px 0 !important;
      width: 100%;
    }

    .button-row button {
      flex: 0 0 112px !important;
      width: 112px !important;
      min-width: 112px !important;
      max-width: 112px !important;
      height: 52px !important;
      min-height: 52px !important;
      padding: 4px 8px !important;
      display: inline-flex !important;
      flex-direction: column !important;
      align-items: center !important;
      justify-content: center !important;
      text-align: center !important;
      line-height: 1.05 !important;
      white-space: normal !important;
      box-sizing: border-box !important;
    }

    .help-button,
    #quickStartBtn {
      background: #facc15 !important;
      color: #111827 !important;
      border-color: #ca8a04 !important;
      font-weight: 800 !important;
    }

    .help-button:hover,
    #quickStartBtn:hover {
      background: #eab308 !important;
      border-color: #a16207 !important;
    }

    .lifecycle-button,
    .postnet-button,
    #clearBtn,
    #postNetBtn {
      background: #b91c1c !important;
      color: white !important;
      border-color: #991b1b !important;
    }

    .lifecycle-button:hover,
    .postnet-button:hover,
    #clearBtn:hover,
    #postNetBtn:hover {
      background: #991b1b !important;
      border-color: #7f1d1d !important;
    }


    /* v8y: restore gray draft buttons */
    #saveBtn,
    #loadBtn {
      background: #e5e7eb !important;
      color: #1f2937 !important;
      border-color: #cbd5e1 !important;
    }

    #saveBtn:hover,
    #loadBtn:hover {
      background: #d1d5db !important;
      border-color: #9ca3af !important;
    }


    /* v8aa: stable two-row button layout with reliable text icons */
    .button-row {
      display: flex !important;
      flex-direction: row !important;
      flex-wrap: nowrap !important;
      gap: 10px !important;
      align-items: stretch !important;
      margin: 10px 0 !important;
      width: 100% !important;
    }

    .button-row button {
      flex: 0 0 126px !important;
      width: 126px !important;
      min-width: 126px !important;
      max-width: 126px !important;
      height: 58px !important;
      min-height: 58px !important;
      padding: 5px 8px !important;
      display: inline-grid !important;
      grid-template-columns: 30px 1fr !important;
      align-items: center !important;
      justify-content: center !important;
      gap: 6px !important;
      text-align: center !important;
      line-height: 1.05 !important;
      white-space: normal !important;
      box-sizing: border-box !important;
      border-radius: 12px !important;
      font-weight: 800 !important;
    }

    .btn-icon {
      display: inline-flex !important;
      align-items: center !important;
      justify-content: center !important;
      width: 26px !important;
      height: 26px !important;
      border: 2px solid currentColor !important;
      border-radius: 7px !important;
      font-size: 0.78rem !important;
      font-weight: 900 !important;
      line-height: 1 !important;
    }

    .draft-button,
    #saveBtn,
    #loadBtn {
      background: #e5e7eb !important;
      color: #1f2937 !important;
      border-color: #cbd5e1 !important;
    }

    .add-button,
    #addRowsBtn {
      background: #1d4ed8 !important;
      color: white !important;
      border-color: #1e40af !important;
    }

    .lifecycle-button,
    .postnet-button,
    #clearBtn,
    #postNetBtn {
      background: #b91c1c !important;
      color: white !important;
      border-color: #991b1b !important;
    }

    .output-button,
    #exportBtn,
    #winlinkBtn,
    #printBtn,
    #ics309Btn {
      background: #0f766e !important;
      color: white !important;
      border-color: #0f5f59 !important;
    }

    .help-button,
    #quickStartBtn {
      background: #facc15 !important;
      color: #111827 !important;
      border-color: #ca8a04 !important;
    }

/* v9i MPE screen column */
.mpe-cell,
td.mpe {
  text-align: center;
}
.mpe-input,
input[data-field="mpe"] {
  width: 64px !important;
  max-width: 64px !important;
  text-transform: uppercase;
  text-align: center;
}

/* v9j MPE dropdown */
.mpe-cell,
td.mpe {
  text-align: center;
}
.mpe-select,
select[data-field="mpe"] {
  width: 64px !important;
  max-width: 64px !important;
  text-align: center;
}
