/* Shared 3-row logbook grid (flights list + reports)
 *
 * Logical columns (body td 1-based):
 *  1 Date | 2-3 Aircraft | 4-5 Crew | 6 Route |
 *  7-10 Single Engine | 11-18 Multi Engine |
 *  19-22 Instrument | 23 Simulator | 24-25 Decks | 26 Comments | [27 Actions]
 *
 * thead row 3 only contains leaf cells (no Date/Sim/Comments/Actions — those rowspan from row 1).
 * Leaf th order: Type,Reg,PIC,P2,From-To, SE×4, ME×8, Inst×4, Decks×2  (23 cells)
 */

table.logbook-grid {
    border-collapse: collapse !important;
    border-spacing: 0 !important;
    min-width: 1700px;
    border: 2px solid #111 !important;
    background: #fff;
}

.logbook-grid-wrap {
    font-size: x-small;
}

/* Neutralise Bootstrap .table bottom-border / box-shadow tricks */
table.logbook-grid.table > :not(caption) > * > * {
    border-bottom-color: #333 !important;
    border-bottom-width: 1px !important;
    box-shadow: none !important;
}

.logbook-grid th,
.logbook-grid td {
    border: 1px solid #333 !important;
    padding: 2px 4px !important;
    vertical-align: middle !important;
    color: #111;
}

.logbook-grid th {
    background: #f0f0f0 !important;
    font-weight: 600;
    text-align: center;
}

/* Open bottoms under multi-row group titles so SE/ME/Day/Night read as one block */
.logbook-grid thead tr:nth-child(1) th[colspan],
.logbook-grid thead tr:nth-child(1) th[rowspan="2"],
.logbook-grid thead tr:nth-child(2) th[colspan] {
    border-bottom: none !important;
}

/* Leaf header row closes the group box */
.logbook-grid thead tr:nth-child(3) th {
    border-top: 1px solid #333 !important;
    border-bottom: 2px solid #111 !important;
}

/* ========== Body: thick right edge after each major block ========== */
.logbook-grid tbody td:nth-child(1),   /* Date | */
.logbook-grid tbody td:nth-child(6),   /* Route | SE */
.logbook-grid tbody td:nth-child(10),  /* SE | ME */
.logbook-grid tbody td:nth-child(18),  /* ME | Instrument */
.logbook-grid tbody td:nth-child(22),  /* Instrument | Sim */
.logbook-grid tbody td:nth-child(23),  /* Sim | Decks */
.logbook-grid tbody td:nth-child(25),  /* Decks | Comments */
.logbook-grid tbody td:nth-child(26)   /* Comments | Actions */ {
    border-right: 2px solid #111 !important;
}

/* Also split Aircraft | Crew | Route lightly in body */
.logbook-grid tbody td:nth-child(3),   /* after Reg */
.logbook-grid tbody td:nth-child(5) {  /* after P2 */
    border-right: 2px solid #111 !important;
}

/* Day | Night inside SE (after col 8) and ME (after col 14) */
.logbook-grid tbody td:nth-child(8),
.logbook-grid tbody td:nth-child(14) {
    border-right: 1px dashed #666 !important;
}

/* ========== thead row 1: thick left edge on major group titles ==========
   Children: Date, Aircraft, Crew, Route, SE, ME, Instrument, Sim, Decks, Comments, [Actions] */
.logbook-grid thead tr:nth-child(1) th:nth-child(1) { /* Date */
    border-right: 2px solid #111 !important;
}
.logbook-grid thead tr:nth-child(1) th:nth-child(2), /* Aircraft */
.logbook-grid thead tr:nth-child(1) th:nth-child(3), /* Crew */
.logbook-grid thead tr:nth-child(1) th:nth-child(4), /* Route */
.logbook-grid thead tr:nth-child(1) th:nth-child(5), /* Single Engine */
.logbook-grid thead tr:nth-child(1) th:nth-child(6), /* Multi Engine */
.logbook-grid thead tr:nth-child(1) th:nth-child(7), /* Instrument */
.logbook-grid thead tr:nth-child(1) th:nth-child(8), /* Simulator */
.logbook-grid thead tr:nth-child(1) th:nth-child(9), /* Decks */
.logbook-grid thead tr:nth-child(1) th:nth-child(10),/* Comments */
.logbook-grid thead tr:nth-child(1) th:nth-child(11) /* Actions */ {
    border-left: 2px solid #111 !important;
}
.logbook-grid thead tr:nth-child(1) th:nth-child(4) { /* Route right → SE */
    border-right: 2px solid #111 !important;
}
.logbook-grid thead tr:nth-child(1) th:nth-child(5) { /* SE right → ME */
    border-right: 2px solid #111 !important;
}
.logbook-grid thead tr:nth-child(1) th:nth-child(6) { /* ME right → Inst */
    border-right: 2px solid #111 !important;
}
.logbook-grid thead tr:nth-child(1) th:nth-child(7) { /* Inst right → Sim */
    border-right: 2px solid #111 !important;
}
.logbook-grid thead tr:nth-child(1) th:nth-child(8) { /* Sim right → Decks */
    border-right: 2px solid #111 !important;
}
.logbook-grid thead tr:nth-child(1) th:nth-child(9) { /* Decks right → Comments */
    border-right: 2px solid #111 !important;
}
.logbook-grid thead tr:nth-child(1) th:nth-child(10) { /* Comments right → Actions */
    border-right: 2px solid #111 !important;
}

/* ========== thead row 2: Day/Night under SE / ME ==========
   Children: SE Day, SE Night, ME Day, ME Night */
.logbook-grid thead tr:nth-child(2) th:nth-child(1) {
    border-left: 2px solid #111 !important;
}
.logbook-grid thead tr:nth-child(2) th:nth-child(2) {
    border-left: 1px dashed #666 !important; /* SE Day | Night */
    border-right: 2px solid #111 !important; /* SE | ME */
}
.logbook-grid thead tr:nth-child(2) th:nth-child(3) {
    border-left: 2px solid #111 !important;
}
.logbook-grid thead tr:nth-child(2) th:nth-child(4) {
    border-left: 1px dashed #666 !important; /* ME Day | Night */
    border-right: 2px solid #111 !important; /* ME | Instrument */
}

/* ========== thead row 3 leaf cells (23): reinforce group edges ==========
   1 Type 2 Reg | 3 PIC 4 P2 | 5 Route |
   6-9 SE | 10-17 ME | 18-21 Inst | 22-23 Decks */
.logbook-grid thead tr:nth-child(3) th:nth-child(2),  /* after Reg → Crew */
.logbook-grid thead tr:nth-child(3) th:nth-child(4),  /* after P2 → Route */
.logbook-grid thead tr:nth-child(3) th:nth-child(5),  /* after Route → SE */
.logbook-grid thead tr:nth-child(3) th:nth-child(9),  /* after SE → ME */
.logbook-grid thead tr:nth-child(3) th:nth-child(17), /* after ME → Inst */
.logbook-grid thead tr:nth-child(3) th:nth-child(21), /* after Inst (Sim is rowspan) */
.logbook-grid thead tr:nth-child(3) th:nth-child(23)  /* after Decks Night */ {
    border-right: 2px solid #111 !important;
}

/* Day | Night leaf splits in SE / ME */
.logbook-grid thead tr:nth-child(3) th:nth-child(7),  /* SE Day PIC | SE Night Dual */
.logbook-grid thead tr:nth-child(3) th:nth-child(13)  /* ME Day PICUS | ME Night Dual */ {
    border-right: 1px dashed #666 !important;
}

.logbook-grid td.text-muted {
    border: 1px solid #333 !important;
}

/* Compact action buttons so they do not inflate row height */
.logbook-grid td.logbook-actions {
    padding: 0 2px !important;
    white-space: nowrap;
    line-height: 1;
    vertical-align: middle !important;
}

.logbook-grid .logbook-action-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0 4px !important;
    margin: 0 1px;
    font-size: inherit;
    line-height: 1.1;
    min-height: 0;
    height: auto;
    border-width: 1px;
    vertical-align: middle;
}

.logbook-grid .logbook-action-btn svg {
    display: block;
}

.logbook-grid .inline-action {
    display: inline;
    margin: 0;
}

/* Column width utilities (optional) */
.col-date { width: 58px; }
.col-ac-group { width: 80px; }
.col-crew-group { width: 120px; }
.col-route { width: 160px; }
.col-inst-group { width: 92px; }
.col-sim { width: 28px; }
.col-decks-group { width: 44px; }
.col-comments { width: 220px; }
.col-actions { width: 70px; }
.col-type { width: 40px; }
.col-reg { width: 40px; }
.col-pic { width: 60px; }
.col-p2 { width: 60px; }
.col-role { width: 22px; }
.col-copilot { width: 28px; }
.col-nonprec { width: 26px; }
