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

body {
    font-family: sans-serif;
    font-size: 16px;
    color: #333;
    background: #f5f5f5;
}

header {
    background: #2c3e50;
    color: white;
    padding: 1rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

header a {
    color: white;
    text-decoration: none;
    margin-left: 1rem;
}

main {
    padding: 2rem;
}

table {
    width: 100%;
    border-collapse: collapse;
    background: white;
    border-radius: 8px;
    overflow: hidden;
}

th, td {
    padding: 0.75rem 1rem;
    text-align: left;
    border-bottom: 1px solid #eee;
}

th {
    background: #34495e;
    color: white;
    font-weight: 500;
}

th.sortable {
    cursor: pointer;
    user-select: none;
    white-space: nowrap;
}
th.sortable:hover { background: #3d566e; }
th.sort-active    { background: #2c4a63; }

.sort-ind {
    display: inline-block;
    margin-left: 4px;
    font-size: 0.8em;
    opacity: 0.5;
}
th.sort-active .sort-ind { opacity: 1; color: #7ec8e3; }

.sort-num {
    font-size: 0.65em;
    vertical-align: super;
    margin-left: 1px;
}

tr:hover { background: #f9f9f9; }
tr.clickable-row { cursor: pointer; }
tr.clickable-row:hover { background: #eef2f7; }

.messages {
    background: #d4edda;
    border: 1px solid #c3e6cb;
    padding: 1rem;
    border-radius: 4px;
    margin-bottom: 1rem;
    list-style: none;
}
h2 { margin-bottom: 1.5rem; color: #2c3e50; }
h3 { margin-bottom: 1rem; color: #34495e; font-size: 1rem; text-transform: uppercase; letter-spacing: 0.05em; }

.form-section {
    background: white;
    padding: 1.5rem;
    border-radius: 8px;
    margin-bottom: 1.5rem;
}

.form-sections-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0 1.5rem;
    align-items: stretch;
}
.form-sections-row > .form-section {
    margin-bottom: 1.5rem;
}

@media (max-width: 768px) {
    .form-sections-row {
        grid-template-columns: 1fr;
    }
}

.form-group {
    margin-bottom: 1rem;
}

.field-hint {
    display: block;
    margin-top: 0.25rem;
    font-size: 0.78rem;
    color: #999;
}

.form-group label {
    display: block;
    margin-bottom: 0.25rem;
    font-weight: 500;
    font-size: 0.9rem;
    color: #555;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 0.5rem 0.75rem;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 1rem;
    color: #333;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: #2c3e50;
}

.form-row {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    align-items: flex-start;
}

.form-row > .form-group {
    min-width: 0;  /* Allow flex items to shrink below intrinsic content size */
}

.form-col {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.form-col > .form-group {
    margin-bottom: 0;
}

.form-group.checkbox label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 400;
}

/* Tagged + Asset Tag row */
.tagged-row {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    flex-wrap: wrap;
    margin-bottom: 1rem;
}
.tagged-label {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
    font-weight: 400;
    cursor: pointer;
    flex: 1;
    min-width: 200px;
}
.tagged-label input[type="checkbox"] {
    flex-shrink: 0;
    margin-top: 0.2rem;
}
.tagged-asset-group {
    flex: 0 0 200px;
    margin-bottom: 0;
}

/* Collector classification stacked list */
.classification-list {
    display: flex;
    flex-direction: column;
    border: 1px solid var(--border, #e0e0e0);
    border-radius: 6px;
    overflow: hidden;
    max-width: 400px;
}

.classification-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.55rem 0.85rem;
    border-bottom: 1px solid var(--border, #e0e0e0);
    cursor: pointer;
    font-size: 0.95rem;
    transition: background 0.12s;
}

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

.classification-item:hover {
    background: #f5f7fa;
}

.classification-item input[type="checkbox"] {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    cursor: pointer;
    accent-color: var(--sidebar-bg, #2c3e50);
}

.form-actions {
    display: flex;
    gap: 1rem;
    align-items: center;
    margin: 1.5rem 0;
}

button[type="submit"] {
    background: #2c3e50;
    color: white;
    border: none;
    padding: 0.75rem 2rem;
    border-radius: 4px;
    font-size: 1rem;
    cursor: pointer;
}

button[type="submit"]:hover { background: #34495e; }

.btn-cancel {
    background: none;
    border: 1px solid #bbb;
    color: #555;
    padding: 0.45rem 0.75rem;
    border-radius: 4px;
    font-size: 0.875rem;
    cursor: pointer;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
}
.btn-cancel:hover { border-color: #2c3e50; color: #2c3e50; background: #f8f9fa; }

.nav-text-links {
    display: flex;
    align-items: center;
    gap: 0.35rem;
}
.nav-text-link {
    font-weight: 600;
    color: #2c3e50;
    text-decoration: none;
    font-size: 0.9rem;
    white-space: nowrap;
}
.nav-text-link:hover {
    color: #34495e;
    text-decoration: underline;
}
.nav-sep {
    color: #ccc;
    font-weight: normal;
    user-select: none;
}

    .view-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.view-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1.5rem;
}

.view-section {
    background: white;
    padding: 1.5rem;
    border-radius: 8px;
}

.view-section.full-width {
    grid-column: 1 / -1;
}

dl { display: grid; grid-template-columns: 1fr 1fr; gap: 0.5rem 1rem; }
dt { font-weight: 500; font-size: 0.9rem; color: #555; }
dd { color: #333; }

.btn-edit {
    background: #2c3e50;
    color: white;
    padding: 0.5rem 1.5rem;
    border-radius: 4px;
    text-decoration: none;
    font-size: 0.9rem;
}

.btn-edit:hover { background: #34495e; }

.view-actions { display: flex; gap: 1rem; align-items: center; }

.photo-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 1rem;
}

.photo-item img {
    width: 100%;
    border-radius: 4px;
}

.app-layout {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: 220px;
    min-width: 220px;
    background: #2c3e50;
    color: white;
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    overflow-y: auto;
}

.sidebar-brand {
    padding: 1.5rem;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.sidebar-brand h1 {
    font-size: 1.1rem;
    font-weight: 600;
    line-height: 1.4;
    color: white;
}

.sidebar-nav {
    padding: 1rem 0;
    flex: 1;
}

.nav-section {
    margin-bottom: 1.5rem;
}

.nav-section-label {
    display: block;
    padding: 0.25rem 1.5rem;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: rgba(255,255,255,0.4);
    margin-bottom: 0.25rem;
}

.nav-link {
    display: block;
    padding: 0.5rem 1.5rem;
    color: rgba(255,255,255,0.75);
    text-decoration: none;
    font-size: 0.9rem;
    transition: all 0.15s;
}

.nav-link:hover {
    background: rgba(255,255,255,0.1);
    color: white;
}

.nav-link.active {
    background: rgba(255,255,255,0.15);
    color: white;
    border-left: 3px solid white;
}

/* Collection switcher states */
.nav-link-active {
    display: block;
    padding: 0.5rem 1.5rem;
    color: white;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: default;
}

.nav-link-collection-switch {
    background: none;
    border: none;
    cursor: pointer;
    width: 100%;
    text-align: left;
    opacity: 0.55;
}

.nav-link-collection-switch:hover {
    opacity: 1;
}

.nav-link-muted {
    opacity: 0.5;
    font-size: 0.82rem;
}

.nav-link-muted:hover {
    opacity: 0.85;
}

/* ── Sidebar user footer ─────────────────────────────────────────────────── */
.sidebar-user {
    padding: 1rem 1.5rem;
    border-top: 1px solid rgba(255,255,255,0.1);
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}
.sidebar-user-email {
    color: rgba(255,255,255,0.9);
    font-size: 0.8rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.sidebar-user-role {
    color: rgba(255,255,255,0.5);
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}
.sidebar-logout {
    margin-top: 0.4rem;
    background: rgba(255,255,255,0.1);
    border: 1px solid rgba(255,255,255,0.2);
    color: rgba(255,255,255,0.8);
    padding: 0.3rem 0.75rem;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.8rem;
    width: 100%;
    text-align: center;
}
.sidebar-logout:hover {
    background: rgba(255,255,255,0.2);
    color: white;
}
.sidebar-public-link {
    display: block;
    margin-top: 0.4rem;
    font-size: 0.78rem;
    color: rgba(255,255,255,0.6);
    text-decoration: none;
    text-align: center;
}
.sidebar-public-link:hover {
    color: rgba(255,255,255,0.9);
}

/* ── Badge ───────────────────────────────────────────────────────────────── */
.badge-you {
    display: inline-block;
    background: #e8f0fe;
    color: #1a56db;
    font-size: 0.7rem;
    padding: 0.1rem 0.4rem;
    border-radius: 3px;
    margin-left: 0.4rem;
    vertical-align: middle;
}

/* ── Login page ──────────────────────────────────────────────────────────── */
.login-page {
    background: #2c3e50;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
}
.login-card {
    background: rgba(30,20,10,0.82);
    padding: 1rem 2rem 2.5rem;
    border-radius: 12px;
    width: 100%;
    max-width: 380px;
    box-shadow: 0 8px 40px rgba(0,0,0,0.5);
    border: 1px solid rgba(255,255,255,0.1);
    overflow: visible;
}
.login-title {
    text-align: center;
    font-size: 1.4rem;
    font-weight: 700;
    color: #f0e8d8;
    margin-bottom: 1.75rem;
    line-height: 1.3;
}
.login-logo {
    display: block;
    width: 100%;
    max-width: 360px;
    margin: -2.5rem auto 2rem;
}
.login-card label {
    color: #d0c8b8;
}
.login-card input[type="email"],
.login-card input[type="password"],
.login-card input[type="text"] {
    background: rgba(255,255,255,0.12);
    border-color: rgba(255,255,255,0.2);
    color: #f0e8d8;
}
.login-card input::placeholder { color: rgba(240,232,216,0.4); }
.login-card a { color: #c8bea8; }
.login-form .form-group {
    margin-bottom: 1rem;
}
.login-btn {
    width: 100%;
    margin-top: 0.5rem;
    padding: 0.65rem;
    font-size: 1rem;
}
.password-wrap {
    position: relative;
    display: flex;
    align-items: center;
}
.password-wrap input {
    flex: 1;
    padding-right: 2.5rem;
}
.password-toggle {
    position: absolute;
    right: 0.5rem;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1.1rem;
    line-height: 1;
    padding: 0.25rem;
    color: #888;
}
.password-toggle:hover { color: #333; }

.login-error {
    background: #fee2e2;
    color: #b91c1c;
    padding: 0.6rem 0.9rem;
    border-radius: 6px;
    margin-bottom: 1rem;
    font-size: 0.9rem;
}

.login-info {
    background: rgba(251,191,36,0.15);
    color: #d97706;
    border: 1px solid rgba(251,191,36,0.3);
    padding: 0.6rem 0.9rem;
    border-radius: 6px;
    margin-bottom: 1rem;
    font-size: 0.9rem;
    text-align: center;
}

.nav-icon {
    margin-right: 0.5rem;
    font-size: 0.8rem;
}

.main-content {
    margin-left: 220px;
    flex: 1;
    padding: 2rem;
}

.messages {
    background: #d4edda;
    border: 1px solid #c3e6cb;
    padding: 1rem;
    border-radius: 4px;
    margin-bottom: 1rem;
    list-style: none;
}

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.btn-primary {
    background: #2c3e50;
    color: white;
    padding: 0.45rem 1.25rem;
    border: 1px solid transparent;
    border-radius: 4px;
    text-decoration: none;
    font-size: 0.875rem;
    display: inline-flex;
    align-items: center;
}

.btn-primary:hover { background: #34495e; }

/* ── Prev/Next navigation ───────────────────────────────────────────── */
.nav-controls {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: nowrap;
}

.nav-position {
    font-size: 0.85rem;
    color: #888;
    min-width: 4rem;
    text-align: center;
}

.btn-nav {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2rem;
    height: 2rem;
    border-radius: 4px;
    background: #2c3e50;
    color: white;
    text-decoration: none;
    font-size: 1.4rem;
    line-height: 1;
}

.btn-nav:hover { background: #34495e; }

.btn-nav-disabled {
    background: #ccc;
    cursor: default;
    pointer-events: none;
}

.btn-nav-label {
    display: inline-block;
    background: #2c3e50;
    color: white;
    padding: 0.5rem 1.25rem;
    border-radius: 4px;
    text-decoration: none;
    font-size: 0.9rem;
    cursor: pointer;
}

.btn-nav-label:hover { background: #34495e; }

.btn-nav-label.btn-nav-disabled {
    background: #ccc;
    cursor: default;
    pointer-events: none;
}

.form-actions-spacer {
    flex: 1;
}

/* ── Clickable table rows ───────────────────────────────────────────── */
tr.clickable-row {
    cursor: pointer;
}

tr.clickable-row:hover td {
    background: #eef2f7;
}

/* ── Dynamic filter builder ─────────────────────────────────────────── */
.filter-builder-wrap {
    background: white;
    border-radius: 8px;
    padding: 0.75rem 1rem;
    margin-bottom: 1rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}

.sort-builder-wrap {
    background: white;
    border-radius: 8px;
    padding: 0.75rem 1rem;
    margin-bottom: 1rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.sort-builder-label {
    font-size: 0.8rem;
    font-weight: 600;
    color: #888;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

#sort-rows {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.sort-row-dyn {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
}

.sort-builder-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    flex-wrap: wrap;
    margin-top: 0.25rem;
}

.sort-dir-btn {
    padding: 0.38rem 0.75rem;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 0.9rem;
    background: white;
    cursor: pointer;
    min-width: 80px;
}

.sort-dir-btn:hover { background: #f5f5f5; }

.search-box-wrap {
    position: relative;
    margin-bottom: 0.75rem;
}

.search-box-input {
    width: 100%;
    box-sizing: border-box;
    padding: 0.55rem 2.25rem 0.55rem 2.25rem;
    border: 1px solid #ddd;
    border-radius: 8px;
    font-size: 0.95rem;
    background-color: #fff;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23999' stroke-width='2' stroke-linecap='round' stroke-linejoin='round' width='16' height='16'%3E%3Ccircle cx='11' cy='11' r='8'/%3E%3Cline x1='21' y1='21' x2='16.65' y2='16.65'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: 0.7rem center;
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}

.search-box-input:focus {
    outline: none;
    border-color: #2980b9;
}

.search-box-clear {
    display: none;
    position: absolute;
    right: 0.4rem;
    top: 50%;
    transform: translateY(-50%);
    width: 1.6rem;
    height: 1.6rem;
    border: none;
    border-radius: 50%;
    background: #ddd;
    color: #555;
    font-size: 0.85rem;
    line-height: 1;
    cursor: pointer;
    align-items: center;
    justify-content: center;
}

.search-box-clear:hover { background: #ccc; }

.search-box-wrap.has-value .search-box-clear { display: flex; }

#filter-rows {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.filter-row-dyn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.ff-field, .ff-op {
    padding: 0.38rem 0.6rem;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 0.9rem;
    background: white;
    cursor: pointer;
}

.ff-field  { min-width: 160px; }
.ff-op     { min-width: 160px; }

.ff-val-container { display: flex; }

.ff-input {
    padding: 0.38rem 0.6rem;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 0.9rem;
    min-width: 180px;
}

.ff-remove {
    background: none;
    border: none;
    color: #aaa;
    font-size: 1rem;
    cursor: pointer;
    padding: 0.25rem 0.4rem;
    border-radius: 4px;
    line-height: 1;
}
.ff-remove:hover { color: #c0392b; background: #fef2f2; }

.filter-builder-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 0.6rem;
    padding-top: 0.6rem;
    border-top: 1px solid #f0f0f0;
}

.btn-add-filter {
    background: none;
    border: 1px dashed #bbb;
    color: #555;
    padding: 0.3rem 0.8rem;
    border-radius: 4px;
    font-size: 0.85rem;
    cursor: pointer;
}
.btn-add-filter:hover { border-color: #2c3e50; color: #2c3e50; background: #f8f9fa; }

.filter-builder-actions {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.result-count {
    padding: 0.5rem 1rem;
    font-size: 0.85rem;
    color: #888;
    text-align: right;
    border-top: 1px solid #eee;
}

/* ── Saved filters bar ──────────────────────────────────────────────── */
.saved-filters-bar {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    flex-wrap: nowrap;
    padding-bottom: 0.65rem;
    margin-bottom: 0.65rem;
    border-bottom: 1px solid #f0f0f0;
}

.sf-delete-link {
    color: #c0392b;
    font-size: 0.85rem;
    text-decoration: none;
    white-space: nowrap;
    flex-shrink: 0;
}
.sf-delete-link:hover { text-decoration: underline; }

.saved-filters-label {
    font-size: 0.72rem;
    font-weight: 700;
    color: #999;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    white-space: nowrap;
}

.saved-filters-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
}

.saved-filter-chip {
    display: inline-flex;
    align-items: stretch;
    background: white;
    border: 1.5px solid #c8d4df;
    border-radius: 99px;
    overflow: hidden;
    font-size: 0.85rem;
    transition: background 0.15s, border-color 0.15s;
}

.saved-filter-chip:hover {
    background: #edf2f7;
    border-color: #7aadcc;
}

.saved-filter-chip.active {
    background: #1a73e8;
    border-color: #1a73e8;
}

.saved-filter-chip.active .saved-filter-name {
    color: white;
}

.saved-filter-chip.active .saved-filter-delete {
    background: rgba(255,255,255,0.25);
}

.saved-filter-chip.active .saved-filter-delete:hover {
    background: rgba(220,50,50,0.85);
}

.saved-filter-name {
    color: #2c3e50;
    text-decoration: none;
    font-size: 0.85rem;
    padding: 0.3rem 0.5rem 0.3rem 0.85rem;
    line-height: 1.3;
    display: flex;
    align-items: center;
}
.saved-filter-name:hover { text-decoration: underline; }

.saved-filter-delete {
    display: flex;
    align-items: center;
    justify-content: center;
    background: #2c3e50;
    border: none;
    color: white;
    font-size: 0.7rem;
    cursor: pointer;
    width: 28px;
    padding: 0;
    margin: 0;
    border-radius: 0 99px 99px 0;
    line-height: 1;
    flex-shrink: 0;
    transition: background 0.15s;
}
.saved-filter-delete:hover { background: #c0392b; }

/* ── Record count bar ───────────────────────────────────────────────── */
.result-count-bar {
    font-size: 0.85rem;
    color: #888;
    margin-bottom: 0.5rem;
    padding-left: 0.25rem;
}

/* ── Save filter button & form ──────────────────────────────────────── */
.btn-save-filter {
    background: none;
    border: 1px solid #bbb;
    color: #555;
    padding: 0.45rem 0.75rem;
    border-radius: 4px;
    font-size: 0.875rem;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
}
.btn-save-filter:hover { border-color: #2c3e50; color: #2c3e50; background: #f8f9fa; }

.save-filter-form {
    margin-top: 0.5rem;
    padding: 0.6rem 0.75rem;
    background: #f8f9fa;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
}

.save-filter-form form {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

/* Photos */
.photo-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.photo-card {
    width: 200px;
    border: 2px solid #ddd;
    border-radius: 8px;
    overflow: hidden;
    background: white;
}

.photo-card.photo-primary {
    border-color: #2c3e50;
}

.photo-card img {
    width: 100%;
    height: 150px;
    object-fit: cover;
    display: block;
}

.primary-badge {
    display: block;
    background: #2c3e50;
    color: white;
    font-size: 0.7rem;
    font-weight: 600;
    text-align: center;
    padding: 0.2rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.photo-caption {
    padding: 0.4rem 0.6rem;
    font-size: 0.85rem;
    color: #555;
}

.photo-actions {
    padding: 0.35rem;
    display: flex;
    gap: 0.25rem;
    align-items: center;
    border-top: 1px solid #eee;
}

.photo-actions .btn-small {
    white-space: nowrap;
    flex: 1;
    text-align: center;
    padding: 0.25rem 0.25rem;
    font-size: 0.75rem;
}

.btn-small {
    padding: 0.25rem 0.6rem;
    font-size: 0.8rem;
    border: 1px solid #ccc;
    border-radius: 4px;
    background: white;
    cursor: pointer;
}

.btn-small:hover { background: #f0f0f0; }

.btn-danger {
    border-color: #e74c3c;
    color: #e74c3c;
}

.btn-danger:hover {
    background: #e74c3c;
    color: white;
}

.no-photos {
    color: #999;
    font-style: italic;
    margin-bottom: 1rem;
}

.upload-form {
    margin-top: 1rem;
}

/* ── Literature PDF upload ──────────────────────────────────────────── */
.pdf-upload-status {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 0.75rem;
}

.pdf-exists {
    color: #2e7d32;
    font-weight: 500;
}

.pdf-upload-form {
    margin-top: 0.5rem;
}

.muted-note {
    color: #999;
    font-style: italic;
    font-size: 0.875rem;
}

.pdf-link {
    color: #1a73e8;
    text-decoration: none;
}

.pdf-link:hover {
    text-decoration: underline;
}

/* ── PDF Modal ──────────────────────────────────────────────────────── */
.pdf-modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.75);
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.pdf-modal-backdrop {
    position: absolute;
    inset: 0;
}

.pdf-modal-dialog {
    position: relative;
    background: white;
    border-radius: 8px;
    /* Width is snapped to canvas by JS; height drives the fit-to-page calc */
    max-width: 96vw;
    max-height: 92vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: 0 8px 32px rgba(0,0,0,0.4);
}

@media (max-width: 600px) {
    .pdf-modal { padding: 0; align-items: flex-end; }
    .pdf-modal-dialog {
        width: 100vw !important;
        max-width: 100vw;
        max-height: 92vh;
        border-radius: 12px 12px 0 0;
    }
}

.pdf-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid #eee;
    flex-shrink: 0;
}

.pdf-modal-header span {
    font-weight: 600;
    font-size: 0.95rem;
    color: #333;
}

.pdf-modal-close {
    background: none;
    border: none;
    font-size: 1.1rem;
    color: #666;
    cursor: pointer;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
}

.pdf-modal-close:hover {
    background: #f0f0f0;
    color: #333;
}

.pdf-modal-nav {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.pdf-nav-btn {
    background: #2c3e50;
    color: white;
    border: none;
    border-radius: 4px;
    width: 2rem;
    height: 2rem;
    font-size: 1.4rem;
    line-height: 1;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.pdf-nav-btn:hover:not(:disabled) { background: #34495e; }
.pdf-nav-btn:disabled { background: #ccc; cursor: default; }

.pdf-page-info {
    font-size: 0.85rem;
    color: #555;
    min-width: 7rem;
    text-align: center;
}

.pdf-modal-body {
    flex: 1;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #525659;
    padding: 1rem;
    position: relative;
}

/* ── Dealers ─────────────────────────────────────────────────────────── */
.dealer-badge {
    display: inline-block;
    font-size: 0.75rem;
    font-weight: 600;
    background: var(--sidebar-bg, #2c3e50);
    color: #fff;
    padding: 0.2rem 0.65rem;
    border-radius: 20px;
    white-space: nowrap;
    flex-shrink: 0;
}

/* List layout */
.dealer-list {
    display: flex;
    flex-direction: column;
    gap: 0;
    border: 1px solid var(--border, #e0e0e0);
    border-radius: 8px;
    overflow: hidden;
    margin-top: 1rem;
}

.dealer-row {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    padding: 0.9rem 1.1rem;
    background: #fff;
    border-bottom: 1px solid var(--border, #e0e0e0);
    transition: background 0.12s;
}

.dealer-row:last-child {
    border-bottom: none;
}

.dealer-row:hover {
    background: #f5f7fa;
}

.dealer-row-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
}

.dealer-row-name {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
    font-size: 0.95rem;
    flex: 1;
    min-width: 0;
}

.dealer-row-desc {
    font-size: 0.85rem;
    color: var(--text-muted, #666);
    line-height: 1.4;
}

.dealer-row-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    margin-top: 0.25rem;
}

/* Desktop: hide mobile Edit, show desktop Edit */
.dealer-edit-mobile  { display: none; }
.dealer-edit-desktop { display: inline-block; flex-shrink: 0; }

/* Contact icon pills */
.dealer-contacts {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
}

.dealer-contact-link {
    display: inline-flex;
    align-items: center;
    font-size: 0.8rem;
    font-weight: 500;
    padding: 0.2rem 0.55rem;
    background: #f0f4f8;
    color: var(--text, #2c3e50);
    border-radius: 20px;
    text-decoration: none;
    transition: background 0.15s, color 0.15s;
    white-space: nowrap;
}

.dealer-contact-link:hover {
    background: var(--sidebar-bg, #2c3e50);
    color: #fff;
}

.dealer-favicon {
    width: 14px;
    height: 14px;
    vertical-align: middle;
    border-radius: 2px;
}

.dealer-link-label {
    display: none;
}

@media (max-width: 600px) {
    /* Mobile: show Edit in header top-right, hide footer Edit */
    .dealer-edit-mobile  { display: inline-block; flex-shrink: 0; }
    .dealer-edit-desktop { display: none; }

    .dealer-row-footer {
        flex-wrap: wrap;
    }

    .dealer-link-label {
        display: inline;
    }
}

/* Contact rows on the detail view */
.dealer-contact-list {
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
}

.dealer-contact-row {
    display: flex;
    align-items: baseline;
    gap: 1rem;
}

.dealer-contact-label {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-muted, #666);
    min-width: 140px;
    flex-shrink: 0;
}

.dealer-contact-row a {
    color: var(--link, #2980b9);
    word-break: break-all;
}

.dealer-contact-row a:hover {
    text-decoration: underline;
}

/* detail-list dl used on the view page */
.detail-list {
    display: grid;
    grid-template-columns: max-content 1fr;
    gap: 0.5rem 1.5rem;
    align-items: baseline;
}

.detail-list dt {
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--text-muted, #666);
    white-space: nowrap;
}

.detail-list dd {
    margin: 0;
}

/* ── PDF loading overlay ─────────────────────────────────────────────── */
.pdf-loading-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: #3a3d40;
    z-index: 10;
    padding: 2rem;
    gap: 0.5rem;
}

.pdf-spinner {
    width: 44px;
    height: 44px;
    border: 4px solid rgba(255,255,255,0.15);
    border-top-color: rgba(255,255,255,0.85);
    border-radius: 50%;
    animation: pdf-spin 0.75s linear infinite;
    margin-bottom: 0.5rem;
}

@keyframes pdf-spin {
    to { transform: rotate(360deg); }
}

.pdf-loading-label {
    color: rgba(255,255,255,0.85);
    font-size: 0.95rem;
}

.pdf-loading-pct {
    color: rgba(255,255,255,0.45);
    font-size: 0.82rem;
    min-height: 1.1em;
}

.pdf-progress-track {
    position: relative;
    width: 220px;
    height: 4px;
    background: rgba(255,255,255,0.15);
    border-radius: 2px;
    overflow: hidden;
    margin-top: 0.25rem;
}

.pdf-progress-fill {
    height: 100%;
    background: rgba(255,255,255,0.8);
    border-radius: 2px;
    width: 0%;
    transition: width 0.25s ease;
}

.pdf-progress-fill.indeterminate {
    position: absolute;
    width: 40%;
    animation: pdf-indeterminate 1.4s ease-in-out infinite;
}

@keyframes pdf-indeterminate {
    0%   { left: -40%; }
    60%  { left: 100%; }
    100% { left: 100%; }
}

#pdf-canvas {
    display: block;
    box-shadow: 0 2px 12px rgba(0,0,0,0.5);
}

.col-thumb {
    width: 60px;
    padding: 4px 6px !important;
}

.list-thumb {
    width: 52px;
    height: 52px;
    object-fit: cover;
    border-radius: 4px;
    display: block;
    opacity: 0;
    transition: opacity 0.2s ease;
}
.list-thumb.img-loaded { opacity: 1; }

.input-readonly {
    background: white;
    color: #444;
    cursor: default;
    border-color: #e8e8e8;
}

.field-value {
    margin: 0;
    padding: 0.4rem 0;
    min-height: 1.75rem;
    color: #333;
    word-break: break-word;
}

.field-value-multiline {
    white-space: pre-wrap;
}

.field-display {
    display: block;
    width: 100%;
    padding: 0.5rem 0.75rem;
    background: white;
    border: 1px solid #e8e8e8;
    border-radius: 4px;
    color: #444;
    font-size: 0.9rem;
    min-height: 2.25rem;
    box-sizing: border-box;
    word-break: break-word;
}

.field-display-multiline {
    white-space: pre-wrap;
}

.linked-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 1rem;
    font-size: 0.9rem;
}
.linked-table th {
    background: #f0f4f8;
    color: #333;
    font-weight: 600;
    padding: 0.5rem 0.75rem;
    text-align: left;
    border-bottom: 2px solid #ddd;
}
.linked-table td {
    padding: 0.5rem 0.75rem;
    border-bottom: 1px solid #eee;
}

@media (max-width: 768px) {
    /* Add Literature row: stack vertically so select gets full width */
    .upload-form .form-row {
        flex-direction: column;
    }
    .upload-form .form-row .form-group {
        width: 100%;
        flex: none !important;
    }
    .upload-form .form-row .form-group input[type="number"] {
        width: 100% !important;
    }

    .linked-table thead { display: none; }
    .linked-table,
    .linked-table tbody,
    .linked-table tr,
    .linked-table td { display: block; width: 100%; box-sizing: border-box; }
    .linked-table tr {
        border: 1px solid #e0e0e0;
        border-radius: 6px;
        margin-bottom: 0.6rem;
        padding: 0.4rem 0.25rem;
        background: #fafafa;
    }
    .linked-table td {
        border: none;
        padding: 0.2rem 0.5rem;
        display: flex;
        align-items: baseline;
        gap: 0.5rem;
    }
    .linked-table td[data-label=""] {
        justify-content: flex-end;
        padding-top: 0.4rem;
    }
    .linked-table td::before {
        content: attr(data-label);
        font-weight: 600;
        font-size: 0.78rem;
        color: #888;
        min-width: 4.5rem;
        flex-shrink: 0;
    }
    .linked-table td[data-label=""]::before { display: none; }
}

.upload-form small {
    display: block;
    color: #888;
    font-size: 0.8rem;
    margin-top: 0.25rem;
}

/* ── Type study detail display ──────────────────────────────────────── */
.ts-detail-row {
    display: flex;
    gap: 2rem;
    flex-wrap: wrap;
    margin-bottom: 0.25rem;
}

.ts-detail-item {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}

.ts-detail-label {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #999;
}

.ts-detail-value {
    font-size: 1rem;
    color: #333;
    font-weight: 500;
}

/* ── Wiki body (Quill-rendered HTML) ───────────────────────────────── */
.mfr-wiki-body {
    line-height: 1.6;
    color: #333;
    font-size: 0.975rem;
}
.mfr-wiki-body h1, .mfr-wiki-body h2, .mfr-wiki-body h3 {
    color: #333;
    text-transform: none;
    letter-spacing: normal;
    font-weight: 600;
}
.mfr-wiki-body h1 { font-size: 1.4rem; margin: 1rem 0 0.2rem; }
.mfr-wiki-body h2 { font-size: 1.2rem; margin: 0.85rem 0 0.2rem; }
.mfr-wiki-body h3 { font-size: 0.975rem; margin: 0.65rem 0 0; }
.mfr-wiki-body h3:first-child { margin-top: 0; }
.mfr-wiki-body p { margin: 0; line-height: 1.3; }
.mfr-wiki-body p:has(> strong:first-child):not(:first-child) { margin-top: 0.65rem; }
.mfr-wiki-body ul, .mfr-wiki-body ol { padding-left: 1.5rem; margin-bottom: 0.5rem; }
.mfr-wiki-body li { margin-bottom: 0.15rem; }
.mfr-wiki-body a { color: #2980b9; }
.mfr-wiki-body a:hover { text-decoration: underline; }
.mfr-wiki-body strong { color: #333; }
.mfr-wiki-body img { max-width: min(400px, 100%); height: auto; border-radius: 4px; margin: 0.5rem 0; }
.mfr-wiki-body blockquote { border-left: 3px solid #ddd; margin: 0.5rem 0; padding: 0.25rem 1rem; color: #666; }

/* ── Type Study wiki toggle ─────────────────────────────────────────── */
.ts-wiki-toggle {
    margin-top: 0.75rem;
}

.ts-wiki-toggle summary {
    cursor: pointer;
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #666;
    user-select: none;
    padding: 0.25rem 0;
}

.ts-wiki-toggle summary:hover {
    color: #2c3e50;
}

.ts-wiki-body {
    margin-top: 0.5rem;
    padding: 0.5rem 0;
    border-top: 1px solid #eee;
}
.ts-wiki-body img { max-width: min(400px, 100%); height: auto; border-radius: 4px; margin: 0.5rem 0; }
.ql-container .ql-editor img { max-width: min(400px, 100%) !important; height: auto !important; }

/* ── Form container ─────────────────────────────────────────────────── */
.form-container {
    max-width: 100%;
    overflow-x: hidden;
}

/* ── Type entry cards ───────────────────────────────────────────────── */
.type-entry-card {
    padding: 0.75rem 0;
    border-bottom: 1px solid #f0f0f0;
    margin-bottom: 0.25rem;
}
.type-entry-card:last-child { border-bottom: none; }

/* ── Trademark filterable dropdown ──────────────────────────────────── */
.tm-wrap {
    position: relative;
    display: flex;
    align-items: center;
}

.tm-wrap input[type="text"] {
    width: 100%;
    padding: 0.5rem 2rem 0.5rem 0.75rem;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 1rem;
    color: #333;
}

.tm-wrap input[type="text"]:focus {
    outline: none;
    border-color: #2c3e50;
}

.tm-clear {
    position: absolute;
    right: 0.4rem;
    background: none;
    border: none;
    color: #bbb;
    font-size: 0.8rem;
    cursor: pointer;
    padding: 0.2rem 0.3rem;
    line-height: 1;
    border-radius: 3px;
}
.tm-clear:hover { color: #c0392b; }

.tm-dropdown {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: white;
    border: 1px solid #ddd;
    border-top: none;
    border-radius: 0 0 4px 4px;
    max-height: 360px;
    overflow-y: auto;
    z-index: 100;
    box-shadow: 0 4px 8px rgba(0,0,0,0.08);
}

.tm-dropdown.open { display: block; }

.tm-option {
    padding: 0.28rem 0.75rem;
    font-size: 0.9rem;
    cursor: pointer;
    color: #333;
    line-height: 1.4;
}

.tm-option:hover,
.tm-option.tm-highlighted { background: #eef2f7; }

.tm-option.tm-selected {
    background: #e8f0fe;
    font-weight: 500;
}

.tm-option.tm-none {
    color: #aaa;
    font-style: italic;
    cursor: default;
}

/* ── Upload label ────────────────────────────────────────────────────── */
.upload-label {
    font-weight: 500;
    font-size: 0.9rem;
    color: #555;
    margin-bottom: 0.5rem;
}

.upload-btn-row {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
    margin-bottom: 0.4rem;
}

.btn-upload-choice {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.45rem 1.1rem;
    border: 1.5px solid #c8d4df;
    border-radius: 6px;
    background: white;
    font-size: 0.9rem;
    color: #2c3e50;
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s;
}

.btn-upload-choice:hover {
    border-color: #2c3e50;
    background: #f0f4f8;
}

.upload-file-name {
    font-size: 0.85rem;
    color: #555;
    font-style: italic;
}

/* Lightbox */
#lightbox {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.88);
    z-index: 1000;
    justify-content: center;
    align-items: center;
    touch-action: none;
    overflow: hidden;
}

#lightbox img {
    max-width: 82vw;
    max-height: 88vh;
    object-fit: contain;
    border-radius: 4px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.5);
    cursor: pointer;
    transform-origin: center center;
    user-select: none;
    -webkit-user-drag: none;
    touch-action: none;
}

@media (max-width: 768px) {
    #lightbox img {
        max-width: 100vw;
        max-height: 100vh;
        border-radius: 0;
        box-shadow: none;
    }
}

.lightbox-close {
    position: fixed;
    top: 1rem;
    right: 1.25rem;
    background: none;
    border: none;
    color: white;
    font-size: 2rem;
    cursor: pointer;
    opacity: 0.7;
    line-height: 1;
    z-index: 1001;
}
.lightbox-close:hover { opacity: 1; }

.lightbox-nav {
    position: fixed;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(255,255,255,0.12);
    border: none;
    color: white;
    font-size: 3.5rem;
    line-height: 1;
    padding: 0.25rem 0.75rem;
    cursor: pointer;
    border-radius: 4px;
    z-index: 1001;
    transition: background 0.15s;
}
.lightbox-nav:hover  { background: rgba(255,255,255,0.25); }
.lightbox-prev { left:  0.75rem; }
.lightbox-next { right: 0.75rem; }

.lightbox-counter {
    position: fixed;
    bottom: 1.25rem;
    left: 50%;
    transform: translateX(-50%);
    color: rgba(255,255,255,0.75);
    font-size: 0.9rem;
    background: rgba(0,0,0,0.4);
    padding: 0.25rem 0.75rem;
    border-radius: 99px;
}

.photo-thumb {
    cursor: zoom-in;
    opacity: 0;
    transition: opacity 0.2s ease;
}
.photo-thumb.img-loaded { opacity: 1; }

.table-container {
    background: white;
    border-radius: 8px;
    overflow: hidden;
}

/* ── Visibility helpers ─────────────────────────────────────────────── */
.mobile-only  { display: none !important; }
.desktop-only { display: block !important; }

/* ── Mobile card list ───────────────────────────────────────────────── */
.card-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.coll-card {
    display: flex;
    gap: 0.75rem;
    align-items: flex-start;
    background: white;
    border-radius: 8px;
    padding: 0.75rem 1rem;
    text-decoration: none;
    color: inherit;
    border: 1px solid #e8e8e8;
    transition: border-color 0.15s, box-shadow 0.15s;
}

.coll-card-thumb {
    width: 72px;
    height: 72px;
    object-fit: cover;
    border-radius: 6px;
    flex-shrink: 0;
    opacity: 0;
    transition: opacity 0.2s ease;
}
.coll-card-thumb.img-loaded { opacity: 1; }

.coll-card-body {
    flex: 1;
    min-width: 0;
}

.coll-card:hover {
    border-color: #2c3e50;
    box-shadow: 0 2px 6px rgba(44,62,80,0.1);
}

.coll-card-header {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 0.5rem;
    margin-bottom: 0.2rem;
}

.coll-card-mfr {
    font-weight: 600;
    font-size: 1rem;
    color: #2c3e50;
}

.coll-card-id {
    font-size: 0.75rem;
    color: #aaa;
}

.coll-card-sub {
    font-size: 0.85rem;
    color: #666;
    margin-bottom: 0.4rem;
}

.coll-card-row {
    display: flex;
    gap: 0.6rem;
    flex-wrap: wrap;
    font-size: 0.85rem;
    color: #444;
}

.coll-card-label {
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #999;
    margin-right: 0.25rem;
}

/* ── Mobile top bar (hidden on desktop) ────────────────────────────── */
.mobile-topbar {
    display: none;
}

.sidebar-backdrop {
    display: none;
}

/* ── Mobile breakpoint ──────────────────────────────────────────────── */
@media (max-width: 768px) {

    /* Visibility helpers */
    .mobile-only  { display: flex !important; flex-direction: column; }
    .desktop-only { display: none !important; }

    /* Top bar */
    .mobile-topbar {
        display: flex;
        align-items: center;
        gap: 0.75rem;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        height: 52px;
        background: #2c3e50;
        color: white;
        padding: 0 1rem;
        z-index: 200;
    }

    .mobile-title {
        font-size: 1rem;
        font-weight: 600;
        color: white;
    }

    .hamburger {
        background: none;
        border: none;
        color: white;
        font-size: 1.4rem;
        cursor: pointer;
        padding: 0.25rem 0.4rem;
        line-height: 1;
    }

    /* Sidebar slides in from left as overlay */
    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        height: 100vh;
        z-index: 300;
        transform: translateX(-100%);
        transition: transform 0.25s ease;
        width: 240px;
    }

    body.sidebar-open .sidebar {
        transform: translateX(0);
    }

    /* Backdrop */
    .sidebar-backdrop {
        display: block;
        position: fixed;
        inset: 0;
        background: rgba(0,0,0,0.45);
        z-index: 250;
        opacity: 0;
        pointer-events: none;
        transition: opacity 0.25s ease;
    }

    body.sidebar-open .sidebar-backdrop {
        opacity: 1;
        pointer-events: auto;
    }

    /* Main content fills full width, shifted down below top bar */
    .main-content {
        margin-left: 0;
        padding: 1rem;
        padding-top: calc(52px + 1rem);
    }

    /* Table scrolls horizontally */
    .table-container {
        overflow-x: auto;
    }

    .table-container table {
        min-width: 600px;
    }

    /* Filter rows: all 4 elements on one row, compressed to fit */
    .filter-row-dyn {
        flex-wrap: nowrap !important;
        align-items: center;
        gap: 0.3rem;
    }

    .ff-field, .ff-op {
        flex: 1 1 0 !important;
        min-width: 0 !important;
        width: auto !important;
    }

    .ff-val-container {
        flex: 1 1 0 !important;
        min-width: 0 !important;
        width: auto !important;
    }

    .ff-remove {
        flex-shrink: 0;
        align-self: center;
    }

    /* Filter/sort footer stacks */
    .filter-builder-footer,
    .sort-builder-footer {
        flex-direction: column;
        align-items: stretch;
        gap: 0.5rem;
    }

    .filter-builder-actions {
        flex-wrap: wrap;
    }

    /* Page header stacks */
    .page-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.75rem;
    }
    .nav-controls {
        flex-wrap: nowrap;
        align-self: flex-end;
    }

    /* Forms stack */
    .form-row {
        flex-direction: column;
    }

    /* Checkbox groups stay horizontal and wrap on mobile */
    .form-row.form-row-inline {
        flex-direction: row;
        flex-wrap: wrap;
    }

    .form-col {
        width: 100%;
    }

    /* View grid single column */
    .view-grid {
        grid-template-columns: 1fr;
    }

    /* Saved filters bar: single row, select flex-shrinks to fit */
    .saved-filters-bar {
        gap: 0.4rem;
    }
    #saved-filter-select {
        min-width: 0 !important;
        flex: 1 1 0;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    /* Save filter form stacks */
    .save-filter-form form {
        flex-direction: column;
        align-items: stretch;
    }

    .save-filter-form .ff-input {
        min-width: unset;
    }

    /* Value + inputs fill their flex cell */
    .ff-val           { width: 100%; }
    .ff-input         { min-width: 0 !important; width: 100% !important; box-sizing: border-box; }
    /* Checkbox dropdown fills its flex cell */
    .filter-row-dyn .ff-checkbox-dropdown { display: block !important; width: 100% !important; }
    .filter-row-dyn .ff-checkbox-trigger  { width: 100% !important; max-width: none !important; box-sizing: border-box; }
    .filter-row-dyn .ff-checkbox-panel    { left: auto; right: 0; width: max-content; min-width: 220px; max-width: calc(100vw - 2rem); box-sizing: border-box; }

    /* Type entry cards: override fixed input widths */
    .type-entry-card .form-group {
        min-width: unset !important;
        width: 100%;
    }
    .type-entry-card .ff-input {
        width: 100% !important;
        min-width: unset;
    }
    .type-entry-card .form-row {
        gap: 0.5rem;
    }

    /* Add Type Entry form: same overrides as type-entry-card */
    .upload-form .form-group {
        min-width: unset !important;
        width: 100%;
    }
    .upload-form .form-row {
        gap: 0.5rem;
    }

    /* Form actions: wrap so buttons don't overflow on small screens */
    .form-actions {
        flex-wrap: wrap;
        gap: 0.5rem;
    }

    /* Main content: prevent any horizontal scrollbar */
    .main-content {
        overflow-x: hidden;
    }

    /* Photo cards: cap at 2 per row on mobile */
    .photo-card {
        width: calc(50% - 0.5rem);
        min-width: 120px;
    }

}

/* ── Filter checkbox dropdown ───────────────────────────────────────────── */
.ff-checkbox-dropdown { position: relative; display: inline-block; }

.ff-checkbox-trigger {
    text-align: left;
    cursor: pointer;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 260px;
    background: white;
    display: block;
}
.ff-checkbox-trigger:hover { border-color: #2c3e50; }

.ff-checkbox-panel {
    display: none;
    position: absolute;
    top: calc(100% + 2px);
    left: 0;
    background: white;
    border: 1px solid #ddd;
    border-radius: 4px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.12);
    z-index: 300;
    min-width: 200px;
    max-height: 280px;
    overflow-y: auto;
    padding: 0.3rem 0;
}
.ff-checkbox-panel.open { display: block; }

.ff-checkbox-option {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.3rem 0.75rem;
    cursor: pointer;
    font-size: 0.875rem;
    color: #333;
    user-select: none;
    font-weight: normal;
}
.ff-checkbox-option:hover { background: #eef2f7; }

.ff-checkbox-option input[type="checkbox"] {
    margin: 0;
    cursor: pointer;
    flex-shrink: 0;
    width: auto;
    min-width: unset;
    border: none;
    padding: 0;
}
/* ── Swipe navigation indicators & overlay ───────────────────────────────── */
.swipe-indicator {
    position: fixed;
    top: 50%;
    width: 44px;
    height: 72px;
    background: rgba(44, 62, 80, 0.8);
    color: white;
    font-size: 2.25rem;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    pointer-events: none;
    opacity: 0;
    will-change: transform, opacity;
}
.swipe-indicator-left {
    left: 0;
    border-radius: 0 8px 8px 0;
    transform: translateY(-50%) translateX(-100%);
}
.swipe-indicator-right {
    right: 0;
    border-radius: 8px 0 0 8px;
    transform: translateY(-50%) translateX(100%);
}
.swipe-overlay {
    position: fixed;
    inset: 0;
    background: white;
    z-index: 9998;
    opacity: 0;
    pointer-events: none;
    will-change: transform;
}

/* ── Page navigation progress bar ───────────────────────────────────────────── */
#page-progress {
    position: fixed;
    top: 0;
    left: 0;
    height: 3px;
    width: 0;
    background: #2c3e50;
    z-index: 10000;
    pointer-events: none;
    transition: none;
}
body.page-loading #page-progress {
    animation: progress-bar-run 2s ease-out forwards;
}
@keyframes progress-bar-run {
    0%   { width: 0;   opacity: 1; }
    50%  { width: 75%; opacity: 1; }
    90%  { width: 90%; opacity: 1; }
    100% { width: 90%; opacity: 1; }
}

/* Spinner on swipe overlay while server loads next page */
.swipe-overlay.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 36px;
    height: 36px;
    margin: -18px 0 0 -18px;
    border: 3px solid #e0e0e0;
    border-top-color: #2c3e50;
    border-radius: 50%;
    animation: spin 0.75s linear infinite;
}
@keyframes spin {
    to { transform: rotate(360deg); }
}
