/* Reset & Base */
* { margin: 0; padding: 0; box-sizing: border-box; }
body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; background: #f5f5f5; color: #333; }
.hidden { display: none !important; }
.required { color: #e74c3c; }

/* Pages */
.page { min-height: 100vh; }

/* Auth Page */
#auth-page { display: flex; align-items: center; justify-content: center; background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); }
.auth-container { background: #fff; border-radius: 12px; padding: 40px; width: 400px; max-width: 90%; box-shadow: 0 20px 60px rgba(0,0,0,0.2); }
.auth-container h1 { text-align: center; margin-bottom: 24px; color: #333; font-size: 24px; }
.tab-container { display: flex; margin-bottom: 24px; border-bottom: 2px solid #eee; }
.tab-btn { flex: 1; padding: 10px; border: none; background: none; cursor: pointer; font-size: 16px; color: #999; transition: all 0.3s; border-bottom: 2px solid transparent; margin-bottom: -2px; }
.tab-btn.active { color: #667eea; border-bottom-color: #667eea; }
.auth-form .form-group { margin-bottom: 16px; }
.auth-form label { display: block; margin-bottom: 6px; font-weight: 500; font-size: 14px; }
.auth-form input { width: 100%; padding: 10px 12px; border: 1px solid #ddd; border-radius: 6px; font-size: 14px; transition: border-color 0.3s; }
.auth-form input:focus { outline: none; border-color: #667eea; }

/* Buttons */
.btn { padding: 10px 20px; border: none; border-radius: 6px; cursor: pointer; font-size: 14px; transition: all 0.3s; display: inline-flex; align-items: center; gap: 6px; }
.btn-primary { background: #667eea; color: #fff; }
.btn-primary:hover { background: #5a6fd6; }
.btn-danger { background: #e74c3c; color: #fff; }
.btn-danger:hover { background: #c0392b; }
.btn-small { padding: 6px 12px; font-size: 12px; }
.btn-add { width: 100%; margin-top: 8px; background: #f0f0f0; color: #666; }
.btn-add:hover { background: #e0e0e0; }
.btn-edit { background: #3498db; color: #fff; padding: 4px 8px; font-size: 12px; }
.btn-edit:hover { background: #2980b9; }
.btn-delete { background: #e74c3c; color: #fff; padding: 4px 8px; font-size: 12px; }
.btn-delete:hover { background: #c0392b; }

/* Navbar */
.navbar { background: #fff; padding: 12px 24px; display: flex; justify-content: space-between; align-items: center; box-shadow: 0 2px 8px rgba(0,0,0,0.1); position: sticky; top: 0; z-index: 100; }
.navbar h1 { font-size: 20px; color: #667eea; }
.nav-right { display: flex; align-items: center; gap: 12px; }
.user-badge { background: #667eea; color: #fff; padding: 6px 14px; border-radius: 20px; font-size: 13px; }

/* Main Layout */
.main-content { display: flex; height: calc(100vh - 56px); }
.sidebar { width: 260px; background: #fff; padding: 20px; border-right: 1px solid #eee; overflow-y: auto; }
.content { flex: 1; padding: 24px; overflow-y: auto; }
.content-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; }
.content-header h2 { font-size: 20px; color: #333; }
.content-title-wrap { display: flex; align-items: center; }

/* Sidebar */
.sidebar-section { margin-bottom: 24px; }
.sidebar-section h3 { font-size: 14px; color: #999; text-transform: uppercase; margin-bottom: 12px; letter-spacing: 1px; }
.sidebar-section h4 { font-size: 14px; color: #666; margin-bottom: 8px; }

/* Category List */
.category-list { margin-bottom: 8px; }
.category-item { display: flex; justify-content: space-between; align-items: center; padding: 8px 12px; border-radius: 6px; cursor: pointer; transition: background 0.2s; margin-bottom: 4px; }
.category-item:hover { background: #f5f5f5; }
.category-item.active { background: #667eea; color: #fff; }
.category-item.active .cat-actions .btn-edit, .category-item.active .cat-actions .btn-delete { color: #fff; background: rgba(255,255,255,0.2); }
.category-item .cat-name { font-size: 14px; }
.category-item .cat-badge { font-size: 10px; background: rgba(102,126,234,0.1); color: #667eea; padding: 2px 6px; border-radius: 4px; margin-left: 8px; }
.category-item.active .cat-badge { background: rgba(255,255,255,0.2); color: #fff; }
.cat-actions { display: flex; gap: 4px; opacity: 0; transition: opacity 0.2s; }
.category-item:hover .cat-actions { opacity: 1; }

/* Filter */
.filter-group { margin-bottom: 12px; }
.filter-group label { display: block; font-size: 12px; color: #999; margin-bottom: 4px; }
.filter-group input, .filter-group select { width: 100%; padding: 8px; border: 1px solid #ddd; border-radius: 4px; font-size: 13px; }
.filter-group input:focus, .filter-group select:focus { outline: none; border-color: #667eea; }

/* Items Grid */
.items-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; }
.items-list { display: flex; flex-direction: column; gap: 0; border: 1px solid #e0e0e0; border-radius: 8px; overflow: hidden; }
.list-header { display: grid; grid-template-columns: 2fr 1fr 1fr 1fr 1fr 1fr; padding: 10px 16px; background: #f5f5f5; font-size: 12px; font-weight: 600; color: #666; border-bottom: 2px solid #e0e0e0; }
.list-row { display: grid; grid-template-columns: 2fr 1fr 1fr 1fr 1fr 1fr; padding: 10px 16px; font-size: 13px; border-bottom: 1px solid #f0f0f0; cursor: pointer; transition: background 0.15s; align-items: center; }
.list-row:last-child { border-bottom: none; }
.list-row:hover { background: #f8f9ff; }
.list-row.row-expired { opacity: 0.7; }
.lr-name { font-weight: 500; color: #333; }
.lr-cat, .lr-prod, .lr-exp, .lr-days, .lr-owner, .lr-actions { color: #666; }
.lr-actions .btn { padding: 2px 8px; font-size: 11px; }

/* View Toggle */
.view-toggle { display: flex; gap: 4px; margin-left: 12px; }
.view-toggle button { background: #fff; border: 1px solid #ddd; border-radius: 4px; padding: 4px 10px; cursor: pointer; font-size: 13px; color: #666; transition: all 0.2s; }
.view-toggle button:hover { border-color: #667eea; color: #667eea; }
.view-toggle button.active { background: #667eea; color: #fff; border-color: #667eea; }
.item-card { background: #fff; border-radius: 10px; padding: 16px; box-shadow: 0 2px 8px rgba(0,0,0,0.06); transition: transform 0.2s, box-shadow 0.2s; cursor: pointer; }
.item-card:hover { transform: translateY(-2px); box-shadow: 0 4px 16px rgba(0,0,0,0.12); }
.item-card .item-img { width: 100%; height: 160px; object-fit: cover; border-radius: 6px; margin-bottom: 12px; background: #f0f0f0; }
.item-card .item-img-placeholder { width: 100%; height: 160px; background: #f5f5f5; border-radius: 6px; display: flex; align-items: center; justify-content: center; color: #ccc; font-size: 40px; margin-bottom: 12px; }
.item-card .item-name { font-size: 16px; font-weight: 600; margin-bottom: 8px; color: #333; }
.item-card .item-meta { font-size: 12px; color: #999; margin-bottom: 4px; }
.item-card .item-meta span { margin-right: 12px; }
.item-card .item-category { display: inline-block; font-size: 11px; background: #667eea; color: #fff; padding: 2px 8px; border-radius: 4px; margin-bottom: 8px; }
.item-card .item-owner { font-size: 11px; color: #999; margin-top: 8px; padding-top: 8px; border-top: 1px solid #f0f0f0; }
.item-card .item-owner .private-badge { background: #f39c12; color: #fff; padding: 1px 6px; border-radius: 3px; font-size: 10px; }
.item-card .item-owner .shared-badge { background: #27ae60; color: #fff; padding: 1px 6px; border-radius: 3px; font-size: 10px; }
.item-card .item-expired { color: #e74c3c; font-weight: 600; }
.item-card .item-expiring-soon { color: #e74c3c; }
.item-card .item-actions { display: flex; gap: 8px; margin-top: 12px; }

/* Pagination */
.pagination { display: flex; justify-content: center; gap: 8px; margin-top: 24px; }
.pagination button { padding: 8px 14px; border: 1px solid #ddd; background: #fff; border-radius: 4px; cursor: pointer; font-size: 13px; }
.pagination button.active { background: #667eea; color: #fff; border-color: #667eea; }
.pagination button:disabled { opacity: 0.5; cursor: not-allowed; }

/* Modal */
.modal { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.5); display: flex; align-items: center; justify-content: center; z-index: 1000; }
.modal-content { background: #fff; border-radius: 12px; padding: 24px; width: 500px; max-width: 90%; max-height: 90vh; overflow-y: auto; }
.modal-large { width: 650px; }
.modal-small { width: 400px; }
.modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; }
.modal-header h3 { font-size: 18px; color: #333; }
.modal-close { background: none; border: none; font-size: 24px; cursor: pointer; color: #999; padding: 0; line-height: 1; }
.modal-close:hover { color: #333; }
.modal-footer { display: flex; justify-content: flex-end; gap: 12px; margin-top: 20px; }

/* Form */
.form-group { margin-bottom: 16px; }
.form-group label { display: block; margin-bottom: 6px; font-weight: 500; font-size: 14px; color: #555; }
.form-group input, .form-group select, .form-group textarea { width: 100%; padding: 10px 12px; border: 1px solid #ddd; border-radius: 6px; font-size: 14px; transition: border-color 0.3s; font-family: inherit; }
.form-group input:focus, .form-group select:focus, .form-group textarea:focus { outline: none; border-color: #667eea; }
.form-row { display: flex; gap: 16px; }
.form-row .form-group { flex: 1; }
.form-hint { display: block; font-size: 12px; color: #999; margin-top: 4px; }
.radio-group { display: flex; gap: 16px; margin-top: 4px; }
.radio-group label { display: flex; align-items: center; gap: 6px; font-weight: normal; cursor: pointer; }
.image-preview { max-width: 200px; max-height: 150px; margin-top: 8px; border-radius: 6px; }
.inline-form { display: flex; gap: 8px; margin-top: 8px; }
.inline-form input { flex: 1; }

/* Item Detail */
.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.detail-item { margin-bottom: 12px; }
.detail-label { font-size: 12px; color: #999; margin-bottom: 4px; }
.detail-value { font-size: 14px; color: #333; }
.detail-image { width: 100%; max-height: 300px; object-fit: contain; border-radius: 8px; margin-bottom: 16px; }
.detail-image-placeholder { width: 100%; height: 120px; background: #f5f5f5; border-radius: 8px; display: flex; align-items: center; justify-content: center; font-size: 48px; color: #ccc; margin-bottom: 16px; }

/* Expiry Alert */
.expiry-alert { background: #fde8e8; border: 1px solid #e74c3c; border-radius: 8px; padding: 12px 16px; margin-bottom: 16px; }
.expiry-alert.hidden { display: none; }
.expiry-alert-title { font-weight: 600; color: #856404; margin-bottom: 8px; font-size: 14px; }
.expiry-alert-simple { font-weight: 600; color: #e74c3c; font-size: 14px; }
.expiry-alert-list { list-style: none; padding: 0; margin: 0; }
.expiry-alert-item { display: flex; justify-content: space-between; align-items: center; padding: 4px 0; font-size: 13px; color: #856404; border-bottom: 1px solid #ffeaa7; }
.expiry-alert-item:last-child { border-bottom: none; }
.expiry-alert-item .item-name { font-weight: 500; cursor: pointer; }
.expiry-alert-item .item-name:hover { text-decoration: underline; }
.expiry-alert-item .days-left { background: #e74c3c; color: #fff; padding: 2px 8px; border-radius: 10px; font-size: 11px; font-weight: 600; }
.expiry-alert-item .days-left.warning { background: #f39c12; }
.expiry-alert-close { float: right; background: none; border: none; font-size: 18px; cursor: pointer; color: #e74c3c; line-height: 1; }

/* Expiring Sidebar */
.expiring-sidebar { display: flex; align-items: center; gap: 8px; padding: 10px 12px; background: #fff8e1; border: 1px solid #ffe082; border-radius: 8px; cursor: pointer; transition: all 0.2s; }
.expiring-sidebar:hover { background: #fff3cd; border-color: #ffc107; }
.expiring-sidebar.active { background: #fff3cd; border-color: #ffc107; box-shadow: 0 0 0 2px rgba(255,193,7,0.3); }
.expiring-icon { font-size: 18px; }
#expiring-count-text { font-size: 14px; color: #856404; font-weight: 500; }
.expiring-badge { background: #e74c3c; color: #fff; padding: 1px 7px; border-radius: 10px; font-size: 12px; font-weight: 600; margin-left: 4px; }

/* Recycle Bin Sidebar */
.recycle-sidebar { display: flex; align-items: center; gap: 8px; padding: 10px 12px; background: #f5f5f5; border: 1px solid #e0e0e0; border-radius: 8px; cursor: pointer; transition: all 0.2s; }
.recycle-sidebar:hover { background: #eee; border-color: #999; }
.recycle-sidebar.active { background: #e8e8e8; border-color: #999; box-shadow: 0 0 0 2px rgba(0,0,0,0.1); }
.recycle-icon { font-size: 18px; }
#recycle-count-text { font-size: 14px; color: #666; font-weight: 500; }
.recycle-badge { background: #999; color: #fff; padding: 1px 7px; border-radius: 10px; font-size: 12px; font-weight: 600; margin-left: 4px; }

/* Maintenance Sidebar */
.maintenance-sidebar { display: flex; align-items: center; gap: 8px; padding: 10px 12px; background: #e8f5e9; border: 1px solid #a5d6a7; border-radius: 8px; cursor: pointer; transition: all 0.2s; }
.maintenance-sidebar:hover { background: #c8e6c9; border-color: #66bb6a; }
.maintenance-sidebar.active { background: #c8e6c9; border-color: #66bb6a; box-shadow: 0 0 0 2px rgba(102,187,106,0.3); }
.maintenance-icon { font-size: 18px; }
#maintenance-count-text { font-size: 14px; color: #2e7d32; font-weight: 500; }

/* Maintenance Plan Cards */
.maint-plan-card { background: #fff; border: 1px solid #e0e0e0; border-radius: 10px; padding: 16px; margin-bottom: 12px; transition: all 0.2s; cursor: pointer; }
.maint-plan-card:hover { border-color: #66bb6a; box-shadow: 0 2px 8px rgba(0,0,0,0.08); }
.maint-plan-header { display: flex; align-items: center; justify-content: space-between; }
.maint-plan-info { display: flex; align-items: center; gap: 10px; }
.maint-plan-icon { font-size: 28px; }
.maint-plan-name { font-size: 16px; font-weight: 600; color: #333; }
.maint-plan-desc { font-size: 12px; color: #999; margin-top: 2px; }
.maint-plan-stats { display: flex; gap: 12px; margin-top: 8px; font-size: 13px; }
.maint-stat-overdue { color: #e74c3c; font-weight: 500; }
.maint-stat-soon { color: #f39c12; font-weight: 500; }
.maint-stat-ok { color: #27ae60; }

/* Maintenance Item Rows */
.maint-item-row { padding: 12px 14px; border-bottom: 1px solid #f0f0f0; }
.maint-item-row:last-child { border-bottom: none; }
.maint-item-row:hover { background: #fafafa; }
.maint-item-row-top { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; }
.maint-item-name { font-weight: 600; font-size: 14px; }
.maint-item-cycle { color: #888; font-size: 12px; }
.maint-item-due { font-size: 13px; }
.maint-item-due.overdue { color: #e74c3c; font-weight: 600; }
.maint-item-due.soon { color: #f39c12; font-weight: 500; }
.maint-item-due.ok { color: #27ae60; }
.maint-item-row-bottom { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.maint-item-last-done { color: #aaa; font-size: 12px; }
.maint-item-actions { display: flex; gap: 6px; }
.btn-done { background: #27ae60; color: #fff; border: none; padding: 5px 12px; border-radius: 4px; cursor: pointer; font-size: 12px; white-space: nowrap; }
.btn-done:hover { background: #219a52; }
.btn-maint-edit { background: #667eea; color: #fff; border: none; padding: 5px 10px; border-radius: 4px; cursor: pointer; font-size: 12px; white-space: nowrap; }
.btn-maint-edit:hover { background: #5a6fd6; }
.btn-maint-del { background: #fff; color: #e74c3c; border: 1px solid #e74c3c; padding: 5px 10px; border-radius: 4px; cursor: pointer; font-size: 12px; white-space: nowrap; }
.btn-maint-del:hover { background: #e74c3c; color: #fff; }

/* Maintenance Detail Panel */
.maint-detail-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; padding-bottom: 12px; border-bottom: 1px solid #eee; }
.maint-detail-title { display: flex; align-items: center; gap: 10px; }
.maint-detail-icon { font-size: 28px; }
.maint-detail-name { font-size: 20px; font-weight: 600; }
.btn-back-maint { background: #667eea; color: #fff; border: none; padding: 8px 18px; border-radius: 6px; cursor: pointer; font-size: 14px; font-weight: 500; display: inline-flex; align-items: center; gap: 4px; }
.btn-back-maint:hover { background: #5a6fd6; }

/* Emoji Picker */
.emoji-picker { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
.emoji-option { cursor: pointer; }
.emoji-option input[type="radio"] { display: none; }
.emoji-option span { display: inline-block; font-size: 24px; padding: 4px 8px; border: 2px solid transparent; border-radius: 6px; transition: all 0.2s; }
.emoji-option input[type="radio"]:checked + span { border-color: #667eea; background: #eef; }

/* Maintenance Alert Banner */
.maintenance-alert { background: linear-gradient(135deg, #e8f5e9, #c8e6c9); border: 1px solid #a5d6a7; border-radius: 8px; padding: 12px 16px; margin-bottom: 16px; display: flex; align-items: center; gap: 8px; font-size: 14px; color: #2e7d32; }
.maintenance-alert-icon { font-size: 20px; }

/* Recycle Bin Actions */
.btn-restore { background: #27ae60; color: #fff; border: none; padding: 2px 10px; border-radius: 4px; cursor: pointer; font-size: 12px; }
.btn-restore:hover { background: #219a52; }
.btn-delete-perm { background: #e74c3c; color: #fff; border: none; padding: 2px 10px; border-radius: 4px; cursor: pointer; font-size: 12px; }
.btn-delete-perm:hover { background: #c0392b; }

/* Recycle Bin Actions Bar */
.recycle-actions { display: flex; justify-content: flex-end; margin-bottom: 12px; }

/* Expiring Days Selector (next to title) */
#expiring-days-selector { display: inline-flex; align-items: center; gap: 4px; margin-left: 8px; font-size: 13px; font-weight: 400; color: #856404; vertical-align: middle; }
#expiring-days-selector label { font-weight: 500; }
#expiring-days-selector select { padding: 2px 6px; border: 1px solid #ffc107; border-radius: 4px; font-size: 13px; background: #fff; cursor: pointer; }

/* Expired Card */
.card-expired { opacity: 0.7; border: 1px solid #ddd; }

/* Maintenance Records */
.btn-secondary { background: #6c757d; color: #fff; border: none; }
.btn-secondary:hover { background: #5a6268; }
.records-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; padding: 0 4px; }
.records-header h4 { margin: 0; font-size: 16px; color: #333; }
.records-count { font-size: 13px; color: #888; }
.records-list { display: flex; flex-direction: column; gap: 8px; }
.record-item { display: flex; align-items: center; justify-content: space-between; padding: 10px 14px; background: #f8f9fa; border-radius: 8px; border: 1px solid #e9ecef; }
.record-item:hover { background: #eef; border-color: #c5cae9; }
.record-info { display: flex; align-items: center; gap: 16px; flex: 1; }
.record-name { font-weight: 500; color: #333; font-size: 14px; }
.record-date { font-size: 13px; color: #888; }
.btn-record-del { background: #fff; color: #e74c3c; border: 1px solid #e74c3c; padding: 4px 12px; border-radius: 4px; cursor: pointer; font-size: 12px; white-space: nowrap; }
.btn-record-del:hover { background: #e74c3c; color: #fff; }

/* Suggestions (意见箱) */
.suggestion-sidebar { cursor: pointer; padding: 8px 12px; border-radius: 8px; display: flex; align-items: center; gap: 8px; transition: background 0.2s; }
.suggestion-sidebar:hover { background: #f0f0f0; }
.suggestion-icon { font-size: 18px; }
.suggestion-toolbar { display: flex; justify-content: flex-end; margin-bottom: 16px; }
.suggestion-list { display: flex; flex-direction: column; gap: 12px; }
.suggestion-card { background: #fff; border-radius: 10px; border: 1px solid #e0e0e0; padding: 16px; transition: box-shadow 0.2s; }
.suggestion-card:hover { box-shadow: 0 2px 8px rgba(0,0,0,0.08); }
.suggestion-content { font-size: 15px; line-height: 1.6; color: #333; margin-bottom: 10px; white-space: pre-wrap; word-break: break-word; }
.suggestion-file { display: flex; align-items: center; gap: 8px; padding: 8px 12px; background: #f5f7fa; border-radius: 6px; margin-bottom: 10px; }
.file-icon { font-size: 16px; }
.file-link { color: #667eea; text-decoration: none; font-size: 13px; }
.file-link:hover { text-decoration: underline; }
.file-size { font-size: 12px; color: #999; margin-left: auto; }
.suggestion-meta { display: flex; align-items: center; justify-content: space-between; }
.suggestion-time { font-size: 12px; color: #999; }
.btn-suggestion-del { background: #fff; color: #e74c3c; border: 1px solid #e74c3c; padding: 4px 12px; border-radius: 4px; cursor: pointer; font-size: 12px; }
.btn-suggestion-del:hover { background: #e74c3c; color: #fff; }
.file-name-preview { font-size: 12px; color: #666; margin-top: 4px; }
#suggestion-content { width: 100%; padding: 10px; border: 1px solid #ddd; border-radius: 6px; font-size: 14px; resize: vertical; font-family: inherit; }
#suggestion-file { margin-top: 4px; }

/* Toast */
#toast-container { position: fixed; top: 20px; right: 20px; z-index: 2000; }
.toast { background: #333; color: #fff; padding: 12px 20px; border-radius: 8px; margin-bottom: 8px; font-size: 14px; animation: slideIn 0.3s ease; min-width: 200px; }
.toast.success { background: #27ae60; }
.toast.error { background: #e74c3c; }
.toast.info { background: #3498db; }
@keyframes slideIn { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* Empty State */
.empty-state { text-align: center; padding: 60px 20px; color: #999; }
.empty-state .empty-icon { font-size: 48px; margin-bottom: 12px; }
.empty-state p { font-size: 14px; }

/* Group Info */
.group-info { margin-bottom: 16px; padding: 12px; background: #f8f9fa; border-radius: 8px; }
.group-info p { margin-bottom: 6px; font-size: 14px; }
.member-list { list-style: none; padding: 0; }
.member-list li { padding: 6px 0; font-size: 14px; border-bottom: 1px solid #eee; }
.member-list li:last-child { border-bottom: none; }

/* Responsive */
@media (max-width: 768px) {
    .main-content { flex-direction: column; }
    .sidebar { width: 100%; border-right: none; border-bottom: 1px solid #eee; max-height: 300px; }
    .items-grid { grid-template-columns: 1fr; }
    .form-row { flex-direction: column; gap: 0; }
    .detail-grid { grid-template-columns: 1fr; }
}