* {
    box-sizing: border-box;
}

:root {
    font-family: Arial, Helvetica, sans-serif;
    color: #222;
    background: #f5f6f8;
}

body {
    margin: 0;
}

a {
    color: #1f5f8f;
}

.wrap {
    width: min(1180px, calc(100% - 32px));
    margin: 0 auto;
}

.site-header {
    background: #243447;
    color: white;
    margin-bottom: 24px;
}

.header-inner {
    display: flex;
    gap: 24px;
    align-items: center;
    min-height: 70px;
    flex-wrap: wrap;
}

.brand {
    color: white;
    text-decoration: none;
    font-size: 1.45rem;
    font-weight: 700;
}

.main-nav {
    display: flex;
    gap: 14px;
    flex-wrap: wrap;
}

.main-nav a {
    color: white;
    text-decoration: none;
    padding: 8px 0;
}

.site-footer {
    margin-top: 40px;
    padding: 24px 0;
    color: #666;
    font-size: .9rem;
}

h1, h2, h3 {
    color: #243447;
}

.card {
    background: white;
    border: 1px solid #dfe3e8;
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 20px;
}

.grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 16px;
}

.metric {
    background: white;
    border: 1px solid #dfe3e8;
    border-radius: 8px;
    padding: 18px;
}

.metric strong {
    display: block;
    font-size: 2rem;
    color: #243447;
}

label {
    display: block;
    font-weight: 700;
    margin-bottom: 5px;
}

input, select, textarea, button {
    font: inherit;
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="date"],
input[type="number"],
select,
textarea {
    width: 100%;
    padding: 9px 10px;
    border: 1px solid #b9c0c7;
    border-radius: 5px;
    background: white;
}

textarea {
    min-height: 110px;
    resize: vertical;
}

.form-row {
    margin-bottom: 14px;
}

.form-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

button,
.button {
    display: inline-block;
    padding: 9px 14px;
    border: 0;
    border-radius: 5px;
    background: #1f5f8f;
    color: white;
    text-decoration: none;
    cursor: pointer;
}

.button.secondary,
button.secondary {
    background: #66717d;
}

.button.danger,
button.danger {
    background: #a23434;
}

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

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

th {
    background: #edf1f4;
}

.status {
    display: inline-block;
    padding: 3px 7px;
    border-radius: 999px;
    background: #e7ebef;
    font-size: .85rem;
}

.status.available {
    background: #dff3e4;
}

.status.checked_out {
    background: #fff0c9;
}

.status.overdue {
    background: #ffd8d8;
}

.flash {
    padding: 12px 14px;
    border-radius: 6px;
    margin-bottom: 16px;
}

.flash.success {
    background: #dff3e4;
    border: 1px solid #afd7b9;
}

.flash.error {
    background: #ffdede;
    border: 1px solid #e6aaaa;
}

.flash.info {
    background: #e2f0ff;
    border: 1px solid #b7d6f3;
}

.book-row {
    display: grid;
    grid-template-columns: 75px 1fr;
    gap: 16px;
    padding: 16px 0;
    border-bottom: 1px solid #e2e5e8;
}

.book-row:last-child {
    border-bottom: 0;
}

.book-cover {
    width: 75px;
    max-height: 110px;
    object-fit: contain;
    background: #eee;
}

.muted {
    color: #6c747c;
}

.small {
    font-size: .88rem;
}

.inline-form {
    display: flex;
    gap: 10px;
    align-items: end;
    flex-wrap: wrap;
}

.inline-form > div {
    flex: 1 1 220px;
}

.copy-box {
    padding: 12px;
    border: 1px solid #dfe3e8;
    border-radius: 6px;
    margin: 10px 0;
}

@media (max-width: 700px) {
    .header-inner {
        align-items: flex-start;
        padding: 14px 0;
    }

    .main-nav {
        width: 100%;
    }

    .book-row {
        grid-template-columns: 55px 1fr;
    }

    .book-cover {
        width: 55px;
    }

    table {
        display: block;
        overflow-x: auto;
    }
}


.account-nav { margin-left:auto; display:flex; align-items:center; gap:10px; font-size:.9rem; }
.account-nav a { color:white; }
.admin-badge { background:#f0c85a; color:#243447; padding:2px 7px; border-radius:999px; font-weight:700; }
.login-card { max-width:460px; margin:60px auto; }
.inline-action { display:inline-block; margin:4px 6px 4px 0; }
.withdrawn-copy { opacity:.62; background:#f2f2f2; }
.status.withdrawn { background:#e2e2e2; }
hr { border:0; border-top:1px solid #dfe3e8; margin:22px 0; }

.checkout-details {
    margin-top: 12px;
    padding-top: 10px;
    border-top: 1px solid #e0e4e8;
}

.checkout-details summary {
    cursor: pointer;
    font-weight: 700;
    color: #1f5f8f;
    margin-bottom: 12px;
}

.copy-checkout-form {
    margin-top: 12px;
}

.transfer-details {
    min-width: 250px;
}

.transfer-details > summary {
    list-style: none;
    width: fit-content;
}

.transfer-details > summary::-webkit-details-marker {
    display: none;
}

.transfer-form {
    margin-top: 12px;
    padding: 12px;
    border: 1px solid #dfe3e8;
    border-radius: 6px;
    background: #f8f9fa;
}

/* Mobile-focused refinements added in 1.2.7 */
.mobile-nav {
    display: none;
}

@media (max-width: 700px) {
    .wrap {
        width: min(100% - 20px, 1180px);
    }

    .site-header {
        margin-bottom: 16px;
    }

    .header-inner {
        min-height: 60px;
        padding: 10px 0;
        align-items: center;
        justify-content: space-between;
        gap: 10px;
    }

    .brand {
        font-size: 1.2rem;
    }

    .desktop-nav,
    .desktop-account-nav {
        display: none;
    }

    .mobile-nav {
        display: block;
        margin-left: auto;
        position: relative;
    }

    .mobile-nav > summary {
        list-style: none;
        min-height: 44px;
        display: flex;
        align-items: center;
        justify-content: center;
        padding: 8px 14px;
        border: 1px solid rgba(255,255,255,.45);
        border-radius: 6px;
        color: white;
        font-weight: 700;
        cursor: pointer;
        user-select: none;
    }

    .mobile-nav > summary::-webkit-details-marker {
        display: none;
    }

    .mobile-nav[open] > summary {
        background: rgba(255,255,255,.12);
    }

    .mobile-nav-panel {
        position: absolute;
        right: 0;
        top: calc(100% + 8px);
        z-index: 1000;
        width: min(310px, calc(100vw - 20px));
        background: white;
        border: 1px solid #d6dbe0;
        border-radius: 8px;
        box-shadow: 0 8px 28px rgba(0,0,0,.2);
        overflow: hidden;
    }

    .mobile-account-line {
        display: flex;
        align-items: center;
        gap: 8px;
        padding: 12px 14px;
        background: #edf1f4;
        color: #243447;
        border-bottom: 1px solid #d6dbe0;
    }

    .mobile-nav-panel a {
        display: block;
        min-height: 46px;
        padding: 13px 14px;
        border-bottom: 1px solid #edf0f2;
        text-decoration: none;
        color: #243447;
        font-weight: 600;
    }

    .mobile-nav-panel a:last-child {
        border-bottom: 0;
    }

    h1 {
        font-size: 1.65rem;
        margin-top: 12px;
    }

    h2 {
        font-size: 1.3rem;
    }

    h3 {
        font-size: 1.08rem;
    }

    .card {
        padding: 14px;
        margin-bottom: 14px;
        border-radius: 7px;
    }

    .grid {
        grid-template-columns: 1fr;
        gap: 10px;
    }

    input[type="text"],
    input[type="email"],
    input[type="password"],
    input[type="date"],
    input[type="number"],
    select,
    textarea {
        min-height: 44px;
        font-size: 16px;
        padding: 10px 11px;
    }

    textarea {
        min-height: 100px;
    }

    button,
    .button {
        min-height: 44px;
        padding: 11px 14px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }

    .form-actions {
        gap: 8px;
    }

    .form-actions > form,
    .form-actions > details {
        max-width: 100%;
    }

    .inline-form {
        align-items: stretch;
    }

    .inline-form > div,
    .inline-form > div[style*="flex:0 0 auto"] {
        flex: 1 1 100% !important;
    }

    .inline-form button,
    .inline-form .button {
        width: 100%;
    }

    .book-row {
        grid-template-columns: 72px minmax(0, 1fr);
        gap: 12px;
        padding: 12px 0;
    }

    .book-cover {
        width: 72px;
        max-height: 108px;
    }

    .copy-box {
        padding: 12px;
    }

    .copy-box .form-actions {
        flex-direction: column;
        align-items: stretch;
    }

    .copy-box .form-actions > *,
    .copy-box .form-actions button,
    .copy-box .form-actions .button {
        width: 100%;
    }

    /* Checked-out list becomes stacked cards instead of a sideways table. */
    .checkout-table,
    .checkout-table thead,
    .checkout-table tbody,
    .checkout-table tr,
    .checkout-table td {
        display: block;
        width: 100%;
    }

    .checkout-table {
        background: transparent;
        overflow: visible;
    }

    .checkout-table thead {
        display: none;
    }

    .checkout-table tr {
        background: white;
        border: 1px solid #dfe3e8;
        border-radius: 8px;
        margin: 0 0 14px;
        padding: 2px 12px 10px;
        overflow: hidden;
    }

    .checkout-table td {
        border-bottom: 1px solid #edf0f2;
        padding: 10px 0;
    }

    .checkout-table td:last-child {
        border-bottom: 0;
    }

    .checkout-table td::before {
        content: attr(data-label);
        display: block;
        margin-bottom: 4px;
        color: #6c747c;
        font-size: .76rem;
        font-weight: 700;
        text-transform: uppercase;
        letter-spacing: .035em;
    }

    .checkout-table td[data-label="Book"]::before {
        display: none;
    }

    .checkout-table td[data-label="Book"] {
        padding-top: 12px;
    }

    .checkout-table td[data-label="Book"] > a {
        font-size: 1.08rem;
    }

    .circulation-actions {
        flex-direction: column;
        align-items: stretch;
    }

    .circulation-actions > form,
    .circulation-actions > details,
    .circulation-actions button,
    .circulation-actions .button {
        width: 100%;
    }

    .transfer-details {
        min-width: 0;
    }

    .transfer-details > summary {
        width: 100%;
    }

    .transfer-form {
        margin-top: 8px;
        padding: 10px;
    }

    .metric {
        padding: 14px;
    }

    .metric strong {
        font-size: 1.7rem;
    }

    /* Other administrative tables can still scroll horizontally when needed. */
    table:not(.checkout-table) {
        display: block;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
}

@media (max-width: 420px) {
    .wrap {
        width: min(100% - 14px, 1180px);
    }

    .brand {
        font-size: 1.1rem;
    }

    .book-row {
        grid-template-columns: 60px minmax(0, 1fr);
    }

    .book-cover {
        width: 60px;
        max-height: 94px;
    }
}

.book-blurb {
    margin: 8px 0 10px;
    line-height: 1.45;
    color: #3d4650;
}

.book-blurb-detail {
    font-size: 1.05rem;
    padding: 10px 12px;
    background: #f4f7f9;
    border-left: 4px solid #1f5f8f;
    border-radius: 4px;
}


/* Physical-possession confirmation dialogs (1.3.3) */
.possession-dialog {
    width: min(92vw, 560px);
    border: 0;
    border-radius: 10px;
    padding: 0;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.28);
}

.possession-dialog::backdrop {
    background: rgba(0, 0, 0, 0.48);
}

.possession-dialog-card {
    padding: 22px;
}

.possession-dialog-card h2 {
    margin-top: 0;
}

.possession-dialog-card p {
    line-height: 1.5;
}

.possession-dialog-actions {
    margin-top: 20px;
    justify-content: flex-end;
}

@media (max-width: 700px) {
    .possession-dialog-card {
        padding: 18px;
    }

    .possession-dialog-actions {
        flex-direction: column-reverse;
        align-items: stretch;
    }

    .possession-dialog-actions button {
        width: 100%;
    }
}
