:root {
    --bg: #f4f8f6;
    --surface: #ffffff;
    --surface-soft: #edf8f1;
    --text: #0f172a;
    --muted: #64748b;
    --primary: #079447;
    --primary-dark: #056b34;
    --navy: #061b2e;
    --navy-soft: #0a2a42;
    --border: #e2e8f0;
    --success: #16a34a;
    --danger: #dc2626;
    --warning: #d97706;
    --shadow: 0 18px 42px rgba(5, 38, 58, .08);
    --radius: 18px;
    --sidebar-width: 255px;
}

* { box-sizing: border-box; }
html { min-width: 0; }
body {
    margin: 0;
    min-width: 0;
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    background: var(--bg);
    color: var(--text);
}
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
img { max-width: 100%; }
p { color: var(--muted); line-height: 1.7; }
h1, h2, h3, p { overflow-wrap: anywhere; }

.app-shell {
    min-height: 100vh;
    display: flex;
    min-width: 0;
}
.sidebar {
    width: var(--sidebar-width);
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 20;
    display: flex;
    flex-direction: column;
    gap: 0;
    padding: 22px 18px;
    color: #fff;
    background: linear-gradient(180deg, #063421 0%, #061a2c 100%);
    overflow-y: auto;
}
.main-content {
    flex: 1;
    min-width: 0;
    margin-left: var(--sidebar-width);
    padding: 22px 34px 28px;
}
.public-main { margin-left: 0; }

.brand,
.brand-top,
.brand-sidebar,
.pdf-toolbar-brand {
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 10px;
}
.brand-logo {
    display: block !important;
    flex: 0 0 auto !important;
    width: 48px !important;
    height: 34px !important;
    max-width: 48px !important;
    max-height: 34px !important;
    object-fit: contain !important;
    object-position: center !important;
}
.brand-sidebar .brand-logo {
    width: 54px !important;
    height: 38px !important;
    max-width: 54px !important;
    max-height: 38px !important;
    filter: drop-shadow(0 8px 18px rgba(0,0,0,.2));
}
.brand-copy {
    min-width: 0;
    display: grid;
    gap: 2px;
    overflow: hidden;
}
.brand-copy strong {
    display: block;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-weight: 850;
    font-size: 16px;
    line-height: 1.15;
}
.brand-copy small {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    max-width: 250px;
    color: var(--muted);
    font-size: 11px;
    font-weight: 600;
    line-height: 1.25;
}
.sidebar .brand-copy small { color: rgba(255,255,255,.78); }

.sidebar-nav {
    margin-top: 28px;
    display: grid;
    gap: 8px;
}
.sidebar-nav a,
.logout-link {
    display: block;
    padding: 12px 14px;
    border-radius: 10px;
    color: rgba(255,255,255,.9);
    font-size: 14px;
    font-weight: 650;
}
.sidebar-nav a:hover,
.sidebar-nav a.active { background: var(--primary); color: #fff; }
.nav-divider { height: 1px; background: rgba(255,255,255,.14); margin: 12px 0; }
.sidebar-identity {
    margin-top: auto;
    padding: 16px 10px 12px;
    border-top: 1px solid rgba(255,255,255,.14);
    display: grid;
    justify-items: center;
    gap: 5px;
    text-align: center;
}
.sidebar-identity img {
    display: block !important;
    width: 74px !important;
    height: 52px !important;
    max-width: 74px !important;
    max-height: 52px !important;
    object-fit: contain !important;
}
.sidebar-identity strong {
    color: #22c55e;
    font-size: 14px;
    letter-spacing: .06em;
}
.sidebar-identity small {
    max-width: 190px;
    color: rgba(255,255,255,.76);
    font-size: 11px;
    line-height: 1.35;
}
.logout-link { margin-top: 10px; }
.logout-link:hover { background: rgba(255,255,255,.1); }

.topbar {
    position: sticky;
    top: 16px;
    z-index: 15;
    display: grid;
    grid-template-columns: minmax(215px, 320px) minmax(260px, 1fr) auto;
    align-items: center;
    gap: 16px;
    min-height: 72px;
    padding: 12px 18px;
    border: 1px solid var(--border);
    border-radius: 16px;
    background: var(--surface);
    box-shadow: var(--shadow);
}
.topbar .brand-top {
    max-width: 320px;
    overflow: hidden;
}
.search-form {
    min-width: 0;
    width: 100%;
    display: flex;
}
.search-form input,
.filter-card input,
.filter-card select,
.form-card input,
.form-card select,
.form-card textarea,
.inline-form select {
    width: 100%;
    min-width: 0;
    border: 1px solid var(--border);
    border-radius: 11px;
    padding: 12px 14px;
    background: #fff;
    color: var(--text);
    outline: none;
}
.search-form input { border-radius: 11px 0 0 11px; }
.search-form button {
    flex: 0 0 auto;
    border: 0;
    border-radius: 0 11px 11px 0;
    padding: 0 18px;
    background: var(--primary);
    color: #fff;
    font-weight: 800;
}
.top-links {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 16px;
    white-space: nowrap;
    font-size: 14px;
    color: #334155;
}
.btn-small,
.user-chip {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 8px 12px;
    border-radius: 999px;
    background: #eafaf0;
    color: var(--primary);
    font-weight: 800;
}

.alert {
    margin: 18px 0;
    padding: 13px 15px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: #fff;
}
.alert-success { border-color: #bbf7d0; color: #166534; background: #f0fdf4; }
.alert-danger { border-color: #fecaca; color: #991b1b; background: #fef2f2; }
.alert-warning { border-color: #fed7aa; color: #9a3412; background: #fff7ed; }

.hero-card {
    margin-top: 24px;
    min-height: 300px;
    display: grid;
    grid-template-columns: minmax(0, 1.05fr) minmax(260px, .95fr);
    align-items: center;
    gap: 30px;
    overflow: hidden;
    padding: 46px;
    border-radius: 24px;
    background: radial-gradient(circle at 82% 35%, rgba(7,148,71,.32), transparent 28%), linear-gradient(135deg, #064225, #061526);
    color: #fff;
    box-shadow: var(--shadow);
}
.eyebrow {
    margin: 0 0 8px;
    color: var(--primary);
    text-transform: uppercase;
    letter-spacing: .12em;
    font-size: 12px;
    font-weight: 850;
}
.hero-card .eyebrow { color: #bbf7d0; }
h1 { margin: 0; font-size: clamp(30px, 4.7vw, 54px); line-height: 1.06; }
h2 { margin: 0; }
.hero-card p { max-width: 640px; color: #dcfce7; }
.btn-primary,
.btn-outline,
.form-card button,
.inline-form button,
.row-actions button {
    min-height: 42px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid transparent;
    border-radius: 11px;
    padding: 11px 16px;
    font-weight: 850;
}
.btn-primary,
.form-card button { background: var(--primary); color: #fff; }
.btn-primary:hover,
.form-card button:hover { background: var(--primary-dark); }
.btn-primary:disabled,
.btn-outline:disabled { opacity: .55; cursor: not-allowed; }
.btn-outline { background: #fff; border-color: var(--border); color: var(--primary); }
.hero-illustration {
    display: grid;
    place-items: center;
    min-width: 0;
    font-size: 16px !important;
}
.hero-brand-mark {
    width: min(100%, 360px);
    min-height: 210px;
    display: grid;
    place-items: center;
    padding: 24px;
    border: 1px solid rgba(255,255,255,.16);
    border-radius: 28px;
    background: rgba(255,255,255,.08);
    text-align: center;
    backdrop-filter: blur(6px);
}
.hero-brand-mark img {
    display: block !important;
    width: min(190px, 68%) !important;
    max-width: 190px !important;
    height: auto !important;
    object-fit: contain !important;
    filter: drop-shadow(0 18px 24px rgba(0,0,0,.24));
}
.hero-brand-mark span {
    display: block;
    margin-top: 14px;
    color: #dcfce7;
    font-size: clamp(16px, 2vw, 24px) !important;
    line-height: 1.25 !important;
    font-weight: 850;
}

.section-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    margin: 32px 0 16px;
}
.section-head a { color: var(--primary); font-weight: 800; font-size: 14px; }
.category-grid,
.stat-grid {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 18px;
}
.category-card,
.stat-card,
.book-card,
.content-card,
.form-card,
.filter-card,
.table-card,
.tabs-card,
.announcement-list,
.empty-state {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: var(--shadow);
}
.category-card { display: grid; gap: 8px; padding: 22px; }
.category-icon {
    width: 52px;
    height: 52px;
    display: grid;
    place-items: center;
    border-radius: 15px;
    background: color-mix(in srgb, var(--cat-color) 14%, white);
}
.category-card small,
.book-card small,
table small { display: block; color: var(--muted); }
.book-grid {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 18px;
}
.catalog-grid { grid-template-columns: repeat(6, minmax(0, 1fr)); }
.book-card { display: flex; flex-direction: column; gap: 8px; padding: 14px; min-width: 0; }
.book-card img {
    width: 100%;
    aspect-ratio: 2 / 3;
    object-fit: cover;
    border-radius: 12px;
    background: #e2e8f0;
}
.book-card h3 { margin: 4px 0 0; font-size: 15px; line-height: 1.35; }
.book-card p { margin: 0; color: #475569; font-size: 13px; }
.book-card-actions { margin-top: auto; display: grid; gap: 8px; }
.book-card-actions .btn-primary,
.book-card-actions .btn-outline { min-height: 36px; padding: 8px 10px; font-size: 13px; }
.book-tags { min-height: 22px; }
.announcement-list { display: grid; gap: 10px; padding: 16px; }
.announcement-list article { display: flex; gap: 12px; align-items: center; padding: 10px; border-bottom: 1px solid var(--border); }
.announcement-list article:last-child { border-bottom: 0; }
.footer {
    margin-top: 34px;
    padding-top: 18px;
    display: flex;
    justify-content: space-between;
    gap: 16px;
    border-top: 1px solid var(--border);
    color: var(--muted);
    font-size: 13px;
}

.page-title { margin: 26px 0 18px; display: flex; justify-content: space-between; gap: 16px; }
.page-title p { margin-bottom: 0; }
.filter-card {
    display: grid;
    grid-template-columns: minmax(220px, 1fr) 210px 160px 170px auto;
    gap: 12px;
    margin-bottom: 20px;
    padding: 16px;
}
.detail-layout {
    display: grid;
    grid-template-columns: 320px minmax(0, 1fr);
    gap: 34px;
    margin-top: 28px;
}
.detail-cover,
.detail-content {
    border: 1px solid var(--border);
    border-radius: 22px;
    background: var(--surface);
    box-shadow: var(--shadow);
}
.detail-cover { height: max-content; padding: 24px; }
.detail-cover img { width: 100%; aspect-ratio: 2 / 3; object-fit: cover; border-radius: 16px; }
.detail-content { min-width: 0; padding: 30px; }
.breadcrumb { color: var(--primary); font-weight: 800; }
.author { margin-top: 6px; font-size: 18px; }
.rating-line { margin: 14px 0; color: #f59e0b; font-weight: 850; }
.rating-line span { color: var(--muted); font-weight: 650; }
.book-meta { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 28px; margin: 22px 0; }
.book-meta div { display: grid; grid-template-columns: 130px minmax(0, 1fr); gap: 10px; }
dt { color: var(--muted); }
dd { margin: 0; font-weight: 750; }
.action-row { display: flex; align-items: center; flex-wrap: wrap; gap: 12px; }
.stack { align-items: stretch; flex-direction: column; }
.tabs-card { margin-top: 24px; padding: 20px; }
.digital-panel { margin-top: 14px; padding: 14px; border-radius: 14px; background: #f0fdf4; border: 1px solid #bbf7d0; }
.digital-panel p { margin: 8px 0 0; font-size: 13px; }

.auth-card { max-width: 1050px; margin: 42px auto; display: grid; grid-template-columns: minmax(0, 1fr) 430px; gap: 28px; align-items: center; }
.form-card { display: grid; gap: 11px; padding: 22px; }
.form-card.narrow { max-width: 620px; }
.form-card label { font-size: 13px; font-weight: 850; }
.form-note { margin: 8px 0 0; font-size: 14px; }
.form-note a { color: var(--primary); font-weight: 850; }
.form-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
input[type="file"] { padding: 11px; background: #f8fafc; border: 1px dashed #cbd5e1; }
.file-note,
.cover-note {
    display: grid;
    gap: 8px;
    padding: 12px;
    border: 1px dashed var(--border);
    border-radius: 12px;
    background: #f8fafc;
    color: #334155;
    font-size: 13px;
}
.cover-preview {
    width: 92px;
    aspect-ratio: 2 / 3;
    object-fit: cover;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: #e2e8f0;
}
.check-row { display: flex !important; align-items: center; gap: 8px; font-weight: 750; color: #334155; }
.check-row input { width: auto !important; }

.table-card { padding: 18px; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 14px 12px; text-align: left; border-bottom: 1px solid var(--border); vertical-align: middle; }
th { color: var(--muted); font-size: 12px; letter-spacing: .08em; text-transform: uppercase; }
.table-book { display: flex; align-items: center; gap: 12px; }
.table-book img,
.admin-cover-thumb { width: 45px; height: 60px; object-fit: cover; border-radius: 8px; background: #e2e8f0; }
.badge { display: inline-flex; align-items: center; padding: 6px 10px; border-radius: 999px; font-size: 12px; font-weight: 850; }
.badge-success { background: #dcfce7; color: #166534; }
.badge-danger { background: #fee2e2; color: #991b1b; }
.badge-primary { background: #dcfce7; color: #166534; }
.badge-muted { background: #f1f5f9; color: #475569; }
.badge-pdf { background: #e0f2fe; color: #075985; }
.row-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
.row-actions a,
.row-actions button { color: var(--primary); background: #fff; border: 1px solid var(--border); border-radius: 9px; padding: 7px 10px; font-size: 13px; font-weight: 800; }
.row-actions form { display: inline; }
.empty-state { padding: 28px; color: var(--muted); text-align: center; }
.dashboard-grid { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(260px, .6fr); gap: 18px; }
.admin-grid { display: grid; grid-template-columns: 430px minmax(0, 1fr); gap: 18px; align-items: start; }
.content-card { padding: 22px; }
.stat-card { padding: 20px; }
.stat-card span { color: var(--muted); font-size: 13px; }
.stat-card strong { display: block; margin-top: 8px; font-size: 36px; }
.inline-form { display: flex; gap: 8px; align-items: center; }
.muted-text { color: var(--muted); font-size: 13px; }

/* PDF reader page: benar-benar full width untuk PC dan laptop */
.pdf-fullscreen-page {
    margin: 0;
    min-height: 100vh;
    overflow: hidden;
    background: #111827;
}
.pdf-toolbar {
    width: 100vw;
    min-height: 72px;
    display: grid;
    grid-template-columns: minmax(220px, 330px) minmax(240px, 1fr) auto;
    align-items: center;
    gap: 14px;
    padding: 10px 18px;
    background: #fff;
    border-bottom: 1px solid var(--border);
    box-shadow: 0 10px 24px rgba(15,23,42,.12);
    position: relative;
    z-index: 5;
}
.pdf-toolbar-brand { overflow: hidden; }
.pdf-toolbar-brand img {
    display: block !important;
    width: 48px !important;
    height: 34px !important;
    max-width: 48px !important;
    max-height: 34px !important;
    object-fit: contain !important;
    flex: 0 0 auto !important;
}
.pdf-toolbar-brand strong,
.pdf-toolbar-title strong {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--text);
    font-size: 15px;
    line-height: 1.2;
}
.pdf-toolbar-brand small,
.pdf-toolbar-title small {
    display: block;
    margin-top: 2px;
    color: var(--muted);
    font-size: 12px;
    line-height: 1.25;
}
.pdf-toolbar-title { min-width: 0; overflow: hidden; }
.pdf-toolbar-actions { display: flex; justify-content: flex-end; align-items: center; gap: 10px; white-space: nowrap; }
.pdf-frame-wrap {
    width: 100vw !important;
    height: calc(100vh - 72px);
    padding: 0;
    margin: 0;
    background: #111827;
}
.pdf-frame-wrap iframe,
#pdfFrame {
    display: block;
    width: 100vw !important;
    height: 100% !important;
    min-height: 360px;
    border: 0;
    background: #fff;
}

@media (max-width: 1280px) {
    .catalog-grid { grid-template-columns: repeat(5, minmax(0, 1fr)); }
    .filter-card { grid-template-columns: minmax(220px, 1fr) 190px 150px 150px auto; }
}
@media (max-width: 1100px) {
    .app-shell { display: block; }
    .sidebar { position: static; width: 100%; min-height: auto; }
    .sidebar-identity { display: none; }
    .main-content,
    .public-main { margin-left: 0; padding: 16px; }
    .topbar { top: 0; }
    .book-grid,
    .catalog-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .category-grid,
    .stat-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .filter-card,
    .detail-layout,
    .auth-card,
    .admin-grid,
    .dashboard-grid { grid-template-columns: 1fr; }
}
@media (max-width: 840px) {
    .topbar {
        position: static;
        grid-template-columns: 1fr;
        align-items: stretch;
        gap: 12px;
        padding: 14px;
    }
    .topbar .brand-top { max-width: none; }
    .brand-copy strong { white-space: normal; }
    .brand-copy small { max-width: none; }
    .top-links { justify-content: flex-start; flex-wrap: wrap; gap: 12px; }
    .hero-card { grid-template-columns: 1fr; padding: 34px; }
    .hero-brand-mark { width: 100%; min-height: 150px; }
    .hero-brand-mark img { width: 130px !important; max-width: 130px !important; }
    .hero-brand-mark span { font-size: 17px !important; }
    .book-meta { grid-template-columns: 1fr; }
    .pdf-fullscreen-page { overflow: auto; }
    .pdf-toolbar { grid-template-columns: 1fr; gap: 8px; align-items: start; }
    .pdf-toolbar-title { display: none; }
    .pdf-toolbar-actions { justify-content: flex-start; flex-wrap: wrap; }
    .pdf-frame-wrap { height: 78vh; }
}
@media (max-width: 640px) {
    .main-content,
    .public-main { padding: 12px; }
    .topbar { border-radius: 14px; }
    .brand-logo,
    .brand-top .brand-logo,
    .pdf-toolbar-brand img {
        width: 42px !important;
        height: 30px !important;
        max-width: 42px !important;
        max-height: 30px !important;
    }
    .brand-sidebar .brand-logo {
        width: 48px !important;
        height: 34px !important;
        max-width: 48px !important;
        max-height: 34px !important;
    }
    .brand-copy strong { font-size: 15px; }
    .search-form { width: 100%; }
    h1 { font-size: clamp(28px, 9vw, 40px); }
    .hero-card { margin-top: 16px; padding: 28px; border-radius: 20px; }
    .hero-card p { font-size: 15px; }
    .book-grid,
    .catalog-grid,
    .category-grid,
    .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .form-row { grid-template-columns: 1fr; }
    .detail-content { padding: 22px; }
    .book-meta div { grid-template-columns: 105px minmax(0, 1fr); }
    .footer { flex-direction: column; }
    .pdf-toolbar { padding: 10px 12px; }
    .pdf-frame-wrap { height: 80vh; }
}
@media (max-width: 420px) {
    .book-grid,
    .catalog-grid,
    .category-grid,
    .stat-grid { grid-template-columns: 1fr; }
    .hero-brand-mark { display: none; }
    .top-links { gap: 10px; }
}
