/* ===== Member view layouts ===== */

.content-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.25rem;
}

.content-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    overflow: hidden;
}

.content-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border);
    font-weight: 600;
    font-size: 0.95rem;
}

.content-card-header i {
    color: var(--primary);
    margin-right: 0.35rem;
}

.content-card-body {
    padding: 0.25rem 0 0.5rem;
}

.content-card-body .empty-state,
.content-card-body .error-state,
.content-card-body .loading-state {
    padding: 2rem 1.25rem;
}

.link-btn {
    color: var(--primary);
    font-weight: 600;
    font-size: 0.85rem;
    background: none;
    border: none;
    cursor: pointer;
}

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

/* Trending list */
.trending-item {
    display: flex;
    align-items: center;
    gap: 0.875rem;
    padding: 0.875rem 1.25rem;
    border-bottom: 1px solid var(--border);
}

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

.trending-rank {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--primary-soft);
    color: var(--primary);
    font-weight: 700;
    font-size: 0.8rem;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

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

.trending-title {
    font-weight: 600;
    font-size: 0.9rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.trending-author {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.trending-bar-wrap {
    flex: 0 0 80px;
    height: 6px;
    background: var(--border);
    border-radius: 999px;
    overflow: hidden;
}

.trending-bar {
    height: 100%;
    background: var(--primary);
    border-radius: 999px;
}

.trending-count {
    font-size: 0.75rem;
    color: var(--text-muted);
    white-space: nowrap;
    min-width: 64px;
    text-align: right;
}

/* Due date rows */
.due-row {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.875rem 1.25rem;
    border-bottom: 1px solid var(--border);
}

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

.date-badge {
    width: 44px;
    height: 48px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    background: var(--surface-muted);
}

.date-badge-day {
    font-weight: 800;
    font-size: 1rem;
    line-height: 1;
}

.date-badge-mon {
    font-size: 0.65rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
}

.date-badge.overdue {
    border-color: var(--danger-border);
    background: var(--danger-soft);
    color: var(--danger-text);
}

.date-badge.soon {
    border-color: #fcd34d;
    background: var(--warning-soft);
}

.due-row-body {
    flex: 1;
    min-width: 0;
}

.due-row-title {
    font-weight: 600;
    font-size: 0.9rem;
}

.due-row-status {
    font-size: 0.8rem;
    margin-top: 0.15rem;
}

.due-row-status.overdue { color: var(--danger); }
.due-row-status.soon { color: var(--warning-text); }
.due-row-status.ok { color: var(--text-muted); }

/* Borrowed cards grid */
.books-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1rem;
}

.borrowed-card {
    display: flex;
    gap: 1rem;
    align-items: flex-start;
    padding: 1.25rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
}

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

.borrowed-card-title {
    font-size: 0.95rem;
    font-weight: 700;
    margin-bottom: 0.2rem;
}

.borrowed-card-author {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 0.35rem;
}

.borrowed-card-meta {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
}

/* Search */
.search-card {
    position: relative;
    display: flex;
    gap: 0.875rem;
    align-items: flex-start;
    padding: 1rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
}

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

.search-card-title {
    font-weight: 700;
    font-size: 0.95rem;
    padding-right: 1.5rem;
}

.search-card-meta {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin: 0.25rem 0 0.5rem;
}

.search-fav-btn {
    position: absolute;
    top: 0.75rem;
    right: 0.75rem;
    color: var(--text-tertiary);
    font-size: 1.1rem;
    padding: 0.25rem;
}

.search-fav-btn.active {
    color: var(--danger);
}

.search-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.search-results-count {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 0.75rem;
}

.search-pagination {
    display: flex;
    justify-content: center;
    margin: 1.5rem 0 0;
}

.search-pagination[hidden] {
    display: none;
}

.search-pagination-list {
    display: flex;
    list-style: none;
    gap: 0.4rem;
    flex-wrap: wrap;
    justify-content: center;
    margin: 0;
    padding: 0;
}

.search-pagination-item button,
.search-pagination-item span {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 36px;
    height: 36px;
    padding: 0 0.5rem;
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--text);
    border: 1px solid var(--border);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
}

.search-pagination-item button:hover {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
}

.search-pagination-item.active span {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
    cursor: default;
}

.search-pagination-item.disabled span {
    background: var(--surface-muted);
    color: var(--text-tertiary);
    cursor: not-allowed;
}

.search-pagination-item.more-pages span {
    cursor: default;
    color: var(--text-muted);
    border-color: transparent;
    background: transparent;
}

/* Borrow scanner */
.scan-card {
    max-width: 560px;
    margin: 0 auto;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    text-align: center;
}

.scan-viewport {
    position: relative;
    width: 100%;
    aspect-ratio: 1;
    max-width: 360px;
    margin: 0 auto 1rem;
    background: #0a0a0a;
    border-radius: var(--radius-md);
    overflow: hidden;
}

.scan-viewport video,
.scan-viewport canvas {
    width: 100% !important;
    height: 100% !important;
    object-fit: cover;
}

.scan-frame {
    position: absolute;
    inset: 12%;
    border: 2px solid rgba(255, 255, 255, 0.85);
    border-radius: var(--radius-sm);
    pointer-events: none;
    box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.35);
}

.scan-laser {
    position: absolute;
    left: 12%;
    right: 12%;
    height: 2px;
    background: #22c55e;
    box-shadow: 0 0 8px #22c55e;
    animation: scanLaser 2s ease-in-out infinite;
    pointer-events: none;
}

@keyframes scanLaser {
    0%, 100% { top: 20%; }
    50% { top: 75%; }
}

.scan-hint {
    font-size: 0.9rem;
    color: var(--text-muted);
    margin-bottom: 1.25rem;
    line-height: 1.5;
}

.scan-status {
    margin-top: 1rem;
    font-size: 0.875rem;
    color: var(--primary);
    font-weight: 500;
}

/* Return selection */
.return-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
}

.return-item {
    display: flex;
    align-items: center;
    gap: 0.875rem;
    padding: 1rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: border-color var(--transition), background var(--transition);
}

.return-item.selected {
    border-color: var(--primary);
    background: var(--primary-soft);
}

.return-item input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--primary);
    flex-shrink: 0;
}

.return-item-body {
    flex: 1;
    min-width: 0;
}

.return-item-title {
    font-weight: 600;
    font-size: 0.9rem;
}

.return-item-due {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 0.15rem;
}

.return-item-due.overdue {
    color: var(--danger);
    font-weight: 600;
}

/* Return code */
.code-display {
    text-align: center;
    padding: 2rem 1.5rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    max-width: 420px;
    margin: 0 auto;
}

.code-value {
    font-size: 2.5rem;
    font-weight: 800;
    letter-spacing: 0.08em;
    color: var(--primary);
    margin: 1rem 0;
}

.code-pending {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    border-radius: var(--radius-full);
    background: var(--warning-soft);
    color: #b45309;
    font-size: 0.85rem;
    font-weight: 600;
}

.code-pending.done {
    background: var(--success-soft);
    color: var(--success);
}

/* History table */
.history-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-bottom: 1.25rem;
}

.history-filters .form-input,
.history-filters .form-select {
    width: auto;
    min-width: 140px;
}

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

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

    .history-filters .form-input,
    .history-filters .form-select {
        width: 100%;
    }

    .history-filters {
        grid-template-columns: 1fr 1fr;
    }

    .history-filters .form-input {
        grid-column: 1 / -1;
    }

    .admin-stats-grid { grid-template-columns: repeat(2, 1fr); }
    .charts-row { grid-template-columns: 1fr; }
    .insight-cards { grid-template-columns: 1fr; }
}

/* ===== Admin dashboard ===== */
.admin-stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.admin-stat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 1rem 1.25rem;
    display: flex;
    align-items: center;
    gap: 0.875rem;
}

.admin-stat-card .stat-icon {
    width: 40px;
    height: 40px;
    font-size: 1.1rem;
}

.admin-stat-card .stat-value {
    font-size: 1.35rem;
}

.admin-stat-card .stat-label {
    font-size: 0.75rem;
}

.insight-cards {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.insight-card {
    padding: 1rem 1.25rem;
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
    font-size: 0.875rem;
}

.insight-card.green { background: #ecfdf5; border-color: #a7f3d0; }
.insight-card.purple { background: #f5f3ff; border-color: #ddd6fe; }
.insight-card.red { background: #fef2f2; border-color: #fecaca; }
.insight-card.blue { background: #eff6ff; border-color: #bfdbfe; }

.insight-card strong { display: block; margin-bottom: 0.35rem; }

.insight-card a {
    color: var(--primary);
    font-weight: 600;
    font-size: 0.8rem;
}

/* Noolz insights — Zia-style 2x2 card grid */
.zia-insights {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 1.15rem 1.25rem 0;
    margin-bottom: 1.5rem;
    overflow: hidden;
}

.zia-insights-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding-bottom: 0.85rem;
    margin-bottom: 0;
    border-bottom: 1px solid var(--border);
}

.zia-insights-title {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--text);
}

.zia-insights-spark {
    color: var(--primary);
    font-size: 1.05rem;
}

.zia-ai-badge {
    display: inline-flex;
    align-items: center;
    padding: 0.12rem 0.5rem;
    border-radius: 999px;
    background: var(--primary);
    color: #fff;
    font-size: 0.65rem;
    font-weight: 700;
    letter-spacing: 0.04em;
}

.zia-insights-header-right {
    display: flex;
    align-items: center;
    gap: 0.65rem;
}

.zia-insights-period {
    color: var(--text-muted);
    font-size: 0.8rem;
    white-space: nowrap;
}

.zia-refresh-btn {
    font-size: 0.85rem;
    display: inline-flex;
    align-items: center;
    color: var(--text-muted);
}

.zia-insights-headline {
    margin: 0.75rem 0 0;
    color: var(--text-secondary);
    font-size: 0.85rem;
}

.zia-insights-headline:empty,
.zia-insights-headline[hidden] {
    display: none;
}

.zia-insights-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    margin-top: 0;
}

.zia-insight-card {
    display: flex;
    gap: 0.85rem;
    align-items: flex-start;
    padding: 1.1rem 1rem;
    background: var(--surface);
    min-height: 6rem;
    border-right: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
}

.zia-insight-card:nth-child(2n) {
    border-right: 0;
}

.zia-insight-card:nth-last-child(-n+2) {
    border-bottom: 0;
}

.zia-insight-icon {
    width: 2.25rem;
    height: 2.25rem;
    border-radius: 0.55rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 1rem;
}

.zia-insight-card.blue .zia-insight-icon { background: #dbeafe; color: #2563eb; }
.zia-insight-card.red .zia-insight-icon { background: #fee2e2; color: #dc2626; }
.zia-insight-card.green .zia-insight-icon { background: #dcfce7; color: #16a34a; }
.zia-insight-card.purple .zia-insight-icon { background: #ede9fe; color: #7c3aed; }

.zia-insight-body {
    min-width: 0;
    flex: 1;
}

.zia-insight-text {
    margin: 0 0 0.5rem;
    font-size: 0.875rem;
    line-height: 1.45;
    color: var(--text);
}

.zia-insight-text strong {
    font-weight: 700;
    color: var(--text);
}

.zia-insight-cta {
    color: var(--primary);
    font-weight: 600;
    font-size: 0.8rem;
    text-decoration: none;
}

.zia-insight-cta:hover {
    text-decoration: underline;
}

@media (max-width: 768px) {
    .zia-insights-grid { grid-template-columns: 1fr; }
    .zia-insight-card {
        border-right: 0;
    }
    .zia-insight-card:last-child {
        border-bottom: 0;
    }
    .zia-insight-card:nth-last-child(-n+2) {
        border-bottom: 1px solid var(--border);
    }
    .zia-insights-period { display: none; }
}

/* Floating Noolz librarian chat (Zia-style dock) */
.noolz-chat-dock {
    position: fixed;
    right: 1.25rem;
    bottom: 1.25rem;
    z-index: 190;
    font-family: var(--font);
}

.noolz-chat-dock.is-open {
    z-index: 1300;
}

.noolz-chat-launcher {
    width: 3.5rem;
    height: 3.5rem;
    border: 0;
    border-radius: 50%;
    background: var(--primary);
    color: #fff;
    box-shadow: 0 10px 24px rgba(37, 99, 235, 0.35);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1.35rem;
    cursor: pointer;
    transition: transform 0.18s ease, box-shadow var(--transition);
    animation: ziaBotIn 0.4s ease both;
}

.noolz-chat-launcher:hover {
    transform: translateY(-2px) scale(1.04);
}

.noolz-chat-launcher.is-hidden {
    display: none;
}

.noolz-chat-panel {
    width: min(380px, calc(100vw - 1.5rem));
    height: min(520px, calc(100vh - 6rem));
    display: flex;
    flex-direction: column;
    background: #f3f4f6;
    border-radius: 16px;
    overflow: hidden;
    box-shadow: 0 18px 40px rgba(15, 23, 42, 0.22);
    transform-origin: bottom right;
    animation: ziaBotIn 0.35s cubic-bezier(0.22, 1, 0.36, 1) both;
}

.noolz-chat-panel.is-closed {
    display: none;
}

.noolz-chat-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.9rem 1rem;
    background: var(--primary);
    color: #fff;
}

.noolz-chat-header-icon {
    width: 2.1rem;
    height: 2.1rem;
    border-radius: 50%;
    border: 1.5px solid rgba(255, 255, 255, 0.85);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.95rem;
    flex-shrink: 0;
}

.noolz-chat-header-text {
    min-width: 0;
    flex: 1;
}

.noolz-chat-title {
    font-weight: 700;
    font-size: 1rem;
    line-height: 1.2;
}

.noolz-chat-online {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    margin-top: 0.15rem;
    font-size: 0.75rem;
    opacity: 0.95;
}

.noolz-chat-online-dot {
    width: 0.5rem;
    height: 0.5rem;
    border-radius: 50%;
    background: #34d399;
    box-shadow: 0 0 0 0 rgba(52, 211, 153, 0.5);
    animation: ziaOnlinePing 2s ease-out infinite;
}

.noolz-chat-online-dot.is-typing {
    background: #fbbf24;
    animation: ziaStatusFlash 1s ease-in-out infinite;
}

.noolz-chat-close {
    border: 0;
    background: transparent;
    color: #fff;
    width: 2.25rem;
    height: 2.25rem;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    opacity: 0.9;
    flex-shrink: 0;
}

.noolz-chat-close:hover {
    background: rgba(255, 255, 255, 0.12);
    opacity: 1;
}

.noolz-chat-back-icon {
    display: none;
}

.noolz-chat-body {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    padding: 0.9rem 0.9rem 0.35rem;
    overflow: hidden;
}

.noolz-chat-log {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
    padding-bottom: 0.5rem;
    scroll-behavior: smooth;
}

.noolz-chat-suggestions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.45rem;
    padding: 0.15rem 0 0.35rem;
    align-self: flex-start;
    max-width: 100%;
}

.noolz-chat-chip {
    border: 1px solid #bfdbfe;
    background: #fff;
    color: var(--primary);
    border-radius: var(--radius-full);
    padding: 0.4rem 0.85rem;
    font-size: 0.78rem;
    font-weight: 500;
    cursor: pointer;
    transition: background var(--transition), transform 0.15s ease;
    animation: ziaChipIn 0.35s ease both;
}

.noolz-chat-chip:nth-child(2) { animation-delay: 0.05s; }
.noolz-chat-chip:nth-child(3) { animation-delay: 0.1s; }

.noolz-chat-chip:hover {
    background: #eff6ff;
    transform: translateY(-1px);
}

.zia-chat-row {
    display: flex;
    max-width: 88%;
    animation: ziaMsgIn 0.3s ease both;
}

.zia-chat-row.user {
    align-self: flex-end;
}

.zia-chat-row.assistant {
    align-self: flex-start;
}

.zia-chat-bubble {
    padding: 0.75rem 0.9rem;
    border-radius: 14px;
    font-size: 0.875rem;
    line-height: 1.45;
    box-shadow: var(--shadow-sm);
}

.zia-chat-md {
    white-space: normal;
}

.zia-chat-md p {
    margin: 0 0 0.45rem;
}

.zia-chat-md p:last-child {
    margin-bottom: 0;
}

.zia-chat-md ul,
.zia-chat-md ol {
    margin: 0.45rem 0 0.2rem;
    padding-left: 1.35rem;
}

.zia-chat-md ul {
    list-style-type: disc;
}

.zia-chat-md ol {
    list-style-type: decimal;
}

.zia-chat-md li {
    margin: 0.35rem 0;
    padding-left: 0.15rem;
    display: list-item;
}

.zia-chat-md ol > li {
    margin: 0.55rem 0;
}

.zia-chat-md li ul,
.zia-chat-md ol ul {
    list-style-type: disc;
    margin: 0.3rem 0 0.15rem;
    padding-left: 1.1rem;
}

.zia-chat-md li ul li {
    margin: 0.15rem 0;
}

.zia-chat-md strong {
    font-weight: 700;
}

.zia-chat-md em {
    font-style: italic;
}

.zia-chat-row.user .zia-chat-md {
    white-space: pre-wrap;
}

.zia-chat-row.assistant .zia-chat-bubble {
    background: #fff;
    border: 1px solid var(--border);
    color: var(--text);
    border-bottom-left-radius: 4px;
}

.zia-chat-row.user .zia-chat-bubble {
    background: var(--primary);
    color: #fff;
    border-bottom-right-radius: 4px;
}

.zia-chat-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    margin-top: 0.55rem;
}

.zia-action-btn {
    border: 1px solid #bfdbfe;
    background: #eff6ff;
    color: #1d4ed8;
    border-radius: var(--radius-full);
    padding: 0.28rem 0.7rem;
    font-size: 0.72rem;
    font-weight: 600;
    cursor: pointer;
}

.zia-action-btn:hover {
    background: #dbeafe;
}

.zia-typing {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    min-height: 1.1rem;
}

.zia-typing span {
    width: 0.4rem;
    height: 0.4rem;
    border-radius: 50%;
    background: #94a3b8;
    animation: ziaTyping 1.2s ease-in-out infinite;
}

.zia-typing span:nth-child(2) { animation-delay: 0.15s; }
.zia-typing span:nth-child(3) { animation-delay: 0.3s; }

.noolz-chat-composer {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    padding: 0.75rem 0.85rem 0.9rem;
    background: var(--surface);
    border-top: 1px solid var(--border);
}

.noolz-chat-input {
    flex: 1;
    min-width: 0;
    border: 1px solid var(--border);
    border-radius: var(--radius-full);
    padding: 0.7rem 1rem;
    font-size: 16px;
    background: var(--surface);
    color: var(--text);
}

.noolz-chat-input::placeholder {
    color: var(--text-muted);
    opacity: 1;
}

.noolz-chat-input:focus {
    outline: none;
    border-color: #93c5fd;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.noolz-chat-send {
    width: 2.6rem;
    height: 2.6rem;
    border: 0;
    border-radius: 50%;
    background: #94a3b8;
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
    transition: background var(--transition), transform 0.15s ease;
}

.noolz-chat-panel:not(.is-busy) .noolz-chat-input:not(:placeholder-shown) + .noolz-chat-send,
.noolz-chat-send:hover {
    background: var(--primary);
}

.noolz-chat-send:disabled {
    opacity: 0.65;
    cursor: not-allowed;
}

.noolz-chat-panel.is-busy .noolz-chat-send i {
    animation: spin 0.8s linear infinite;
}

@media (max-width: 768px) {
    .noolz-chat-dock {
        right: 1rem;
        bottom: calc(var(--bottom-nav-height) + env(safe-area-inset-bottom, 0px) + 0.85rem);
        z-index: 190;
    }

    .noolz-chat-dock.is-open {
        inset: 0;
        right: 0;
        bottom: 0;
        z-index: 1300;
        display: flex;
        flex-direction: column;
    }

    .noolz-chat-dock.is-open .noolz-chat-panel {
        flex: 1;
        width: 100%;
        height: 100%;
        max-height: none;
        border-radius: 0;
        box-shadow: none;
        animation: none;
    }

    .noolz-chat-close {
        order: -1;
    }

    .noolz-chat-back-icon {
        display: inline-flex;
    }

    .noolz-chat-x-icon {
        display: none;
    }

    .noolz-chat-close {
        width: 2.5rem;
        height: 2.5rem;
        background: rgba(255, 255, 255, 0.14);
        font-size: 1.15rem;
        opacity: 1;
    }

    .noolz-chat-composer {
        padding-bottom: calc(0.9rem + env(safe-area-inset-bottom, 0px));
    }

    body.noolz-chat-open {
        overflow: hidden;
    }

    body.noolz-chat-open .bottom-nav {
        visibility: hidden;
        pointer-events: none;
    }

    body.org-sheet-open .noolz-chat-dock:not(.is-open) {
        z-index: 180;
    }
}

@keyframes ziaStatusFlash {
    0%, 100% { opacity: 0.75; }
    50% { opacity: 1; }
}

@keyframes ziaBotIn {
    from { opacity: 0; transform: translateY(12px) scale(0.96); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

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

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

@keyframes ziaTyping {
    0%, 80%, 100% { transform: translateY(0); opacity: 0.35; }
    40% { transform: translateY(-3px); opacity: 1; }
}

@keyframes ziaOnlinePing {
    0% { box-shadow: 0 0 0 0 rgba(52, 211, 153, 0.55); }
    70% { box-shadow: 0 0 0 6px rgba(52, 211, 153, 0); }
    100% { box-shadow: 0 0 0 0 rgba(52, 211, 153, 0); }
}

[data-theme="dark"] .noolz-chat-panel {
    background: #0f172a;
}

[data-theme="dark"] .noolz-chat-composer {
    background: #1e293b;
    border-top-color: #475569;
}

[data-theme="dark"] .zia-chat-row.assistant .zia-chat-bubble,
[data-theme="dark"] .noolz-chat-chip {
    background: #1e293b;
    border-color: #475569;
    color: #f1f5f9;
}

[data-theme="dark"] .noolz-chat-chip {
    color: #93c5fd;
}

[data-theme="dark"] .zia-action-btn {
    background: #1e3a5f;
    border-color: #334155;
    color: #93c5fd;
}

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

.chart-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 1.25rem;
    text-align: center;
}

.chart-card h4 {
    font-size: 0.9rem;
    margin-bottom: 1rem;
    color: var(--text-secondary);
}

.chart-card canvas {
    max-width: 160px;
    margin: 0 auto;
}

.chart-legend {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.5rem 1rem;
    margin-top: 0.875rem;
    font-size: 0.8125rem;
    color: var(--text-secondary);
}

.chart-legend-item {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
}

.chart-legend-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.chart-legend-empty {
    color: var(--text-muted);
    font-size: 0.8125rem;
}

.rank-list-item {
    display: flex;
    align-items: center;
    gap: 0.875rem;
    padding: 0.875rem 1.25rem;
    border-bottom: 1px solid var(--border);
}

.rank-list-item:last-child {
    border-bottom: none;
    padding-bottom: 1rem;
}

.rank-num {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--primary-soft);
    color: var(--primary);
    font-size: 0.8rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.rank-list-body {
    flex: 1;
    min-width: 0;
}

.rank-list-title {
    font-weight: 600;
    font-size: 0.9rem;
    line-height: 1.35;
}

.rank-list-meta {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 0.15rem;
    line-height: 1.35;
}

.rank-list-count {
    font-weight: 600;
    color: var(--primary);
    font-size: 0.9rem;
    flex-shrink: 0;
    min-width: 1.5rem;
    text-align: right;
}

@media (max-width: 1024px) {
    .admin-stats-grid { grid-template-columns: repeat(2, 1fr); }
    .charts-row { grid-template-columns: 1fr; }
    .insight-cards { grid-template-columns: 1fr; }
    .add-book-layout { grid-template-columns: 1fr; }
}

/* ===== Admin manage books ===== */
.admin-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-bottom: 1rem;
    align-items: center;
}

.admin-search {
    flex: 1;
    min-width: 200px;
}

.admin-book-cell {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.admin-book-title {
    font-weight: 600;
    font-size: 0.9rem;
}

.admin-book-meta {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.row-actions {
    display: flex;
    gap: 0.35rem;
}

.icon-btn {
    width: 32px;
    height: 32px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--surface);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    cursor: pointer;
}

.icon-btn:hover {
    background: var(--primary-soft);
    border-color: var(--primary);
    color: var(--primary);
}

.icon-btn-danger:hover {
    background: #fef2f2;
    border-color: #fecaca;
    color: var(--danger);
}

.table-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 0;
    font-size: 0.85rem;
    color: var(--text-muted);
    flex-wrap: wrap;
    gap: 0.75rem;
}

.pagination {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.pagination-label {
    font-weight: 600;
    color: var(--text);
}

.admin-book-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.admin-book-card {
    display: flex;
    align-items: center;
    gap: 0.875rem;
    padding: 1rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
}

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

.admin-book-card-body h3 {
    font-size: 0.95rem;
    font-weight: 600;
    margin-bottom: 0.15rem;
}

.admin-book-card-actions {
    display: flex;
    gap: 0.25rem;
    flex-shrink: 0;
}

/* ===== Add book ===== */
.add-book-layout {
    display: grid;
    grid-template-columns: 1fr 280px;
    gap: 1.25rem;
    align-items: start;
}

.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.form-grid .full,
.form-grid .form-actions {
    grid-column: 1 / -1;
}

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

.form-actions {
    display: flex;
    gap: 0.75rem;
    justify-content: flex-end;
    flex-wrap: wrap;
    padding-top: 0.5rem;
}

.input-row {
    display: flex;
    gap: 0.5rem;
}

.input-row .form-input {
    flex: 1;
}

.preview-heading {
    font-size: 0.9rem;
    font-weight: 600;
    margin-bottom: 1rem;
    color: var(--text-secondary);
}

.add-preview-card {
    text-align: center;
}

.add-preview-card h4 {
    margin: 0.75rem 0 0.25rem;
    font-size: 1rem;
}

.add-preview-card p {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 1rem;
}

.add-preview-cover {
    display: block;
    width: 100%;
    max-width: 180px;
    border-radius: var(--radius-sm);
    margin: 0 auto 1rem;
    object-fit: cover;
    aspect-ratio: 2 / 3;
}

.cover-upload {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    padding: 1.25rem;
    border: 2px dashed var(--border);
    border-radius: var(--radius-md);
    text-align: center;
    cursor: pointer;
    color: var(--text-muted);
    transition: border-color var(--transition), background var(--transition);
    margin-bottom: 1rem;
}

.cover-upload:hover {
    border-color: var(--primary);
    background: var(--primary-soft);
}

.cover-upload.has-image {
    padding: 0.75rem;
    margin-top: -0.5rem;
}

.cover-upload i {
    font-size: 1.75rem;
}

.cover-upload small {
    font-size: 0.75rem;
}

.add-meta-preview {
    text-align: center;
}

.add-meta-preview h4 {
    margin: 0 0 0.25rem;
    font-size: 1rem;
}

.add-meta-preview p {
    font-size: 0.85rem;
    color: var(--text-muted);
}

.text-muted {
    color: var(--text-muted);
    font-weight: 400;
}

.form-input.is-invalid,
.form-select.is-invalid {
    border-color: var(--danger);
    box-shadow: 0 0 0 2px var(--danger-soft);
}

.isbn-scanner-overlay {
    position: fixed;
    inset: 0;
    z-index: 600;
    background: rgba(0, 0, 0, 0.55);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.isbn-scanner-overlay[hidden] {
    display: none;
}

.isbn-scanner-modal {
    width: 100%;
    max-width: 520px;
}

.isbn-scanner-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 0.75rem;
}

.isbn-scanner-head h3 {
    margin: 0;
    font-size: 1rem;
}

.isbn-scanner-viewport {
    position: relative;
    width: 100%;
    aspect-ratio: 4 / 3;
    min-height: 240px;
    max-height: min(52vh, 420px);
    border-radius: var(--radius-md);
    overflow: hidden;
    background: #000;
}

.isbn-scanner-viewport video {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: contain;
    background: #000;
}

.isbn-scanner-frame {
    position: absolute;
    left: 8%;
    right: 8%;
    top: 28%;
    bottom: 28%;
    border: 2px solid rgba(255, 255, 255, 0.85);
    border-radius: var(--radius-sm);
    pointer-events: none;
    box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.28);
}

.isbn-scanner-hint {
    margin: 0.75rem 0 0;
    font-size: 0.85rem;
    color: var(--text-muted);
    text-align: center;
}

.input-row .btn {
    flex-shrink: 0;
}

@media (max-width: 768px) {
    .input-row {
        flex-wrap: wrap;
    }

    .input-row .form-input {
        min-width: 0;
        flex: 1 1 100%;
    }

    .input-row .btn {
        flex: 1 1 auto;
    }
}

/* ===== QR download ===== */
.qr-download-card {
    max-width: 420px;
    margin: 0 auto;
    text-align: center;
}

.qr-download-preview {
    margin-bottom: 1rem;
}

.qr-image {
    max-width: 220px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
}

.qr-placeholder {
    padding: 2rem;
    color: var(--text-muted);
}

.qr-placeholder i {
    font-size: 4rem;
    display: block;
    margin-bottom: 0.5rem;
}

.qr-hint {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 1.25rem;
}

/* ===== Manage returns ===== */
.admin-tabs {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1.25rem;
    border-bottom: 1px solid var(--border);
    padding-bottom: 0;
}

.admin-tab {
    padding: 0.65rem 1rem;
    border: none;
    background: none;
    font-weight: 600;
    font-size: 0.875rem;
    color: var(--text-muted);
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    cursor: pointer;
}

.admin-tab.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
}

.verify-card {
    max-width: 480px;
    margin: 0 auto 1.5rem;
    text-align: center;
}

.verify-icon {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--primary-soft);
    color: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    margin: 0 auto 1rem;
}

.verify-card h2 {
    font-size: 1.15rem;
    margin-bottom: 0.35rem;
}

.code-input-row {
    display: flex;
    gap: 0.5rem;
    justify-content: center;
    margin: 1.25rem 0;
}

.code-digit {
    width: 44px;
    height: 52px;
    text-align: center;
    font-size: 1.35rem;
    font-weight: 700;
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    font-family: inherit;
}

.code-digit:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-soft);
}

.btn-block {
    width: 100%;
    justify-content: center;
}

.form-error {
    color: var(--danger);
    font-size: 0.85rem;
    margin-top: 0.75rem;
}

.returns-books-section {
    margin-bottom: 1.25rem;
}

.returns-verify-bar {
    margin-bottom: 1.25rem;
}

.returns-section-title {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 0.875rem;
}

.returns-section-title-danger {
    color: var(--danger);
}

.returns-verify-row {
    display: flex;
    gap: 0.75rem;
    align-items: stretch;
}

.returns-code-input {
    flex: 1;
    min-width: 0;
}

.returns-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1.25rem;
    align-items: start;
}

.returns-column {
    min-height: 280px;
}

.returns-list-item {
    display: flex;
    align-items: center;
    gap: 0.875rem;
    padding: 0.875rem 0;
    border-bottom: 1px solid var(--border);
}

.returns-list-item:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

.returns-list-body {
    flex: 1;
    min-width: 0;
}

.returns-list-title {
    font-weight: 600;
    font-size: 0.9375rem;
    margin-bottom: 0.15rem;
}

.returns-list-meta {
    font-size: 0.8125rem;
    color: var(--text-muted);
}

.returns-list-meta-danger {
    color: var(--danger);
}

.returns-user-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1rem;
    padding: 0.75rem 1rem;
    background: var(--surface-muted);
    border-radius: var(--radius-md);
}

.returns-user-bar > div:first-child {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.returns-panel {
    margin-top: 0.25rem;
}

.returns-table-member {
    display: flex;
    align-items: center;
    gap: 0.625rem;
}

.returns-table-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 0.5rem;
    white-space: nowrap;
    text-align: right;
}

/* Admin mobile card lists (overdue, history) */
.admin-mobile-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.admin-mobile-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 1rem;
}

.admin-mobile-card-header,
.admin-mobile-card-top {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
}

.admin-mobile-card-top {
    margin-bottom: 0.625rem;
}

.admin-mobile-card-main {
    flex: 1;
    min-width: 0;
}

.admin-mobile-card-title {
    font-weight: 600;
    font-size: 0.9375rem;
    line-height: 1.35;
    margin-bottom: 0.15rem;
}

.admin-mobile-card-subtitle {
    font-size: 0.8125rem;
    color: var(--text-muted);
    word-break: break-word;
}

.admin-mobile-card-book {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    margin-bottom: 0.75rem;
    font-size: 0.875rem;
    line-height: 1.35;
}

.admin-mobile-card-book .admin-mobile-card-main {
    min-width: 0;
}

.admin-mobile-card-meta-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem 1rem;
    margin-bottom: 0.875rem;
    padding: 0.75rem;
    background: var(--surface-muted);
    border-radius: var(--radius-sm);
}

.admin-mobile-card-meta-grid:last-child {
    margin-bottom: 0;
}

.admin-mobile-card-meta-label {
    font-size: 0.6875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-muted);
    margin-bottom: 0.15rem;
}

.admin-mobile-card-meta-value {
    font-size: 0.8125rem;
    font-weight: 500;
}

.admin-mobile-card-actions {
    display: flex;
    gap: 0.5rem;
}

.admin-mobile-card-actions .btn {
    flex: 1;
    justify-content: center;
}

.admin-mobile-card-header .badge,
.admin-mobile-card-top .badge {
    flex-shrink: 0;
    margin-top: 0.125rem;
}

.return-verify-row {
    display: flex;
    align-items: center;
    gap: 0.875rem;
    padding: 0.875rem 1rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    margin-bottom: 0.75rem;
}

.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    z-index: 500;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.modal-overlay[hidden] {
    display: none;
}

.modal-card {
    width: 100%;
    max-width: 400px;
}

/* Manage admins */
.manage-admins-page {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.manage-admins-page .page-header {
    margin-bottom: 0;
}

.ma-panel-toolbar {
    display: flex;
    justify-content: flex-end;
    margin-bottom: 0.75rem;
}

.ma-stats {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 1rem;
}

.ma-stat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 1.125rem 1.25rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    min-height: 88px;
}

.ma-stat-body {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    min-width: 0;
}

.ma-stat-card .stat-value {
    font-size: 1.35rem;
    font-weight: 700;
    line-height: 1.2;
    color: var(--text);
}

.ma-stat-card .stat-label {
    font-size: 0.8rem;
    color: var(--text-muted);
    line-height: 1.3;
}

.ma-section {
    margin-bottom: 0;
}

.ma-section.card-padded {
    padding: 1.5rem;
}

.ma-section-head {
    margin-bottom: 1.25rem;
}

.card-title {
    margin: 0 0 0.35rem;
    font-size: 1.125rem;
    font-weight: 700;
}

.card-subtitle {
    margin: 0;
    color: var(--text-muted);
    font-size: 0.9rem;
    line-height: 1.45;
}

.ma-grant-form {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 180px auto;
    gap: 1rem 1.25rem;
    align-items: start;
}

.ma-role-field,
.ma-grant-action {
    display: flex;
    flex-direction: column;
}

.ma-label-spacer {
    visibility: hidden;
    user-select: none;
    margin-bottom: 0.4rem;
}

.ma-grant-btn {
    height: 42px;
    padding-inline: 1.125rem;
    white-space: nowrap;
}

.ma-search-field {
    position: relative;
}

.ma-search-box {
    position: relative;
}

.ma-search-box i {
    position: absolute;
    left: 0.875rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    pointer-events: none;
}

.ma-search-box .form-input {
    padding-left: 2.5rem;
    height: 42px;
}

.ma-role-field .form-select {
    height: 42px;
}

.ma-search-results {
    position: absolute;
    left: 0;
    right: 0;
    top: calc(100% + 0.35rem);
    z-index: 20;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-md);
    max-height: 240px;
    overflow-y: auto;
}

.ma-result {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    width: 100%;
    padding: 0.75rem 1rem;
    border: none;
    background: transparent;
    text-align: left;
    cursor: pointer;
    font: inherit;
    color: var(--text);
}

.ma-result:hover {
    background: var(--surface-muted);
}

.ma-result small {
    color: var(--text-muted);
    font-size: 0.8rem;
}

.ma-result.muted {
    cursor: default;
    color: var(--text-muted);
}

.ma-help {
    margin: 1rem 0 0;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
    color: var(--text-muted);
    font-size: 0.85rem;
    line-height: 1.45;
}

.ma-admin-list {
    display: flex;
    flex-direction: column;
    gap: 0.625rem;
}

.ma-admin-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 1rem;
    padding: 0.875rem 1rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface-muted);
}

.ma-admin-user {
    display: flex;
    align-items: center;
    gap: 0.875rem;
    min-width: 0;
}

.ma-admin-info {
    min-width: 0;
}

.ma-admin-email {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
    font-weight: 600;
    font-size: 0.925rem;
    line-height: 1.35;
    word-break: break-word;
}

.ma-admin-actions {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    flex-shrink: 0;
}

.ma-you {
    font-size: 0.7rem;
}

.badge-purple {
    background: var(--purple-soft);
    color: var(--purple);
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.625rem;
    margin-top: 1.25rem;
}

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

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

    .returns-verify-row {
        flex-direction: column;
    }

    .returns-verify-row .btn {
        width: 100%;
        justify-content: center;
    }

    .returns-list-item {
        flex-wrap: wrap;
        align-items: flex-start;
        padding: 1rem 0;
    }

    .returns-list-item > .user-avatar {
        flex-shrink: 0;
    }

    .returns-list-body {
        flex: 1 1 calc(100% - 52px);
        min-width: 0;
    }

    .returns-list-item > .btn {
        width: 100%;
        justify-content: center;
        margin-top: 0.125rem;
    }

    .returns-user-bar {
        flex-direction: column;
        align-items: stretch;
        gap: 0.75rem;
    }

    .returns-user-bar > div:first-child {
        width: 100%;
    }

    .admin-tabs {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        gap: 0;
    }

    .admin-tabs::-webkit-scrollbar {
        display: none;
    }

    .admin-tab {
        flex-shrink: 0;
        padding: 0.65rem 0.875rem;
    }

    .history-filters {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 0.625rem;
    }

    .history-filters .form-input {
        grid-column: 1 / -1;
    }

    .ma-grant-form {
        grid-template-columns: 1fr;
        gap: 1rem;
    }

    .ma-label-spacer {
        display: none;
    }

    .ma-grant-btn {
        width: 100%;
    }

    .manage-admins-page {
        gap: 1rem;
    }

    .ma-stats {
        grid-template-columns: 1fr;
    }

    .ma-admin-row {
        grid-template-columns: 1fr;
        gap: 0.75rem;
    }

    .ma-admin-actions {
        justify-content: flex-start;
        flex-wrap: wrap;
    }

    .ma-admin-actions .btn {
        flex: 0 1 auto;
    }

    .modal-overlay {
        align-items: flex-end;
        padding: 0;
    }

    .modal-card {
        max-width: none;
        border-radius: var(--radius-xl) var(--radius-xl) 0 0;
        padding-bottom: calc(env(safe-area-inset-bottom) + 1rem);
    }

    .code-digit {
        width: 38px;
        height: 46px;
        font-size: 1.15rem;
    }
}

/* ===== Cliq reports ===== */

.cliq-page {
    max-width: 720px;
}

.cliq-page-embedded {
    max-width: none;
}

.cliq-panel-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1rem;
}

.cliq-panel-toolbar .cliq-subtitle {
    margin: 0;
}

.cliq-page-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1.25rem;
}

.cliq-title {
    font-size: 1.35rem;
    font-weight: 700;
    color: var(--text);
    margin: 0;
}

.cliq-subtitle {
    margin: 0.25rem 0 0;
    color: var(--text-muted);
    font-size: 0.9rem;
}

.cliq-section {
    margin-bottom: 1rem;
}

.cliq-section-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
}

.cliq-status-line {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin: 0.35rem 0 0;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.cliq-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--success);
    flex-shrink: 0;
}

.cliq-quiet-actions {
    display: flex;
    gap: 0.25rem;
    flex-shrink: 0;
}

.btn-ghost {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-weight: 600;
}

.btn-ghost:hover {
    color: var(--primary);
    background: var(--primary-soft);
}

.cliq-danger-text {
    color: var(--danger) !important;
}

.cliq-danger-text:hover {
    background: var(--danger-soft) !important;
}

.cliq-channel-name {
    margin: 0.35rem 0 0;
    font-weight: 600;
    color: var(--text);
}

.cliq-inline-form {
    display: flex;
    gap: 0.75rem;
    align-items: center;
    margin-top: 0.5rem;
}

.cliq-inline-form .form-input {
    flex: 1;
}

.cliq-group {
    margin-top: 1.25rem;
    padding-top: 1.1rem;
    border-top: 1px solid var(--border);
}

.cliq-group:first-of-type {
    border-top: none;
    padding-top: 0.5rem;
}

.cliq-group-title {
    font-size: 0.95rem;
    font-weight: 700;
    margin: 0 0 0.75rem;
    color: var(--text);
}

.cliq-group-label {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.03em;
    margin: 0.85rem 0 0.5rem;
}

.cliq-toggle {
    display: flex;
    gap: 0.75rem;
    align-items: flex-start;
    cursor: pointer;
}

.cliq-toggle input {
    margin-top: 0.2rem;
}

.cliq-toggle-label {
    display: block;
    font-weight: 600;
    color: var(--text);
}

.cliq-toggle-help {
    display: block;
    margin-top: 0.15rem;
    font-size: 0.85rem;
    color: var(--text-muted);
}

.cliq-check-list {
    display: flex;
    flex-direction: column;
    gap: 0.55rem;
}

.cliq-check {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    font-weight: 500;
    color: var(--text);
    cursor: pointer;
}

.cliq-cadence-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.cliq-inline-select {
    width: auto;
    min-width: 96px;
}

.cliq-time-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.875rem;
    margin-top: 1rem;
}

.cliq-last-sent {
    margin: 1.1rem 0 0.5rem;
    font-size: 0.85rem;
    color: var(--text-muted);
}

.cliq-validation {
    margin: 0 0 0.5rem;
    font-size: 0.85rem;
    color: var(--danger);
}

.cliq-report-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.65rem;
    margin-top: 0.75rem;
}

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

.cliq-search-box {
    position: relative;
}

.cliq-search-box i {
    position: absolute;
    left: 0.85rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-tertiary);
    pointer-events: none;
}

.cliq-search-box .form-input {
    padding-left: 2.25rem;
}

.cliq-search-results {
    position: absolute;
    left: 0;
    right: 0;
    top: calc(100% + 4px);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-md);
    z-index: 20;
    max-height: 220px;
    overflow: auto;
}

.cliq-search-item {
    display: block;
    width: 100%;
    text-align: left;
    padding: 0.7rem 0.9rem;
    border: none;
    background: transparent;
    cursor: pointer;
    color: var(--text);
    border-bottom: 1px solid var(--border);
}

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

.cliq-search-item:hover {
    background: var(--primary-soft);
}

.cliq-search-empty {
    padding: 0.85rem 0.9rem;
    color: var(--text-muted);
    font-size: 0.9rem;
}

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

.cliq-member-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.7rem 0;
    border-bottom: 1px solid var(--border);
}

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

.cliq-empty-members {
    padding: 0.5rem 0;
    color: var(--text-muted);
    font-size: 0.9rem;
}

@media (max-width: 768px) {
    .cliq-page-head {
        flex-direction: column;
        align-items: stretch;
    }

    .cliq-inline-form {
        flex-direction: column;
        align-items: stretch;
    }

    .cliq-section-head {
        flex-direction: column;
    }

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

    .cliq-report-actions {
        position: sticky;
        bottom: calc(var(--bottom-nav-height) + 0.75rem);
        background: var(--surface);
        padding-top: 0.75rem;
        z-index: 5;
    }
}

/* Favourites / donated / More sheet */
.page-note {
    margin: -0.5rem 0 1rem;
    font-size: 0.85rem;
    color: var(--text-muted);
}

.donated-summary {
    margin-bottom: 1rem;
    padding: 0.75rem 1rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.donated-card {
    position: relative;
}

.donated-mark {
    color: #db2777;
    font-size: 1.1rem;
    flex-shrink: 0;
}

.overview-shortcuts {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
    margin: 0 0 1.25rem;
}

.overview-shortcut {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.85rem 1rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    text-align: left;
    color: var(--text);
}

.overview-shortcut:hover {
    border-color: var(--primary);
}

.overview-shortcut-icon {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #fef2f2;
    color: #dc2626;
    flex-shrink: 0;
}

.overview-shortcut-icon.gift {
    background: #fdf2f8;
    color: #db2777;
}

.overview-shortcut-body {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.overview-shortcut-label {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.overview-shortcut-value {
    font-size: 1.15rem;
    font-weight: 700;
}

.overview-shortcut .bi-chevron-right {
    color: var(--text-muted);
    font-size: 0.85rem;
}

.donor-picker {
    position: relative;
}

.donor-results {
    position: absolute;
    left: 0;
    right: 0;
    top: calc(100% + 4px);
    z-index: 20;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-md);
    max-height: 220px;
    overflow-y: auto;
}

.donor-result {
    display: block;
    width: 100%;
    text-align: left;
    padding: 0.65rem 0.85rem;
    font-size: 0.875rem;
    color: var(--text);
    background: transparent;
}

.donor-result:hover {
    background: var(--surface-muted);
}

.donor-chip {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-top: 0.5rem;
    padding: 0.5rem 0.75rem;
    background: var(--surface-muted);
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
}

.donor-chip-clear {
    margin-left: auto;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    color: var(--text-muted);
}

.donor-chip-clear:hover {
    background: var(--border);
}

.more-panel {
    display: none;
    position: fixed;
    z-index: 1250;
    left: 0;
    right: 0;
    bottom: 0;
    max-height: 70vh;
    overflow-y: auto;
    background: var(--surface);
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
    box-shadow: var(--shadow-lg);
    padding-bottom: calc(env(safe-area-inset-bottom) + 0.5rem);
}

.more-panel.show {
    display: block;
}

.more-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem;
    border-bottom: 1px solid var(--border);
    font-weight: 600;
}

.more-panel-list {
    padding: 0.5rem;
    display: flex;
    flex-direction: column;
}

.more-list-item {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    width: 100%;
    padding: 0.9rem 1rem;
    border: 0;
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--text);
    font-size: 0.95rem;
    text-align: left;
}

.more-list-item i {
    width: 1.25rem;
    color: var(--text-muted);
}

.more-list-item.active {
    background: var(--surface-muted);
    font-weight: 600;
    color: var(--primary);
}

.more-list-item.active i {
    color: var(--primary);
}

.more-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    z-index: 1240;
}

.more-backdrop.show {
    display: block;
}

@media (min-width: 769px) {
    .more-backdrop.show,
    .more-panel {
        display: none !important;
    }
}

@media (max-width: 768px) {
    .overview-shortcuts {
        grid-template-columns: 1fr;
    }
}
