/* ── Reset & Base ── */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

:root {
    --bg: #0f0f0f;
    --bg-card: #1a1a1a;
    --bg-elevated: #222;
    --bg-input: #1e1e1e;
    --border: #2a2a2a;
    --border-focus: #b8860b;
    --text: #e8e0d4;
    --text-muted: #8a8278;
    --text-dim: #5a554e;
    --accent: #d4a043;
    --accent-hover: #e6b454;
    --danger: #c0392b;
    --danger-bg: rgba(192, 57, 43, 0.15);
    --success: #27ae60;
    --radius: 10px;
    --radius-sm: 6px;
    --shadow: 0 2px 12px rgba(0,0,0,0.4);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
    -webkit-tap-highlight-color: transparent;
    -webkit-font-smoothing: antialiased;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 16px;
}

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

code { background: var(--bg-elevated); padding: 2px 6px; border-radius: 4px; font-size: 0.85em; }

/* ── Header ── */
.header {
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    padding: 12px 0;
    position: sticky;
    top: 0;
    z-index: 100;
    backdrop-filter: blur(10px);
}

.header-inner {
    display: flex;
    align-items: center;
    gap: 16px;
}

.logo {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--accent) !important;
    white-space: nowrap;
    flex-shrink: 0;
}

.logo-icon { flex-shrink: 0; }

.search-form { flex: 1; max-width: 480px; }

.search-wrapper { position: relative; }

.search-input {
    width: 100%;
    padding: 8px 36px 8px 14px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 20px;
    color: var(--text);
    font-size: 0.9rem;
    transition: border-color 0.2s;
}
.search-input:focus { outline: none; border-color: var(--border-focus); }
.search-input::placeholder { color: var(--text-dim); }

.search-clear {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    background: var(--bg-elevated);
    border: none;
    color: var(--text-muted);
    width: 22px;
    height: 22px;
    border-radius: 50%;
    font-size: 1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    transition: color 0.15s;
}
.search-clear:hover { color: var(--text); }

.header-right { margin-left: auto; flex-shrink: 0; }

/* ── Dropdown ── */
.dropdown { position: relative; }

.dropdown-toggle {
    display: flex;
    align-items: center;
    gap: 6px;
}

.dropdown-menu {
    display: none;
    position: absolute;
    right: 0;
    top: calc(100% + 6px);
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    min-width: 180px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.4);
    z-index: 200;
    overflow: hidden;
    transform-origin: top right;
}

.dropdown-menu.open {
    display: block;
    animation: dropdownIn 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes dropdownIn { from { opacity: 0; transform: scale(0.95) translateY(-4px); } to { opacity: 1; transform: scale(1) translateY(0); } }

.dropdown-item {
    display: block;
    padding: 10px 16px;
    color: var(--text);
    transition: background 0.15s;
}
.dropdown-item:hover { background: var(--bg-card); color: var(--text); }
.dropdown-item--danger { color: var(--danger); }

/* ── Buttons ── */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 18px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-elevated);
    color: var(--text);
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.15s;
    text-decoration: none;
    white-space: nowrap;
    font-family: inherit;
}
.btn:hover { border-color: var(--text-muted); color: var(--text); }
.btn:active { transform: scale(0.97); transition-duration: 0.08s; }

.btn-primary {
    background: var(--accent);
    color: #0f0f0f;
    border-color: var(--accent);
    font-weight: 600;
}
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); color: #0f0f0f; }

.btn-ghost { background: transparent; border-color: transparent; }
.btn-ghost:hover { background: var(--bg-elevated); border-color: var(--border); }

.btn-danger { color: var(--danger); border-color: var(--danger); background: transparent; }
.btn-danger:hover { background: var(--danger-bg); }

.btn-sm { padding: 4px 12px; font-size: 0.8rem; }
.btn-block { width: 100%; justify-content: center; }

.btn-icon {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.2rem;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 4px;
    line-height: 1;
}
.btn-icon:hover { color: var(--text); background: var(--bg-card); }
.btn-icon-danger:hover { color: var(--danger); background: var(--danger-bg); }

/* ── Page header ── */
.main { padding-top: 24px; padding-bottom: 40px; }

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
    flex-wrap: wrap;
    gap: 12px;
}
.page-header h1 { font-size: 1.5rem; color: var(--text); }

.actions { display: flex; gap: 8px; align-items: center; }
.inline-form { display: inline; }

/* ── Filters ── */
.filters { margin-bottom: 24px; }

.filters-form {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
}

.filter-select {
    padding: 8px 12px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-size: 0.9rem;
    cursor: pointer;
}
.filter-select:focus { outline: none; border-color: var(--border-focus); }

/* ── Grid ── */
.grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 16px;
}

/* ── Card ── */
.card {
    background: var(--bg-card);
    border-radius: var(--radius);
    overflow: hidden;
    border: 1px solid var(--border);
    text-decoration: none;
    color: inherit;
    transition: border-color 0.3s ease, transform 0.3s ease, box-shadow 0.3s ease;
    will-change: transform;
}
.card:hover {
    border-color: var(--accent);
    transform: translateY(-3px);
    box-shadow: 0 8px 24px rgba(0,0,0,0.3);
    color: inherit;
}
.card:active {
    transform: scale(0.98);
    transition-duration: 0.1s;
}

.card-image {
    aspect-ratio: 1;
    overflow: hidden;
    background: var(--bg);
    position: relative;
}

.card-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.card-placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 3.5rem;
    opacity: 0.15;
}

.card-body { padding: 12px 14px; }
.card-body h3 { font-size: 0.95rem; margin-bottom: 6px; color: var(--text); }

.card-meta { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 6px; }

.card-tags { display: flex; gap: 6px; flex-wrap: wrap; }

.badge {
    display: inline-block;
    padding: 2px 10px;
    background: var(--bg-elevated);
    border-radius: 20px;
    font-size: 0.75rem;
    color: var(--text-muted);
    border: 1px solid var(--border);
}

.badge-category {
    background: rgba(212, 160, 67, 0.15);
    color: var(--accent);
    border-color: rgba(212, 160, 67, 0.3);
}

.badge-lg { padding: 4px 14px; font-size: 0.85rem; }

.tag {
    font-size: 0.75rem;
    color: var(--text-dim);
}

/* ── Carousel ── */
.carousel {
    position: relative;
    width: 100%;
    height: 100%;
}

.carousel-slide {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    opacity: 0;
    transition: opacity 0.3s;
}
.carousel-slide.active { opacity: 1; }

.carousel-btn {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(0,0,0,0.5);
    color: #fff;
    border: none;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    font-size: 1.2rem;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.2s;
    z-index: 2;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}
.carousel:hover .carousel-btn { opacity: 1; }
.carousel-prev { left: 8px; }
.carousel-next { right: 8px; }

.carousel-dots {
    position: absolute;
    bottom: 8px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 5px;
    z-index: 2;
}

.dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: rgba(255,255,255,0.4);
    transition: background 0.2s;
}
.dot.active { background: #fff; }

/* ── Bottle navigation ── */
.bottle-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    gap: 12px;
}

.bottle-nav-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 8px 14px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    font-size: 0.85rem;
    transition: all 0.15s;
}
.bottle-nav-btn:hover { border-color: var(--accent); color: var(--accent); }
.bottle-nav-btn svg { flex-shrink: 0; }

.bottle-nav-counter {
    color: var(--text-dim);
    font-size: 0.85rem;
}

/* Swipe hint on mobile */
@media (max-width: 768px) {
    .detail {
        transition: transform 0.25s ease, opacity 0.25s ease;
    }
    .bottle-nav-btn { font-size: 0; padding: 10px 14px; }
    .bottle-nav-btn svg { width: 24px; height: 24px; }
}

/* ── Tag chips (editable) ── */
.tag-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 8px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    min-height: 42px;
    cursor: text;
    transition: border-color 0.2s;
}
.tag-chips:focus-within { border-color: var(--border-focus); }

.tag-chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 8px 3px 10px;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: 20px;
    font-size: 0.8rem;
    color: var(--text-muted);
}

.tag-chip-remove {
    background: none;
    border: none;
    color: var(--text-dim);
    cursor: pointer;
    font-size: 1rem;
    line-height: 1;
    padding: 0 2px;
    border-radius: 50%;
    transition: color 0.15s;
}
.tag-chip-remove:hover { color: var(--danger); }

.tag-chip-removing {
    animation: chipRemove 0.2s ease forwards;
}

@keyframes chipRemove { to { opacity: 0; transform: scale(0.8); } }

.tag-chips-input {
    border: none;
    background: transparent;
    color: var(--text);
    font-size: 0.85rem;
    outline: none;
    min-width: 80px;
    flex: 1;
    padding: 2px 0;
    font-family: inherit;
}
.tag-chips-input::placeholder { color: var(--text-dim); }

/* ── Empty state ── */
.empty-state {
    text-align: center;
    padding: 80px 20px;
    color: var(--text-dim);
}
.empty-state p { margin-bottom: 16px; font-size: 1.1rem; }

/* ── Detail page ── */
.detail {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0;
    background: var(--bg-card);
    border-radius: var(--radius);
    overflow: hidden;
    border: 1px solid var(--border);
}

.detail-image {
    aspect-ratio: 1;
    background: var(--bg);
    position: relative;
}
.detail-image img { width: 100%; height: 100%; object-fit: cover; }

.detail-placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 5rem;
    opacity: 0.1;
}

.detail-info { padding: 32px; }
.detail-info h1 { font-size: 1.5rem; margin-bottom: 12px; }
.detail-desc { color: var(--text-muted); margin: 16px 0; line-height: 1.7; }

.props {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 8px 20px;
    margin: 20px 0;
}
.props dt { color: var(--text-dim); font-size: 0.9rem; }
.props dd { font-size: 0.9rem; }

.detail-tags { display: flex; gap: 8px; flex-wrap: wrap; margin: 16px 0; }
.detail-tags .tag { font-size: 0.85rem; color: var(--accent); }
.detail-tags .tag:hover { text-decoration: underline; }

.detail-date { color: var(--text-dim); font-size: 0.8rem; margin-top: 20px; }

/* ── Form ── */
.form {
    background: var(--bg-card);
    padding: 28px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    max-width: 680px;
}

.form-group { margin-bottom: 20px; }

.form-group label {
    display: block;
    margin-bottom: 6px;
    font-weight: 500;
    font-size: 0.9rem;
    color: var(--text-muted);
}

.form-group label small { color: var(--text-dim); font-weight: 400; }

.form-group input[type="text"],
.form-group input[type="number"],
.form-group input[type="password"],
.form-group textarea,
.form-group select {
    width: 100%;
    padding: 10px 12px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-size: 1rem;
    font-family: inherit;
    transition: border-color 0.2s;
}
.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--border-focus);
}

.form-group input[type="file"] {
    color: var(--text-muted);
    font-size: 0.9rem;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 16px;
}

.form-actions {
    display: flex;
    gap: 12px;
    margin-top: 24px;
}

.checkbox-label {
    display: flex !important;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    color: var(--text) !important;
}

.category-select-wrapper {
    display: flex;
    gap: 8px;
    align-items: stretch;
}
.category-select-wrapper select { flex: 1; }

/* ── Category manager ── */
.category-manager {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 16px;
    margin-bottom: 20px;
}
.category-manager h4 { font-size: 0.9rem; margin-bottom: 12px; color: var(--text-muted); }

.category-add {
    display: flex;
    gap: 8px;
    margin-bottom: 12px;
}
.category-add input {
    flex: 1;
    padding: 6px 10px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-size: 0.85rem;
}
.category-add input:focus { outline: none; border-color: var(--border-focus); }

.category-list {
    list-style: none;
    max-height: 200px;
    overflow-y: auto;
}
.category-list li {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 8px;
    border-radius: 4px;
    font-size: 0.85rem;
}
.category-list li:hover { background: var(--bg-card); }

/* ── Tags ── */
.tags-suggestions {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    margin-top: 8px;
}

.tag-clickable {
    cursor: pointer;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 2px 10px;
    color: var(--text-dim);
    font-size: 0.75rem;
    transition: all 0.15s;
}
.tag-clickable:hover { border-color: var(--accent); color: var(--accent); }

.tag-suggestion {
    display: inline-flex;
    align-items: center;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: 20px;
    font-size: 0.75rem;
    color: var(--text-dim);
    transition: all 0.15s;
    overflow: hidden;
}

.tag-suggestion-add {
    padding: 2px 4px 2px 10px;
    cursor: pointer;
    transition: color 0.15s;
}
.tag-suggestion-add:hover { color: var(--accent); }

.tag-suggestion-delete {
    background: none;
    border: none;
    border-left: 1px solid var(--border);
    color: var(--text-dim);
    cursor: pointer;
    padding: 2px 7px;
    font-size: 0.85rem;
    line-height: 1;
    transition: all 0.15s;
}
.tag-suggestion-delete:hover { color: var(--danger); background: var(--danger-bg); }

/* ── Existing images ── */
.existing-images {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 12px;
}

.existing-image {
    position: relative;
    width: 100px;
    height: 100px;
    border-radius: var(--radius-sm);
    overflow: hidden;
    border: 1px solid var(--border);
}

.existing-image img { width: 100%; height: 100%; object-fit: cover; }

.img-delete-btn {
    position: absolute;
    top: 4px;
    right: 4px;
    background: rgba(192, 57, 43, 0.85);
    color: #fff;
    border: none;
    border-radius: 50%;
    width: 26px;
    height: 26px;
    font-size: 1.1rem;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.15s, transform 0.15s;
    padding: 0;
}
.img-delete-btn:hover { background: rgba(192, 57, 43, 1); transform: scale(1.1); }

/* ── Image preview & OCR ── */
.image-preview-list {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-top: 10px;
}

.image-preview-thumb {
    width: 80px;
    height: 80px;
    object-fit: cover;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
}

.ocr-status {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 10px;
    color: var(--accent);
    font-size: 0.85rem;
}

.ocr-spinner {
    width: 16px;
    height: 16px;
    border: 2px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

/* ── Auth page ── */
.auth-page {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 60vh;
}

.auth-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 36px;
    width: 100%;
    max-width: 380px;
}
.auth-card h1 { text-align: center; margin-bottom: 24px; font-size: 1.4rem; }

.auth-logo {
    text-align: center;
    margin-bottom: 16px;
    opacity: 0.8;
}

/* ── Table ── */
.table-responsive { overflow-x: auto; }

.table {
    width: 100%;
    border-collapse: collapse;
    background: var(--bg-card);
    border-radius: var(--radius);
    overflow: hidden;
    border: 1px solid var(--border);
}

.table th, .table td {
    padding: 12px 16px;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

.table th {
    background: var(--bg-elevated);
    color: var(--text-muted);
    font-size: 0.85rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.table-actions { display: flex; gap: 6px; justify-content: flex-end; }

/* ── Alert ── */
.alert {
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    margin-bottom: 20px;
    font-size: 0.9rem;
}
.alert-error {
    background: var(--danger-bg);
    color: var(--danger);
    border: 1px solid rgba(192, 57, 43, 0.3);
}
.alert-info {
    background: rgba(212, 160, 67, 0.1);
    color: var(--accent);
    border: 1px solid rgba(212, 160, 67, 0.25);
}

/* ── Toast ── */
.toast-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.toast {
    padding: 14px 22px;
    border-radius: var(--radius);
    color: #fff;
    font-size: 0.9rem;
    font-weight: 500;
    animation: toastIn 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
    box-shadow: 0 8px 24px rgba(0,0,0,0.4);
    backdrop-filter: blur(8px);
}
.toast-out { animation: toastOut 0.3s ease forwards; }
.toast-success { background: rgba(39, 174, 96, 0.92); }
.toast-error { background: rgba(192, 57, 43, 0.92); }

@keyframes toastIn { from { opacity: 0; transform: translateY(20px) scale(0.95); } to { opacity: 1; transform: translateY(0) scale(1); } }
@keyframes toastOut { from { opacity: 1; transform: translateY(0); } to { opacity: 0; transform: translateY(-10px); } }

/* ── Modal ── */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.6);
    z-index: 500;
    justify-content: center;
    align-items: flex-end;
    backdrop-filter: blur(6px);
    padding: 16px;
}
.modal-overlay.open { display: flex; }

.modal {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 28px;
    max-width: 400px;
    width: 100%;
    box-shadow: 0 -4px 32px rgba(0,0,0,0.4);
    animation: modalSlideUp 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.modal h3 { margin-bottom: 12px; }
.modal p { color: var(--text-muted); margin-bottom: 20px; font-size: 0.95rem; }
.modal-actions { display: flex; gap: 10px; }
.modal-actions .btn { flex: 1; justify-content: center; }

@keyframes modalSlideUp { from { opacity: 0; transform: translateY(40px); } to { opacity: 1; transform: translateY(0); } }

@media (min-width: 769px) {
    .modal-overlay { align-items: center; }
}

/* ── Skeleton loading ── */
.skeleton {
    background: linear-gradient(90deg, var(--bg-elevated) 25%, var(--border) 50%, var(--bg-elevated) 75%);
    background-size: 200% 100%;
    animation: skeleton 1.5s infinite;
    border-radius: var(--radius-sm);
}
.skeleton-card { height: 300px; border-radius: var(--radius); }
.skeleton-text { height: 16px; margin-bottom: 8px; }
.skeleton-text:last-child { width: 60%; }

@keyframes skeleton { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

/* ── Lightbox ── */
.lightbox {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.92);
    z-index: 600;
    justify-content: center;
    align-items: center;
    cursor: zoom-out;
    backdrop-filter: blur(8px);
    animation: fadeIn 0.2s ease;
}
.lightbox.open { display: flex; }
.lightbox img {
    max-width: 95vw;
    max-height: 90vh;
    object-fit: contain;
    border-radius: 4px;
}
.lightbox-close {
    position: absolute;
    top: 16px;
    right: 16px;
    background: rgba(255,255,255,0.1);
    border: none;
    color: #fff;
    font-size: 1.8rem;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

/* ── Detail extras ── */
.detail-badges { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 4px; }
.detail-badges a.badge { text-decoration: none; }
.detail-badges a.badge:hover { border-color: var(--accent); color: var(--accent); }

.detail-notes {
    margin: 16px 0;
    padding: 12px 16px;
    background: var(--bg-elevated);
    border-radius: var(--radius-sm);
    border-left: 3px solid var(--accent);
    font-size: 0.9rem;
}
.detail-notes strong { color: var(--text-muted); font-size: 0.8rem; display: block; margin-bottom: 4px; }
.detail-notes p { color: var(--text); margin: 0; }

/* ── Card tag links ── */
.card-tag-link { cursor: pointer; transition: color 0.15s; }
.card-tag-link:hover { color: var(--accent); }

/* ── Stats ── */
.stats-total {
    text-align: center;
    padding: 32px 0;
}
.stats-total-number {
    font-size: 3.5rem;
    font-weight: 700;
    color: var(--accent);
    line-height: 1;
}
.stats-total-label {
    color: var(--text-muted);
    font-size: 1rem;
    margin-top: 8px;
}

.stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 40px;
}

.stats-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
}
.stats-card h2 {
    font-size: 1rem;
    color: var(--text-muted);
    margin-bottom: 16px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 500;
}

.stats-bars { display: flex; flex-direction: column; gap: 10px; }

.stats-bar-row {
    display: flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
    color: var(--text);
    transition: opacity 0.15s;
}
.stats-bar-row:hover { opacity: 0.8; color: var(--text); }

.stats-bar-label { min-width: 90px; font-size: 0.85rem; color: var(--text-muted); }
.stats-bar-track { flex: 1; height: 8px; background: var(--bg); border-radius: 4px; overflow: hidden; }
.stats-bar-fill {
    height: 100%;
    border-radius: 4px;
    transition: width 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.stats-bar-fill-accent { background: var(--accent); }
.stats-bar-fill-green { background: var(--success); }
.stats-bar-count { font-size: 0.85rem; font-weight: 600; min-width: 24px; text-align: right; }

.stats-tags-cloud { display: flex; flex-wrap: wrap; gap: 8px; }

.stats-tag {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: 20px;
    color: var(--text-muted);
    font-size: 0.85rem;
    text-decoration: none;
    transition: all 0.15s;
}
.stats-tag:hover { border-color: var(--accent); color: var(--accent); }
.stats-tag-count {
    background: var(--bg);
    padding: 1px 7px;
    border-radius: 10px;
    font-size: 0.75rem;
    font-weight: 600;
}

.stats-empty { color: var(--text-dim); font-size: 0.9rem; }

/* ── Footer ── */
.page-footer {
    text-align: center;
    padding: 32px 0;
    color: var(--text-dim);
    font-size: 0.9rem;
}
.page-footer a { color: var(--text-muted); }
.page-footer a:hover { color: var(--accent); }

/* ── Confetti ── */
.confetti-piece {
    position: fixed;
    width: 8px;
    height: 8px;
    border-radius: 2px;
    pointer-events: none;
    z-index: 9999;
    animation: confettiFall 2.5s ease-out forwards;
}

@keyframes confettiFall {
    0% { opacity: 1; transform: translateY(0) rotate(0deg) scale(1); }
    100% { opacity: 0; transform: translateY(100vh) rotate(720deg) scale(0.5); }
}

/* ── Responsive ── */
@media (max-width: 768px) {
    .stats-grid { grid-template-columns: 1fr; }
    .header-inner { flex-wrap: wrap; }
    .search-form { order: 3; max-width: 100%; flex-basis: 100%; }

    .detail { grid-template-columns: 1fr; }
    .detail-info { padding: 20px; }
    .detail-image { aspect-ratio: 4/3; }

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

    .grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; }

    .page-header h1 { font-size: 1.2rem; }

    .table th, .table td { padding: 8px 10px; font-size: 0.85rem; }
}

@media (max-width: 480px) {
    .grid { grid-template-columns: 1fr 1fr; }
    .filters-form { flex-direction: column; }
    .filter-select { width: 100%; }
}
