body {
    font-family: 'Arial', sans-serif;
    margin: 0;
    padding: 0;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    color: var(--text-primary, #333);
    transition: background 0.3s ease, color 0.3s ease;
}

[data-theme="dark"] body {
    background: linear-gradient(135deg, #1a202c 0%, #2d3748 100%);
}

header {
    background: linear-gradient(135deg, var(--accent-primary, #667eea) 0%, var(--accent-secondary, #764ba2) 100%);
    color: #fff;
    padding: 0;
    box-shadow: 0 2px 10px var(--shadow, rgba(0,0,0,0.1));
}

.header-content {
    max-width: 1200px;
    margin: 0 auto;
    padding: 15px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
}

h1 {
    margin: 0;
    font-size: 1.8em;
    font-weight: 600;
}

nav {
    margin: 0;
}

.nav-list {
    display: flex;
    list-style: none;
    margin: 0;
    padding: 0;
    gap: 8px;
}

.nav-link {
    color: #fff;
    text-decoration: none;
    padding: 10px 16px;
    border-radius: 6px;
    transition: all 0.3s ease;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 6px;
}

.nav-link:hover {
    background: rgba(255,255,255,0.2);
    transform: translateY(-1px);
}

.nav-link.active {
    background: rgba(255,255,255,0.25);
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

main {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

/* Section Management */
.app-section {
    display: none;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(15px);
    border-radius: 20px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12);
    padding: 35px;
    margin-bottom: 25px;
    border: 1px solid rgba(255, 255, 255, 0.18);
}

.app-section.active {
    display: block;
    animation: fadeIn 0.3s ease-in;
}

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

/* Section Headers */
.section-header {
    margin-bottom: 30px;
    border-bottom: 2px solid #f3f4f6;
    padding-bottom: 20px;
}

.section-header h2 {
    margin: 0 0 8px 0;
    font-size: 2em;
    font-weight: 700;
    color: #1f2937;
}

.section-description {
    margin: 0;
    color: #6b7280;
    font-size: 1.1em;
}

table {
    width: 100%;
    border-collapse: collapse;
}

th, td {
    padding: 10px;
    text-align: left;
    border-bottom: 1px solid #ddd;
}

th {
    background: #007bff;
    color: #fff;
}

tr:hover {
    background: #f1f1f1;
}

button {
    background: #28a745;
    color: #fff;
    border: none;
    padding: 10px 15px;
    border-radius: 5px;
    cursor: pointer;
    transition: background 0.3s;
}

button:hover {
    background: #218838;
}

input, select, textarea {
    width: 100%;
    padding: 10px;
    margin: 10px 0;
    border: 1px solid #ccc;
    border-radius: 5px;
}

input:focus, select:focus, textarea:focus {
    border-color: #007bff;
    outline: none;
}

footer {
    text-align: center;
    padding: 20px;
    background: linear-gradient(135deg, var(--accent-primary, #667eea) 0%, var(--accent-secondary, #764ba2) 100%);
    color: #fff;
    position: relative;
    bottom: 0;
    width: 100%;
}

/* visually-hidden utility */
.visually-hidden {
    position: absolute !important;
    height: 1px; width: 1px;
    overflow: hidden;
    clip: rect(1px, 1px, 1px, 1px);
    white-space: nowrap;
}

/* visible focus for keyboard users */
:focus {
    outline: 3px solid #2563eb; /* accessible blue */
    outline-offset: 2px;
}

/* simple table styling */
.records-table {
    border-collapse: collapse;
}
.records-table th, .records-table td {
    padding: 8px 10px;
    border-bottom: 1px solid #e5e7eb;
    text-align: left;
}

/* mark styling for highlights */
mark {
    background: #fff59d;
    color: #000;
    padding: 0 2px;
}

/* small utility for search row spacing */
.search-row input[type="text"] {
    min-width: 220px;
    padding: 6px 8px;
}




/* ...existing styles ... */

/* visually-hidden utility */
.visually-hidden {
    position: absolute !important;
    height: 1px; width: 1px;
    overflow: hidden;
    clip: rect(1px, 1px, 1px, 1px);
    white-space: nowrap;
}

/* visible focus for keyboard users */
:focus {
    outline: 3px solid #2563eb; /* accessible blue */
    outline-offset: 2px;
}

/* simple table styling */
.records-table {
    border-collapse: collapse;
}
.records-table th, .records-table td {
    padding: 8px 10px;
    border-bottom: 1px solid #e5e7eb;
    text-align: left;
}

/* mark styling for highlights */
mark {
    background: #fff59d;
    color: #000;
    padding: 0 2px;
}

/* small utility for search row spacing */
.search-row input[type="text"] {
    min-width: 220px;
    padding: 6px 8px;
}

/* Dashboard Stats */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-top: 20px;
}

.stat-card {
    background: linear-gradient(135deg, var(--accent-primary) 0%, var(--accent-secondary) 100%);
    color: white;
    padding: 25px;
    border-radius: 12px;
    text-align: center;
    box-shadow: 0 4px 15px rgba(14, 165, 233, 0.3);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(14, 165, 233, 0.4);
}

.stat-number {
    font-size: 2.5em;
    font-weight: 700;
    margin-bottom: 8px;
}

.stat-label {
    font-size: 1em;
    opacity: 0.9;
}

/* Form Styling */
.form-container {
    max-width: 600px;
}

.book-form {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    padding: 30px;
    border-radius: 16px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
}

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

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

.form-group label {
    display: block;
    margin-bottom: 6px;
    font-weight: 600;
    color: #374151;
}

.form-group input, .form-control {
    width: 100%;
    padding: 14px 18px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 12px;
    font-size: 16px;
    background: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(5px);
    transition: all 0.3s ease;
    box-sizing: border-box;
}

.form-group input:focus, .form-control:focus {
    border-color: var(--accent-primary);
    background: rgba(255, 255, 255, 0.95);
    outline: none;
    box-shadow: 0 0 0 4px rgba(14, 165, 233, 0.15);
    transform: translateY(-1px);
}

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

/* Button Styles */
.btn {
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 16px;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.btn-primary {
    background: linear-gradient(135deg, var(--accent-primary) 0%, var(--accent-secondary) 100%);
    color: white;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(14, 165, 233, 0.4);
}

.btn-secondary {
    background: #6b7280;
    color: white;
}

.btn-secondary:hover {
    background: #4b5563;
}

.btn-outline {
    background: transparent;
    border: 2px solid var(--accent-primary);
    color: var(--accent-primary);
}

.btn-outline:hover {
    background: var(--accent-primary);
    color: white;
}

/* Settings */
.settings-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 25px;
}

.setting-card {
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(10px);
    padding: 28px;
    border-radius: 16px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.08);
}

.setting-card h3 {
    margin: 0 0 20px 0;
    color: #1f2937;
    font-size: 1.3em;
}

.setting-actions {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.setting-item {
    margin-bottom: 15px;
}

.setting-item label {
    display: block;
    margin-bottom: 6px;
    font-weight: 600;
    color: #374151;
}

/* Table Improvements */
.records-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 20px;
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(10px);
    border-radius: 16px;
    overflow: hidden;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.records-table th {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 15px 12px;
    font-weight: 600;
    text-align: left;
}

.records-table td {
    padding: 18px 15px;
    border-bottom: 1px solid var(--border-primary);
    vertical-align: middle;
}

.records-table tr:hover {
    background: var(--bg-secondary);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px var(--shadow-light);
}

.records-table td:first-child {
    font-weight: 600;
    color: var(--text-primary);
}

.pages-badge {
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
    color: white;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
}

.tag-badge {
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    padding: 6px 12px;
    border-radius: 16px;
    font-size: 13px;
    font-weight: 500;
    border: 1px solid var(--border-secondary);
}

.actions {
    white-space: nowrap;
}

.actions button {
    margin: 0 3px;
    padding: 8px 12px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
    transition: all 0.2s ease;
}

.records-table button {
    padding: 6px 12px;
    margin: 0 4px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
}

.edit-btn {
    background: var(--success);
    color: white;
    transition: all 0.2s ease;
}

.delete-btn {
    background: var(--danger);
    color: white;
    transition: all 0.2s ease;
}

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

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

/* Real-time Validation Styles */
.form-group input.valid {
    border-color: var(--success);
    box-shadow: 0 0 0 3px rgba(5, 150, 105, 0.1);
}

.form-group input.invalid {
    border-color: var(--danger);
    box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.1);
}

.validation-feedback {
    font-size: 0.875rem;
    margin-top: 0.5rem;
    padding: 0.5rem;
    border-radius: 6px;
    transition: all 0.3s ease;
}

.validation-feedback.success {
    color: var(--success);
    background: rgba(5, 150, 105, 0.1);
    border: 1px solid var(--success);
}

.validation-feedback.error {
    color: var(--danger);
    background: rgba(220, 38, 38, 0.1);
    border: 1px solid var(--danger);
}

/* Enhanced Focus Styles */
.form-group input:focus {
    outline: 3px solid var(--accent-primary);
    outline-offset: 2px;
}

/* Keyboard Navigation Enhancements */
.category-card:focus,
.book-item:focus,
.action-btn:focus {
    outline: 3px solid var(--accent-primary);
    outline-offset: 2px;
}

/* Error States */
.form-error {
    background: rgba(220, 38, 38, 0.05);
    border-left: 4px solid var(--danger);
    padding: 1rem;
    margin: 1rem 0;
    border-radius: 8px;
}

.success-message {
    background: rgba(5, 150, 105, 0.05);
    border-left: 4px solid var(--success);
    padding: 1rem;
    margin: 1rem 0;
    border-radius: 8px;
    color: var(--success);
}

/* Search Highlighting */
.search-highlight {
    background: linear-gradient(135deg, #fef3c7, #fbbf24);
    color: #92400e;
    padding: 2px 4px;
    border-radius: 4px;
    font-weight: 600;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    animation: highlightPulse 0.3s ease-in-out;
}

@keyframes highlightPulse {
    0% { background-color: #fef3c7; }
    50% { background-color: #fbbf24; }
    100% { background-color: #fef3c7; }
}

[data-theme="dark"] .search-highlight {
    background: linear-gradient(135deg, #451a03, #92400e);
    color: #fbbf24;
}

/* Enhanced Table Accessibility */
.records-table tr:focus-within {
    background: var(--bg-secondary);
    outline: 2px solid var(--accent-primary);
    outline-offset: -2px;
}

.records-table button:focus {
    outline: 2px solid var(--accent-primary);
    outline-offset: 2px;
    z-index: 1;
    position: relative;
}