* { margin: 0; padding: 0; box-sizing: border-box; }
:root {
  --primary: #4A90D9; --primary-dark: #357ABD; --success: #52C41A; --warning: #FAAD14; --danger: #FF4D4F;
  --bg: #f0f2f5; --card-bg: #fff; --text: #333; --text-secondary: #666; --text-muted: #999;
  --border: #e8e8e8; --sidebar-bg: #001529; --sidebar-text: #ffffffb3; --sidebar-active: #1890ff;
  --radius: 8px; --shadow: 0 2px 8px rgba(0,0,0,0.08);
}
body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif; background: var(--bg); color: var(--text); line-height: 1.5; }

.login-page { display: flex; align-items: center; justify-content: center; min-height: 100vh; background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); }
.login-card { background: #fff; border-radius: 12px; padding: 40px; width: 400px; max-width: 90vw; box-shadow: 0 20px 60px rgba(0,0,0,0.15); }
.login-header { text-align: center; margin-bottom: 32px; }
.login-header h1 { font-size: 28px; color: #333; }
.login-header p { font-size: 14px; color: var(--text-muted); margin-top: 4px; }
.login-error { color: var(--danger); font-size: 13px; min-height: 20px; margin-bottom: 8px; text-align: center; }

.main-page { display: flex; min-height: 100vh; }
.sidebar { width: 220px; background: var(--sidebar-bg); display: flex; flex-direction: column; position: fixed; top: 0; left: 0; bottom: 0; z-index: 100; }
.sidebar-header { padding: 24px 20px; border-bottom: 1px solid rgba(255,255,255,0.1); }
.sidebar-header h2 { color: #fff; font-size: 18px; }
.sidebar-subtitle { color: var(--sidebar-text); font-size: 12px; }
.sidebar-nav { flex: 1; padding: 12px 0; overflow-y: auto; }
.nav-item { display: flex; align-items: center; gap: 10px; padding: 12px 24px; color: var(--sidebar-text); text-decoration: none; font-size: 14px; cursor: pointer; transition: all 0.2s; border-left: 3px solid transparent; }
.nav-item:hover { color: #fff; background: rgba(255,255,255,0.05); }
.nav-item.active { color: #fff; background: var(--sidebar-active); border-left-color: #fff; }
.nav-icon { font-size: 18px; }
.sidebar-footer { padding: 16px 20px; border-top: 1px solid rgba(255,255,255,0.1); }
.user-info { display: flex; flex-direction: column; gap: 4px; margin-bottom: 12px; }
.user-info span { color: var(--sidebar-text); font-size: 13px; }
.tenant-badge { background: rgba(255,255,255,0.15); padding: 2px 8px; border-radius: 4px; font-size: 11px !important; display: inline-block; width: fit-content; }

.main-content { margin-left: 220px; flex: 1; padding: 24px; min-height: 100vh; }
.page { animation: fadeIn 0.3s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

.page-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 24px; }
.page-title { font-size: 22px; font-weight: 600; }
.page-subtitle { font-size: 13px; color: var(--text-muted); margin-top: 4px; }

.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; margin-bottom: 24px; }
.stat-card { background: var(--card-bg); border-radius: var(--radius); padding: 24px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 8px; }
.stat-card .stat-value { font-size: 32px; font-weight: 700; color: var(--primary); }
.stat-card .stat-label { font-size: 13px; color: var(--text-muted); }
.stat-card .stat-icon { font-size: 28px; }

.card { background: var(--card-bg); border-radius: var(--radius); padding: 24px; box-shadow: var(--shadow); margin-bottom: 20px; }
.card-title { font-size: 16px; font-weight: 600; margin-bottom: 16px; display: flex; align-items: center; gap: 8px; }

.chart-container { height: 280px; display: flex; align-items: flex-end; gap: 8px; padding: 20px 0 0; }
.chart-bar-wrap { flex: 1; display: flex; flex-direction: column; align-items: center; height: 100%; }
.chart-bar { width: 100%; max-width: 50px; background: linear-gradient(180deg, var(--primary) 0%, #83b8f0 100%); border-radius: 4px 4px 0 0; transition: height 0.5s ease; min-height: 4px; }
.chart-label { font-size: 11px; color: var(--text-muted); margin-top: 8px; text-align: center; }
.chart-value { font-size: 11px; color: var(--text-secondary); margin-bottom: 4px; }

table { width: 100%; border-collapse: collapse; }
th, td { padding: 12px 16px; text-align: left; border-bottom: 1px solid var(--border); font-size: 13px; }
th { background: #fafafa; font-weight: 600; color: var(--text-secondary); white-space: nowrap; }
tr:hover { background: #fafafa; }
.table-wrap { overflow-x: auto; }

.btn { padding: 8px 20px; border: 1px solid var(--border); border-radius: var(--radius); font-size: 14px; cursor: pointer; transition: all 0.2s; background: #fff; color: var(--text); display: inline-flex; align-items: center; gap: 6px; }
.btn:hover { border-color: var(--primary); color: var(--primary); }
.btn-primary { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-dark); color: #fff; }
.btn-success { background: var(--success); color: #fff; border-color: var(--success); }
.btn-warning { background: var(--warning); color: #fff; border-color: var(--warning); }
.btn-danger { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn-danger:hover { background: #ff7875; color: #fff; }
.btn-sm { padding: 4px 12px; font-size: 12px; }
.btn-block { width: 100%; justify-content: center; }
.btn-outline { background: transparent; color: var(--sidebar-text); border-color: rgba(255,255,255,0.3); }
.btn-outline:hover { color: #fff; border-color: #fff; }

.form-group { margin-bottom: 20px; }
.form-group label { display: block; font-size: 13px; color: var(--text-secondary); margin-bottom: 6px; font-weight: 500; }
.label-hint { font-weight: 400; color: var(--text-muted); }
.form-group input, .form-group select, .form-group textarea {
  width: 100%; padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius); font-size: 14px; transition: border-color 0.2s; outline: none; font-family: inherit;
}
.form-group input:focus, .form-group select:focus, .form-group textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 2px rgba(74,144,217,0.15); }
.form-group textarea { resize: vertical; min-height: 80px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

.tag { display: inline-block; padding: 2px 8px; border-radius: 4px; font-size: 12px; font-weight: 500; }
.tag-success { background: #f6ffed; color: var(--success); border: 1px solid #b7eb8f; }
.tag-warning { background: #fffbe6; color: #d48806; border: 1px solid #ffe58f; }
.tag-danger { background: #fff2f0; color: var(--danger); border: 1px solid #ffccc7; }
.tag-info { background: #e6f7ff; color: var(--primary); border: 1px solid #91d5ff; }
.tag-system { background: #f9f0ff; color: #722ed1; border: 1px solid #d3adf7; }
.clickable-tag { cursor: pointer; transition: all 0.2s; }
.clickable-tag:hover { transform: scale(1.05); box-shadow: 0 2px 6px rgba(0,0,0,0.1); }


.actions { display: flex; gap: 8px; flex-wrap: wrap; }
.empty-state { text-align: center; padding: 60px 20px; color: var(--text-muted); }
.empty-state .empty-icon { font-size: 48px; margin-bottom: 12px; }
.pagination { display: flex; justify-content: center; align-items: center; gap: 8px; margin-top: 20px; }
.pagination .page-info { font-size: 13px; color: var(--text-muted); }

.modal-overlay { position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: rgba(0,0,0,0.45); z-index: 1000; display: flex; align-items: center; justify-content: center; }
#modal-container { position: relative; }
.modal { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); background: #fff; border-radius: 12px; width: 560px; max-width: 90vw; max-height: 90vh; display: flex; flex-direction: column; box-shadow: 0 20px 60px rgba(0,0,0,0.2); }
.modal-header { display: flex; justify-content: space-between; align-items: center; padding: 20px 24px; border-bottom: 1px solid var(--border); flex-shrink: 0; }
.modal-title { font-size: 16px; font-weight: 600; }
.modal-close { cursor: pointer; font-size: 20px; color: var(--text-muted); background: none; border: none; padding: 4px; }
.modal-close:hover { color: var(--text); }
.modal-body { padding: 24px; overflow-y: auto; flex: 1; min-height: 100px; }
.modal-footer { display: flex; justify-content: flex-end; gap: 12px; padding: 16px 24px; border-top: 1px solid var(--border); flex-shrink: 0; }

.toast { position: fixed; top: 24px; left: 50%; transform: translateX(-50%); background: #333; color: #fff; padding: 12px 24px; border-radius: 8px; font-size: 14px; z-index: 2000; animation: slideDown 0.3s ease; }
.toast.success { background: var(--success); }
.toast.error { background: var(--danger); }
@keyframes slideDown { from { transform: translateX(-50%) translateY(-20px); opacity: 0; } to { transform: translateX(-50%) translateY(0); opacity: 1; } }

.loading { text-align: center; padding: 40px; color: var(--text-muted); }
.spinner { display: inline-block; width: 24px; height: 24px; border: 3px solid var(--border); border-top-color: var(--primary); border-radius: 50%; animation: spin 0.6s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.upload-area { border: 2px dashed var(--border); border-radius: var(--radius); padding: 24px; text-align: center; cursor: pointer; transition: border-color 0.2s; margin-bottom: 8px; }
.upload-area:hover { border-color: var(--primary); }
.upload-area img { max-width: 200px; max-height: 150px; border-radius: 4px; }
.upload-placeholder { font-size: 32px; color: var(--text-muted); }

.storage-bar { height: 8px; background: #f0f0f0; border-radius: 4px; margin-top: 4px; overflow: hidden; }
.storage-bar-fill { height: 100%; background: var(--primary); border-radius: 4px; transition: width 0.3s; }
.storage-bar-fill.warning { background: var(--warning); }
.storage-bar-fill.danger { background: var(--danger); }

@media (max-width: 768px) {
  .sidebar { width: 60px; }
  .sidebar-header h2, .sidebar-subtitle { display: none; }
  .nav-item { justify-content: center; padding: 12px 0; }
  .nav-item span:not(.nav-icon) { display: none; }
  .main-content { margin-left: 60px; }
  .sidebar-footer { display: none; }
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .form-row { grid-template-columns: 1fr; }
}

.switch { position: relative; display: inline-block; width: 44px; height: 24px; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch-slider { position: absolute; cursor: pointer; top: 0; left: 0; right: 0; bottom: 0; background: #ccc; border-radius: 24px; transition: 0.3s; }
.switch-slider:before { content: ''; position: absolute; height: 18px; width: 18px; left: 3px; bottom: 3px; background: white; border-radius: 50%; transition: 0.3s; }
.switch input:checked + .switch-slider { background: var(--primary); }
.switch input:checked + .switch-slider:before { transform: translateX(20px); }

.tab-nav { display: flex; gap: 0; margin-bottom: 16px; border-bottom: 2px solid var(--border); }
.tab-item { padding: 10px 20px; cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -2px; font-weight: 500; font-size: 14px; color: var(--text-muted); transition: all 0.2s; }
.tab-item:hover { color: var(--primary); }
.tab-item.active { color: var(--primary); border-bottom-color: var(--primary); }