.tab-btn {
    padding: 0.35rem 0.9rem;
    border-radius: 0.375rem;
    color: #cbd5e1;
}
.tab-btn:hover { background: #334155; color: white; }
.tab-btn.active { background: #1e40af; color: white; }

/* Click-to-open nav dropdowns (Components ▾, Products ▾) */
.nav-dropdown {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    background: #1e293b;          /* slate-800 */
    border: 1px solid #334155;
    border-radius: 0.5rem;
    box-shadow: 0 6px 20px rgba(0,0,0,0.35);
    z-index: 40;
    min-width: 12rem;
    padding: 0.25rem;
    display: flex;
    flex-direction: column;
    gap: 0.125rem;
    animation: fade-down .08s ease-out;
}
@keyframes fade-down {
    from { opacity: 0; transform: translateY(-4px); }
    to   { opacity: 1; transform: translateY(0); }
}
.dropdown-item {
    text-align: left;
    padding: 0.4rem 0.8rem;
    border-radius: 0.375rem;
    color: #cbd5e1;
    font-size: 0.875rem;
    white-space: nowrap;
}
.dropdown-item:hover  { background: #334155; color: white; }
.dropdown-item.active { background: #1e40af; color: white; }

.tab-section { animation: fade .15s ease-in; }
@keyframes fade { from { opacity: 0 } to { opacity: 1 } }

.lbl { display:block; font-size:0.75rem; color:#475569; margin-bottom:2px; }

/* Abbreviations get a thin dotted underline as a "hover me for the full
   name" cue. Browsers natively show the title= text on hover. */
abbr[title] {
    text-decoration: underline dotted;
    text-decoration-color: #94a3b8;
    text-underline-offset: 2px;
    cursor: help;
}
.inp {
    border: 1px solid #cbd5e1;
    border-radius: 0.375rem;
    padding: 0.35rem 0.55rem;
    font-size: 0.875rem;
    min-width: 10rem;
    background: white;
}
.inp:focus { outline: 2px solid #2563eb; outline-offset: 1px; }

.btn-primary {
    background: #1e40af;
    color: white;
    padding: 0.4rem 0.9rem;
    border-radius: 0.375rem;
    font-size: 0.875rem;
}
.btn-primary:hover { filter: brightness(1.1); }

.data-table { width: 100%; font-size: 0.85rem; }
.data-table thead th {
    text-align: left;
    background: #f1f5f9;
    color: #334155;
    padding: 0.4rem 0.6rem;
    border-bottom: 1px solid #e2e8f0;
    position: sticky; top: 0;
}
/* Override the left-default when the header asks for right or center
   alignment via a utility class — beats the element-selector rule above. */
.data-table thead th.text-right,
.data-table thead th.num         { text-align: right; }
.data-table thead th.text-center { text-align: center; }

.data-table tbody td {
    padding: 0.3rem 0.6rem;
    border-bottom: 1px solid #f1f5f9;
    white-space: nowrap;
}
.data-table tbody tr:hover { background: #f8fafc; }
.data-table .num { text-align: right; font-variant-numeric: tabular-nums; }

/* Optional vertical grid lines. Toggled per-table by adding the
   `.gridlines` modifier class. Right border on every cell except the
   last one in each row. */
.data-table.gridlines thead th,
.data-table.gridlines tbody td {
    border-right: 1px solid #e2e8f0;
}
.data-table.gridlines thead th:last-child,
.data-table.gridlines tbody td:last-child {
    border-right: none;
}

.pill {
    display: inline-block;
    padding: 1px 6px;
    border-radius: 999px;
    font-size: 0.7rem;
    background: #e2e8f0;
    color: #334155;
}
.pill-in  { background: #dcfce7; color: #166534; }
.pill-out { background: #fee2e2; color: #991b1b; }
.pill-adj { background: #fef3c7; color: #92400e; }
.pill-trn { background: #dbeafe; color: #1e40af; }

/* ECN lifecycle pills */
.pill-ecn-draft       { background: #fef3c7; color: #92400e; }   /* amber */
.pill-ecn-released    { background: #dcfce7; color: #166534; }   /* green */
.pill-ecn-superseded  { background: #e0e7ff; color: #3730a3; }   /* indigo */
.pill-ecn-cancelled   { background: #fee2e2; color: #991b1b; }   /* red */

.lk-tab-btn {
    padding: 0.25rem 0.75rem;
    border-radius: 0.375rem;
    font-size: 0.85rem;
    background: #f1f5f9;
    color: #334155;
}
.lk-tab-btn:hover { background: #e2e8f0; }
.lk-tab-btn.active { background: #1e40af; color: white; }

.btn-sm  { padding: 0.2rem 0.55rem; border-radius: 0.25rem; font-size: 0.78rem; }
.btn-edit   { background: #e0e7ff; color: #3730a3; }
.btn-edit:hover  { background: #c7d2fe; }
.btn-delete { background: #fee2e2; color: #991b1b; }
.btn-delete:hover { background: #fecaca; }
.btn-delete:disabled { background: #f1f5f9; color: #94a3b8; cursor: not-allowed; }
.btn-save   { background: #dcfce7; color: #166534; }
.btn-save:hover  { background: #bbf7d0; }
.btn-cancel { background: #f1f5f9; color: #475569; }
.btn-cancel:hover { background: #e2e8f0; }

/* Resizable split-pane divider (Products / Purchasing) */
.resizer {
    width: 8px;
    flex-shrink: 0;
    cursor: ew-resize;
    background: transparent;
    margin: 0 4px;
    position: relative;
    transition: background 0.12s;
}
.resizer::before {
    content: '';
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    width: 2px;
    height: 40px;
    background: #cbd5e1;
    border-radius: 1px;
    transition: background 0.12s;
}
.resizer:hover::before,
.resizer.dragging::before {
    background: #1e40af;
    width: 3px;
}
.resizer:hover,
.resizer.dragging {
    background: rgba(30, 64, 175, 0.08);
}

/* Vertical (top/bottom) split-pane divider */
.v-resizer {
    height: 8px;
    flex-shrink: 0;
    cursor: ns-resize;
    background: transparent;
    margin: 4px 0;
    position: relative;
    transition: background 0.12s;
}
.v-resizer::before {
    content: '';
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    height: 2px;
    width: 40px;
    background: #cbd5e1;
    border-radius: 1px;
    transition: background 0.12s;
}
.v-resizer:hover::before,
.v-resizer.dragging::before {
    background: #1e40af;
    height: 3px;
}
.v-resizer:hover,
.v-resizer.dragging {
    background: rgba(30, 64, 175, 0.08);
}

/* Left-edge handle for the Log drawer (right-side slide-out panel).
   Sits on the inside of the drawer's left border so the user can grab it
   without overlapping page content. */
.drawer-resizer {
    position: absolute;
    top: 0;
    left: 0;
    width: 6px;
    height: 100%;
    cursor: ew-resize;
    background: transparent;
    z-index: 10;
    transition: background 0.12s;
}
.drawer-resizer:hover,
.drawer-resizer.dragging {
    background: rgba(30, 64, 175, 0.15);
}

/* Component-table column reorder drag-and-drop */
.col-draggable {
    cursor: grab;
    user-select: none;
}
.col-draggable:active { cursor: grabbing; }
.col-drag-src {
    opacity: 0.4;
}
.col-drag-over {
    /* Vertical line on the left edge of the target column to show where
       the dragged column will land (insert-before semantics). */
    box-shadow: inset 3px 0 0 0 #1e40af;
    background: rgba(30, 64, 175, 0.06);
}
.col-menu-row {
    padding: 2px 4px;
    border-radius: 3px;
}
.col-menu-row:hover {
    background: rgba(30, 64, 175, 0.06);
}
.col-menu-row.col-drag-over {
    box-shadow: inset 0 3px 0 0 #1e40af;
    background: rgba(30, 64, 175, 0.06);
}

/* Pagination footer */
.paginator {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    border-top: 1px solid #e2e8f0;
    background: #f8fafc;
    font-size: 0.8rem;
    color: #475569;
}
.paginator:empty { display: none; }
.paginator .pg-info  { flex-shrink: 0; }
.paginator .pg-spacer { flex: 1; }
.paginator button {
    padding: 0.2rem 0.5rem;
    border-radius: 0.25rem;
    background: white;
    border: 1px solid #cbd5e1;
    color: #334155;
    font-variant-numeric: tabular-nums;
    min-width: 1.75rem;
}
.paginator button:hover:not(:disabled) { background: #e0e7ff; border-color: #818cf8; }
.paginator button:disabled { opacity: 0.4; cursor: not-allowed; }
.paginator select {
    border: 1px solid #cbd5e1;
    border-radius: 0.25rem;
    padding: 0.15rem 0.35rem;
    background: white;
    font-size: 0.8rem;
}

/* ============================================================
   Mobile + tablet responsive layout
   ============================================================
   The desktop layout assumes a wide screen with side-by-side
   panels and dense forms. On phones/tablets we override the
   tightest assumptions:
     - Less padding around the main content area
     - Header + nav stack vertically; nav can wrap
     - Side-by-side split panes (Products / POs) stack vertically
     - Touch targets bumped up to ~40px
     - Tables stay scrollable (overflow-x-auto already set)
       but font is slightly larger so it's still readable
   ============================================================ */

/* --- Tablet & phone (≤ 768px) ------------------------------ */
@media (max-width: 768px) {
    /* Header brand + nav stack instead of being side-by-side */
    body > header {
        flex-direction: column;
        align-items: stretch !important;
        gap: 0.5rem;
        padding-left: 0.75rem;
        padding-right: 0.75rem;
    }
    body > header > div:first-child {
        justify-content: space-between;
    }
    /* Nav wraps neatly */
    nav#tabs {
        flex-wrap: wrap;
        gap: 0.125rem;
        justify-content: flex-start;
    }

    /* Products + POs split panes: stack top/bottom instead of left/right.
       Both panes auto-size; we cap the list pane height so detail is
       still reachable below it. */
    [data-resizable] {
        flex-direction: column !important;
        height: auto !important;
    }
    [data-resizable] > div {
        flex: 0 0 auto !important;
        width: 100% !important;
    }
    [data-resizable] > div:first-child {
        max-height: 50vh;
        overflow-y: auto;
    }
    .resizer { display: none !important; }

    /* Slightly tighter outer padding on phones */
    main { padding: 0.5rem !important; }
}

/* --- Phone only (≤ 640px) ---------------------------------- */
@media (max-width: 640px) {
    /* Tighter tab buttons in the header nav */
    nav#tabs .tab-btn {
        font-size: 0.78rem;
        padding: 0.3rem 0.55rem;
    }

    /* Bigger touch targets for the small in-row buttons.
       Apple guidelines say 44px minimum; this lands ≈ 38–40px
       which is enough for thumbs without eating screen space. */
    .btn-sm {
        padding: 0.45rem 0.7rem;
        font-size: 0.82rem;
    }
    .btn-primary {
        padding: 0.55rem 1rem;
        font-size: 0.9rem;
    }

    /* Slightly larger table font + cell padding for thumb scrolling */
    .data-table {
        font-size: 0.85rem;
    }
    .data-table thead th,
    .data-table tbody td {
        padding: 0.5rem 0.55rem;
    }

    /* Inputs: bigger tap area + readable size */
    .inp {
        font-size: 16px;            /* ≥ 16px stops iOS from auto-zooming */
        min-height: 38px;
    }

    /* Modal cards: a hair of side margin so they don't kiss the screen edge */
    .fixed.inset-0 > div[class*="max-w-"] {
        margin-left: 0.5rem;
        margin-right: 0.5rem;
    }

    /* Any 2-column form drops to 1 column on phone. (md: 2-cols still
       applies on tablet+.) Most forms use `grid grid-cols-2 gap-3`. */
    form.grid.grid-cols-2,
    .grid.grid-cols-2:not([class*="md:grid-cols-"]):not([class*="sm:grid-cols-"]) {
        grid-template-columns: 1fr;
    }

    /* The Log drawer goes full-width on phones — fixed 384px would
       eat most of the screen. */
    #changes-drawer { width: 100vw !important; }
    #changes-drawer-resizer { display: none; }
}
