/* Global & Theme */
        :root {
            --primary-color: #f35525;
            --secondary-color: #2c3e50;
            --bg-gradient: linear-gradient(180deg, #fdfbfb 0%, #ebedee 100%);
            --card-bg: rgba(255, 255, 255, 0.95);
            --card-radius: 24px;
        }

        body {
            background: var(--bg-gradient);
            font-family: 'Sarabun', sans-serif;
            min-height: 100vh;
            color: #334155;
            padding-bottom: 90px;
        }

        h1,
        h2,
        h3,
        h4,
        h5,
        h6,
        .btn,
        .badge {
            font-family: 'Prompt', sans-serif;
        }

        /* UI Components */
        .app-header {
            background: rgba(255, 255, 255, 0.9);
            backdrop-filter: blur(15px);
            -webkit-backdrop-filter: blur(15px);
            border-bottom-left-radius: 30px;
            border-bottom-right-radius: 30px;
            padding: 15px 15px 10px 15px;
            box-shadow: 0 10px 40px rgba(0, 0, 0, 0.05);
            position: sticky;
            top: 0;
            z-index: 100;
            display: none; /* Hidden by default until login */
        }

        .brand-logo {
            max-height: 45px;
            margin-bottom: 5px;
            filter: drop-shadow(0 4px 6px rgba(0, 0, 0, 0.1));
            transition: transform 0.3s;
        }

        .brand-logo:hover {
            transform: scale(1.1) rotate(-5deg);
        }

        .brand-title {
            font-family: 'Prompt', sans-serif;
            font-weight: 600;
            font-size: 0.9rem;
            color: var(--primary-color);
            line-height: 1.2;
            margin-bottom: 0;
        }

        .brand-subtitle {
            font-size: 0.75rem;
            color: #64748b;
            font-weight: 500;
        }

        .search-box {
            background: #fff;
            border: 1px solid #e2e8f0;
            border-radius: 50px;
            padding: 10px 20px 10px 50px;
            width: 100%;
            transition: all 0.3s;
            font-size: 0.95rem;
            box-shadow: 0 4px 10px rgba(0, 0, 0, 0.03);
        }

        .search-box:focus {
            border-color: var(--primary-color);
            box-shadow: 0 4px 15px rgba(243, 85, 37, 0.15);
            transform: translateY(-2px);
        }

        .search-icon {
            position: absolute;
            left: 20px;
            top: 50%;
            transform: translateY(-50%);
            color: #94a3b8;
            font-size: 1.1rem;
        }

        .filter-scroll {
            display: flex;
            gap: 8px;
            overflow-x: auto;
            padding-bottom: 5px;
            scrollbar-width: none;
        }

        .filter-scroll::-webkit-scrollbar {
            display: none;
        }

        .filter-chip {
            white-space: nowrap;
            padding: 8px 16px;
            border-radius: 50px;
            background: white;
            border: 1px solid #e2e8f0;
            color: #64748b;
            font-size: 0.85rem;
            font-family: 'Prompt', sans-serif;
            cursor: pointer;
            transition: all 0.2s;
        }

        .filter-chip:hover {
            transform: translateY(-2px);
        }

        .filter-chip.active {
            background: var(--primary-color);
            color: white;
            border-color: var(--primary-color);
            box-shadow: 0 8px 15px rgba(243, 85, 37, 0.3);
            transform: translateY(-2px);
        }

        /* Cards - Optimized animations - Reduced will-change for better performance */
        .book-card {
            background: var(--card-bg);
            border-radius: var(--card-radius);
            border: 1px solid rgba(255, 255, 255, 0.8);
            box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.05), 0 5px 10px -5px rgba(0, 0, 0, 0.01);
            padding: 18px;
            height: 100%;
            display: flex;
            flex-direction: column;
            position: relative;
            transition: transform 0.2s ease-out, box-shadow 0.2s ease-out;
            /* Removed will-change - causes performance issues with many cards */
        }

        .book-card:hover {
            transform: translateY(-3px);
            /* Reduced from -5px for smoother performance */
            box-shadow: 0 15px 30px -5px rgba(243, 85, 37, 0.12), 0 8px 15px -5px rgba(0, 0, 0, 0.08);
        }

        .book-status {
            position: absolute;
            top: 15px;
            right: 15px;
            font-size: 0.7rem;
            padding: 5px 12px;
            border-radius: 20px;
            font-weight: 600;
            box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
        }

        .status-vacant {
            background: #d1fae5;
            color: #065f46;
        }

        .status-borrowed {
            background: #ffedd5;
            color: #9a3412;
        }

        .status-overdue {
            background: #fee2e2;
            color: #991b1b;
        }

        .status-disposed {
            background: #f3f4f6;
            color: #6b7280;
            border: 1px solid #e5e7eb;
        }

        .book-title {
            font-weight: 600;
            font-size: 1.05rem;
            margin-bottom: 8px;
            margin-right: 75px;
            color: #1e293b;
            line-height: 1.4;
            display: -webkit-box;
            -webkit-line-clamp: 2;
            line-clamp: 2;
            -webkit-box-orient: vertical;
            overflow: hidden;
        }

        .book-meta {
            font-size: 0.8rem;
            color: #64748b;
            margin-bottom: 5px;
            display: flex;
            align-items: center;
            gap: 6px;
            flex-wrap: wrap;
        }

        .book-action-btn {
            margin-top: auto;
            width: 100%;
            border-radius: 12px;
            padding: 10px;
            font-weight: 600;
            border: none;
            transition: 0.2s;
            font-family: 'Prompt', sans-serif;
            font-size: 0.9rem;
        }

        .btn-borrow {
            background: var(--primary-color);
            color: white;
            box-shadow: 0 4px 10px rgba(243, 85, 37, 0.3);
        }

        .btn-borrow:hover {
            box-shadow: 0 6px 12px rgba(243, 85, 37, 0.35);
            transform: translateY(-1px);
        }

        .btn-return {
            background: #10b981;
            color: white;
            box-shadow: 0 4px 10px rgba(16, 185, 129, 0.3);
        }

        .btn-edit-borrow {
            background: #0ea5e9;
            color: white;
            box-shadow: 0 4px 10px rgba(14, 165, 233, 0.3);
        }

        .btn-disabled {
            background: #f1f5f9;
            color: #cbd5e1;
            cursor: not-allowed;
            border: 1px solid #e2e8f0;
        }

        /* Dashboard */
        .dashboard-section {
            display: flex;
            flex-direction: column;
            gap: 12px;
            margin-bottom: 18px;
        }

        .dashboard-toolbar {
            display: flex;
            align-items: flex-end;
            justify-content: space-between;
            gap: 12px;
            padding: 4px 2px 0;
        }

        .dashboard-kicker {
            display: inline-flex;
            align-items: center;
            gap: 6px;
            color: #f35525;
            font-family: 'Prompt', sans-serif;
            font-size: 0.74rem;
            font-weight: 700;
            text-transform: uppercase;
        }

        .dashboard-title {
            margin: 0;
            color: #0f172a;
            font-size: 1.35rem;
            font-weight: 700;
        }

        .dashboard-subtitle {
            color: #64748b;
            font-size: 0.86rem;
            margin: 2px 0 0;
        }

        .dashboard-toolbar-actions {
            display: flex;
            align-items: center;
            justify-content: flex-end;
            gap: 8px;
            flex-wrap: wrap;
        }

        .dashboard-pill {
            display: inline-flex;
            align-items: center;
            gap: 6px;
            border: 1px solid #e2e8f0;
            background: #ffffff;
            color: #475569;
            border-radius: 50px;
            padding: 7px 12px;
            font-family: 'Prompt', sans-serif;
            font-size: 0.78rem;
            font-weight: 600;
            white-space: nowrap;
        }

        .dashboard-pill button {
            border: 0;
            background: transparent;
            color: inherit;
            padding: 0;
            line-height: 1;
        }

        .dashboard-metrics {
            display: grid;
            grid-template-columns: repeat(5, minmax(0, 1fr));
            gap: 10px;
        }

        .dashboard-metric {
            min-height: 112px;
            background: #ffffff;
            border: 1px solid #e2e8f0;
            border-radius: 18px;
            padding: 14px;
            display: flex;
            flex-direction: column;
            justify-content: space-between;
            box-shadow: 0 8px 18px rgba(15, 23, 42, 0.04);
            cursor: pointer;
            transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
        }

        .dashboard-metric:hover {
            transform: translateY(-2px);
            border-color: #cbd5e1;
            box-shadow: 0 14px 28px rgba(15, 23, 42, 0.08);
        }

        .dashboard-metric-top {
            display: flex;
            align-items: center;
            justify-content: space-between;
            gap: 8px;
        }

        .dashboard-metric-label {
            color: #64748b;
            font-family: 'Prompt', sans-serif;
            font-size: 0.78rem;
            font-weight: 600;
        }

        .dashboard-metric-icon {
            width: 34px;
            height: 34px;
            border-radius: 12px;
            display: inline-flex;
            align-items: center;
            justify-content: center;
            font-size: 0.95rem;
        }

        .dashboard-metric-value {
            color: #0f172a;
            font-family: 'Prompt', sans-serif;
            font-size: 1.9rem;
            font-weight: 700;
            line-height: 1.05;
            margin-top: 8px;
        }

        .dashboard-metric-foot {
            color: #64748b;
            font-size: 0.78rem;
            margin-top: 5px;
        }

        .dashboard-metric.total .dashboard-metric-icon { background: #e0f2fe; color: #0369a1; }
        .dashboard-metric.available .dashboard-metric-icon { background: #dcfce7; color: #15803d; }
        .dashboard-metric.borrowed .dashboard-metric-icon { background: #ffedd5; color: #c2410c; }
        .dashboard-metric.overdue .dashboard-metric-icon { background: #fee2e2; color: #b91c1c; }
        .dashboard-metric.arrivals .dashboard-metric-icon { background: #ccfbf1; color: #0f766e; }

        .dashboard-grid {
            display: grid;
            grid-template-columns: minmax(0, 1.2fr) minmax(0, 0.8fr);
            gap: 10px;
        }

        .dashboard-panel {
            background: #ffffff;
            border: 1px solid #e2e8f0;
            border-radius: 18px;
            padding: 14px;
            box-shadow: 0 8px 18px rgba(15, 23, 42, 0.04);
            min-width: 0;
        }

        .dashboard-panel-header {
            display: flex;
            align-items: center;
            justify-content: space-between;
            gap: 10px;
            margin-bottom: 12px;
        }

        .dashboard-panel-title {
            margin: 0;
            color: #0f172a;
            font-size: 0.95rem;
            font-weight: 700;
        }

        .dashboard-panel-meta {
            color: #94a3b8;
            font-size: 0.76rem;
            white-space: nowrap;
        }

        .dashboard-panel-wide {
            grid-column: 1 / -1;
        }

        .dashboard-year-field {
            display: inline-flex;
            align-items: center;
            gap: 8px;
            color: #475569;
            font-family: 'Prompt', sans-serif;
            font-size: 0.78rem;
            font-weight: 600;
            white-space: nowrap;
        }

        .dashboard-year-select {
            min-width: 104px;
            border: 1px solid #cbd5e1;
            background: #ffffff;
            color: #0f172a;
            border-radius: 12px;
            padding: 7px 30px 7px 10px;
            font-family: 'Prompt', sans-serif;
            font-size: 0.82rem;
            font-weight: 600;
        }

        .dashboard-acquisition-summary {
            display: grid;
            grid-template-columns: repeat(3, minmax(0, 1fr));
            gap: 9px;
            margin-bottom: 12px;
        }

        .dashboard-acquisition-card {
            border: 1px solid #e2e8f0;
            background: #f8fafc;
            border-radius: 14px;
            padding: 11px;
            min-width: 0;
        }

        .dashboard-acquisition-label {
            display: block;
            color: #64748b;
            font-family: 'Prompt', sans-serif;
            font-size: 0.76rem;
            font-weight: 600;
        }

        .dashboard-acquisition-value {
            display: block;
            color: #0f172a;
            font-family: 'Prompt', sans-serif;
            font-size: 1.45rem;
            font-weight: 700;
            line-height: 1.15;
            margin-top: 3px;
        }

        .dashboard-acquisition-note {
            display: block;
            color: #94a3b8;
            font-size: 0.74rem;
            margin-top: 2px;
            overflow: hidden;
            text-overflow: ellipsis;
            white-space: nowrap;
        }

        .dashboard-acquisition-layout {
            display: grid;
            grid-template-columns: minmax(0, 1.25fr) minmax(260px, 0.75fr);
            gap: 12px;
        }

        .dashboard-month-list {
            display: flex;
            flex-direction: column;
            gap: 8px;
        }

        .dashboard-month-row {
            display: grid;
            grid-template-columns: 42px minmax(0, 1fr) 36px;
            gap: 8px;
            align-items: center;
            min-height: 28px;
        }

        .dashboard-month-label {
            color: #475569;
            font-family: 'Prompt', sans-serif;
            font-size: 0.76rem;
            font-weight: 700;
        }

        .dashboard-month-track {
            height: 9px;
            border-radius: 50px;
            background: #e2e8f0;
            overflow: hidden;
        }

        .dashboard-month-fill {
            height: 100%;
            border-radius: inherit;
            background: #14b8a6;
        }

        .dashboard-month-row.active .dashboard-month-label {
            color: #0f766e;
        }

        .dashboard-month-row.active .dashboard-month-fill {
            background: #f35525;
        }

        .dashboard-month-count {
            color: #0f172a;
            font-family: 'Prompt', sans-serif;
            font-size: 0.78rem;
            font-weight: 700;
            text-align: right;
        }

        .dashboard-received-list {
            display: flex;
            flex-direction: column;
            gap: 8px;
        }

        .dashboard-status-strip {
            display: flex;
            width: 100%;
            height: 14px;
            overflow: hidden;
            border-radius: 50px;
            background: #f1f5f9;
            border: 1px solid #e2e8f0;
        }

        .dashboard-status-segment {
            min-width: 0;
            transition: width 0.25s ease;
        }

        .dashboard-status-segment.available { background: #22c55e; }
        .dashboard-status-segment.borrowed { background: #f97316; }
        .dashboard-status-segment.overdue { background: #ef4444; }
        .dashboard-status-segment.disposed { background: #94a3b8; }

        .dashboard-legend {
            display: grid;
            grid-template-columns: repeat(2, minmax(0, 1fr));
            gap: 8px;
            margin-top: 12px;
        }

        .dashboard-legend-item {
            display: flex;
            align-items: center;
            justify-content: space-between;
            gap: 8px;
            color: #475569;
            font-size: 0.82rem;
            background: #f8fafc;
            border: 1px solid #eef2f7;
            border-radius: 12px;
            padding: 8px 10px;
        }

        .dashboard-dot {
            width: 9px;
            height: 9px;
            border-radius: 50%;
            display: inline-block;
            margin-right: 6px;
        }

        .dashboard-dot.available { background: #22c55e; }
        .dashboard-dot.borrowed { background: #f97316; }
        .dashboard-dot.overdue { background: #ef4444; }
        .dashboard-dot.disposed { background: #94a3b8; }

        .dashboard-progress-list,
        .dashboard-list {
            display: flex;
            flex-direction: column;
            gap: 9px;
        }

        .dashboard-progress-row {
            display: grid;
            grid-template-columns: minmax(0, 1fr) auto;
            gap: 10px;
            align-items: center;
        }

        .dashboard-progress-label {
            color: #334155;
            font-size: 0.82rem;
            overflow: hidden;
            text-overflow: ellipsis;
            white-space: nowrap;
        }

        .dashboard-progress-track {
            grid-column: 1 / -1;
            height: 7px;
            border-radius: 50px;
            background: #e2e8f0;
            overflow: hidden;
        }

        .dashboard-progress-fill {
            height: 100%;
            border-radius: inherit;
            background: #0ea5e9;
        }

        .dashboard-progress-count {
            color: #0f172a;
            font-family: 'Prompt', sans-serif;
            font-size: 0.8rem;
            font-weight: 700;
        }

        .dashboard-list-item {
            display: grid;
            grid-template-columns: 34px minmax(0, 1fr) auto;
            gap: 9px;
            align-items: center;
            border: 1px solid #eef2f7;
            background: #f8fafc;
            border-radius: 14px;
            padding: 9px;
            min-height: 54px;
        }

        .dashboard-list-icon {
            width: 34px;
            height: 34px;
            border-radius: 12px;
            display: inline-flex;
            align-items: center;
            justify-content: center;
            background: #e0f2fe;
            color: #0369a1;
            font-size: 0.9rem;
        }

        .dashboard-list-main {
            min-width: 0;
        }

        .dashboard-list-title {
            color: #0f172a;
            font-size: 0.86rem;
            font-weight: 700;
            overflow: hidden;
            text-overflow: ellipsis;
            white-space: nowrap;
        }

        .dashboard-list-subtitle {
            color: #64748b;
            font-size: 0.76rem;
            overflow: hidden;
            text-overflow: ellipsis;
            white-space: nowrap;
        }

        .dashboard-tag {
            border-radius: 50px;
            padding: 5px 8px;
            font-family: 'Prompt', sans-serif;
            font-size: 0.72rem;
            font-weight: 700;
            white-space: nowrap;
        }

        .dashboard-tag.due-soon { background: #fef3c7; color: #92400e; }
        .dashboard-tag.overdue { background: #fee2e2; color: #991b1b; }
        .dashboard-tag.mine { background: #dcfce7; color: #166534; }

        .dashboard-empty {
            min-height: 96px;
            display: flex;
            align-items: center;
            justify-content: center;
            text-align: center;
            color: #94a3b8;
            border: 1px dashed #cbd5e1;
            border-radius: 14px;
            background: #f8fafc;
            font-size: 0.88rem;
        }

        .book-section-header {
            display: flex;
            align-items: center;
            justify-content: space-between;
            gap: 10px;
            margin: 8px 2px 10px;
        }

        .book-section-title {
            margin: 0;
            color: #0f172a;
            font-size: 1rem;
            font-weight: 700;
        }

        .book-section-count {
            color: #64748b;
            font-size: 0.78rem;
            font-family: 'Prompt', sans-serif;
        }

        .app-view {
            display: none;
        }

        .app-view.active {
            display: block;
        }

        @media (max-width: 992px) {
            .dashboard-metrics {
                grid-template-columns: repeat(2, minmax(0, 1fr));
            }

            .dashboard-grid {
                grid-template-columns: 1fr;
            }

            .dashboard-acquisition-layout {
                grid-template-columns: 1fr;
            }
        }

        @media (max-width: 576px) {
            .dashboard-toolbar {
                align-items: flex-start;
                flex-direction: column;
            }

            .dashboard-toolbar-actions {
                width: 100%;
                justify-content: flex-start;
            }

            .dashboard-metrics {
                grid-template-columns: 1fr;
            }

            .dashboard-acquisition-summary {
                grid-template-columns: 1fr;
            }

            .dashboard-metric {
                min-height: 96px;
            }

            .dashboard-legend {
                grid-template-columns: 1fr;
            }

            .dashboard-list-item {
                grid-template-columns: 30px minmax(0, 1fr);
            }

            .dashboard-list-icon {
                width: 30px;
                height: 30px;
            }

            .dashboard-tag {
                grid-column: 2;
                justify-self: start;
            }
        }

        /* FAB */
        .fab-container {
            position: fixed;
            bottom: 25px;
            right: 20px;
            display: none; /* Hidden by default until login */
            flex-direction: column;
            gap: 15px;
            z-index: 200;
        }

        .fab-btn {
            width: 58px;
            height: 58px;
            border-radius: 50%;
            background: var(--primary-color);
            color: white;
            border: none;
            box-shadow: 0 10px 25px rgba(243, 85, 37, 0.5);
            display: flex;
            align-items: center;
            justify-content: center;
            font-size: 1.5rem;
            transition: transform 0.2s;
        }

        .fab-btn.secondary {
            width: 48px;
            height: 48px;
            background: white;
            color: #475569;
            font-size: 1.2rem;
            box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
        }

        .fab-btn.help-btn {
            background: #8e44ad;
            color: white;
            box-shadow: 0 8px 20px rgba(142, 68, 173, 0.4);
        }

        .fab-btn:hover {
            transform: scale(1.1);
        }
        /* AI Assistant */
        .fab-btn.ai-btn {
            background: linear-gradient(135deg, #0ea5e9, #0f766e);
            color: #fff;
            box-shadow: 0 10px 25px rgba(14, 165, 233, 0.35);
        }

        .ai-assistant-overlay {
            position: fixed;
            inset: 0;
            background: rgba(15, 23, 42, 0.48);
            backdrop-filter: blur(2px);
            -webkit-backdrop-filter: blur(2px);
            display: none;
            align-items: center;
            justify-content: center;
            padding: 14px;
            z-index: 2000;
        }

        .ai-assistant-overlay.open {
            display: flex;
        }

        .ai-assistant-modal {
            width: min(980px, 100%);
            height: min(88vh, 760px);
            background: #f8fafc;
            border: 1px solid #e2e8f0;
            border-radius: 18px;
            box-shadow: 0 24px 60px rgba(15, 23, 42, 0.32);
            display: flex;
            flex-direction: column;
            overflow: hidden;
        }

        .ai-assistant-header {
            padding: 14px 16px;
            background: #ffffff;
            border-bottom: 1px solid #e2e8f0;
            display: flex;
            align-items: center;
            justify-content: space-between;
        }

        .ai-assistant-title-wrap {
            display: flex;
            align-items: center;
            gap: 10px;
        }

        .ai-assistant-title-wrap h3 {
            margin: 0;
            font-size: 1.8rem;
            color: #0f172a;
            font-family: 'Prompt', sans-serif;
        }

        .ai-assistant-icon {
            width: 32px;
            height: 32px;
            border-radius: 10px;
            background: #e0f2fe;
            color: #0369a1;
            display: inline-flex;
            align-items: center;
            justify-content: center;
            font-size: 1rem;
        }

        .ai-assistant-close {
            width: 36px;
            height: 36px;
            border-radius: 50%;
            border: 1px solid #cbd5e1;
            background: #f8fafc;
            color: #475569;
        }

        .ai-assistant-controls {
            padding: 12px 16px;
            display: flex;
            flex-wrap: wrap;
            gap: 10px 16px;
            align-items: center;
            border-bottom: 1px solid #e2e8f0;
            background: #f8fafc;
        }

        .ai-summary-btn {
            border: none;
            border-radius: 999px;
            padding: 9px 14px;
            font-size: 0.86rem;
            font-weight: 600;
            color: #fff;
            background: linear-gradient(135deg, #0284c7, #0f766e);
            box-shadow: 0 8px 20px rgba(14, 116, 144, 0.28);
            font-family: 'Prompt', sans-serif;
        }

        .ai-assistant-option {
            display: inline-flex;
            align-items: center;
            gap: 6px;
            color: #334155;
            font-size: 0.9rem;
            user-select: none;
        }

        .ai-assistant-messages {
            flex: 1;
            margin: 0 16px;
            border: 1px solid #cbd5e1;
            background: #e2e8f0;
            border-radius: 12px;
            padding: 12px;
            overflow-y: auto;
            display: flex;
            flex-direction: column;
            gap: 10px;
        }

        .ai-msg {
            max-width: 86%;
            border-radius: 12px;
            padding: 10px 12px;
            line-height: 1.45;
            word-break: break-word;
            white-space: pre-wrap;
            font-size: 0.93rem;
        }

        .ai-msg-label {
            display: block;
            font-size: 0.75rem;
            opacity: 0.8;
            margin-bottom: 4px;
            font-weight: 700;
        }

        .ai-msg.assistant {
            align-self: flex-start;
            background: #ffffff;
            border: 1px solid #cbd5e1;
            color: #1e293b;
        }

        .ai-msg.user {
            align-self: flex-end;
            background: #0ea5e9;
            border: 1px solid #0284c7;
            color: #ffffff;
        }

        .ai-assistant-input-wrap {
            padding: 10px 16px 6px;
        }

        .ai-assistant-input {
            width: 100%;
            min-height: 70px;
            max-height: 130px;
            resize: vertical;
            border: 1px solid #0ea5e9;
            background: #ffffff;
            border-radius: 10px;
            padding: 12px;
            font-size: 0.95rem;
            font-family: 'Sarabun', sans-serif;
        }

        .ai-assistant-actions {
            padding: 0 16px 14px;
            display: flex;
            justify-content: flex-end;
            gap: 10px;
        }

        .ai-btn-reset {
            border: none;
            border-radius: 10px;
            background: #64748b;
            color: #fff;
            padding: 9px 16px;
            font-size: 0.88rem;
            font-weight: 600;
            font-family: 'Prompt', sans-serif;
        }

        .ai-btn-send {
            border: none;
            border-radius: 10px;
            background: #0891b2;
            color: #fff;
            padding: 9px 16px;
            font-size: 0.88rem;
            font-weight: 600;
            font-family: 'Prompt', sans-serif;
        }

        .ai-summary-btn:disabled,
        .ai-btn-reset:disabled,
        .ai-btn-send:disabled,
        .ai-assistant-input:disabled {
            opacity: 0.65;
            cursor: not-allowed;
        }

        @media (max-width: 768px) {
            .ai-assistant-modal {
                height: min(92vh, 860px);
                border-radius: 14px;
            }

            .ai-assistant-title-wrap h3 {
                font-size: 1.4rem;
            }

            .ai-assistant-controls {
                gap: 8px;
            }

            .ai-assistant-option {
                font-size: 0.82rem;
            }

            .ai-assistant-messages {
                margin: 0 10px;
            }

            .ai-assistant-input-wrap,
            .ai-assistant-actions {
                padding-left: 10px;
                padding-right: 10px;
            }
        }
        /* SweetAlert & Custom */
        .swal2-popup.rounded-4 {
            border-radius: 24px !important;
            font-family: 'Sarabun', sans-serif;
            box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2);
        }

        .swal2-title {
            font-family: 'Prompt', sans-serif !important;
            font-size: 1.4rem !important;
        }

        .form-control,
        .form-select {
            border-radius: 12px;
            background-color: #f8fafc;
            border: 1px solid #e2e8f0;
            padding: 12px;
            font-size: 0.95rem;
            transition: 0.2s;
        }

        .form-control:focus,
        .form-select:focus {
            border-color: var(--primary-color);
            box-shadow: 0 0 0 4px rgba(243, 85, 37, 0.15);
        }

        .history-card {
            border-radius: 16px;
            border: 1px solid #f1f5f9;
            transition: transform 0.2s;
            background: white;
        }

        .history-card:hover {
            transform: translateY(-3px);
            box-shadow: 0 10px 25px rgba(0, 0, 0, 0.08);
        }

        .manual-step {
            margin-bottom: 18px;
            border-left: 4px solid var(--primary-color);
            padding-left: 15px;
            background: #fff5f2;
            border-radius: 0 10px 10px 0;
            padding: 10px 10px 10px 15px;
        }

        .manual-icon {
            color: var(--primary-color);
            width: 25px;
            text-align: center;
            margin-right: 5px;
        }

        /* Loading overlay */
        .loading-overlay {
            position: fixed;
            top: 0;
            left: 0;
            right: 0;
            bottom: 0;
            background: rgba(255, 255, 255, 0.8);
            display: flex;
            align-items: center;
            justify-content: center;
            z-index: 9999;
        }

        .loading-overlay.hidden {
            display: none;
        }

        /* Real-time indicator */
        .realtime-indicator {
            display: inline-flex;
            align-items: center;
            gap: 5px;
            font-size: 0.7rem;
            color: #10b981;
            font-weight: 500;
            padding: 2px 8px;
            background: #d1fae5;
            border-radius: 20px;
            animation: fadeInUp 0.3s ease;
        }

        .realtime-dot {
            width: 6px;
            height: 6px;
            border-radius: 50%;
            background: #10b981;
            animation: pulse-dot 2s infinite;
        }

        @keyframes pulse-dot {
            0%, 100% { opacity: 1; transform: scale(1); }
            50% { opacity: 0.5; transform: scale(0.7); }
        }

        @keyframes fadeInUp {
            from { opacity: 0; transform: translateY(10px); }
            to { opacity: 1; transform: translateY(0); }
        }

        /* Real-time toast */
        .realtime-toast {
            position: fixed;
            top: 15px;
            left: 50%;
            transform: translateX(-50%);
            background: rgba(16, 185, 129, 0.95);
            color: white;
            padding: 8px 20px;
            border-radius: 50px;
            font-size: 0.8rem;
            font-family: 'Prompt', sans-serif;
            font-weight: 500;
            z-index: 10000;
            box-shadow: 0 8px 25px rgba(16, 185, 129, 0.4);
            animation: toastIn 0.4s ease, toastOut 0.4s ease 2.6s forwards;
            pointer-events: none;
        }

        @keyframes toastIn {
            from { opacity: 0; transform: translateX(-50%) translateY(-20px); }
            to { opacity: 1; transform: translateX(-50%) translateY(0); }
        }

        @keyframes toastOut {
            from { opacity: 1; transform: translateX(-50%) translateY(0); }
            to { opacity: 0; transform: translateX(-50%) translateY(-20px); }
        }

        /* Card update flash */
        .book-card.updated {
            animation: cardFlash 1s ease;
        }

        @keyframes cardFlash {
            0% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.5); }
            50% { box-shadow: 0 0 20px 5px rgba(16, 185, 129, 0.3); }
            100% { box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.05), 0 5px 10px -5px rgba(0, 0, 0, 0.01); }
        }