.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: 14rem;
    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;
    color: #1e293b;             /* slate-800 — readable on white */
}
.inp:focus { outline: 2px solid #2563eb; outline-offset: 1px; }
.inp::placeholder { color: #94a3b8; }       /* slate-400, lighter than the value */

/* Disabled / read-only inputs (e.g. Username on Edit profile) — keep
   the value readable. The browser default for disabled is greyed-out
   text on a grey background, which can become invisible on our
   already-grey bg-slate-100. */
.inp:disabled,
.inp[readonly] {
    color: #334155;             /* slate-700 — readable but visibly "inactive" */
    -webkit-text-fill-color: #334155;
    opacity: 1;                 /* WebKit drops opacity on disabled by default */
    cursor: not-allowed;
}

/* Chrome / Edge autofill override. By default the browser paints
   autofilled fields with a pale yellow background and ghostly grey
   text, which is unreadable against our white inputs and labels the
   data as "this is autofilled" instead of "this is your saved value".
   We push the text back to slate-800 and white-out the background. */
.inp:-webkit-autofill,
.inp:-webkit-autofill:hover,
.inp:-webkit-autofill:focus,
.inp:-webkit-autofill:active {
    -webkit-text-fill-color: #1e293b !important;
    /* 1000px-wide inset shadow paints over the yellow autofill bg. */
    box-shadow: 0 0 0 1000px white inset !important;
    /* Delay the autofill repaint so the override sticks. */
    transition: background-color 600000s ease-in-out 0s;
    caret-color: #1e293b;
}

.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); }
/* Grey out any disabled button so the user can see the click is off. */
.btn-primary:disabled,
button:disabled,
.btn-edit:disabled,
.btn-save:disabled {
    background: #cbd5e1;      /* slate-300 */
    color: #64748b;           /* slate-500 */
    cursor: not-allowed;
    filter: none;
    opacity: 0.9;
}
.btn-primary:disabled:hover,
button:disabled:hover { filter: none; }

.data-table { width: 100%; font-size: 0.85rem; }
/* Data cells default to centered so they line up under the (also-centered)
   header. Per-cell `text-left` / `text-right` / `num` classes still win.
   Header text-alignment matches via the per-column thCls, or falls through
   to the .num / .text-right overrides at the bottom of this file. */
.data-table tbody td {
    text-align: center;
}
.data-table thead th {
    text-align: center;
    background: #f1f5f9;
    color: #334155;
    padding: 0.4rem 0.6rem;
    border-bottom: 1px solid #e2e8f0;
    /* See `.data-table.sticky-head thead th` below for the opt-in
       sticky-header behaviour. The default thead just scrolls with
       its content — adding the .sticky-head modifier + wrapping the
       table in `.table-scroll-y` is what makes the column headers
       stay visible while scrolling rows. */
}

/* Drag-to-resize column widths.
   Width is set inline on each <th> via min-width/width. Auto table
   layout is preserved (no `table-layout: fixed`) so display stays
   robust — the browser still auto-sizes columns whose content is
   wider than the set width, and shorter content honors the width.
   This is less strict than `table-layout: fixed` but doesn't risk
   collapsing the whole table when widths conflict with the parent. */
.data-table th.resizable {
    position: relative;
    /* Padding-right makes room for the resize handle so the label
       text doesn't run into it. */
    padding-right: 14px;
}
.col-resize-handle {
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    width: 8px;
    cursor: col-resize;
    user-select: none;
    /* Visible cue on hover so users discover the affordance. */
    background: transparent;
    transition: background 80ms ease;
    z-index: 6;     /* over the sticky header background */
}
.col-resize-handle:hover,
.col-resize-handle:active {
    background: #94a3b8;   /* slate-400 */
}

/* Excel-style per-column filter popover (Components browse).
   The ▾ icon next to a column label is the affordance; clicking it
   opens this popover positioned just below the th. Filters are
   client-side, applied on top of whatever the server returned. */
.col-filter-btn {
    display: inline-block;
    margin-left: 4px;
    padding: 0 2px;
    cursor: pointer;
    color: #94a3b8;          /* slate-400 — subtle until needed */
    font-size: 0.8em;
    user-select: none;
    line-height: 1;
}
.col-filter-btn:hover { color: #1e40af; background: #e0e7ff; border-radius: 3px; }
.col-filter-btn.col-filter-active {
    color: #1d4ed8;          /* blue-700 — louder when a filter is active */
    background: #dbeafe;     /* blue-100 */
    font-weight: 700;
    border-radius: 3px;
}
.data-table thead th.th-filtered {
    background: #eff6ff;     /* blue-50 — tint the whole header when filtered */
    color: #1d4ed8;          /* blue-700 */
    border-bottom: 2px solid #3b82f6; /* blue-500 underline */
}
.col-filter-menu {
    background: white;
    border: 1px solid #cbd5e1;
    border-radius: 0.375rem;
    box-shadow: 0 6px 24px rgba(0,0,0,0.18);
    z-index: 100;
    padding: 0.5rem;
    min-width: 16rem;
    max-width: 24rem;
    font-size: 0.85rem;
}
.col-filter-search {
    width: 100%;
    min-width: 0;
    margin-bottom: 0;
}
.col-filter-list {
    max-height: 16rem;
    overflow-y: auto;
    border: 1px solid #e2e8f0;
    border-radius: 0.25rem;
    padding: 0.25rem;
    background: #f8fafc;
}
.col-filter-row {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.2rem 0.4rem;
    cursor: pointer;
    border-radius: 0.25rem;
    color: #1e293b;
}
.col-filter-row:hover { background: #e0e7ff; }
.col-filter-row input { cursor: pointer; }
.col-filter-row span { flex: 1; }

/* Wrapper for character-perfectly-clipped cell text. JS measures the
   parent td's available width and rewrites textContent to the longest
   prefix of data-full that fits — no half-glyphs, no "..." marker.
   overflow:hidden + nowrap is the CSS safety net (also handles the
   HTML-rendered cells that skip the JS path). */
.cell-truncate {
    overflow: hidden;
    white-space: nowrap;
}

/* Components browse table only: fixed layout so each th's inline
   width is strictly honored. Without this, auto-layout uses the
   widest cell content as a floor and the user can't drag the column
   narrower than its longest cell (e.g. Spec stuck at the full
   sentence width). Other tables on the page keep their default
   auto-layout. */
#s-table { table-layout: fixed; }
#s-table td { overflow: hidden; }

/* Column-truncation indicator: lights up on a th when the column's
   current width is narrower than the widest cell in that column.
   Pseudo-element so we don't need to inject extra DOM into the header
   template. Small amber dot + "…" trailing the label is unobtrusive
   but visible at a glance — same visual weight as the filter ▾ icon
   so it doesn't compete. Tooltip explains the meaning. Hidden until
   _markTruncatingColumns() toggles the class.

   DELIBERATELY no `position: relative` on the th here — that would
   override the `position: sticky` set by .data-table.sticky-head
   (this selector is more specific) and the sticky header would drop
   out of place on scroll. The ::after below is inline-block so it
   doesn't need a positioned parent to layout correctly. */
#s-table thead th.col-truncating::after {
    content: "…";
    display: inline-block;
    margin-left: 4px;
    padding: 0 4px;
    border-radius: 3px;
    background: #fef3c7;     /* amber-100 */
    color: #b45309;          /* amber-700 */
    font-weight: 700;
    line-height: 1;
    font-size: 0.9em;
    vertical-align: middle;
    cursor: help;
}

/* Inline manufacturer / vendor logo next to the name in Components
   Browse and the Edit Component modal. Vertically aligned with the
   text, small enough not to overpower the row, fixed-height so rows
   stay uniform regardless of source aspect ratio. */
.inline-logo {
    display: inline-block;
    height: 14px;
    width: auto;
    max-width: 40px;
    object-fit: contain;
    vertical-align: middle;
    margin-right: 4px;
}

/* Archived (soft-deleted) component rows. Only seen when the user
   ticks "Show archived" in the Search tab. Distinct from row-eol
   (which is an active-but-discontinued part): archived means the
   row is out of the catalog entirely until restored. Strike-through
   + heavily faded so it's obvious at a glance you're looking at a
   tombstone, not a live row you might accidentally spec into a BOM. */
.data-table tbody tr.row-archived {
    background: #f1f5f9;          /* slate-100 */
    color: #94a3b8;               /* slate-400 */
    text-decoration: line-through;
}
.data-table tbody tr.row-archived:hover {
    background: #e2e8f0;          /* slate-200 */
}
.data-table tbody tr.row-archived .font-mono {
    color: #94a3b8;
}
/* Restore-action button shouldn't be struck-through — it has to be
   readable + clickable. Also the cell-truncate wrappers should NOT
   inherit strike-through into truncated text (looks like garbage). */
.data-table tbody tr.row-archived button,
.data-table tbody tr.row-archived a {
    text-decoration: none;
}

/* EOL rows — discontinued parts. Visibly darker so they don't get
   specced into new designs by mistake. Slight amber tint hints at
   "warning" without being alarming. */
.data-table tbody tr.row-eol {
    background: #e5e7eb;          /* slate-200 */
    color: #4b5563;               /* slate-600 — dim the text too */
}
.data-table tbody tr.row-eol:hover {
    background: #d1d5db;          /* slate-300 */
}
.data-table tbody tr.row-eol .font-mono {
    color: #4b5563;
}

/* Category boundary divider. Added by renderCompRows() whenever a
   row's category differs from the previous row, giving the browse
   table visual grouping by category without the noise of a full
   group-header row. A solid slate-300 line is heavier than the
   default thin row border so the eye picks it out at a glance. */
.data-table tbody tr.row-cat-divider > td {
    border-top: 2px solid #94a3b8;   /* slate-400 — readable on white + slate-200 EOL bg */
}

/* Click-to-select highlight on the Components Browse. Sky-blue tint
   so it reads clearly on plain rows, EOL (slate-200) rows, and
   archived rows. !important so it wins against row-eol / row-archived
   when the user selects one of those — selection state takes priority
   over the muted/EOL background once they've actively picked the row. */
.data-table tbody tr.row-selected,
.data-table tbody tr.row-selected:hover {
    background: #bae6fd !important;  /* sky-200 */
}
.data-table tbody tr.row-selected > td {
    color: #0c4a6e;                  /* sky-900 — strong contrast on the tint */
}

/* Resizable columns — generic helper applied via JS to any table
   that opts in (currently the product BOM lines table). Each <th>
   gets a 6px-wide invisible handle on its right edge that the user
   can drag. Light grey on hover so they discover it; doesn't
   interrupt the table's visual rhythm when idle. */
table.col-resizable {
    /* Fixed layout makes the <th> inline width authoritative — without
       it, a wide cell in the column expands past the drag target and
       resizing feels sticky (drag left, content springs back). */
    table-layout: fixed;
}
table.col-resizable th {
    position: relative;
}
/* When layout is fixed, cells with long content otherwise overflow
   the fixed column width and leak out. Clip them (nowrap + ellipsis)
   so widths behave. Cells that opted into wrapping (cell-wrap) are
   preserved. */
table.col-resizable tbody td:not(.cell-wrap) {
    overflow: hidden;
    text-overflow: ellipsis;
}
table.col-resizable th .col-resize-handle {
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    width: 6px;
    cursor: col-resize;
    user-select: none;
    /* Sit on top of any th content (abbr tooltips, sort arrows) */
    z-index: 1;
}
table.col-resizable th .col-resize-handle:hover {
    background: #cbd5e1;          /* slate-300 */
}

/* Sticky column headers — opt-in via `.data-table.sticky-head` plus
   wrapping the table in `.table-scroll-y` (below). The wrapper is
   what creates the scroll container the sticky positioning anchors
   to; without it, `position: sticky` has nothing to stick to and
   the header just scrolls away with the rows.

   Used on the Components browse table where the row count routinely
   exceeds the viewport height. */
.data-table.sticky-head thead th {
    position: sticky;
    top: 0;
    z-index: 5;
    /* Re-apply background so the cell isn't transparent against
       scrolled rows behind it. */
    background: #f1f5f9;
    /* A bottom border-on-cell instead of border-on-row, so it
       doesn't disappear when the cell sticks (sticky cells can lose
       their tr borders in some browsers). */
    box-shadow: inset 0 -1px 0 #cbd5e1;
}

/* Scrollable wrapper used together with `.data-table.sticky-head`.
   max-height keeps the table viewable above the paginator on tall
   result sets; both axes scroll inside the wrapper. */
.table-scroll-y {
    /* 100vh fallback for browsers without dvh support; 100dvh is the
       dynamic viewport height — accounts for mobile Safari / Chrome
       URL bar showing & hiding, which 100vh gets wrong (it reports
       the "large" viewport, leaving content off-screen behind the
       URL bar on first paint). */
    max-height: calc(100vh - var(--header-h, 4rem) - 14rem);
    max-height: calc(100dvh - var(--header-h, 4rem) - 14rem);
    /* Floor so the table never collapses to a sliver on small phones
       where the nav header wraps and --header-h gets big. */
    min-height: 50vh;
    min-height: 50dvh;
    overflow: auto;
    /* Smooth momentum scrolling on iOS — without this, swipe scroll
       jumps in fixed steps. */
    -webkit-overflow-scrolling: touch;
}
/* On phones (narrow viewport) just turn sticky off entirely — the
   user can scroll back to the top to see column labels. Trying to
   make `position: sticky` work reliably across iOS Safari + Android
   Chrome inside both inner-scroll and page-scroll layouts wasn't
   landing, and a slightly-broken sticky is worse than no sticky.
   Desktop inner-scroll behavior stays unchanged. */
@media (max-width: 768px) {
    .table-scroll-y {
        max-height: none;
        min-height: 0;
        overflow-x: auto;
        overflow-y: visible;
    }
    .data-table.sticky-head thead th {
        position: static;
    }
}
/* On very short viewports (mobile landscape, etc.), keep at least a
   usable amount of table visible. */
@media (max-height: 600px) {
    .table-scroll-y { max-height: 70vh; max-height: 70dvh; }
}

/* iOS Safari < 13 needs the -webkit-sticky fallback for position:sticky
   to actually stick. Modern browsers ignore the prefix; older ones use
   it. Applied to all sticky elements via attribute selector so we don't
   miss any. */
.sticky,
[class*=" sticky"],
.data-table.sticky-head thead th {
    position: -webkit-sticky;
    position: sticky;
}
/* 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;
}
/* Opt-in wrapping for cells that legitimately hold long text
   (BOM ref designators, notes lists, spec strings). Add the
   .cell-wrap class to the <td> and give it a sensible max-width
   so it takes room from other columns predictably. */
.data-table tbody td.cell-wrap {
    white-space: normal;
    max-width: 22rem;
    word-break: break-word;
    line-height: 1.35;
}
.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; }
.pill-sample { background: #ccfbf1; color: #0f766e; }

/* 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; }
}
