:root {
    color-scheme: light;
    --ink: #172b24;
    --muted: #66766e;
    --line: #e2ebe5;
    --surface: #ffffff;
    --canvas: #f4f8f5;
    --green: #16734a;
    --green-dark: #105b3a;
    --green-soft: #e6f4eb;
    --shadow: 0 12px 32px rgba(23, 43, 36, 0.08);
}

* {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    margin: 0;
    color: var(--ink);
    background: var(--canvas);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    line-height: 1.55;
}

a {
    color: var(--green);
}

a:hover {
    color: var(--green-dark);
}

.site-header {
    position: sticky;
    z-index: 20;
    top: 0;
    width: 100%;
    border-bottom: 1px solid rgba(226, 235, 229, 0.9);
    background: rgba(255, 255, 255, 0.96);
    backdrop-filter: blur(14px);
}

.staff-banner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.6rem max(1.25rem, calc((100% - 1200px) / 2));
    color: #17432e;
    background: var(--green-soft);
    font-size: 0.875rem;
}

.site-nav {
    display: flex;
    min-height: 76px;
    align-items: center;
    justify-content: space-between;
    gap: 1.5rem;
    width: min(100% - 2.5rem, 1200px);
    margin: 0 auto;
}

.site-brand {
    display: inline-flex;
    flex: 0 0 auto;
    align-items: center;
}

.site-brand img {
    display: block;
    width: auto;
    height: 48px;
}

.site-nav-links {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: flex-end;
    gap: 0.5rem;
}

.site-nav-links > a,
.site-nav-links .nav-link {
    display: inline-flex;
    align-items: center;
    min-height: 42px;
    padding: 0.55rem 0.9rem;
    border: 0;
    border-radius: 999px;
    color: #42554b;
    background: transparent;
    font-size: 0.95rem;
    font-weight: 600;
    text-decoration: none;
}

.site-nav-links > a:hover,
.site-nav-links .nav-link:hover,
.site-nav-links > a.active {
    color: var(--green-dark);
    background: var(--green-soft);
}

.site-nav-links form {
    margin: 0;
}

.library-page {
    min-height: 100vh;
    background: var(--canvas);
}

.library-hero {
    border-bottom: 1px solid rgba(226, 235, 229, 0.8);
}

.library-section {
    background: var(--canvas);
}

.library-section.popular-section {
    background: #edf5ef;
}

.section-title {
    letter-spacing: -0.035em;
}

.book-card {
    border-color: var(--line);
    box-shadow: 0 8px 22px rgba(23, 43, 36, 0.06);
}

.book-link:focus-visible,
.site-nav a:focus-visible,
.site-nav button:focus-visible {
    outline: 3px solid rgba(22, 115, 74, 0.45);
    outline-offset: 3px;
}

.guest-page {
    display: flex;
    min-height: 100vh;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 2rem 1rem;
    background:
        radial-gradient(ellipse at 15% 10%, rgba(51, 152, 95, 0.12), transparent 36%),
        radial-gradient(ellipse at 90% 85%, rgba(22, 115, 74, 0.1), transparent 34%),
        var(--canvas);
}

.auth-card {
    width: min(100%, 520px);
    padding: clamp(1.5rem, 4vw, 2.5rem);
    border: 1px solid var(--line);
    border-radius: 1.25rem;
    background: var(--surface);
    box-shadow: var(--shadow);
    text-align: left;
}

.auth-brand {
    display: inline-block;
    margin-bottom: 0.4rem;
    color: var(--green-dark);
    font-size: 1.8rem;
    font-weight: 800;
    letter-spacing: -0.05em;
    text-decoration: none;
}

.auth-heading {
    margin: 0 0 1.4rem;
    color: var(--ink);
    font-size: 1.35rem;
    font-weight: 700;
}

.auth-card form {
    padding: 0 !important;
}

.admin-shell {
    display: flex;
    min-height: 100vh;
    background: var(--canvas);
}

.admin-sidebar {
    display: flex;
    width: 260px;
    flex: 0 0 260px;
    flex-direction: column;
    gap: 1.5rem;
    padding: 1.5rem 1rem;
    color: #e7f1eb;
    background: #143c2c;
}

.admin-brand {
    display: block;
    padding: 0.25rem 0.8rem 1rem;
    color: #ffffff;
    font-size: 1.35rem;
    font-weight: 800;
    letter-spacing: -0.04em;
    text-decoration: none;
}

.admin-brand small {
    display: block;
    margin-top: 0.15rem;
    color: #a9c9b6;
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.12em;
    text-transform: uppercase;
}

.admin-nav {
    display: grid;
    gap: 0.3rem;
}

.admin-nav a {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    min-height: 46px;
    padding: 0.7rem 0.85rem;
    border-radius: 0.7rem;
    color: #d1e2d7;
    font-weight: 600;
    text-decoration: none;
    transition: background-color 160ms ease, color 160ms ease;
}

.admin-nav a:hover,
.admin-nav a.active {
    color: #ffffff;
    background: rgba(255, 255, 255, 0.13);
}

.admin-nav a.active {
    box-shadow: inset 3px 0 #76d69b;
}

.admin-main {
    display: flex;
    min-width: 0;
    flex: 1;
    flex-direction: column;
}

.admin-topbar {
    display: flex;
    min-height: 76px;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.8rem clamp(1rem, 3vw, 2rem);
    border-bottom: 1px solid var(--line);
    background: var(--surface);
}

.admin-topbar-title {
    margin: 0;
    color: var(--muted);
    font-size: 0.9rem;
    font-weight: 600;
}

.admin-user {
    display: flex;
    align-items: center;
    gap: 1rem;
    font-weight: 650;
}

.admin-user form {
    margin: 0;
}

.admin-content {
    width: min(100%, 1480px);
    flex: 1;
    margin: 0 auto;
    padding: clamp(1rem, 3vw, 2rem);
}

.admin-page-heading {
    margin: 0 0 1.4rem;
    color: var(--ink);
    font-size: clamp(1.4rem, 2vw, 1.8rem);
    font-weight: 750;
    letter-spacing: -0.04em;
}

.admin-footer {
    padding: 1.2rem;
    border-top: 1px solid var(--line);
    color: var(--muted);
    background: var(--surface);
    font-size: 0.85rem;
    text-align: center;
}

.admin-footer a {
    font-weight: 650;
    text-decoration: none;
}

.card {
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 0.95rem;
    background: var(--surface);
    box-shadow: 0 6px 22px rgba(23, 43, 36, 0.045);
}

.card-header {
    border-bottom-color: var(--line);
    background: #fbfdfb;
}

.text-primary {
    color: var(--green) !important;
}

.text-success {
    color: #21804d !important;
}

.bg-primary {
    background-color: var(--green) !important;
}

.border-primary {
    border-color: var(--green) !important;
}

.border-left-primary,
.border-left-success,
.border-left-warning,
.border-left-info {
    border-left: 4px solid var(--green) !important;
}

.border-left-success {
    border-left-color: #21804d !important;
}

.border-left-warning {
    border-left-color: #e5ad32 !important;
}

.border-left-info {
    border-left-color: #3687a7 !important;
}

.text-xs {
    font-size: 0.72rem;
}

.font-weight-bold {
    font-weight: 700;
}

.text-gray-800 {
    color: #263c31;
}

.text-gray-300 {
    color: #a7b8ad;
}

.card-body {
    padding: 1.35rem;
}

.table-responsive {
    border-radius: 0.65rem;
}

.table {
    --bs-table-color: #33463c;
    --bs-table-bg: transparent;
    margin-bottom: 0;
}

.table > :not(caption) > * > * {
    padding: 0.85rem 0.9rem;
    border-bottom-color: var(--line);
    vertical-align: middle;
}

.table thead th {
    color: #52645a;
    background: #f4f8f5;
    font-size: 0.76rem;
    font-weight: 750;
    letter-spacing: 0.055em;
    text-transform: uppercase;
    white-space: nowrap;
}

.table tbody tr:last-child > * {
    border-bottom-width: 0;
}

.form-label {
    margin-bottom: 0.45rem;
    color: #34483d;
    font-size: 0.9rem;
    font-weight: 650;
}

.form-control,
.form-select {
    min-height: 44px;
    border-color: #d5e1d9;
    border-radius: 0.65rem;
    color: var(--ink);
    background-color: #ffffff;
    box-shadow: none;
}

textarea.form-control {
    min-height: 140px;
}

.form-control:focus,
.form-select:focus {
    border-color: #4aa673;
    box-shadow: 0 0 0 0.22rem rgba(22, 115, 74, 0.13);
}

.btn {
    min-height: 40px;
    border-radius: 0.65rem;
    font-weight: 650;
}

.btn-primary {
    border-color: var(--green);
    color: #ffffff;
    background: var(--green);
}

.btn-primary:hover,
.btn-primary:focus {
    border-color: var(--green-dark);
    color: #ffffff;
    background: var(--green-dark);
}

.btn-success {
    border-color: #238451;
    background: #238451;
}

.btn-warning {
    border-color: #e6b94e;
}

.btn-outline-primary {
    border-color: var(--green);
    color: var(--green);
}

.btn-outline-primary:hover {
    border-color: var(--green);
    color: #ffffff;
    background: var(--green);
}

.btn-link {
    color: var(--green);
    text-decoration: none;
}

.btn-link:hover {
    color: var(--green-dark);
    text-decoration: underline;
}

.badge {
    border-radius: 999px;
    font-weight: 650;
}

.badge-success {
    color: #155b35;
    background: #d9f0e1;
}

.badge-warning {
    color: #765512;
    background: #fff0c2;
}

.badge-danger {
    color: #8a2932;
    background: #fde1e3;
}

.badge-dark {
    color: #ffffff;
    background: #40534a;
}

.badge-info {
    color: #155b70;
    background: #d9f0f6;
}

.pagination {
    gap: 0.25rem;
}

.page-link {
    border-color: var(--line);
    border-radius: 0.5rem !important;
    color: var(--green);
}

.page-item.active .page-link {
    border-color: var(--green);
    background: var(--green);
}

.delete-confirm {
    position: relative;
    display: inline-block;
}

.delete-confirm summary {
    cursor: pointer;
    list-style: none;
}

.delete-confirm summary::-webkit-details-marker {
    display: none;
}

.delete-confirm .delete-confirm-panel {
    position: absolute;
    z-index: 5;
    min-width: 210px;
    padding: 0.75rem;
    border: 1px solid var(--line);
    border-radius: 0.7rem;
    background: #ffffff;
    box-shadow: var(--shadow);
}

.delete-confirm-panel p {
    margin: 0 0 0.5rem;
    color: var(--muted);
    font-size: 0.85rem;
}

.logout-confirm .delete-confirm-panel {
    right: 0;
}

@media (max-width: 767.98px) {
    .site-nav {
        width: min(100% - 1.5rem, 1200px);
        min-height: 68px;
        gap: 0.75rem;
    }

    .site-brand img {
        height: 40px;
    }

    .site-nav-links {
        gap: 0.15rem;
    }

    .site-nav-links > a,
    .site-nav-links .nav-link {
        min-height: 38px;
        padding: 0.4rem 0.6rem;
        font-size: 0.85rem;
    }

    .staff-banner {
        padding-right: 0.75rem;
        padding-left: 0.75rem;
    }

    .admin-shell {
        display: block;
    }

    .admin-sidebar {
        width: auto;
        gap: 0.65rem;
        padding: 0.8rem;
    }

    .admin-brand {
        padding: 0.25rem 0.4rem;
    }

    .admin-nav {
        display: flex;
        flex-wrap: wrap;
        gap: 0.25rem;
    }

    .admin-nav a {
        min-height: 40px;
        gap: 0.45rem;
        padding: 0.5rem 0.6rem;
        font-size: 0.85rem;
    }

    .admin-topbar {
        min-height: 60px;
    }

    .admin-user {
        gap: 0.5rem;
        font-size: 0.85rem;
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        scroll-behavior: auto !important;
        transition-duration: 0.01ms !important;
    }
}
