    /* ===========================================================================
   NETROIST BASE STYLESHEET
   =========================================================================== */

:root {
    --bg-primary: #161c1d;
    --bg-secondary: #1e2628;
    --bg-tertiary: #293436;
    --bg-card: #232d2f;
    --text-primary: #e6edf3;
    --text-secondary: #8b949e;
    --text-muted: #6e7681;
    --accent-cyan: #74ced5;
    --accent-orange: #f0883e;
    --accent-green: #29d686;
    --accent-purple: #a371f7;
    --accent-blue: #58a6ff;
    --accent-red: #b01810;
    --accent-yellow: #d29922;
    --accent-pink: #db61a2;
    --accent-teal: #2ea043;
    --accent-lime: #a5d610;
    --accent-slate: #577a9c;
    --border-color: #30363d;
    --border-hover: #484f58;
    --glow-cyan: rgba(57, 197, 207, 0.15);
    --glow-orange: rgba(240, 136, 62, 0.15);

    /* --- Type --- */
    --fs-xs: 0.75rem;
    --fs-sm: 0.8125rem;
    --fs-base: 0.875rem;
    --fs-md: 1rem;
    --fs-lg: 1.125rem;
    --fs-xl: 1.25rem;
    --fs-2xl: 1.5rem;
    --fs-3xl: 1.75rem;
    --fs-display-sm: 2.5rem;
    --fs-display: 3rem;

    --fw-medium: 500;
    --fw-semibold: 600;
    --fw-bold: 700;
    --tracking-wide: 0.05em;

    /* --- Spacing --- */
    --sp-1: 0.25rem;
    --sp-2: 0.5rem;
    --sp-3: 0.75rem;
    --sp-4: 1rem;
    --sp-5: 1.5rem;
    --sp-6: 2rem;
    --sp-7: 3rem;
    --sp-8: 4rem;

    /* --- Radius --- */
    --radius-sm: 4px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --radius-full: 50%;

    /* --- Motion --- */
    --transition-fast: all 0.12s ease;

    /* --- Elevation --- */
    --shadow-focus: 0 0 0 3px var(--glow-cyan);
    --shadow-card: 0 4px 12px rgba(0, 0, 0, 0.3);
    --shadow-raised: 0 8px 24px rgba(0, 0, 0, 0.4);
}

/* ===========================================================================
   UTILITIES
   =========================================================================== */

/* --- Display & flexbox --- */
.flex        { display: flex; }
.inline-flex { display: inline-flex; }
.grid        { display: grid; }
.block       { display: block; }

.flex-col    { flex-direction: column; }
.flex-wrap   { flex-wrap: wrap; }
.flex-1      { flex: 1; }

.ai-center   { align-items: center; }
.ai-start    { align-items: flex-start; }
.ai-end      { align-items: flex-end; }
.ai-baseline { align-items: baseline; }

.jc-center   { justify-content: center; }
.jc-between  { justify-content: space-between; }
.jc-end      { justify-content: flex-end; }

/* --- Gap --- */
.gap-1 { gap: var(--sp-1); }
.gap-2 { gap: var(--sp-2); }
.gap-3 { gap: var(--sp-3); }
.gap-4 { gap: var(--sp-4); }
.gap-5 { gap: var(--sp-5); }
.gap-6 { gap: var(--sp-6); }
.gap-7 { gap: var(--sp-7); }
.gap-8 { gap: var(--sp-8); }

/* --- Padding --- */
.p-1 { padding: var(--sp-1); }
.p-2 { padding: var(--sp-2); }
.p-3 { padding: var(--sp-3); }
.p-4 { padding: var(--sp-4); }
.p-5 { padding: var(--sp-5); }
.p-6 { padding: var(--sp-6); }
.p-7 { padding: var(--sp-7); }
.p-8 { padding: var(--sp-8); }
.px-1 { padding-inline: var(--sp-1); }
.px-2 { padding-inline: var(--sp-2); }
.px-3 { padding-inline: var(--sp-3); }
.px-4 { padding-inline: var(--sp-4); }
.px-5 { padding-inline: var(--sp-5); }
.px-6 { padding-inline: var(--sp-6); }
.px-7 { padding-inline: var(--sp-7); }
.px-8 { padding-inline: var(--sp-8); }
.py-1 { padding-block: var(--sp-1); }
.py-2 { padding-block: var(--sp-2); }
.py-3 { padding-block: var(--sp-3); }
.py-4 { padding-block: var(--sp-4); }
.py-5 { padding-block: var(--sp-5); }
.py-6 { padding-block: var(--sp-6); }
.py-7 { padding-block: var(--sp-7); }
.py-8 { padding-block: var(--sp-8); }
.pt-1 { padding-top: var(--sp-1); }
.pt-2 { padding-top: var(--sp-2); }
.pt-3 { padding-top: var(--sp-3); }
.pt-4 { padding-top: var(--sp-4); }
.pt-5 { padding-top: var(--sp-5); }
.pt-6 { padding-top: var(--sp-6); }
.pt-7 { padding-top: var(--sp-7); }
.pt-8 { padding-top: var(--sp-8); }
.pb-1 { padding-bottom: var(--sp-1); }
.pb-2 { padding-bottom: var(--sp-2); }
.pb-3 { padding-bottom: var(--sp-3); }
.pb-4 { padding-bottom: var(--sp-4); }
.pb-5 { padding-bottom: var(--sp-5); }
.pb-6 { padding-bottom: var(--sp-6); }
.pb-7 { padding-bottom: var(--sp-7); }
.pb-8 { padding-bottom: var(--sp-8); }
.p-0 { padding: 0; }

/* --- Margin --- */
.mt-1 { margin-top: var(--sp-1); }
.mt-2 { margin-top: var(--sp-2); }
.mt-3 { margin-top: var(--sp-3); }
.mt-4 { margin-top: var(--sp-4); }
.mt-5 { margin-top: var(--sp-5); }
.mt-6 { margin-top: var(--sp-6); }
.mt-7 { margin-top: var(--sp-7); }
.mt-8 { margin-top: var(--sp-8); }
.mb-1 { margin-bottom: var(--sp-1); }
.mb-2 { margin-bottom: var(--sp-2); }
.mb-3 { margin-bottom: var(--sp-3); }
.mb-4 { margin-bottom: var(--sp-4); }
.mb-5 { margin-bottom: var(--sp-5); }
.mb-6 { margin-bottom: var(--sp-6); }
.mb-7 { margin-bottom: var(--sp-7); }
.mb-8 { margin-bottom: var(--sp-8); }
.m-0  { margin: 0; }
.mt-0 { margin-top: 0; }
.mb-0 { margin-bottom: 0; }
.mx-auto { margin-inline: auto; }

/* --- Type --- */
.fs-xs   { font-size: var(--fs-xs); }
.fs-sm   { font-size: var(--fs-sm); }
.fs-base { font-size: var(--fs-base); }
.fs-md   { font-size: var(--fs-md); }
.fs-lg   { font-size: var(--fs-lg); }
.fs-xl   { font-size: var(--fs-xl); }
.fs-2xl  { font-size: var(--fs-2xl); }
.fs-3xl  { font-size: var(--fs-3xl); }

.fw-medium   { font-weight: var(--fw-medium); }
.fw-semibold { font-weight: var(--fw-semibold); }
.fw-bold     { font-weight: var(--fw-bold); }

.text-primary   { color: var(--text-primary); }
.text-secondary { color: var(--text-secondary); }
.text-muted     { color: var(--text-muted); }
.text-accent    { color: var(--accent-cyan); }

.text-center   { text-align: center; }
.text-right    { text-align: right; }
.uppercase     { text-transform: uppercase; }
.tracking-wide { letter-spacing: var(--tracking-wide); }
.nowrap        { white-space: nowrap; }
.no-underline  { text-decoration: none; }

/* --- Surface --- */
.bordered  { border: 1px solid var(--border-color); }
.border-t  { border-top: 1px solid var(--border-color); }
.border-b  { border-bottom: 1px solid var(--border-color); }

.rounded      { border-radius: var(--radius-sm); }
.rounded-md   { border-radius: var(--radius-md); }
.rounded-lg   { border-radius: var(--radius-lg); }
.rounded-full { border-radius: var(--radius-full); }

.bg-card      { background: var(--bg-card); }
.bg-secondary { background: var(--bg-secondary); }
.bg-tertiary  { background: var(--bg-tertiary); }

/* --- Misc --- */
.w-full   { width: 100%; }
.pointer  { cursor: pointer; }
.overflow-hidden { overflow: hidden; }
.hidden { display: none !important; }

/* ===========================================================================
   GLOBAL STYLES
   =========================================================================== */

body,
input, button, select, textarea,
pre, code, kbd, samp {
    font-family: 'Fira Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    /* Column layout so the footer block can absorb the leftover height on
       short pages (see .site-footer) and its texture always runs to the
       bottom of the viewport. */
    display: flex;
    flex-direction: column;
}

/* The centering `margin: 0 auto` on .container opts the main block out of a
   flex item's default cross-axis stretch, so give it the width back. */
body > main {
    width: 100%;
}

:where(a) {
    color: var(--accent-cyan);
    text-decoration: none;
}

:where(a:hover) {
    text-decoration: underline;
}


/* ===========================================================================
   COMPONENTS
   =========================================================================== */

/* --- Card --- */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
}

/* A card that is itself a link. */
.card--link {
    color: inherit;
    text-decoration: none;
}

.card--link:hover {
    border-color: var(--border-hover);
    transform: translateY(-2px);
    box-shadow: var(--shadow-card);
}

/* Image-led card: clips its photo to the card's corners. */
.card--flush { overflow: hidden; }

/* Recessed tile, used for dashboard and collection stat counts. */
.card--inset {
    background: var(--bg-tertiary);
    border-radius: var(--radius-md);
}

/* Image-led cards zoom their photo on hover. */
/* .card--link:hover .thumbnail-image img { transform: scale(1.05); } */

/* --- Badge --- */
.badge {
    display: inline-block;
    width: fit-content;
    font-size: var(--fs-xs);
    padding: var(--sp-1) var(--sp-3);
    border-radius: var(--radius-sm);
    background: var(--bg-tertiary);
    border: 1px solid var(--accent-slate);
    color: var(--text-primary);
}

.badge--tight { padding: var(--sp-1) var(--sp-2); }

.badge--category {
    text-transform: uppercase;
    letter-spacing: var(--tracking-wide);
}

/* Interface and protocol badges on detail pages. */
.badge--feature { font-size: var(--fs-sm); }

.badge--pinned {
    position: absolute;
    top: var(--sp-2);
    left: var(--sp-2);
    z-index: 10;
}

.badge[data-tooltip] { cursor: default; }

/* --- Icon button --- */
.icon-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border: 1.5px solid var(--accent-slate);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    background: none;
    text-decoration: none;
    cursor: pointer;
}

.icon-btn:hover {
    background: var(--glow-cyan);
    border-color: var(--accent-cyan);
    color: var(--accent-cyan);
}

/* --- Table --------------------------------------------------------------
   Shared header band and row rules for the three table families. */
.table {
    width: 100%;
    border-collapse: collapse;
}

.table th {
    text-align: left;
    padding: var(--sp-3);
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    font-weight: var(--fw-medium);
    border-bottom: 1px solid var(--border-color);
}

.table td {
    padding: var(--sp-3);
    border-bottom: 1px solid var(--border-color);
}

.table tr:last-child td { border-bottom: none; }

.table--panel {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    overflow: hidden;
}

.table--panel th { padding: var(--sp-4); }
.table--panel td { padding: var(--sp-3) var(--sp-4); vertical-align: middle; }
.table--panel tr:hover td { background: var(--bg-tertiary); }

/* --- Form controls --- */
.input,
.form-group input,
.submission-form .detail-grid :is(input, select, textarea),
.formset-cell :is(input, select, textarea) {
    font-size: var(--fs-base);
    padding: var(--sp-3);
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
}

.input:focus,
.form-group input:focus,
.submission-form .detail-grid :is(input, select, textarea):focus,
.formset-cell :is(input, select, textarea):focus {
    outline: none;
    border-color: var(--accent-cyan);
    box-shadow: var(--shadow-focus);
}

.input--full,
.submission-form .detail-grid :is(input, select, textarea),
.formset-cell :is(input, select, textarea) { width: 100%; }

select.input { cursor: pointer; }
textarea.input { resize: vertical; min-height: 80px; }

.submission-form .detail-grid :is(input, select, textarea) { padding: var(--sp-2) var(--sp-3); }
.formset-cell :is(input, select, textarea) { padding: var(--sp-1) var(--sp-2); font-size: var(--fs-sm); }
.submission-form .detail-grid input[type="checkbox"] { width: auto; }

.input::placeholder { color: var(--text-muted); }

.interfaces-table .badge--feature {
    font-size: var(--fs-xs);
    padding: var(--sp-1) var(--sp-2);
    margin: var(--sp-1) var(--sp-1) var(--sp-1) 0;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: var(--sp-6);
}

/* Category icons */
.cat-icon {
    height: 1em;
    width: auto;
    display: block;
}

/* Header / Navigation */
.site-header {
    background: linear-gradient(180deg, var(--bg-secondary) 0%, var(--bg-primary) 100%);
    border-bottom: 1px solid var(--border-color);
    padding: var(--sp-5) 0;
    position: sticky;
    top: 0;
    z-index: 100;
}

/* Decorative isometric cube texture, tiled across the full width of the bar. */
.site-header::before {
    content: '';
    position: absolute;
    inset: 0;
    z-index: -1;
    background-image: url("../img/cube-pattern.61128e3ba32e.svg");
    background-size: auto 170px;
    background-repeat: repeat-x;
    background-position: center;
    opacity: 0.10;
    pointer-events: none;
}

.header-content {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 var(--sp-6);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.site-logo {
    text-decoration: none;
    display: flex;
    align-items: center;
}

.logo-img {
    height: 72px;
    width: auto;
    margin: calc(-1 * var(--sp-4)) 0;
}

@keyframes led-blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0; }
}

.site-logo:hover .led-1 {
    animation: led-blink 0.4s ease-in-out 3;
}

.site-logo:hover .led-2 {
    animation: led-blink 0.4s ease-in-out 0.2s 3;
}

.nav-group {
    display: flex;
    align-items: center;
}

.nav-links {
    display: flex;
    gap: var(--sp-1);
    align-items: center;
}

.nav-link {
    font-size: var(--fs-sm);
    color: var(--text-secondary);
    text-decoration: none;
    padding: var(--sp-2) var(--sp-3);
    border-radius: var(--radius-sm);
    border: 1px solid transparent;
    white-space: nowrap;
}

.nav-link:hover,
.nav-link.active {
    color: var(--accent-cyan);
    border-color: var(--border-color);
}

.nav-divider {
    width: 1px;
    background: var(--border-color);
    align-self: stretch;
}

/* Dropdown Menu Styles */
.nav-dropdown {
    position: relative;
    display: flex;
    align-items: center;
}

.dropdown-toggle {
    background: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: var(--sp-1);
}

.dropdown-arrow {
    font-size: var(--fs-xs);
    transition: transform 0.2s ease;
}

.nav-dropdown:hover .dropdown-arrow {
    transform: rotate(180deg);
}

.dropdown-menu {
    position: absolute;
    top: 100%;
    left: 0;
    min-width: 180px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: var(--sp-2) 0;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    z-index: 200;
    box-shadow: var(--shadow-card);
}

.nav-dropdown:hover .dropdown-menu {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.dropdown-item {
    display: block;
    font-size: var(--fs-sm);
    color: var(--text-secondary);
    text-decoration: none;
    padding: var(--sp-3) var(--sp-4);
}

.dropdown-item:hover,
.dropdown-item.active {
    color: var(--accent-cyan);
    background: var(--bg-tertiary);
}

/* Hamburger Button */
.hamburger-btn {
    display: none;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    width: 40px;
    height: 40px;
    background: transparent;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    cursor: pointer;
    padding: 0;
    gap: var(--sp-1);
}

.hamburger-btn:hover {
    border-color: var(--accent-cyan);
}

.hamburger-line {
    width: 20px;
    height: 2px;
    background: var(--text-secondary);
    transition: all 0.3s ease;
}

.hamburger-btn.active .hamburger-line:nth-child(1) {
    transform: translateY(calc(var(--sp-1) + 2px)) rotate(45deg);
}

.hamburger-btn.active .hamburger-line:nth-child(2) {
    opacity: 0;
}

.hamburger-btn.active .hamburger-line:nth-child(3) {
    transform: translateY(calc(-1 * (var(--sp-1) + 2px))) rotate(-45deg);
}

/* Page Title */
.page-header {
    margin-bottom: var(--sp-6);
    padding-bottom: var(--sp-5);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--sp-4);
}


.page-title {
    font-size: var(--fs-3xl);
    font-weight: var(--fw-semibold);
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: var(--sp-4);
}

.page-title .icon {
    font-size: var(--fs-2xl);
}

.page-subtitle {
    color: var(--text-secondary);
    margin-top: var(--sp-2);
    font-size: var(--fs-md);
}

/* Filter Panel */
.filter-panel {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: var(--sp-5);
    margin-bottom: var(--sp-6);
}


.filter-title {
    font-size: var(--fs-base);
    font-weight: bold;
    color: var(--accent-orange);
    text-transform: uppercase;
    letter-spacing: var(--tracking-wide);
}

.filter-clear {
    font-size: var(--fs-base);
    color: var(--text-muted);
    text-decoration: none;
}

.filter-clear:hover {
    color: var(--accent-red);
}

.filter-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: var(--sp-4);
}


.filter-label {
    font-size: var(--fs-xs);
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: var(--tracking-wide);
}



.year-range {
    display: flex;
    gap: var(--sp-2);
    align-items: center;
}

.year-range input {
    width: 90px;
}



.year-separator {
    color: var(--text-muted);
    font-size: var(--fs-base);
}

.advanced-filters {
    margin-top: var(--sp-4);
    border-top: 1px solid var(--border-color);
    padding-top: var(--sp-3);
}

.advanced-filters-toggle {
    font-size: var(--fs-sm);
    color: var(--text-secondary);
    cursor: pointer;
    user-select: none;
    list-style: none;
    letter-spacing: var(--tracking-wide);
}

.advanced-filters-toggle::-webkit-details-marker {
    display: none;
}

.advanced-filters-toggle::before {
    content: '▸ ';
    display: inline-block;
    transition: transform 0.15s;
}

.advanced-filters[open] > .advanced-filters-toggle::before {
    content: '▾ ';
}

.advanced-filters-toggle:hover {
    color: var(--accent-cyan);
}


.interface-filter-group,
.slot-filter-group {
    display: flex;
    flex-direction: column;
    gap: var(--sp-3);
}

.slot-filter-group {
    margin-top: var(--sp-5);
}

.interface-filter-row,
.slot-filter-row {
    display: flex;
    gap: var(--sp-2);
    align-items: center;
    flex-wrap: wrap;
}

.slot-filter-row .slot-qty-op {
    width: 52px;
    min-width: 52px;
    padding: var(--sp-3) var(--sp-1) var(--sp-3) var(--sp-2);
    text-align: center;
}

.slot-filter-row .slot-qty {
    width: 70px;
}

.slot-filter-row .autocomplete-wrapper {
    min-width: 200px;
}

.iface-field-label {
    font-size: var(--fs-xs);
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: var(--tracking-wide);
    margin-right: calc(-1 * var(--sp-1));
}

.interface-filter-row .iface-qty-op,
.interface-filter-row .iface-speed-op {
    width: 52px;
    min-width: 52px;
    padding: var(--sp-3) var(--sp-1) var(--sp-3) var(--sp-2);
    text-align: center;
}

.interface-filter-row .iface-qty {
    width: 70px;
}

.interface-filter-row .iface-speed {
    width: 90px;
}

.interface-filter-row .iface-unit,
.interface-filter-row .iface-proto,
.interface-filter-row .iface-if {
    width: auto;
    min-width: 120px;
}

.btn-add-interface,
.btn-add-slot,
.btn-add-row {
    align-self: flex-start;
    background: transparent;
    border: 1px dashed var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: var(--fs-sm);
    padding: var(--sp-2) var(--sp-3);
    cursor: pointer;
}

.btn-add-interface:hover,
.btn-add-slot:hover,
.btn-add-row:hover {
    border-color: var(--accent-cyan);
    color: var(--accent-cyan);
}

.btn-remove-interface,
.btn-remove-slot,
.btn-remove-row {
    background: transparent;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    font-size: var(--fs-lg);
    line-height: 1;
    padding: var(--sp-2);
    cursor: pointer;
}

.btn-remove-interface:hover,
.btn-remove-slot:hover,
.btn-remove-row:hover {
    border-color: var(--accent-red);
    color: var(--accent-red);
}

.tooltip-text {
    position: relative;
    border-bottom: 1px dashed var(--text-muted);
    cursor: help;
}

.tooltip-text::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: calc(100% + 6px);
    left: 50%;
    transform: translateX(-50%);
    background: var(--bg-tertiary);
    color: var(--text-primary);
    font-size: var(--fs-xs);
    padding: var(--sp-2) var(--sp-3);
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
    white-space: normal;
    text-transform: none;
    width: 260px;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.15s;
    z-index: 10;
}

.tooltip-text:hover::after {
    opacity: 1;
}

.interface-filter-group input[type="checkbox"] {
    -webkit-appearance: none;
    appearance: none;
    width: 16px;
    height: 16px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    cursor: pointer;
    vertical-align: middle;
    margin-right: var(--sp-1);
    position: relative;
}

.interface-filter-group input[type="checkbox"]:checked {
    background: var(--bg-secondary);
    border-color: var(--accent-cyan);
}

.interface-filter-group input[type="checkbox"]:checked::after {
    content: '✓';
    position: absolute;
    top: -1px;
    left: 2px;
    font-size: var(--fs-sm);
    color: var(--accent-cyan);
}

.filter-actions {
    display: flex;
    gap: var(--sp-3);
    margin-top: var(--sp-4);
    padding-top: var(--sp-4);
    border-top: 1px solid var(--border-color);
}

.btn {
    font-size: var(--fs-base);
    padding: var(--sp-3) var(--sp-5);
    border-radius: var(--radius-sm);
    border: 1px solid transparent;
    cursor: pointer;
    text-decoration: none;
    display: inline-block;
}

.btn-primary {
    background: var(--accent-cyan);
    color: var(--bg-primary);
    border-color: var(--accent-cyan);
}

.btn-primary:hover {
    background: transparent;
    color: var(--accent-cyan);
}



/* Results Info */
.results-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--sp-4);
    padding: var(--sp-3) 0;
}

.results-count {
    font-size: var(--fs-base);
    color: var(--text-secondary);
}

.results-count strong {
    color: var(--accent-cyan);
}

.sort-controls {
    display: flex;
    align-items: center;
    gap: var(--sp-3);
}

.sort-label {
    font-size: var(--fs-base);
    color: var(--text-muted);
}

.sort-controls .input {
    width: auto;
    min-width: 180px;
}

/* Data Table */


.data-table th a {
    color: var(--text-secondary);
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: var(--sp-2);
}

.data-table th a:hover {
    color: var(--accent-cyan);
}

.sort-icon {
    font-size: var(--fs-xs);
    opacity: 0.5;
}

.sort-icon.active {
    opacity: 1;
    color: var(--accent-cyan);
}



/* SHA-256 checksum on the attachment detail page */
.file-hash {
    font-size: var(--fs-sm);
    color: var(--text-secondary);
    word-break: break-all;
}


.cell-primary {
    color: var(--text-primary);
}

.cell-secondary {
    color: var(--text-secondary);
}

.cell-muted {
    color: var(--text-muted);
    font-size: var(--fs-sm);
}

.cell-mono {
    font-size: var(--fs-sm);
}


.cell-null {
    color: var(--text-muted);
}

/* Pagination */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: var(--sp-2);
    margin-top: var(--sp-6);
    padding: var(--sp-4) 0;
}

.pagination a {
    font-size: var(--fs-base);
    color: var(--text-secondary);
    text-decoration: none;
    padding: var(--sp-2) var(--sp-3);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
}

.pagination a:hover {
    border-color: var(--accent-cyan);
    color: var(--accent-cyan);
}

.pagination .current {
    font-size: var(--fs-base);
    color: var(--text-muted);
    padding: var(--sp-2) var(--sp-3);
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: var(--sp-8) var(--sp-6);
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
}

.empty-icon {
    font-size: var(--fs-display);
    margin-bottom: var(--sp-4);
    opacity: 0.5;
}

.empty-title {
    font-size: var(--fs-xl);
    color: var(--text-primary);
    margin-bottom: var(--sp-2);
}

.empty-message {
    color: var(--text-secondary);
    margin-bottom: var(--sp-5);
}

.empty-state .btn {
    margin-top: var(--sp-2);
}

.submit-device-hint {
    text-align: center;
    color: var(--text-muted);
    font-size: var(--fs-sm);
    margin-top: var(--sp-6);
}

/* Home page styles */

.home-title {
    font-size: var(--fs-display);
    font-weight: var(--fw-bold);
    color: var(--accent-cyan);
    text-shadow: 0 0 30px var(--glow-cyan);
    margin-bottom: var(--sp-4);
}

.home-definition {
    font-size: var(--fs-base);
    color: var(--text-secondary);
    max-width: 520px;
    margin: 0 auto var(--sp-5) auto;
    line-height: 1.6;
    opacity: 0.85;
}

.home-definition .def-word {
    font-weight: var(--fw-bold);
    font-style: normal;
    color: var(--text-primary);
}

.home-definition .def-pos {
    font-style: normal;
    margin-left: 0.4em;
    color: var(--text-muted);
}

.home-definition .def-type {
    font-style: italic;
    margin-left: 0.4em;
    color: var(--text-muted);
}

.home-definition .def-text {
    margin-left: 0.3em;
}


.category-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: var(--sp-5);
}



.category-icon {
    font-size: var(--fs-display-sm);
    margin-bottom: var(--sp-4);
}

.category-name {
    font-size: var(--fs-xl);
    font-weight: var(--fw-semibold);
    color: var(--text-primary);
    margin-bottom: var(--sp-2);
}

.category-count {
    font-size: var(--fs-base);
    color: var(--text-muted);
}

.category-count strong {
    color: var(--accent-cyan);
}



/* Home page sections */
.home-section {
    margin-bottom: 5rem;
}

.section-header {
    font-size: var(--fs-2xl);
    font-weight: var(--fw-semibold);
    color: var(--accent-cyan);
    margin-bottom: var(--sp-5);
}

/* Back link */
.back-link {
    display: inline-flex;
    align-items: center;
    gap: var(--sp-2);
    font-size: var(--fs-base);
    color: var(--text-secondary);
    text-decoration: none;
    margin-bottom: var(--sp-5);
}

.back-link:hover {
    color: var(--accent-cyan);
}

/* Boolean indicators */
.bool-yes {
    color: var(--accent-green);
}


/* Responsive */
@media (max-width: 768px) {
    .container {
        padding: var(--sp-4);
    }

    .header-content {
        flex-wrap: wrap;
        position: relative;
    }

    .hamburger-btn {
        display: flex;
    }

    .nav-group {
        display: none;
        width: 100%;
        flex-direction: column;
        background: var(--bg-secondary);
        border: 1px solid var(--border-color);
        border-radius: var(--radius-md);
        margin-top: var(--sp-4);
        padding: var(--sp-4);
    }

    .nav-group.active {
        display: flex;
    }

    .nav-links {
        flex-direction: column;
        gap: 0;
        width: 100%;
        align-items: center;
    }

    .nav-link {
        padding: var(--sp-3) var(--sp-4);
        border-radius: var(--radius-sm);
    }

    .nav-divider {
        display: none;
    }

    /* Mobile dropdown styles */
    .nav-dropdown {
        width: 100%;
        flex-direction: column;
        border-bottom: 1px solid var(--border-color);
        padding-bottom: var(--sp-2);
        margin-bottom: var(--sp-2);
    }

    .dropdown-toggle {
        width: 100%;
        justify-content: center;
        gap: var(--sp-1);
    }

    .dropdown-menu {
        position: static;
        opacity: 1;
        visibility: visible;
        transform: none;
        max-height: 0;
        overflow: hidden;
        padding: 0;
        border: none;
        background: transparent;
        box-shadow: none;
        transition: max-height 0.3s ease;
    }

    .nav-dropdown.open .dropdown-menu {
        max-height: 300px;
        padding: var(--sp-2) 0;
    }


    .nav-dropdown.open .dropdown-arrow {
        transform: rotate(180deg);
    }

    .dropdown-item {
        padding: var(--sp-3) var(--sp-5);
        text-align: center;
    }

    .auth-links {
        width: 100%;
        flex-direction: column;
        gap: 0;
        margin-top: var(--sp-2);
        padding-top: var(--sp-2);
        border-top: 1px solid var(--border-color);
    }

    .auth-links .nav-link {
        width: 100%;
        text-align: center;
    }

    .filter-grid {
        grid-template-columns: 1fr;
    }

    .data-table {
        display: block;
        overflow-x: auto;
    }

    .home-title {
        font-size: var(--fs-3xl);
    }

    .results-info {
        flex-wrap: wrap;
        gap: var(--sp-2);
    }
    .view-controls {
        flex-wrap: wrap;
        gap: var(--sp-2);
        width: 100%;
    }
    .sort-controls {
        width: 100%;
    }
    .sort-controls .input {
        flex: 1;
        min-width: 0;
    }
}

/* ===========================================
VIEW TOGGLE & THUMBNAIL GRID STYLES
=========================================== */

/* View Toggle Controls */
.view-controls {
    display: flex;
    align-items: center;
    gap: var(--sp-5);
}

.view-toggle {
    display: flex;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: var(--sp-1);
    gap: var(--sp-1);
}

.view-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 28px;
    background: transparent;
    border: none;
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    cursor: pointer;
}

.view-btn:hover {
    color: var(--text-secondary);
    background: var(--bg-secondary);
}

.view-btn.active {
    color: var(--accent-cyan);
    background: var(--bg-secondary);
}

/* Thumbnail Grid */
.thumbnail-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: var(--sp-5);
}

.thumbnail-grid-single-row {
    grid-template-rows: auto;
    grid-auto-rows: 0;
    overflow: hidden;
    padding-top: 2px;
}



.thumbnail-image {
    position: relative;
    aspect-ratio: 4 / 3;
    overflow: hidden;
    background: var(--bg-tertiary);
}

.thumbnail-image img {
    width: 100%;
    height: 100%;
    object-fit: scale-down;
    /* transition: transform 0.3s ease; */
}


.thumbnail-placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-tertiary);
}

.placeholder-icon {
    font-size: var(--fs-display);
    opacity: 0.4;
    filter: grayscale(0.5);
    color: var(--text-secondary);
}

.thumbnail-card {
    display: flex;
    flex-direction: column;
}

.thumbnail-info {
    flex: 1;
    padding: var(--sp-3);
    display: flex;
    flex-direction: column;
    gap: var(--sp-1);
}

.thumbnail-info .badge,
.thumbnail-owner {
    margin-top: auto;
}

.thumbnail-manufacturer {
    font-size: var(--fs-sm);
    color: var(--text-secondary);
    text-transform: uppercase;
    /* letter-spacing: var(--tracking-wide);*/
}

.thumbnail-model {
    font-size: var(--fs-lg);
    font-weight: var(--fw-medium);
    color: var(--text-primary);
    line-height: 1.3;
}

.thumbnail-owner {
    font-size: var(--fs-xs);
    color: var(--text-muted);
}

/* Responsive adjustments for thumbnail grid */
@media (max-width: 768px) {
    .thumbnail-grid {
        grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
        gap: var(--sp-4);
    }

    .thumbnail-info {
        padding: var(--sp-3);
    }

    .thumbnail-model {
        font-size: var(--fs-base);
    }

    .placeholder-icon {
        font-size: var(--fs-display-sm);
    }

    .view-controls {
        flex-wrap: wrap;
        gap: var(--sp-4);
    }
}

/* ===========================================================================
   COMMON DETAIL VIEW COMPONENTS
   =========================================================================== */

.detail-header {
    display: flex;
    align-items: flex-start;
    gap: var(--sp-5);
    margin-bottom: var(--sp-6);
    padding-bottom: var(--sp-5);
    border-bottom: 1px solid var(--border-color);
}

.detail-icon { font-size: var(--fs-display); line-height: 1; }
.detail-title { font-size: var(--fs-3xl); font-weight: var(--fw-semibold); color: var(--text-primary); margin: 0; }
.detail-subtitle { color: var(--text-secondary); margin: var(--sp-2) 0 0 0; font-size: var(--fs-lg); }

.detail-actions-group {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: var(--sp-2);
    flex-shrink: 0;
}




.collection-indicator {
    font-size: var(--fs-xs);
    padding: var(--sp-1) var(--sp-3);
    border: 1px solid var(--accent-cyan);
    border-radius: var(--radius-sm);
    color: var(--accent-cyan);
    white-space: nowrap;
}

.submitted-by {
    font-size: var(--fs-sm);
    color: var(--text-muted);
    text-align: right;
    margin: var(--sp-5) 0 0 0;
}

.detail-section { margin-top: var(--sp-6); }

.section-title {
    display: flex;
    align-items: center;
    gap: var(--sp-2);
    font-size: var(--fs-base);
    font-weight: var(--fw-semibold);
    color: var(--accent-orange);
    text-transform: uppercase;
    letter-spacing: var(--tracking-wide);
    margin-bottom: var(--sp-4);
    padding-bottom: var(--sp-2);
    border-bottom: 1px solid var(--border-color);
}

/* Section-heading icons. Inline SVG drawn with currentColor, so they pick up the
   heading's accent without a second colour to keep in sync; each sizes itself off its
   own viewBox, so a wide or tall glyph keeps its proportions. */
.section-title > svg { flex: none; }


/* Two-column layout for detail pages */
.detail-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--sp-5);
    margin-top: var(--sp-6);
}

.detail-row .detail-section {
    margin-top: 0;
}

/* When only one item in a row, don't stretch it */
.detail-row .detail-section:only-child {
    grid-column: span 1;
}

.detail-row .detail-section.detail-section--docs { grid-column: 1; }
.detail-row .detail-section.detail-section--links { grid-column: 2; }

.detail-column-stack {
    display: flex;
    flex-direction: column;
    gap: var(--sp-5);
}

.detail-column-stack .detail-section {
    margin-top: 0;
}

@media (max-width: 768px) {
    .detail-row {
        grid-template-columns: 1fr;
    }
    /* Single column on narrow screens: stack docs above links. */
    .detail-row .detail-section.detail-section--docs,
    .detail-row .detail-section.detail-section--links {
        grid-column: auto;
    }
    .interfaces-table { display: block; overflow-x: auto; }
    .compatible-modules-group { margin-left: 0 !important; }
    .module-type-group { margin-left: 0 !important; }
    .modules-list { grid-template-columns: repeat(2, 1fr) !important; }
    .detail-header { flex-wrap: wrap; }
    .detail-actions-group { width: 100%; }
}

.detail-grid {
    display: grid;
    grid-template-columns: 180px 1fr;
    gap: var(--sp-3) var(--sp-5);
}
.detail-grid dt { font-weight: var(--fw-medium); color: var(--text-secondary); }
.detail-grid dd { color: var(--text-primary); margin: 0; }

/* Photos Section */
.photos-grid { display: grid; grid-template-columns: repeat(auto-fill, 300px); gap: var(--sp-4); }
a.photo-item { display: block; text-decoration: none; color: inherit; }
.photo-item { border-radius: var(--radius-md); overflow: hidden; border: 1px solid var(--border-color); background: var(--bg-tertiary); position: relative; }
.photo-item img { width: 100%; max-height: 300px; object-fit: contain; display: block; }
.photo-cell { position: relative; }
.photo-vector-link { position: absolute; top: var(--sp-2); right: var(--sp-2); padding: 0.1em 0.5em; font-size: var(--fs-sm); font-weight: 600; letter-spacing: 0.04em; border-radius: var(--radius-sm); background: var(--bg-primary); color: var(--text-secondary); border: 1px solid var(--border-color); text-decoration: none; opacity: 0.85; }
.photo-vector-link:hover { opacity: 1; color: var(--text-primary); }
.photo-delete-x {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 24px;
    height: 24px;
    border-radius: var(--radius-full);
    border: none;
    background: rgba(0, 0, 0, 0.7);
    color: #fff;
    font-size: var(--fs-md);
    line-height: 1;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.15s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}
.photo-item:hover .photo-delete-x { opacity: 1; }
.photo-delete-x:hover { background: var(--accent-red); }

.existing-photos .photo-item { cursor: grab; }
.photo-item-ghost { opacity: 0.4; border: 2px dashed var(--accent-cyan); }
.photo-item-drag { transform: scale(1.05); box-shadow: var(--shadow-raised); cursor: grabbing; }
.photo-item.photo-primary { border: 2px solid var(--accent-green); }

.photo-upload-row { display: flex; gap: var(--sp-3); align-items: center; }
.photo-upload-row .input { flex: 1; }
.existing-photos { margin-bottom: var(--sp-5); }
.existing-photos > label { display: block; margin-bottom: var(--sp-3); font-weight: var(--fw-medium); color: var(--text-primary); }
.photo-caption { padding: var(--sp-2); font-size: var(--fs-base); color: var(--text-secondary); background: var(--bg-tertiary); margin: 0; }

/* Shared Tables & Lists */
.interfaces-table { font-size: var(--fs-base); }
.interfaces-table td { color: var(--text-primary); }
.breakout-toggle { color: var(--accent-cyan); cursor: pointer; white-space: nowrap; border-radius: var(--radius-sm); padding: 0.05rem 0.35rem; /* hairline: off-scale on purpose */ transition: var(--transition-fast); }
.breakout-toggle:hover { text-decoration: underline; }
.interfaces-table td:has(.breakout-toggle) { white-space: nowrap; }
.iface-breakout { display: none; }
.iface-breakout::before { content: "→"; margin: 0 var(--sp-2); color: var(--text-muted); }
.interfaces-table tr.broken-out .qty-pre { opacity: 0.4; }
.interfaces-table tr.broken-out .breakout-toggle { background: var(--accent-cyan); color: var(--bg-primary); text-decoration: none; }
.interfaces-table tr.broken-out .iface-pre { opacity: 0.4; }
.interfaces-table tr.broken-out .iface-breakout { display: inline; }
.detail-card .interfaces-table { table-layout: fixed; }
.iface-notes { display: flex; align-items: baseline; gap: var(--sp-2); overflow: hidden; white-space: nowrap; }
.iface-notes-text { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.iface-notes.is-expanded { white-space: normal; flex-wrap: wrap; }
.iface-notes.is-expanded .iface-notes-text { white-space: normal; overflow: visible; text-overflow: clip; overflow-wrap: break-word; }
.iface-notes-expand { flex-shrink: 0; font-size: var(--fs-sm); white-space: nowrap; cursor: pointer; }
.subsection-title { font-size: var(--fs-sm); font-weight: var(--fw-medium); color: var(--text-secondary); margin: var(--sp-5) 0 var(--sp-3) 0; text-transform: uppercase; letter-spacing: var(--tracking-wide); }
.subsection-title:first-of-type { margin-top: 0; }

/* Form-factor headings under Compatible Modules carry the expansion-slot glyph.
   Scoped to this group so the other subsection titles keep their plain block layout. */
.compatible-modules-group > .subsection-title { display: flex; align-items: center; gap: var(--sp-2); }
.compatible-modules-group > .subsection-title > svg { flex: none; width: 1em; height: 1em; }

.iface-group-slot { font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: var(--tracking-wide); color: var(--text-secondary); border: 1px solid var(--border-color); border-radius: var(--radius-sm); padding: 0.1rem 0.45rem; }
.iface-group-name { font-size: var(--fs-base); font-weight: var(--fw-semibold); color: var(--text-primary); }
a.iface-group-name { color: var(--accent-cyan); }

.module-notes { color: var(--text-muted); font-weight: normal; }

.module-group { margin-bottom: var(--sp-5); }
.module-group:last-child { margin-bottom: 0; }
.module-group .modules-list { padding-left: 0.45rem; }

.links-list, .modules-list { list-style: none; padding: 0; margin: 0; }
.links-list li, .modules-list li { padding: var(--sp-2) 0; }
.links-list li:last-child, .modules-list li:last-child { border-bottom: none; }

/* Attachments Table */
/* The rows run a step larger than .interfaces-table, which sets --fs-base on the
   whole table; the header band is pinned to that size so it reads the same here
   as it does there. */
.attachments-table { table-layout: fixed; }
.attachments-table th { font-size: var(--fs-base); }
/* 25/25/50. Fixed layout, so these hold whatever the rows contain -- auto layout
   was tried and lets one long description starve Name and Type down to a few
   characters each. */
.attachments-table th:first-child,
.attachments-table th:nth-child(2) { width: 25%; }
.attachments-table th, .attachments-table td { overflow-wrap: break-word; }

/* Submissions cap the description at 500 chars, so the only risk is a very tall
   row. Clamp to three lines (~215 chars in a half-width column) rather than
   shortening the text itself; the attachment page always shows it in full. */
.attach-desc {
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 3;
    line-clamp: 3;
    overflow: hidden;
}

/* Pinout Components */
/* Reads as a badge at rest, lights up like .icon-btn on hover. */
.pinout-toggle { font-size: var(--fs-xs); padding: var(--sp-1) var(--sp-2); background: var(--bg-tertiary); border: 1px solid var(--accent-slate); border-radius: var(--radius-sm); color: var(--text-primary); cursor: pointer; }
.pinout-toggle:hover { background: var(--glow-cyan); border-color: var(--accent-cyan); color: var(--accent-cyan); }
.pinout-row td { padding: 0 !important; background: var(--bg-tertiary); }
.pinout-title { font-size: var(--fs-xs); font-weight: var(--fw-medium); color: var(--accent-cyan); text-transform: uppercase; }
.pinout-data { font-size: var(--fs-sm); line-height: 1.5; color: var(--text-primary); background: var(--bg-secondary); border: 1px solid var(--border-color); border-radius: var(--radius-sm); padding: var(--sp-4); overflow-x: auto; white-space: pre-wrap; }

/* ===========================================
   AUTHENTICATION STYLES
   =========================================== */

.auth-links {
    display: flex;
    align-items: center;
}

.logout-form {
    display: inline;
    margin: 0;
    padding: 0;
}

.logout-btn {
    background: none;
    border: 1px solid transparent;
    cursor: pointer;
}

.btn-register {
    background: var(--accent-cyan);
    color: var(--bg-primary) !important;
    border-radius: var(--radius-sm);
}

.btn-register:hover {
    background: transparent;
    color: var(--accent-cyan) !important;
    border-color: var(--accent-cyan);
}

.auth-container {
    max-width: 400px;
    margin: var(--sp-7) auto;
    padding: var(--sp-6);
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
}

/* The single-column auth width can't fit two plan cards side by side, so the chooser page opts into a wider shell. */
.auth-container.auth-container-wide {
    max-width: 46rem;
}

.auth-container h1 {
    font-size: var(--fs-3xl);
    color: var(--text-primary);
    margin-bottom: var(--sp-5);
    text-align: center;
}

.auth-form {
    display: flex;
    flex-direction: column;
    gap: var(--sp-4);
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: var(--sp-2);
}

.form-group label {
    font-size: var(--fs-base);
    color: var(--text-secondary);
    font-weight: var(--fw-medium);
}

.form-group small {
    font-size: var(--fs-xs);
    color: var(--text-muted);
}

.auth-form .btn {
    margin-top: var(--sp-2);
    padding: var(--sp-3);
    font-size: var(--fs-md);
}

.auth-alt {
    text-align: center;
    margin-top: var(--sp-5);
    font-size: var(--fs-base);
    color: var(--text-secondary);
}

.auth-info {
    text-align: center;
    color: var(--text-secondary);
    margin-bottom: var(--sp-5);
    line-height: 1.6;
}

/* Standalone action button on an auth page (no surrounding form). */
.error-message {
    background: rgba(248, 81, 73, 0.1);
    border: 1px solid var(--accent-red);
    border-radius: var(--radius-sm);
    padding: var(--sp-4);
    margin-bottom: var(--sp-4);
    color: var(--accent-red);
    font-size: var(--fs-base);
}

.error-message ul {
    margin: 0;
    padding-left: var(--sp-5);
}

.error-message li {
    margin: var(--sp-1) 0;
}

/* ===========================================
   MANAGE DASHBOARD STYLES
   =========================================== */

.manage-dashboard {
    max-width: 800px;
    margin: 0 auto;
}

.manage-dashboard h1 {
    font-size: var(--fs-3xl);
    color: var(--text-primary);
    margin-bottom: var(--sp-2);
}

.welcome-message {
    color: var(--text-secondary);
    margin-bottom: var(--sp-6);
}

.collection-stats {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: var(--sp-5);
    margin-bottom: var(--sp-6);
}

.collection-stats h2 {
    font-size: var(--fs-md);
    color: var(--accent-orange);
    text-transform: uppercase;
    letter-spacing: var(--tracking-wide);
    margin-bottom: var(--sp-4);
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: var(--sp-4);
}


.stat-count {
    display: block;
    font-size: var(--fs-3xl);
    font-weight: var(--fw-semibold);
    color: var(--accent-cyan);
    margin-bottom: var(--sp-1);
}

.stat-label {
    font-size: var(--fs-base);
    color: var(--text-secondary);
}

.view-all-link {
    margin-top: var(--sp-5);
    padding-top: var(--sp-5);
    border-top: 1px solid var(--border-color);
    text-align: center;
}

.manage-actions {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: var(--sp-5);
}

.manage-actions h2 {
    font-size: var(--fs-md);
    color: var(--accent-orange);
    text-transform: uppercase;
    letter-spacing: var(--tracking-wide);
    margin-bottom: var(--sp-4);
}

.manage-actions.manage-actions--plain {
    background: none;
    border: none;
    padding: 0;
    margin-top: var(--sp-6);
}

.action-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.action-list li {
    padding: var(--sp-3) 0;
}

.action-list a {
    font-size: var(--fs-base);
}



.stat-card-empty {
    opacity: 0.5;
    cursor: default;
}

/* ===========================================
   MANAGE COLLECTION LIST STYLES
   =========================================== */

.manage-collection {
    max-width: 1200px;
    margin: 0 auto;
}

.collection-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: var(--sp-5);
}

.unit-card {
    position: relative;
}

.unit-card:hover {
    border-color: var(--border-hover);
    transform: translateY(-2px);
    box-shadow: var(--shadow-card);
}

.unit-card-link {
    text-decoration: none;
    color: inherit;
    display: block;
}

.unit-card-specs {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    z-index: 2;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: var(--sp-1);
    opacity: 0;
    transition: opacity 0.2s ease;
}

.unit-card:hover .unit-card-specs {
    opacity: 1;
}

.unit-delete-x {
    position: absolute;
    top: 0.5rem;
    right: 2.25rem;
    width: 24px;
    height: 24px;
    border-radius: var(--radius-full);
    border: none;
    background: rgba(0, 0, 0, 0.7);
    color: #fff;
    font-size: var(--fs-md);
    line-height: 1;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.15s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    z-index: 3;
}
.unit-card:hover .unit-delete-x { opacity: 1; }
.unit-delete-x:hover { background: var(--accent-red); }

.unit-image {
    position: relative;
    aspect-ratio: 4 / 3;
    overflow: hidden;
    background: var(--bg-tertiary);
}

.unit-image img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.unit-placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-tertiary);
}

.unit-placeholder .placeholder-icon {
    font-size: var(--fs-display);
    opacity: 0.4;
}



.unit-manufacturer {
    font-size: var(--fs-xs);
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: var(--tracking-wide);
}

.specs-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--text-primary);
    text-decoration: none;
    padding: var(--sp-1);
    border-radius: var(--radius-sm);
}

.specs-link:hover {
    color: var(--accent-cyan);
    background: var(--bg-tertiary);
}

.unit-model {
    font-size: var(--fs-md);
    font-weight: var(--fw-medium);
    color: var(--text-primary);
}


.unit-model-link {
    text-decoration: none;
    color: inherit;
}

.unit-model-link:hover .unit-model {
    color: var(--accent-cyan);
}

.unit-serial {
    font-size: var(--fs-sm);
    color: var(--text-secondary);
}

.unit-date-acquired {
    font-size: var(--fs-sm);
    color: var(--text-muted);
}



.unit-visibility {
    font-size: var(--fs-xs);
    padding: var(--sp-1) var(--sp-2);
    border-radius: var(--radius-sm);
}

.unit-visibility.public {
    background: rgba(63, 185, 80, 0.15);
    border: 1px solid var(--accent-green);
    color: var(--accent-green);
}

.unit-visibility.private {
    background: rgba(139, 148, 158, 0.15);
    border: 1px solid var(--text-muted);
    color: var(--text-muted);
}


.btn-small {
    font-size: var(--fs-xs);
    padding: var(--sp-2) var(--sp-3);
    line-height: 1.3;
}

.btn-secondary {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
}

.btn-secondary:hover {
    border-color: var(--accent-cyan);
    color: var(--accent-cyan);
}

.btn-danger {
    background: var(--accent-red);
    color: var(--bg-primary);
    border-color: var(--accent-red);
}

.btn-danger:hover {
    background: transparent;
    color: var(--accent-red);
}

/* ===========================================
   UNIT FORM STYLES
   =========================================== */

.manage-form {
    max-width: 800px;
    margin: 0 auto;
}

.form-header {
    margin-bottom: var(--sp-6);
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: var(--sp-4);
}


.form-header h1 {
    font-size: var(--fs-3xl);
    color: var(--text-primary);
    margin-bottom: var(--sp-2);
}

.form-subtitle {
    color: var(--text-secondary);
}


.form-section-title {
    display: flex;
    align-items: center;
    gap: var(--sp-2);
    font-size: var(--fs-md);
    color: var(--accent-orange);
    text-transform: uppercase;
    letter-spacing: var(--tracking-wide);
    margin-bottom: var(--sp-4);
    padding-bottom: var(--sp-2);
    border-bottom: 1px solid var(--border-color);
}

/* Same deal as .section-title: currentColor inline SVG sized off its own viewBox. */
.form-section-title > svg { flex: none; }

.form-help {
    font-size: var(--fs-base);
    color: var(--text-muted);
    margin-bottom: var(--sp-4);
    margin-top: var(--sp-4);
}

.form-help a {
    color: var(--text-secondary);
    text-decoration: none;
}

.form-help a:hover {
    color: var(--accent-cyan);
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--sp-4);
}

.unit-form .form-group {
    margin-bottom: var(--sp-4);
}

.unit-form .form-group:last-child {
    margin-bottom: 0;
}

.unit-form label {
    display: block;
    font-size: var(--fs-base);
    color: var(--text-secondary);
    font-weight: var(--fw-medium);
    margin-bottom: var(--sp-2);
}

.unit-form small {
    display: block;
    font-size: var(--fs-xs);
    color: var(--text-muted);
    margin-top: var(--sp-1);
}



.checkbox {
    width: auto;
    margin-right: var(--sp-2);
}

.checkbox-group {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--sp-2);
}

.checkbox-group label {
    display: inline;
    margin-bottom: 0;
}

.checkbox-group small {
    flex-basis: 100%;
    margin-top: var(--sp-1);
}

/* Autocomplete */
.autocomplete-wrapper {
    position: relative;
}

.autocomplete-input {
    width: 100%;
}

.autocomplete-input--browse {
    cursor: pointer;
    background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10 6'%3E%3Cpath fill='%23888' d='M0 0h10L5 6z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    background-size: 10px 6px;
    padding-right: var(--sp-6);
}

.autocomplete-input.has-value {
    border-color: var(--accent-slate);
}

.autocomplete-results,
.autocomplete-dropdown {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    z-index: 100;
    max-height: 250px;
    overflow-y: auto;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-top: none;
    border-radius: 0 0 6px 6px;
}

.autocomplete-dropdown {
    max-height: 200px;
    border-color: var(--accent-cyan);
    box-shadow: var(--shadow-card);
}

.autocomplete-dropdown .autocomplete-item {
    padding: var(--sp-2) var(--sp-3);
    font-size: var(--fs-base);
    color: var(--text-primary);
}

.autocomplete-item {
    padding: var(--sp-3);
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-color);
}

.autocomplete-item:last-child {
    border-bottom: none;
}

.autocomplete-item:hover,
.autocomplete-item.selected {
    background: var(--bg-tertiary);
}

.autocomplete-item.no-results {
    color: var(--text-secondary);
    cursor: default;
    font-style: italic;
}

.autocomplete-item.no-results:hover {
    background: transparent;
}

.autocomplete-manufacturer {
    font-size: var(--fs-xs);
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.autocomplete-model {
    font-size: var(--fs-base);
    color: var(--text-primary);
}

.autocomplete-item-info {
    display: flex;
    flex-direction: column;
    gap: var(--sp-1);
}

.autocomplete-specs-link {
    flex-shrink: 0;
    margin-left: var(--sp-2);
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: var(--sp-1);
    opacity: 0;
    transition: opacity 0.2s ease;
}

.autocomplete-item:hover .autocomplete-specs-link {
    opacity: 1;
}

.device-input-row {
    position: relative;
}

.device-specs-link {
    position: absolute;
    top: 50%;
    right: 0.5rem;
    transform: translateY(-50%);
    z-index: 2;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: var(--sp-1);
    opacity: 0;
    transition: opacity 0.2s ease;
}

.device-input-row:hover .device-specs-link:not(.hidden) {
    opacity: 1;
}

/* Form actions */
.form-actions {
    display: flex;
    justify-content: flex-end;
    gap: var(--sp-4);
    margin-top: var(--sp-4);
    margin-bottom: var(--sp-6);
}

.form-actions-inline {
    margin-top: var(--sp-5);
    padding-top: var(--sp-5);
    border-top: 1px solid var(--border-color);
}

/* Profile photo section */
.current-photo {
    flex-shrink: 0;
    width: 120px;
    display: flex;
    flex-direction: column;
    gap: var(--sp-2);
}

.profile-photo-preview {
    width: 120px;
    height: 120px;
    display: block;
    border-radius: var(--radius-md);
    object-fit: cover;
    border: 2px solid var(--border-color);
}

.profile-photo-placeholder {
    width: 120px;
    height: 120px;
    border-radius: var(--radius-md);
    background: var(--bg-tertiary);
    border: 2px dashed var(--border-color);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    font-size: var(--fs-sm);
}

.delete-photo-btn {
    width: 100%;
    text-align: center;
}

.photo-controls {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: var(--sp-4);
}

.photo-controls .form-group {
    margin-bottom: 0;
}

/* Delete photo form */
.form-card-danger {
    background: rgba(176, 24, 16, 0.1);
    border-color: var(--accent-red);
}


/* Form error messages */
.form-error {
    display: block;
    color: var(--accent-red);
    font-size: var(--fs-sm);
    margin-top: var(--sp-1);
}

/* Unverified email banner (dashboard) */
.verify-banner {
    display: flex;
    flex-wrap: wrap;
    gap: var(--sp-4);
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--sp-5);
    padding: var(--sp-4) var(--sp-5);
    background: rgba(176, 24, 16, 0.1);
    border: 1px solid var(--accent-red);
    border-radius: var(--radius-sm);
}

.verify-banner-text {
    flex: 1 1 20rem;
}

.verify-banner-text p {
    margin: var(--sp-1) 0 0;
    color: var(--text-secondary);
    font-size: var(--fs-base);
}

/* Registration tier chooser */
.plan-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr));
    gap: var(--sp-5);
    margin: var(--sp-5) 0;
    text-align: left;
}

.plan-grid .form-card {
    display: flex;
    flex-direction: column;
}

.plan-grid .form-card .btn {
    text-align: center;
}

.plan-grid .plan-features {
    flex: 1;
    margin: 0 0 var(--sp-5);
    padding-left: var(--sp-5);
    color: var(--text-secondary);
    font-size: var(--fs-base);
}

.plan-grid .plan-features li {
    margin-bottom: var(--sp-1);
}

/* Delete confirmation page */
.delete-warning-text {
    color: var(--text-primary);
    font-size: var(--fs-md);
    line-height: 1.6;
    margin-bottom: var(--sp-6);
}

.btn-success {
    background: var(--accent-green);
    color: var(--bg-primary);
    border: none;
}

.btn-success:hover {
    background: #2ea043;
}

/* Messages */
.messages {
    margin-bottom: var(--sp-5);
}

.message {
    padding: var(--sp-4);
    border-radius: var(--radius-sm);
    margin-bottom: var(--sp-5);
    font-size: var(--fs-base);
}

.message-success {
    background: rgba(63, 185, 80, 0.15);
    border: 1px solid var(--accent-green);
    color: var(--accent-green);
}

.message-error {
    background: rgba(248, 81, 73, 0.15);
    border: 1px solid var(--accent-red);
    color: var(--accent-red);
}

/* Collections Index */
.collections-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: var(--sp-5);
    margin-top: var(--sp-5);
}

.collection-card-photo img {
    width: 64px;
    height: 64px;
    border-radius: var(--radius-full);
    object-fit: cover;
}

.collection-card-placeholder {
    width: 64px;
    height: 64px;
    border-radius: var(--radius-full);
    background: var(--border-color);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: var(--fs-2xl);
    font-weight: var(--fw-semibold);
    color: var(--text-secondary);
}

.collection-card-info {
    flex: 1;
    min-width: 0;
}

.collection-card-name {
    font-size: var(--fs-lg);
    font-weight: var(--fw-semibold);
    margin: 0 0 var(--sp-1) 0;
    color: var(--text-primary);
}

.collection-card-count {
    font-size: var(--fs-sm);
    color: var(--text-secondary);
    margin: 0 0 var(--sp-2) 0;
}

.collection-card-about {
    font-size: var(--fs-sm);
    color: var(--text-muted);
    margin: 0;
    line-height: 1.4;
}

/* User Collection Page */
.collection-header {
    display: flex;
    gap: var(--sp-5);
    align-items: flex-start;
    margin-bottom: var(--sp-6);
}

.collection-header-photo img,
.collection-profile-photo {
    width: 120px;
    height: 120px;
    border-radius: var(--radius-full);
    object-fit: cover;
    border: 3px solid var(--border-color);
}

.collection-profile-placeholder {
    width: 120px;
    height: 120px;
    border-radius: var(--radius-full);
    background: var(--border-color);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: var(--fs-display);
    font-weight: var(--fw-semibold);
    color: var(--text-secondary);
}


.collection-title {
    font-size: var(--fs-3xl);
    font-weight: var(--fw-bold);
    margin: 0 0 var(--sp-2) 0;
    color: var(--text-primary);
}

.collection-about-me {
    color: var(--text-secondary);
    margin: 0 0 var(--sp-3) 0;
    line-height: 1.5;
}


.collection-about-text {
    color: var(--text-secondary);
    line-height: 1.6;
}

.collection-about-text p {
    margin: 0 0 var(--sp-4) 0;
}

.collection-about-text p:last-child {
    margin-bottom: 0;
}


.collection-category-title {
    font-size: var(--fs-xl);
    font-weight: var(--fw-semibold);
    margin: 0 0 var(--sp-4) 0;
    padding-bottom: var(--sp-2);
    border-bottom: 1px solid var(--border-color);
    color: var(--text-primary);
}

/* Unit Detail */
.note-date {
    font-size: var(--fs-xs);
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: var(--tracking-wide);
}

.notes-content {
    color: var(--text-secondary);
    line-height: 1.6;
}

.note-content code {
    font-size: 0.85em;
    background: var(--bg-tertiary);
    padding: 0.15em 0.4em;
    border-radius: var(--radius-sm);
}

.note-content pre {
    background: var(--bg-tertiary);
    border-radius: var(--radius-sm);
    padding: 0.75em 1em;
    overflow-x: auto;
    margin: 0.5em 0;
}

.note-content pre code {
    background: none;
    padding: 0;
    font-size: 0.85em;
}

.modules-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.modules-list li {
    padding: var(--sp-2) 0;
    color: var(--text-secondary);
}

.modules-list li:last-child {
    border-bottom: none;
}

.module-notes {
    color: var(--text-muted);
    font-style: italic;
}

@media (max-width: 768px) {
    .auth-links {
        margin-left: 0;
        padding-left: 0;
        border-left: none;
        margin-top: var(--sp-4);
    }

    .auth-container {
        margin: var(--sp-4);
        padding: var(--sp-5);
    }

    .collection-grid {
        grid-template-columns: 1fr;
    }

    .form-row {
        grid-template-columns: 1fr;
    }


    .collections-grid {
        grid-template-columns: 1fr;
    }

    .collection-header {
        flex-direction: column;
        align-items: center;
        text-align: center;
    }

    .collection-header-photo img,
    .collection-profile-photo,
    .collection-profile-placeholder {
        width: 100px;
        height: 100px;
    }

    .collection-title {
        font-size: var(--fs-2xl);
    }
}

/* Submission status rows */
/* A draft is nobody's business but its owner's, so it reads as inert rather
   than borrowing one of the review states' colours. */
.data-table tr.submission-status-draft td { background: rgba(139, 148, 158, 0.10); }
.data-table tr.submission-status-under_review td { background: rgba(88, 166, 255, 0.12); }
.data-table tr.submission-status-published td { background: rgba(63, 185, 80, 0.12); }
.data-table tr.submission-status-rejected td { background: rgba(176, 24, 16, 0.18); }

.submission-status-link {
    color: var(--accent-green);
    text-decoration: none;
}
.submission-status-link:hover {
    text-decoration: underline;
}

.submissions-help {
    margin-top: var(--sp-6);
    color: var(--text-secondary);
    font-size: var(--fs-base);
}

/* ============================================================
   CHANGE HISTORY OVERLAY
   ============================================================ */

/* Overlay container */
.history-overlay {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 1000;
}

.history-overlay--open {
    display: flex;
    justify-content: flex-end;
}

.history-overlay-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
}

/* Slide-in panel */
.history-panel {
    position: relative;
    width: min(420px, 90vw);
    height: 100%;
    background: var(--bg-secondary);
    border-left: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    animation: history-slide-in 0.2s ease-out;
}

@keyframes history-slide-in {
    from { transform: translateX(100%); }
    to { transform: translateX(0); }
}

.history-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--sp-5);
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0;
}

.history-panel-title {
    font-size: var(--fs-md);
    font-weight: var(--fw-semibold);
    color: var(--text-primary);
}

.history-panel-close {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: var(--fs-2xl);
    cursor: pointer;
    padding: 0;
    line-height: 1;
}

.history-panel-close:hover {
    color: var(--text-primary);
}

.history-panel-body {
    overflow-y: auto;
    padding: var(--sp-4) var(--sp-5);
    flex: 1;
}

.history-entry {
    background: var(--bg-tertiary);
    border-left: 3px solid var(--border-color);
    border-radius: 0 8px 8px 0;
    padding: var(--sp-3) var(--sp-4);
    margin-bottom: var(--sp-2);
}


.history-action {
    font-size: var(--fs-xs);
    font-weight: var(--fw-semibold);
    text-transform: uppercase;
    letter-spacing: var(--tracking-wide);
    padding: var(--sp-1) var(--sp-2);
    border-radius: var(--radius-sm);
}

.history-action--created {
    background: rgba(63, 185, 80, 0.15);
    color: var(--accent-green);
}

.history-action--updated {
    background: rgba(57, 197, 207, 0.15);
    color: var(--accent-cyan);
}

.history-action--deleted {
    background: rgba(176, 24, 16, 0.18);
    color: var(--accent-red);
}

.history-user {
    color: var(--text-primary);
    font-size: var(--fs-sm);
}

.history-time {
    color: var(--text-muted);
    font-size: var(--fs-sm);
    margin-left: auto;
}

.history-changes {
    list-style: none;
    margin-top: var(--sp-2);
    padding: 0;
    font-size: var(--fs-sm);
    color: var(--text-secondary);
}

.history-changes li {
    padding: var(--sp-1) 0;
}

.history-old {
    color: var(--accent-red);
    text-decoration: line-through;
}

.history-new {
    color: var(--accent-green);
}

/* ============================================================
   SITE FOOTER
   ============================================================ */
.site-footer {
    position: relative;
    isolation: isolate;
    /* Grow into any leftover viewport height. The text stays at the top of the
       block, directly under the page content, exactly where it sits on a page
       that fills the window. */
    flex: 1 0 auto;
    text-align: center;
    padding: var(--sp-6) var(--sp-4);
    margin-top: var(--sp-7);
    border-top: 1px solid var(--border-color);
    font-size: var(--fs-sm);
    color: var(--text-muted);
}

/* Same cube texture as the site header, fading in from the top down. The block
   stretches to the bottom of the viewport on short pages, so the texture always
   runs to the window edge instead of stopping where the content happens to. */
.site-footer::before {
    content: '';
    position: absolute;
    inset: 0;
    z-index: -1;
    background-image: url("../img/cube-pattern.61128e3ba32e.svg");
    background-size: auto 170px;
    background-repeat: repeat-x;
    background-position: center bottom;
    opacity: 0.10;
    /* The mask covers exactly the band the tile occupies, so the fade reaches
       zero right where the tile ends however tall the footer grows. */
    -webkit-mask-image: linear-gradient(180deg, transparent 0%, #000 100%);
    mask-image: linear-gradient(180deg, transparent 0%, #000 100%);
    -webkit-mask-size: 100% 170px;
    mask-size: 100% 170px;
    -webkit-mask-position: center bottom;
    mask-position: center bottom;
    -webkit-mask-repeat: no-repeat;
    mask-repeat: no-repeat;
    pointer-events: none;
}

.site-footer a {
    color: var(--text-secondary);
    text-decoration: none;
}

.site-footer a:hover {
    color: var(--accent-cyan);
}

.footer-watermark {
    height: 60px;
    margin-top: var(--sp-3);
    opacity: 0.6;
    transition: opacity 0.2s;
}

.footer-watermark:hover {
    opacity: 1;
}

/* Partial date inputs (year / month / day side-by-side) */
.date-partial-inputs {
    display: flex;
    gap: var(--sp-2);
    align-items: center;
}
.date-partial-inputs input[name="date_acquired_year"] {
    width: 6rem;
}
.date-partial-inputs select[name="date_acquired_month"] {
    width: 10rem;
}
.date-partial-inputs input[name="date_acquired_day"] {
    width: 5rem;
}

dt.aka-label {
    font-size: var(--fs-base);
    color: var(--text-muted);
    font-weight: 400;
    margin-top: calc(-1 * var(--sp-2));
}

dd.also-known-as {
    font-size: var(--fs-base);
    color: var(--text-secondary);
    margin-top: calc(-1 * var(--sp-2));
}

.aka-bracket {
    color: var(--text-muted);
}

.modules-hidden {
    display: none;
}

.modules-expand-toggle {
    margin-top: var(--sp-3);
    margin-left: var(--sp-5);
}

.modules-expand-link {
    font-size: var(--fs-sm);
}

/* ===========================================================================
   SUBMISSION FORMS
   =========================================================================== */

.category-selector {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: var(--sp-5);
    margin-top: var(--sp-5);
}

.category-option:hover {
    border-color: var(--border-hover);
    transform: translateY(-2px);
    box-shadow: var(--shadow-card);
}

.category-option-disabled {
    opacity: 0.5;
    cursor: default;
}

.category-option-disabled:hover {
    border-color: var(--border-color);
    transform: none;
    box-shadow: none;
}

.category-option-icon {
    font-size: var(--fs-display-sm);
    margin-bottom: var(--sp-4);
    color: white !important;
}

/* --- Inline formsets --- */
.formset-section { margin-bottom: var(--sp-5); }
.formset-section:last-child { margin-bottom: 0; }
.formset-section .subsection-title { font-size: var(--fs-base); margin-bottom: var(--sp-2); }
.formset-col-quantity { width: 104px; }
.formset-col-breakout_quantity { width: 112px; }
.formset-col-speed_value { width: 108px; }
.col-actions { width: 36px; text-align: center; }
.formset-cell-quantity input { text-align: center; }
.formset-cell-breakout_quantity input { text-align: center; }
.formset-row-hidden { display: none !important; }

/* The row's × is the delete control; this box is the mechanism behind it,
   ticked and left in the POST by formset_rows.js so Django sees the deletion.
   It has to be in the DOM and never on screen -- two controls crowding one
   36px column is the mechanism showing through. Only a reopened draft has rows
   with a pk, so nothing rendered it until drafts existed. */
.formset-table input[name$="-DELETE"] { display: none; }

.btn-remove-row { width: 26px; height: 26px; padding: 0; font-size: var(--fs-md); }
.btn-add-row { margin-top: var(--sp-2); }

/* --- Photo upload preview --- */
.photo-preview-container {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: var(--sp-3);
    margin-top: var(--sp-4);
}

.photo-preview-item {
    position: relative;
    border-radius: var(--radius-md);
    overflow: hidden;
    border: 1px solid var(--border-color);
    background: var(--bg-tertiary);
}

.photo-preview-item img {
    width: 100%;
    aspect-ratio: 1;
    object-fit: cover;
    display: block;
}

.photo-preview-name {
    padding: var(--sp-1) var(--sp-2);
    font-size: var(--fs-xs);
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.photo-count-warning {
    color: var(--accent-yellow);
    font-size: var(--fs-sm);
    margin-top: var(--sp-2);
}

/* --- Misc --- */
.submission-form .form-actions {
    margin-top: var(--sp-6);
    padding-top: var(--sp-5);
    border-top: 1px solid var(--border-color);
}

/* Save for Later sits between Cancel and the primary action on screen, but is
   written after it so the primary action stays the form's implicit submitter —
   Enter in a text field fires the first submit button in tree order, and on a
   form this long that should send the submission, not quietly park it. */
.form-actions__cancel { order: 1; }
.form-actions__draft { order: 2; }
.form-actions__submit { order: 3; }

/* Photos already on a reopened draft: a tick box rather than the unit form's
   hover ×, because removal happens on the next save and has to be visible
   (and reversible) until then. */
.existing-photos .photo-delete-check {
    display: flex;
    align-items: center;
    gap: var(--sp-2);
    padding: var(--sp-2) var(--sp-3);
    font-size: var(--fs-sm);
    color: var(--text-secondary);
    cursor: pointer;
}

.submission-form .existing-photos .photo-item { cursor: default; }

.submission-actions {
    display: flex;
    gap: var(--sp-2);
    align-items: center;
}

.submission-actions form { display: inline; }

.form-error-message {
    background: rgba(176, 24, 16, 0.1);
    border: 1px solid var(--accent-red);
    color: var(--accent-red);
    padding: var(--sp-2) var(--sp-3);
    border-radius: var(--radius-sm);
    font-size: var(--fs-sm);
    margin-bottom: var(--sp-4);
}

.view-original-link {
    display: inline-block;
    margin-top: var(--sp-2);
    padding: var(--sp-1) var(--sp-3);
    font-size: var(--fs-sm);
    color: var(--accent-cyan);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    text-decoration: none;
}

.view-original-link:hover {
    border-color: var(--accent-cyan);
    background: var(--glow-cyan);
}

@media (max-width: 768px) {
    .category-selector { grid-template-columns: 1fr; }
    .formset-table { font-size: var(--fs-sm); }
    .formset-cell :is(input, select) { font-size: var(--fs-sm); padding: var(--sp-1); }
    .name-list__row .autocomplete-dropdown {
        position: static;
        max-height: 160px;
        border-top: 1px solid var(--accent-cyan);
        border-radius: 0 0 6px 6px;
    }
    .photo-preview-container { grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); }
}

/* --- Lightbox (GLightbox overrides) --- */
/* glightbox.min.css loads after this file, so these need the extra class to win. */
.glightbox-clean .gslide-description.description-bottom {
    background: #000;
}

.glightbox-clean .gslide-description.description-bottom .gslide-title {
    color: var(--text-primary);
}

.glightbox-clean .gdesc-inner {
    font-size: var(--fs-lg);
}
/* ==========================================================================
   Submission form
   ========================================================================== */

/* --- The field itself --- */
.lookup-or-new {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: var(--sp-1);
}
.lookup-or-new__picker,
.lookup-or-new__new { width: 100%; }
.lookup-or-new__new { display: none; }
.lookup-or-new--open .lookup-or-new__picker { display: none; }
.lookup-or-new--open .lookup-or-new__new { display: block; }

.lookup-or-new--open[data-lookup-or-new="additive"] .lookup-or-new__picker {
    display: block;
}

.lookup-or-new__toggle {
    width: auto;
    padding: 0;
    border: none;
    background: none;
    color: var(--accent-cyan);
    font-size: var(--fs-sm);
    white-space: nowrap;
    text-decoration: underline;
    cursor: pointer;
    margin-left: var(--sp-1);
}
.lookup-or-new__toggle:hover { opacity: 0.8; }

.formset-cell { vertical-align: top; }

/* --- Repeatable picker (NameListWidget) --- */
.name-list,
.name-list__values {
    display: flex;
    flex-direction: column;
    gap: var(--sp-1);
    width: 100%;
}
.name-list { align-items: flex-start; }
.name-list__control { position: relative; }
.name-list__row input {
    width: 100%;
    padding-right: var(--sp-6);
}
.name-list__remove {
    position: absolute;
    top: 0;
    right: 0;
    height: 100%;
    width: var(--sp-6);
    z-index: 101;
    padding: 0;
    border: none;
    background: none;
    color: var(--text-secondary);
    font-size: var(--fs-md);
    line-height: 1;
    cursor: pointer;
}
.name-list__remove:hover { color: var(--accent-cyan); }

/* --- Breakout toggle --- */
.breakout-check {
    display: flex;
    align-items: center;
    gap: var(--sp-1);
    margin-top: var(--sp-1);
    color: var(--text-secondary);
    font-size: var(--fs-sm);
    white-space: nowrap;
    cursor: pointer;
}
.formset-table tr > :first-child .tooltip-text::after {
    left: 0;
    transform: none;
}
.breakout-check input {
    width: auto;
    margin: 0;
    padding: 0;
    background: none;
    border: none;
    cursor: pointer;
}

.formset-table:not(.formset-table--breakout) :is(
    .formset-col-breakout_quantity,
    .formset-col-breakout_interfaces,
    .formset-cell-breakout_quantity,
    .formset-cell-breakout_interfaces
) { display: none; }

.formset-cell--disabled { opacity: 0.35; }
.formset-cell--disabled :is(input, select, button) { cursor: not-allowed; }
