:root {
    --primary-blue: #205a88;
    --deep-blue: #123a59;
    --accent-teal: #4f8fb0;
    --light-surface: #f4f7fb;
    --card-bg: rgba(255,255,255,0.96);
    --border-grey: #d8e3ed;
    --text-main: #243746;
    --muted-text: #667786;
}

body {
    margin: 0;
    background: var(--light-surface);
    color: var(--text-main);
    font-family: "Segoe UI", "PingFang SC", "Microsoft YaHei", Arial, sans-serif;
}

.app-navbar {
    background: linear-gradient(90deg, var(--deep-blue), var(--primary-blue));
}

.app-container {
    max-width: 1480px;
    padding: 26px;
}

.flash-area {
    max-width: 1080px;
    margin: 0 auto 18px auto;
}

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 16px;
    margin-bottom: 20px;
}

.page-header h1,
.page-header h2 {
    margin: 0;
    font-weight: 700;
}

.page-header p { margin: 6px 0 0; }

.app-card {
    border: 1px solid var(--border-grey);
    border-radius: 16px;
    overflow: hidden;
    background: #fff;
    box-shadow: 0 10px 26px rgba(17, 58, 89, 0.06);
}

.app-card > .card-header {
    background: #fff;
    font-weight: 650;
    border-bottom: 1px solid var(--border-grey);
    padding: 16px 18px;
}

.auth-page {
    background: linear-gradient(rgba(244, 247, 251, 0.55), rgba(244, 247, 251, 0.85)),
        url('../uploads/resources/login_bg.png') center/cover fixed no-repeat;
}

.auth-wrapper {
    min-height: calc(100vh - 40px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px 0;
}

.auth-card {
    width: 460px;
    padding: 34px;
    background: rgba(255,255,255,0.94);
    backdrop-filter: blur(6px);
    border-radius: 22px;
    border: 1px solid rgba(255,255,255,0.72);
    box-shadow: 0 20px 45px rgba(18, 58, 89, 0.14);
}

.auth-card-wide { width: 760px; }

.auth-title {
    font-size: 2rem;
    font-weight: 800;
    letter-spacing: 0.4px;
}

.auth-subtitle {
    color: var(--muted-text);
    margin-top: 6px;
}

.captcha-box {
    min-width: 130px;
    min-height: 54px;
    padding: 6px 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    background: linear-gradient(135deg, #f7fbff, #eaf2f8);
    border: 1px dashed #8cb5cf;
    border-radius: 12px;
    user-select: none;
    overflow: hidden;
}

.captcha-char {
    display: inline-block;
    font-weight: 800;
    line-height: 1;
}

.filter-bar {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 18px;
    background: #fff;
    padding: 14px;
    border: 1px solid var(--border-grey);
    border-radius: 14px;
}

.filter-bar .form-control,
.filter-bar .form-select { min-width: 170px; max-width: 250px; }

.metric-card {
    display: block;
    background: #fff;
    border: 1px solid var(--border-grey);
    border-radius: 16px;
    padding: 18px 20px;
    text-decoration: none;
    color: var(--text-main);
    transition: 0.16s ease;
    height: 100%;
}

.metric-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 28px rgba(31, 93, 137, 0.12);
}

.metric-card span {
    display: block;
    color: var(--muted-text);
    font-size: 14px;
}

.metric-card strong {
    display: block;
    font-size: 30px;
    margin-top: 6px;
    color: var(--primary-blue);
}

.metric-card.warning strong { color: #b7791f; }
.metric-card.danger strong { color: #c0392b; }

.resource-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 18px;
}

.resource-card {
    background: #fff;
    border: 1px solid var(--border-grey);
    border-radius: 16px;
    overflow: hidden;
    box-shadow: 0 8px 20px rgba(17, 58, 89, 0.05);
}

.resource-card img {
    width: 100%;
    aspect-ratio: 4 / 3;
    object-fit: cover;
    background: #eef3f7;
}

.resource-image-link,
.resource-image-link img {
    display: block;
}

.resource-image-link:focus-visible {
    outline: 3px solid var(--primary-blue);
    outline-offset: -3px;
}

.resource-card-body { padding: 16px; }

.detail-image {
    width: 100%;
    height: 260px;
    object-fit: cover;
    background: #eef3f7;
}

.preview-image {
    width: 180px;
    height: 110px;
    object-fit: cover;
    border-radius: 10px;
    border: 1px solid var(--border-grey);
}

.table-thumb {
    width: 84px;
    height: 56px;
    object-fit: cover;
    border-radius: 8px;
    border: 1px solid var(--border-grey);
}

.item-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 12px;
}

.item-card {
    border: 1px solid var(--border-grey);
    border-radius: 12px;
    padding: 14px;
    background: #fbfdff;
}

.item-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.form-card { max-width: 820px; }
.form-card-wide { max-width: 1020px; }

.empty-state {
    padding: 28px;
    text-align: center;
    color: #6c757d;
}

.timeline-wrapper {
    overflow-x: auto;
    padding: 14px;
    background: #fff;
}

.timeline-grid {
    display: grid;
    gap: 4px;
    min-width: 1120px;
    align-items: stretch;
}

.timeline-head {
    background: var(--deep-blue);
    color: #fff;
    font-size: 12px;
    font-weight: 700;
    text-align: center;
    padding: 8px 4px;
    border-radius: 6px;
}

.timeline-item-label {
    background: #f1f5f9;
    font-weight: 700;
    padding: 8px;
    border-radius: 6px;
    border: 1px solid var(--border-grey);
}

.timeline-cell {
    min-height: 34px;
    padding: 7px 4px;
    text-align: center;
    border-radius: 6px;
    font-size: 12px;
    border: 1px solid rgba(0, 0, 0, 0.05);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.timeline-cell.available { background: #e8f5e9; color: #1b5e20; }
.timeline-cell.reserved { background: #fff3cd; color: #7a5c00; }
.timeline-cell.borrowed { background: #d7ecff; color: #124a73; }
.timeline-cell.overdue { background: #f8d7da; color: #842029; font-weight: 700; }
.timeline-cell.maintenance { background: #e2e3e5; color: #41464b; }

.timeline-legend {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    font-size: 12px;
    color: #5f6b76;
}

.legend {
    display: inline-block;
    width: 12px;
    height: 12px;
    border-radius: 3px;
    margin-right: 4px;
    vertical-align: -1px;
}

.legend.available { background: #a5d6a7; }
.legend.reserved { background: #ffe08a; }
.legend.borrowed { background: #90caf9; }
.legend.overdue { background: #ef9a9a; }
.legend.maintenance { background: #bfc5ca; }

.progress-track {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    flex-wrap: wrap;
}

.progress-step {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 135px;
}

.progress-dot {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: #d5dee6;
    color: #fff;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.progress-step.active .progress-dot { background: var(--primary-blue); }
.progress-step.rejected .progress-dot { background: #dc3545; }
.progress-step.cancelled .progress-dot { background: #6c757d; }
.progress-line {
    width: 36px;
    height: 2px;
    background: #d5dee6;
    margin-top: 14px;
}

.progress-step.active + .progress-line { background: var(--primary-blue); }

.chart-box { padding: 18px; }

.file-input-box {
    border: 1px solid var(--border-grey);
    border-radius: 12px;
    background: #fbfdff;
    padding: 10px 12px;
}

.file-input-row {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.file-input-hidden { display: none; }

.file-input-name {
    color: var(--muted-text);
    font-size: 14px;
}

.table td, .table th { vertical-align: middle; }

.status-note {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 10px;
    border-radius: 999px;
    background: #eef4f8;
    color: var(--muted-text);
    font-size: 13px;
}

.btn-primary {
    background-color: var(--primary-blue);
    border-color: var(--primary-blue);
}

.btn-primary:hover,
.btn-primary:focus {
    background-color: var(--deep-blue);
    border-color: var(--deep-blue);
}

@media (max-width: 768px) {
    .page-header, .filter-bar { flex-direction: column; }
    .filter-bar .form-control, .filter-bar .form-select { max-width: none; }
    .app-container { padding: 16px; }
    .auth-card, .auth-card-wide { width: 100%; }
}

/* V4 layout and visual polish */
.layout-shell {
    display: flex;
    min-height: 100vh;
    background: var(--light-surface);
}

.app-sidebar {
    width: 252px;
    flex: 0 0 252px;
    background: linear-gradient(180deg, #123a59, #1f5d89);
    color: #fff;
    padding: 22px 18px;
    position: sticky;
    top: 0;
    height: 100vh;
    display: flex;
    flex-direction: column;
    box-shadow: 14px 0 30px rgba(18, 58, 89, 0.12);
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 26px;
}

.sidebar-brand span,
.sidebar-user span {
    display: block;
    font-size: 12px;
    opacity: 0.72;
    margin-top: 2px;
}

.brand-mark {
    width: 42px;
    height: 42px;
    border-radius: 12px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: rgba(255,255,255,0.16);
    font-weight: 800;
    letter-spacing: 0.5px;
}

.sidebar-user {
    padding: 14px;
    background: rgba(255,255,255,0.12);
    border: 1px solid rgba(255,255,255,0.15);
    border-radius: 14px;
    margin-bottom: 22px;
}

.sidebar-menu {
    display: grid;
    gap: 8px;
}

.sidebar-menu a,
.sidebar-logout {
    color: rgba(255,255,255,0.9);
    text-decoration: none;
    border-radius: 12px;
    padding: 11px 13px;
    font-weight: 600;
    transition: 0.14s ease;
}

.sidebar-menu a:hover,
.sidebar-logout:hover {
    background: rgba(255,255,255,0.15);
    color: #fff;
}

.sidebar-logout {
    margin-top: auto;
    border: 1px solid rgba(255,255,255,0.18);
    text-align: center;
}

.app-main {
    flex: 1;
    padding: 28px;
    min-width: 0;
}

.chart-box {
    height: 340px;
    position: relative;
}

.chart-box canvas {
    max-height: 300px;
}

.dashboard-chart-card .card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.dashboard-chart-card .card-header span:last-child {
    color: var(--muted-text);
    font-size: 12px;
    font-weight: 400;
}

.timeline-cell-link {
    display: block;
    text-decoration: none;
}

.timeline-cell-link:hover .timeline-cell.available {
    outline: 2px solid #5aa469;
    transform: translateY(-1px);
}

@media (max-width: 992px) {
    .layout-shell { display: block; }
    .app-sidebar {
        width: auto;
        height: auto;
        position: static;
        flex: none;
        border-radius: 0 0 18px 18px;
    }
    .sidebar-menu { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
    .sidebar-logout { margin-top: 14px; display: block; }
    .app-main { padding: 18px; }
}
