* { box-sizing: border-box; margin: 0; padding: 0; }
body {
    font-family: -apple-system, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
    background: #f5f6fa;
    color: #2c3e50;
}

.topbar {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 16px 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}
.brand { display: flex; align-items: center; gap: 12px; }
.logo { font-size: 32px; }
.topbar h1 { font-size: 20px; font-weight: 600; }
.ver { background: rgba(255,255,255,0.2); padding: 2px 8px; border-radius: 4px; font-size: 12px; margin-left: 8px; }
.user select {
    padding: 6px 12px; border: none; border-radius: 6px; font-size: 14px; cursor: pointer;
}

.layout { display: flex; min-height: calc(100vh - 70px); }

.sidebar {
    width: 240px; background: white; padding: 20px;
    box-shadow: 2px 0 4px rgba(0,0,0,0.05);
}
.sidebar h3 { font-size: 16px; margin-bottom: 12px; color: #555; }
.cat-list { list-style: none; }
.cat-item {
    padding: 10px 14px; border-radius: 6px; cursor: pointer; margin-bottom: 4px;
    display: flex; justify-content: space-between; align-items: center;
    transition: all 0.2s;
}
.cat-item:hover { background: #f0f1f5; }
.cat-item.active { background: #667eea; color: white; }
.cat-item .badge {
    background: rgba(255,255,255,0.3); padding: 2px 8px; border-radius: 10px;
    font-size: 12px;
}
.cat-item.active .badge { background: rgba(255,255,255,0.3); }

.filter-box { margin-top: 20px; padding: 12px; background: #f9f9fb; border-radius: 6px; }
.filter-box label { display: flex; align-items: center; gap: 6px; cursor: pointer; }

.upload-box { margin-top: 20px; padding: 12px; background: #f9f9fb; border-radius: 6px; }
.upload-box h4 { font-size: 14px; margin-bottom: 8px; }
.upload-box input[type=file] { width: 100%; font-size: 12px; }
.preview {
    margin-top: 8px; height: 120px; border: 2px dashed #ccc; border-radius: 6px;
    display: flex; align-items: center; justify-content: center; overflow: hidden;
    color: #aaa; font-size: 13px;
}
.preview img { width: 100%; height: 100%; object-fit: cover; }

.main { flex: 1; padding: 20px 24px; overflow-y: auto; }
.search-bar { position: relative; margin-bottom: 20px; }
.search-bar input {
    width: 100%; padding: 12px 16px; font-size: 15px; border: 2px solid #e0e0e0;
    border-radius: 8px; outline: none; transition: border-color 0.2s;
}
.search-bar input:focus { border-color: #667eea; }
.search-bar .hint {
    position: absolute; right: 16px; top: 50%; transform: translateY(-50%);
    font-size: 13px; color: #888;
}

.book-grid {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 16px; margin-bottom: 30px;
}
.book-card {
    background: white; border-radius: 10px; overflow: hidden;
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
    transition: transform 0.2s, box-shadow 0.2s;
    display: flex; flex-direction: column;
}
.book-card:hover { transform: translateY(-4px); box-shadow: 0 8px 20px rgba(0,0,0,0.12); }
.book-card .cover {
    height: 180px; background: linear-gradient(135deg, #e0e7ff 0%, #c7d2fe 100%);
    display: flex; align-items: center; justify-content: center;
    font-size: 64px; color: rgba(102,126,234,0.5);
    position: relative; overflow: hidden;
}
.book-card .cover img { width: 100%; height: 100%; object-fit: cover; }
.book-card .info { padding: 12px; flex: 1; }
.book-card .title { font-size: 15px; font-weight: 600; margin-bottom: 4px; line-height: 1.4; }
.book-card .author { color: #888; font-size: 13px; margin-bottom: 6px; }
.book-card .meta { display: flex; justify-content: space-between; align-items: center; font-size: 12px; color: #999; margin-top: 6px; }
.book-card .stock { font-weight: 600; }
.book-card .stock.zero { color: #e74c3c; }
.book-card .stock.normal { color: #27ae60; }
.book-card .action { padding: 0 12px 12px; }
.borrow-btn {
    width: 100%; padding: 8px; border: none; border-radius: 6px;
    background: #667eea; color: white; font-size: 14px; cursor: pointer;
    transition: all 0.2s;
}
.borrow-btn:hover:not(:disabled) { background: #5568d3; }
.borrow-btn:disabled { background: #ccc; cursor: not-allowed; }
.borrow-btn.borrowed { background: #95a5a6; }

.records { background: white; padding: 20px; border-radius: 10px; box-shadow: 0 2px 8px rgba(0,0,0,0.06); }
.records h3 { margin-bottom: 12px; }
.record-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.record-table th, .record-table td { padding: 8px 10px; text-align: left; border-bottom: 1px solid #eee; }
.record-table th { background: #f8f9fc; color: #666; }
.record-table .empty { text-align: center; color: #aaa; padding: 20px; }
.status-tag { padding: 2px 8px; border-radius: 4px; font-size: 12px; }
.status-tag.borrowed { background: #fff3cd; color: #856404; }
.status-tag.returned { background: #d4edda; color: #155724; }

.modal {
    position: fixed; inset: 0; background: rgba(0,0,0,0.5);
    display: flex; align-items: center; justify-content: center; z-index: 999;
}
.modal.hidden { display: none; }
.modal-content {
    background: white; padding: 24px; border-radius: 10px;
    min-width: 320px; max-width: 500px; box-shadow: 0 10px 40px rgba(0,0,0,0.2);
}
.modal-content h3 { margin-bottom: 12px; color: #2c3e50; }
.modal-content p { margin-bottom: 16px; line-height: 1.6; }
.modal-content button {
    padding: 8px 20px; border: none; border-radius: 6px; background: #667eea;
    color: white; cursor: pointer; font-size: 14px;
}
.modal-content.error h3 { color: #e74c3c; }
.modal-content.success h3 { color: #27ae60; }

.contract {
    position: fixed; bottom: 10px; right: 10px; background: white;
    border-radius: 6px; box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    max-width: 600px;
}
.contract summary { padding: 8px 12px; cursor: pointer; font-size: 13px; color: #667eea; }
.contract pre {
    padding: 10px; background: #f8f9fc; font-size: 12px; max-height: 300px; overflow: auto;
    border-top: 1px solid #eee;
}

.empty-tip {
    grid-column: 1/-1; text-align: center; padding: 60px 0; color: #999;
}
