/* ============================================
   mari-library - Dark Theme Styles
   ============================================ */

:root {
    --bg-primary: #0f0f13;
    --bg-secondary: #1a1a24;
    --bg-tertiary: #22222e;
    --bg-card: #1e1e2a;
    --bg-hover: #282838;
    --bg-input: #1a1a24;
    --border: #2a2a3a;
    --border-light: #333345;
    --text-primary: #e8e8f0;
    --text-secondary: #9898b0;
    --text-muted: #6868a0;
    --accent: #7c5bf5;
    --accent-light: #9b7ff7;
    --accent-dark: #5a3dd4;
    --accent-glow: rgba(124, 91, 245, 0.15);
    --success: #48bb78;
    --error: #e53e3e;
    --warning: #ecc94b;
    --info: #63b3ed;
    --status-reading: #63b3ed;
    --status-completed: #48bb78;
    --status-plan: #ecc94b;
    --status-dropped: #e53e3e;
    --status-rereading: #9b7ff7;
    --radius: 12px;
    --radius-sm: 8px;
    --radius-xs: 6px;
    --shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 8px 40px rgba(0, 0, 0, 0.4);
    --transition: all 0.2s ease;
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}

/* ============================================
   Login Screen
   ============================================ */
.login-screen {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #0f0f13 0%, #1a1025 50%, #0f0f13 100%);
    position: relative;
    overflow: hidden;
}

.login-screen::before {
    content: '';
    position: absolute;
    width: 600px;
    height: 600px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(124, 91, 245, 0.08) 0%, transparent 70%);
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

.login-container {
    background: var(--bg-secondary);
    padding: 50px 40px;
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 400px;
    border: 1px solid var(--border);
    position: relative;
    z-index: 1;
}

.login-logo {
    text-align: center;
    margin-bottom: 36px;
}

.login-icon {
    font-size: 48px;
    display: block;
    margin-bottom: 12px;
}

.login-logo h1 {
    font-size: 28px;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.02em;
}

.login-logo p {
    font-size: 14px;
    color: var(--text-muted);
    margin-top: 4px;
}

.login-form .form-group {
    margin-bottom: 16px;
}

.login-form input {
    width: 100%;
    padding: 14px 16px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 15px;
    transition: var(--transition);
    font-family: inherit;
}

.login-form input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

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

.login-error {
    margin-top: 16px;
    padding: 12px 16px;
    background: rgba(229, 62, 62, 0.1);
    border: 1px solid rgba(229, 62, 62, 0.3);
    border-radius: var(--radius-sm);
    color: var(--error);
    font-size: 14px;
    text-align: center;
}

/* ============================================
   Buttons
   ============================================ */
.btn-primary {
    width: 100%;
    padding: 14px 24px;
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    font-family: inherit;
}

.btn-primary:hover {
    background: var(--accent-light);
    transform: translateY(-1px);
    box-shadow: 0 4px 15px rgba(124, 91, 245, 0.3);
}

.btn-primary:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.btn-cancel {
    padding: 12px 24px;
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    font-family: inherit;
}

.btn-cancel:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.btn-add {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    font-family: inherit;
}

.btn-add:hover {
    background: var(--accent-light);
    transform: translateY(-1px);
}

.btn-icon {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-secondary);
    width: 40px;
    height: 40px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--transition);
}

.btn-icon:hover {
    background: var(--bg-hover);
    color: var(--error);
    border-color: var(--error);
}

.btn-search {
    padding: 10px 20px;
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    font-family: inherit;
    white-space: nowrap;
}

.btn-search:hover { background: var(--accent-light); }

/* ============================================
   Header
   ============================================ */
.app-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 32px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.header-logo { font-size: 28px; }

.header-title {
    font-size: 20px;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.header-stats {
    display: flex;
    gap: 32px;
}

.stat-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
}

.stat-value {
    font-size: 22px;
    font-weight: 700;
    color: var(--accent-light);
}

.stat-label {
    font-size: 11px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* ============================================
   Tabs
   ============================================ */
.tabs-nav {
    display: flex;
    gap: 0;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    padding: 0 32px;
}

.tab-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 14px 24px;
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    color: var(--text-muted);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    font-family: inherit;
}

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

.tab-btn.active {
    color: var(--accent-light);
    border-bottom-color: var(--accent);
}

.tab-icon { font-size: 18px; }

.tab-count {
    background: var(--bg-tertiary);
    color: var(--text-muted);
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 12px;
    font-weight: 600;
}

.tab-btn.active .tab-count {
    background: var(--accent-glow);
    color: var(--accent-light);
}

/* ============================================
   Toolbar
   ============================================ */
.toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 32px;
    gap: 16px;
    flex-wrap: wrap;
}

.toolbar-left {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    flex: 1;
}

.search-box {
    position: relative;
    flex: 1;
    min-width: 200px;
    max-width: 350px;
}

.search-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    pointer-events: none;
}

.search-box input {
    width: 100%;
    padding: 10px 12px 10px 40px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 14px;
    transition: var(--transition);
    font-family: inherit;
}

.search-box input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

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

.filters-row {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.filter-select {
    padding: 10px 12px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 13px;
    cursor: pointer;
    transition: var(--transition);
    font-family: inherit;
}

.filter-select:focus {
    outline: none;
    border-color: var(--accent);
}

/* ============================================
   Collection Grid
   ============================================ */
.collection-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 20px;
    padding: 20px 32px 40px;
}

/* ============================================
   Book/Manga Card
   ============================================ */
.item-card {
    background: var(--bg-card);
    border-radius: var(--radius);
    overflow: hidden;
    cursor: pointer;
    transition: var(--transition);
    border: 1px solid var(--border);
    position: relative;
}

.item-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.4);
    border-color: var(--border-light);
}

.item-card-cover {
    width: 100%;
    aspect-ratio: 2/3;
    object-fit: cover;
    display: block;
    background: var(--bg-tertiary);
}

.item-card-nocover {
    width: 100%;
    aspect-ratio: 2/3;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-tertiary);
    font-size: 48px;
    opacity: 0.3;
}

.item-card-info {
    padding: 12px 14px 14px;
}

.item-card-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    line-height: 1.3;
    margin-bottom: 4px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.item-card-author {
    font-size: 12px;
    color: var(--text-muted);
    margin-bottom: 8px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.item-card-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
}

.item-card-status {
    padding: 3px 8px;
    border-radius: 20px;
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.status-lendo { background: rgba(99, 179, 237, 0.15); color: var(--status-reading); }
.status-lido { background: rgba(72, 187, 120, 0.15); color: var(--status-completed); }
.status-quero_ler { background: rgba(236, 201, 75, 0.15); color: var(--status-plan); }
.status-quero_comprar { background: rgba(237, 137, 54, 0.15); color: #ed8936; }
.status-dropado { background: rgba(229, 62, 62, 0.15); color: var(--status-dropped); }
.status-relendo { background: rgba(155, 127, 247, 0.15); color: var(--status-rereading); }

.item-card-rating {
    font-size: 12px;
    color: var(--warning);
    font-weight: 600;
}

.item-card-volumes {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 4px;
}

/* ============================================
   Skeleton Loader
   ============================================ */
.skeleton-card {
    border-radius: var(--radius);
    overflow: hidden;
    background: var(--bg-card);
    border: 1px solid var(--border);
}

.skeleton-card::before {
    content: '';
    display: block;
    aspect-ratio: 2/3;
    background: linear-gradient(90deg, var(--bg-tertiary) 25%, var(--bg-hover) 50%, var(--bg-tertiary) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
}

.skeleton-card::after {
    content: '';
    display: block;
    height: 80px;
    background: var(--bg-card);
}

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

/* ============================================
   Empty State
   ============================================ */
.empty-state {
    text-align: center;
    padding: 80px 32px;
}

.empty-icon {
    font-size: 64px;
    display: block;
    margin-bottom: 16px;
    opacity: 0.5;
}

.empty-state h3 {
    font-size: 20px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.empty-state p {
    color: var(--text-muted);
    margin-bottom: 24px;
}

/* ============================================
   Modal
   ============================================ */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(8px);
    animation: fadeIn 0.2s ease;
    overflow-y: auto;
}

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

.modal-content {
    background: var(--bg-secondary);
    margin: 40px auto;
    border-radius: var(--radius);
    width: 95%;
    max-width: 700px;
    padding: 32px;
    position: relative;
    border: 1px solid var(--border);
    animation: slideUp 0.3s ease;
    max-height: calc(100vh - 80px);
    overflow-y: auto;
}

.modal-content.modal-large {
    max-width: 800px;
}

.modal-content.modal-detail {
    max-width: 900px;
    padding: 0;
}

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

.modal-close {
    position: absolute;
    right: 16px;
    top: 16px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 20px;
    transition: var(--transition);
    z-index: 10;
}

.modal-close:hover {
    background: var(--error);
    color: #fff;
    border-color: var(--error);
}

.modal-content h3 {
    font-size: 22px;
    font-weight: 700;
    margin-bottom: 24px;
    color: var(--text-primary);
    padding-right: 40px;
}

/* ============================================
   API Search Section
   ============================================ */
.api-search-section {
    margin-bottom: 20px;
}

.api-search-box {
    display: flex;
}

.api-search-box input {
    flex: 1;
    padding: 12px 16px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm) 0 0 var(--radius-sm);
    color: var(--text-primary);
    font-size: 14px;
    font-family: inherit;
}

.api-search-box input:focus {
    outline: none;
    border-color: var(--accent);
}

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

.api-results {
    margin-top: 12px;
    max-height: 300px;
    overflow-y: auto;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-tertiary);
}

.api-result-item {
    display: flex;
    gap: 12px;
    padding: 12px;
    cursor: pointer;
    transition: var(--transition);
    border-bottom: 1px solid var(--border);
}

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

.api-result-item:hover {
    background: var(--bg-hover);
}

.api-result-cover {
    width: 50px;
    height: 70px;
    object-fit: cover;
    border-radius: var(--radius-xs);
    background: var(--bg-secondary);
    flex-shrink: 0;
}

.api-result-nocover {
    width: 50px;
    height: 70px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-secondary);
    border-radius: var(--radius-xs);
    font-size: 20px;
    opacity: 0.4;
    flex-shrink: 0;
}

.api-result-info {
    flex: 1;
    min-width: 0;
}

.api-result-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.api-result-meta {
    font-size: 12px;
    color: var(--text-muted);
    line-height: 1.4;
}

.api-loading {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 20px;
    color: var(--text-muted);
    font-size: 14px;
}

.divider {
    display: flex;
    align-items: center;
    gap: 16px;
    margin: 20px 0;
    color: var(--text-muted);
    font-size: 13px;
}

.divider::before, .divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--border);
}

/* ============================================
   Form Styles
   ============================================ */
.item-form .form-section {
    margin-bottom: 24px;
}

.item-form .form-section h4 {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 14px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border);
}

.form-row {
    display: flex;
    gap: 12px;
    margin-bottom: 12px;
}

.form-group {
    flex: 1;
}

.flex-2 { flex: 2; }
.flex-1 { flex: 1; }

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

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 10px 12px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-xs);
    color: var(--text-primary);
    font-size: 14px;
    transition: var(--transition);
    font-family: inherit;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

.form-group input::placeholder,
.form-group textarea::placeholder {
    color: var(--text-muted);
}

.form-group textarea {
    resize: vertical;
}

/* Rating Input */
.rating-input {
    display: flex;
    align-items: center;
    gap: 12px;
}

.rating-input input[type="range"] {
    flex: 1;
    accent-color: var(--accent);
    height: 6px;
    cursor: pointer;
}

.rating-display {
    background: var(--accent);
    color: #fff;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: 700;
    flex-shrink: 0;
}

/* Cover Preview */
.cover-preview-row {
    display: flex;
    gap: 20px;
    align-items: flex-start;
}

.cover-preview {
    width: 140px;
    height: 200px;
    border-radius: var(--radius-sm);
    overflow: hidden;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

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

.cover-placeholder {
    color: var(--text-muted);
    font-size: 13px;
}

.cover-actions {
    flex: 1;
}

/* Upload Area */
.upload-area {
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    padding: 30px 20px;
    text-align: center;
    cursor: pointer;
    transition: var(--transition);
    background: var(--bg-tertiary);
}

.upload-area:hover {
    border-color: var(--accent);
    background: var(--accent-glow);
}

.upload-area.drag-over {
    border-color: var(--accent);
    background: var(--accent-glow);
    transform: scale(1.01);
}

.upload-placeholder { pointer-events: none; }

.upload-icon {
    font-size: 32px;
    display: block;
    margin-bottom: 8px;
}

.upload-area p {
    color: var(--text-secondary);
    font-size: 14px;
    margin-bottom: 4px;
}

.upload-area small {
    color: var(--text-muted);
    font-size: 12px;
}

/* Camera Button */
.btn-camera {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 12px 16px;
    margin-top: 8px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    font-family: inherit;
}

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

.btn-camera span {
    font-size: 18px;
}

/* Form Actions */
.form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    margin-top: 24px;
    padding-top: 20px;
    border-top: 1px solid var(--border);
}

.form-actions .btn-primary {
    width: auto;
    min-width: 140px;
}

/* ============================================
   Detail Modal
   ============================================ */
.detail-layout {
    display: grid;
    grid-template-columns: 280px 1fr;
    min-height: 400px;
}

.detail-cover-section {
    background: var(--bg-tertiary);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 30px;
}

.detail-cover-section img {
    width: 100%;
    max-width: 220px;
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-lg);
}

.detail-cover-noimg {
    width: 200px;
    height: 280px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-secondary);
    border-radius: var(--radius-sm);
    font-size: 64px;
    opacity: 0.3;
}

.detail-info-section {
    padding: 32px;
    overflow-y: auto;
    max-height: calc(100vh - 120px);
}

.detail-title {
    font-size: 24px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 4px;
    padding-right: 40px;
}

.detail-author {
    font-size: 15px;
    color: var(--text-muted);
    margin-bottom: 16px;
}

.detail-badges {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 20px;
}

.detail-badge {
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
}

.detail-rating {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 20px;
}

.detail-rating-value {
    font-size: 28px;
    font-weight: 700;
    color: var(--warning);
}

.detail-rating-label {
    font-size: 13px;
    color: var(--text-muted);
}

.detail-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-bottom: 24px;
}

.detail-field {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.detail-field-label {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.detail-field-value {
    font-size: 14px;
    color: var(--text-primary);
}

.detail-notes {
    margin-top: 20px;
    padding: 16px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
}

.detail-notes h5 {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    margin-bottom: 8px;
}

.detail-notes p {
    font-size: 14px;
    color: var(--text-secondary);
    line-height: 1.6;
    white-space: pre-wrap;
}

.detail-actions {
    display: flex;
    gap: 12px;
    margin-top: 24px;
    padding-top: 20px;
    border-top: 1px solid var(--border);
}

.btn-edit {
    padding: 10px 20px;
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    font-family: inherit;
}

.btn-edit:hover { background: var(--accent-light); }

.btn-delete {
    padding: 10px 20px;
    background: transparent;
    color: var(--error);
    border: 1px solid var(--error);
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    font-family: inherit;
}

.btn-delete:hover {
    background: var(--error);
    color: #fff;
}

.btn-external {
    padding: 10px 20px;
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 14px;
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
    font-family: inherit;
}

.btn-external:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

/* ============================================
   Toast Notifications
   ============================================ */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 10px;
    pointer-events: none;
}

.toast {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 20px;
    border-radius: var(--radius-sm);
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-lg);
    min-width: 300px;
    max-width: 450px;
    pointer-events: auto;
    animation: toastIn 0.4s ease;
}

.toast-success { border-left: 4px solid var(--success); }
.toast-error { border-left: 4px solid var(--error); }
.toast-info { border-left: 4px solid var(--info); }

.toast-icon {
    font-size: 16px;
    font-weight: 700;
    flex-shrink: 0;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
}

.toast-success .toast-icon { background: rgba(72, 187, 120, 0.2); color: var(--success); }
.toast-error .toast-icon { background: rgba(229, 62, 62, 0.2); color: var(--error); }
.toast-info .toast-icon { background: rgba(99, 179, 237, 0.2); color: var(--info); }

.toast-message {
    font-size: 14px;
    color: var(--text-primary);
    line-height: 1.4;
    flex: 1;
}

.toast-close {
    background: none;
    border: none;
    font-size: 18px;
    color: var(--text-muted);
    cursor: pointer;
    padding: 0;
    margin-left: 8px;
}

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

.toast-out { animation: toastOut 0.3s ease forwards; }

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

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

/* ============================================
   Loading Spinner
   ============================================ */
.loading-spinner {
    width: 32px;
    height: 32px;
    border: 3px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

/* ============================================
   Scrollbar
   ============================================ */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover { background: var(--border-light); }

/* ============================================
   Volume Grid
   ============================================ */
.vol-grid-wrapper {
    margin-top: 12px;
}

.vol-progress {
    position: relative;
    height: 28px;
    background: var(--bg-tertiary);
    border-radius: 14px;
    overflow: hidden;
    margin-bottom: 10px;
    border: 1px solid var(--border);
}

.vol-progress-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--accent-dark), var(--accent));
    border-radius: 14px;
    transition: width 0.3s ease;
    min-width: 0;
}

.vol-progress-text {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 12px;
    font-weight: 600;
    color: var(--text-primary);
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
    white-space: nowrap;
}

.vol-actions {
    display: flex;
    gap: 8px;
    margin-bottom: 10px;
}

.vol-action-btn {
    padding: 6px 14px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius-xs);
    color: var(--text-secondary);
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    font-family: inherit;
}

.vol-action-btn:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
    border-color: var(--accent);
}

.vol-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.vol-btn {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius-xs);
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    -webkit-tap-highlight-color: transparent;
    user-select: none;
}

.vol-btn:hover {
    border-color: var(--accent);
    color: var(--text-primary);
}

.vol-btn.owned {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
    box-shadow: 0 2px 8px rgba(124, 91, 245, 0.3);
}

.vol-btn.owned:hover {
    background: var(--accent-light);
}

/* Volume grid in detail modal (read-only) */
.vol-grid-detail {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-top: 12px;
}

.vol-chip {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-xs);
    font-size: 11px;
    font-weight: 600;
    border: 1px solid var(--border);
}

.vol-chip.owned {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}

.vol-chip.missing {
    background: var(--bg-tertiary);
    color: var(--text-muted);
    opacity: 0.5;
}

/* Volume mini progress bar on cards */
.item-card-vol-bar {
    height: 4px;
    background: var(--bg-tertiary);
    border-radius: 2px;
    overflow: hidden;
    margin-top: 6px;
}

.item-card-vol-bar-fill {
    height: 100%;
    background: var(--accent);
    border-radius: 2px;
    transition: width 0.3s ease;
}

/* "Já Comprei" button in detail modal */
.btn-purchased {
    padding: 10px 20px;
    background: #ed8936;
    color: #fff;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    font-family: inherit;
    display: flex;
    align-items: center;
    gap: 8px;
}

.btn-purchased:hover {
    background: #dd6b20;
    transform: translateY(-1px);
}

/* Purchase mini-form */
.purchase-mini-form {
    padding: 16px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    margin-top: 16px;
}

.purchase-mini-form h5 {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 12px;
}

.purchase-mini-form .form-row {
    display: flex;
    gap: 10px;
    margin-bottom: 10px;
}

.purchase-mini-form .form-group {
    flex: 1;
}

.purchase-mini-form .form-group label {
    display: block;
    font-size: 11px;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 4px;
}

.purchase-mini-form .form-group input {
    width: 100%;
    padding: 8px 10px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-xs);
    color: var(--text-primary);
    font-size: 14px;
    font-family: inherit;
}

.purchase-mini-form .form-group input:focus {
    outline: none;
    border-color: var(--accent);
}

.purchase-mini-form .purchase-form-actions {
    display: flex;
    gap: 8px;
    margin-top: 12px;
}

/* ============================================
   Mobile FAB (Floating Action Button)
   ============================================ */
.fab {
    display: none;
    position: fixed;
    bottom: 24px;
    right: 20px;
    width: 56px;
    height: 56px;
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: 50%;
    font-size: 28px;
    line-height: 1;
    cursor: pointer;
    box-shadow: 0 4px 20px rgba(124, 91, 245, 0.4);
    z-index: 99;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
    -webkit-tap-highlight-color: transparent;
}

.fab:hover { background: var(--accent-light); transform: scale(1.05); }
.fab:active { transform: scale(0.95); }

/* ============================================
   Users Management Panel
   ============================================ */
.users-subtitle {
    color: var(--text-muted);
    font-size: 14px;
    margin-bottom: 20px;
}

.add-user-form {
    display: flex;
    gap: 10px;
    margin-bottom: 24px;
    align-items: center;
}

.add-user-form input {
    flex: 1;
    padding: 10px 14px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-xs);
    color: var(--text-primary);
    font-size: 14px;
    font-family: inherit;
}

.add-user-form input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

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

.user-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    margin-bottom: 8px;
}

.user-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.user-email {
    font-size: 14px;
    color: var(--text-primary);
    font-weight: 500;
}

.user-role {
    font-size: 12px;
    padding: 2px 8px;
    border-radius: 10px;
    display: inline-block;
    width: fit-content;
}

.role-admin {
    background: rgba(124, 91, 245, 0.15);
    color: var(--accent-light);
}

.role-viewer {
    background: rgba(99, 179, 237, 0.15);
    color: var(--info);
}

.btn-remove-user {
    background: transparent;
    border: 1px solid var(--error);
    color: var(--error);
    padding: 6px 14px;
    border-radius: var(--radius-xs);
    font-size: 12px;
    cursor: pointer;
    transition: var(--transition);
    font-family: inherit;
}

.btn-remove-user:hover {
    background: var(--error);
    color: #fff;
}

.no-users {
    color: var(--text-muted);
    font-size: 14px;
    text-align: center;
    padding: 20px;
}

/* ============================================
   Responsive — Tablet & Mobile (max-width: 768px)
   ============================================ */
@media (max-width: 768px) {
    /* -- Header: compact -- */
    .app-header {
        flex-wrap: wrap;
        padding: 10px 16px;
        gap: 8px;
    }

    .header-left { gap: 8px; }
    .header-title { font-size: 17px; }
    .header-logo { font-size: 24px; }

    .header-stats {
        order: 3;
        width: 100%;
        display: flex;
        justify-content: space-around;
        padding-top: 8px;
        border-top: 1px solid var(--border);
        gap: 8px;
    }

    .stat-value { font-size: 16px; }
    .stat-label { font-size: 10px; }

    .header-right { display: flex; gap: 6px; }
    .header-right .btn-icon { width: 36px; height: 36px; }
    .header-right .btn-icon svg { width: 18px; height: 18px; }

    /* -- Tabs -- */
    .tabs-nav { padding: 0; }
    .tab-btn {
        flex: 1;
        justify-content: center;
        padding: 10px 12px;
        font-size: 13px;
        gap: 6px;
    }
    .tab-icon { font-size: 16px; }
    .tab-count { font-size: 11px; padding: 2px 7px; }

    /* -- Toolbar: search on own row, filters scroll below -- */
    .toolbar {
        padding: 10px 16px;
        flex-direction: column;
        align-items: stretch;
        gap: 8px;
    }

    .toolbar-left {
        display: flex;
        flex-direction: column;
        gap: 8px;
    }

    .search-box {
        max-width: none;
        min-width: 0;
        width: 100%;
        flex: none;
    }

    /* Filters row: horizontal scroll on mobile */
    .filters-row {
        display: flex;
        flex-wrap: nowrap;
        overflow-x: auto;
        gap: 8px;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        padding-bottom: 2px;
    }

    .filters-row::-webkit-scrollbar { display: none; }

    .filter-select {
        flex-shrink: 0;
        font-size: 13px;
        padding: 8px 10px;
        min-width: max-content;
    }

    /* Hide desktop add button, show FAB instead */
    .toolbar-right { display: none; }
    .fab { display: flex; }

    /* -- Grid: auto-fill with min 130px -- */
    .collection-grid {
        grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
        gap: 10px;
        padding: 10px 16px 90px;
    }

    /* -- Cards -- */
    .item-card {
        border-radius: var(--radius-sm);
        overflow: hidden;
    }
    .item-card:hover { transform: none; box-shadow: none; }
    .item-card-info { padding: 8px 10px 10px; }
    .item-card-title { font-size: 13px; -webkit-line-clamp: 2; }
    .item-card-author { font-size: 11px; margin-bottom: 6px; }
    .item-card-status { font-size: 10px; padding: 2px 7px; }
    .item-card-rating { font-size: 11px; }
    .item-card-volumes { font-size: 10px; }

    /* -- Modals: full-screen with safe area -- */
    .modal {
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }

    .modal-content {
        margin: 0;
        padding: 20px 16px 0;
        border-radius: 0;
        max-width: 100%;
        width: 100%;
        min-height: 100vh;
        min-height: 100dvh;
        max-height: none;
        overflow-y: visible;
        border: none;
    }

    .modal-content.modal-large {
        max-width: 100%;
        display: flex;
        flex-direction: column;
    }

    .modal-content.modal-detail {
        padding: 0;
        max-width: 100%;
    }

    .modal-content h3 {
        font-size: 18px;
        margin-bottom: 16px;
        position: sticky;
        top: 0;
        background: var(--bg-secondary);
        padding: 16px 16px 12px 0;
        z-index: 6;
    }

    .modal-close {
        position: fixed;
        right: 12px;
        top: 12px;
        width: 36px;
        height: 36px;
        font-size: 20px;
        z-index: 1001;
        background: var(--bg-tertiary);
        border: 1px solid var(--border);
    }

    /* -- Form -- */
    .item-form {
        flex: 1;
    }

    .form-row {
        flex-direction: column;
        gap: 10px;
    }

    .form-section { margin-bottom: 16px; }
    .form-section h4 { font-size: 13px; margin-bottom: 10px; }

    .form-group input,
    .form-group select,
    .form-group textarea {
        padding: 12px;
        font-size: 16px; /* Prevents iOS zoom on focus */
    }

    .form-group label { font-size: 12px; }

    .rating-input input[type="range"] { height: 8px; }
    .rating-display { width: 34px; height: 34px; font-size: 14px; }

    .api-search-section { margin-bottom: 12px; }

    .api-search-box {
        flex-direction: column;
        gap: 8px;
    }

    .api-search-box input {
        padding: 12px 14px;
        font-size: 16px;
        border-radius: var(--radius-sm);
    }

    .btn-search {
        padding: 12px 16px;
        font-size: 14px;
        border-radius: var(--radius-sm);
        width: 100%;
    }

    .api-results {
        max-height: 200px;
    }

    .divider { margin: 14px 0; font-size: 12px; }

    /* -- Cover upload -- */
    .cover-preview-row {
        flex-direction: column;
        align-items: center;
    }

    .cover-preview {
        width: 120px;
        height: 170px;
    }

    .cover-actions { width: 100%; }

    .upload-area {
        padding: 20px 16px;
    }

    .upload-area p { font-size: 13px; }
    .upload-icon { font-size: 28px; }

    /* -- Form actions: sticky bottom bar -- */
    /* NOTE: position:fixed breaks inside backdrop-filter containers,
       so we use sticky instead which works inside scroll containers */
    .form-actions {
        position: sticky;
        bottom: 0;
        background: var(--bg-secondary);
        margin: 0 -16px;
        padding: 12px 16px;
        padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px));
        border-top: 1px solid var(--border);
        border-radius: 0;
        gap: 10px;
        z-index: 100;
        box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.3);
    }

    .form-actions .btn-primary,
    .form-actions .btn-cancel {
        flex: 1;
        text-align: center;
        padding: 14px;
    }

    /* -- Detail modal -- */
    .detail-layout {
        grid-template-columns: 1fr;
    }

    .detail-cover-section {
        padding: 24px 20px;
    }

    .detail-cover-section img {
        max-width: 160px;
    }

    .detail-cover-noimg {
        width: 140px;
        height: 200px;
        font-size: 48px;
    }

    .detail-info-section {
        padding: 20px 16px 24px;
        max-height: none;
    }

    .detail-title { font-size: 20px; padding-right: 40px; }
    .detail-author { font-size: 14px; }

    .detail-grid {
        grid-template-columns: 1fr 1fr;
        gap: 12px;
    }

    .detail-actions {
        flex-wrap: wrap;
    }

    .detail-actions button,
    .detail-actions a {
        flex: 1;
        text-align: center;
        min-width: 100px;
        padding: 12px 16px;
    }

    /* -- Toasts: above FAB -- */
    .toast-container {
        top: auto;
        bottom: 90px;
        right: 12px;
        left: 12px;
    }

    .toast {
        min-width: 0;
        max-width: none;
        width: 100%;
    }

    /* -- Login -- */
    .login-container {
        margin: 16px;
        padding: 36px 24px;
    }

    .login-icon { font-size: 40px; }
    .login-logo h1 { font-size: 24px; }

    .login-form input {
        padding: 14px;
        font-size: 16px;
    }

    /* -- Empty state -- */
    .empty-state { padding: 60px 24px 100px; }
    .empty-icon { font-size: 48px; }
    .empty-state h3 { font-size: 18px; }

    /* -- Volume grid -- */
    .vol-btn { width: 36px; height: 36px; font-size: 12px; }
    .vol-chip { width: 28px; height: 28px; font-size: 10px; }
    .vol-action-btn { padding: 8px 14px; font-size: 12px; }
    .purchase-mini-form .form-row { flex-direction: column; gap: 8px; }

    /* -- Users panel -- */
    .add-user-form {
        flex-direction: column;
    }

    .add-user-form input, .add-user-form button {
        width: 100%;
    }
}

/* ============================================
   Responsive — Small phones (max-width: 480px)
   ============================================ */
@media (max-width: 480px) {
    .app-header { padding: 8px 12px; }
    .header-title { font-size: 15px; }
    .header-logo { font-size: 20px; }

    .stat-value { font-size: 15px; }
    .stat-label { font-size: 9px; }

    .header-right .btn-icon { width: 32px; height: 32px; }
    .header-right .btn-icon svg { width: 16px; height: 16px; }

    /* -- Tabs -- */
    .tab-btn { padding: 10px 8px; font-size: 12px; }
    .tab-icon { font-size: 15px; }
    .tab-count { font-size: 10px; padding: 1px 6px; }

    /* -- Toolbar -- */
    .toolbar { padding: 8px 12px; gap: 6px; }

    .search-box input {
        padding: 10px 10px 10px 36px;
        font-size: 14px;
    }

    .search-icon { left: 10px; width: 16px; height: 16px; }

    .filter-select {
        padding: 8px;
        font-size: 11px;
    }

    /* -- Grid: 2 columns -- */
    .collection-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
        padding: 8px 12px 90px;
    }

    /* -- Cards: compact -- */
    .item-card-info { padding: 6px 8px 8px; }
    .item-card-title { font-size: 12px; -webkit-line-clamp: 1; }
    .item-card-author { font-size: 10px; margin-bottom: 4px; }
    .item-card-footer { gap: 4px; }
    .item-card-status { font-size: 9px; padding: 2px 6px; }
    .item-card-rating { font-size: 10px; }
    .item-card-volumes { font-size: 9px; margin-top: 2px; }

    /* -- Skeleton -- */
    .skeleton-card::after { height: 60px; }

    /* -- Modal form -- */
    .modal-content { padding: 16px 14px; }
    .modal-content h3 { font-size: 17px; padding: 14px 14px 10px 0; }

    .form-group input,
    .form-group select,
    .form-group textarea {
        padding: 11px 10px;
    }

    /* -- Detail: compact -- */
    .detail-cover-section { padding: 20px 16px; }
    .detail-cover-section img { max-width: 130px; }
    .detail-info-section { padding: 16px 14px 20px; }
    .detail-title { font-size: 18px; }
    .detail-grid { grid-template-columns: 1fr; gap: 10px; }
    .detail-field-label { font-size: 10px; }
    .detail-field-value { font-size: 13px; }
    .detail-notes { padding: 12px; }
    .detail-notes p { font-size: 13px; }

    .detail-actions {
        flex-direction: column;
    }

    .detail-actions button,
    .detail-actions a {
        width: 100%;
        text-align: center;
    }

    /* -- FAB -- */
    .fab { width: 52px; height: 52px; font-size: 24px; right: 16px; }

    /* -- Toast -- */
    .toast { padding: 12px 14px; }
    .toast-message { font-size: 13px; }

    /* -- API results -- */
    .api-result-item { padding: 10px; gap: 10px; }
    .api-result-cover { width: 40px; height: 56px; }
    .api-result-title { font-size: 13px; }
    .api-result-meta { font-size: 11px; }

    /* -- Login -- */
    .login-container { padding: 32px 20px; }
    .login-logo { margin-bottom: 28px; }
}
