/* ===== Reset & Base ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
:root {
  --primary: #1890ff;
  --primary-hover: #40a9ff;
  --primary-dark: #096dd9;
  --danger: #ff4d4f;
  --danger-hover: #ff7875;
  --success: #52c41a;
  --warning: #faad14;
  --text: #333;
  --text-secondary: #666;
  --text-light: #999;
  --border: #e8e8e8;
  --bg: #f0f2f5;
  --bg-component: #fff;
  --sidebar-bg: #001529;
  --sidebar-text: #a6adb4;
  --sidebar-active: #1890ff;
  --sidebar-hover: rgba(255,255,255,0.08);
  --radius: 6px;
  --shadow: 0 2px 8px rgba(0,0,0,0.08);
  --shadow-lg: 0 4px 20px rgba(0,0,0,0.15);
}
html, body { height: 100%; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "PingFang SC", "Microsoft YaHei", sans-serif; font-size: 14px; color: var(--text); background: var(--bg); }
a { color: var(--primary); text-decoration: none; }
input, select, textarea { font-family: inherit; font-size: 14px; }

/* ===== Buttons ===== */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 4px; padding: 6px 16px; border: 1px solid var(--border); border-radius: var(--radius); background: #fff; color: var(--text); cursor: pointer; transition: all .2s; font-size: 14px; white-space: nowrap; }
.btn:hover { border-color: var(--primary); color: var(--primary); }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); color: #fff; }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-danger:hover { background: var(--danger-hover); border-color: var(--danger-hover); color: #fff; }
.btn-default { background: #fff; }
.btn-block { width: 100%; }
.btn-icon { padding: 6px 10px; border: none; background: transparent; font-size: 16px; }
.btn-icon:hover { background: rgba(0,0,0,0.06); }
.btn-text { border: none; background: transparent; color: var(--sidebar-text); }
.btn-text:hover { color: #fff; background: var(--sidebar-hover); }
.btn-sm { padding: 2px 8px; font-size: 12px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ===== Login Page ===== */
.login-page { display: flex; align-items: center; justify-content: center; min-height: 100vh; background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); }
.login-card { width: 400px; max-width: 90vw; background: #fff; border-radius: 12px; padding: 40px; box-shadow: var(--shadow-lg); }
.login-header { text-align: center; margin-bottom: 32px; }
.login-header .brand-logo { height: 64px; width: auto; max-width: 100%; display: block; margin: 0 auto 12px; }
.login-header h1 { font-size: 28px; color: var(--text); margin-bottom: 8px; }
.login-header p { color: var(--text-light); font-size: 14px; }
.login-form .form-group { margin-bottom: 20px; }
.login-form label { display: block; margin-bottom: 6px; font-weight: 500; color: var(--text-secondary); }
.login-form input { width: 100%; padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius); transition: border-color .2s; }
.login-form input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 2px rgba(24,144,255,.2); }
.login-form .btn-block { padding: 10px; font-size: 16px; margin-top: 8px; }
.error-msg { color: var(--danger); font-size: 13px; margin-top: 12px; text-align: center; min-height: 20px; }
.login-hint { text-align: center; color: var(--text-light); font-size: 12px; margin-top: 8px; }
.login-divider { display: flex; align-items: center; text-align: center; margin: 20px 0 16px; color: var(--text-light); font-size: 13px; }
.login-divider::before, .login-divider::after { content: ''; flex: 1; border-bottom: 1px solid var(--border); }
.login-divider span { padding: 0 16px; }
.btn-wx { display: flex; align-items: center; justify-content: center; width: 100%; padding: 10px; font-size: 15px; border-radius: var(--radius); border: 1px solid #07c160; background: #07c160; color: #fff; cursor: pointer; text-decoration: none; transition: opacity .2s; }
.btn-wx:hover { opacity: 0.9; color: #fff; }
.btn-wx svg { margin-right: 6px; }
.user-badge { font-size: 13px; color: var(--text-secondary); padding: 4px 12px; background: var(--bg); border-radius: 16px; white-space: nowrap; }

/* ===== Dashboard Layout ===== */
.dashboard { display: flex; min-height: 100vh; }

/* Sidebar */
.sidebar { width: 240px; background: var(--sidebar-bg); display: flex; flex-direction: column; flex-shrink: 0; transition: width .2s; position: fixed; top: 0; left: 0; bottom: 0; z-index: 100; }
.sidebar.collapsed { width: 0; overflow: hidden; }
.sidebar-header { padding: 20px 24px; border-bottom: 1px solid rgba(255,255,255,0.1); }
.sidebar-header h2 { color: #fff; font-size: 18px; }
.sidebar-header .brand-logo-sidebar { height: 40px; width: auto; display: block; margin: 0 auto; background: #fff; padding: 8px 14px; border-radius: 4px; }
.sidebar-nav { flex: 1; overflow-y: auto; padding: 8px 0; }
.sidebar-nav .nav-item { display: flex; align-items: center; gap: 10px; padding: 10px 24px; color: var(--sidebar-text); cursor: pointer; transition: all .2s; border-left: 3px solid transparent; font-size: 14px; }
.sidebar-nav .nav-item:hover { background: var(--sidebar-hover); color: #fff; }
.sidebar-nav .nav-item.active { background: rgba(24,144,255,.15); color: #fff; border-left-color: var(--sidebar-active); }
.sidebar-nav .nav-icon { font-size: 16px; flex-shrink: 0; }
.sidebar-nav .nav-group-title { padding: 16px 24px 8px; color: rgba(255,255,255,0.3); font-size: 12px; text-transform: uppercase; letter-spacing: 1px; }
.sidebar-footer { padding: 12px 24px; border-top: 1px solid rgba(255,255,255,0.1); }
.sidebar-footer .btn-text { width: 100%; text-align: center; }

/* Main Content */
.main-content { flex: 1; margin-left: 240px; display: flex; flex-direction: column; min-height: 100vh; transition: margin-left .2s; }
.main-content.sidebar-collapsed { margin-left: 0; }

/* Header */
.main-header { display: flex; align-items: center; justify-content: space-between; padding: 0 24px; height: 64px; background: #fff; box-shadow: var(--shadow); position: sticky; top: 0; z-index: 50; }
.header-left { display: flex; align-items: center; gap: 12px; }
.header-left h2 { font-size: 18px; font-weight: 500; }
.header-right { display: flex; align-items: center; gap: 12px; }
.search-box { display: flex; align-items: center; gap: 0; }
.search-box input { padding: 6px 12px; border: 1px solid var(--border); border-right: none; border-radius: var(--radius) 0 0 var(--radius); width: 220px; transition: width .2s; }
.search-box input:focus { outline: none; border-color: var(--primary); width: 280px; }
.search-box .btn-icon { border: 1px solid var(--border); border-radius: 0 var(--radius) var(--radius) 0; background: #fff; height: 34px; }

/* Content Body */
.content-body { padding: 24px; flex: 1; }

/* ===== Table ===== */
.table-container { background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; overflow-x: auto; }
table.data-table { width: 100%; border-collapse: collapse; min-width: 600px; }
.data-table th, .data-table td { padding: 12px 16px; text-align: left; border-bottom: 1px solid var(--border); white-space: nowrap; }
.data-table th { background: #fafafa; font-weight: 600; color: var(--text-secondary); font-size: 13px; position: sticky; top: 0; z-index: 10; }
.data-table tbody tr { transition: background .2s; }
.data-table tbody tr:hover { background: #f5f5f5; }
.data-table td.actions { display: flex; gap: 8px; align-items: center; }
.data-table .text-cell { display: inline-block; max-width: 200px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; vertical-align: middle; cursor: pointer; }
.data-table .text-cell:hover { color: var(--primary); }
.data-table .cell-id { display: inline-block; max-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; vertical-align: middle; cursor: pointer; color: var(--text-secondary); }
.data-table .cell-id:hover { color: var(--primary); }
.data-table .json-cell { display: inline-block; max-width: 150px; overflow: hidden; text-overflow: ellipsis; color: var(--text-light); font-family: monospace; font-size: 12px; white-space: nowrap; vertical-align: middle; }
.data-table .bool-badge { display: inline-block; padding: 2px 8px; border-radius: 4px; font-size: 12px; }
.badge-yes { background: #f6ffed; color: var(--success); border: 1px solid #b7eb8f; }
.badge-no { background: #fff1f0; color: var(--danger); border: 1px solid #ffa39e; }
.status-badge { display: inline-block; padding: 2px 10px; border-radius: 10px; font-size: 12px; font-weight: 500; }
.status-active, .status-registered, .status-uploaded, .status-draft, .status-pending { background: #e6f7ff; color: #1890ff; }
.status-expired, .status-revoked, .status-cancelled, .status-error { background: #fff1f0; color: var(--danger); }
.status-confirmed, .status-printing, .status-ready, .status-completed { background: #f6ffed; color: var(--success); }
.status-shipped, .status-quality_check, .status-submitted { background: #fffbe6; color: var(--warning); }

/* ===== Pagination ===== */
.pagination { display: flex; align-items: center; justify-content: center; gap: 4px; margin-top: 20px; }
.pagination .page-info { margin: 0 12px; color: var(--text-secondary); font-size: 13px; }
.pagination .page-btn { min-width: 32px; height: 32px; padding: 0 8px; border: 1px solid var(--border); background: #fff; border-radius: var(--radius); cursor: pointer; transition: all .2s; display: flex; align-items: center; justify-content: center; font-size: 13px; }
.pagination .page-btn:hover:not(:disabled) { border-color: var(--primary); color: var(--primary); }
.pagination .page-btn.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.pagination .page-btn:disabled { opacity: .4; cursor: not-allowed; }

/* ===== Modal ===== */
.modal { position: fixed; top: 0; left: 0; width: 100%; height: 100%; z-index: 1000; display: flex; align-items: center; justify-content: center; }
.modal-overlay { position: absolute; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.45); }
.modal-content { position: relative; background: #fff; border-radius: 8px; box-shadow: var(--shadow-lg); width: 600px; max-width: 90vw; max-height: 85vh; display: flex; flex-direction: column; z-index: 1; }
.modal-content.modal-small { width: 400px; }
.modal-header { display: flex; align-items: center; justify-content: space-between; padding: 16px 24px; border-bottom: 1px solid var(--border); }
.modal-header h3 { font-size: 16px; font-weight: 500; }
.modal-body { padding: 24px; overflow-y: auto; flex: 1; }
.modal-footer { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 24px; border-top: 1px solid var(--border); }

/* ===== Form ===== */
.record-form { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.record-form .full-width { grid-column: 1 / -1; }
.form-group { display: flex; flex-direction: column; }
.form-group label { margin-bottom: 6px; font-weight: 500; color: var(--text-secondary); font-size: 13px; }
.form-group label .required { color: var(--danger); margin-left: 2px; }
.form-group input, .form-group select, .form-group textarea { padding: 8px 12px; border: 1px solid var(--border); border-radius: var(--radius); transition: border-color .2s; width: 100%; }
.form-group input:focus, .form-group select:focus, .form-group textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 2px rgba(24,144,255,.15); }
.form-group textarea { min-height: 80px; resize: vertical; }
.form-group .hint { font-size: 12px; color: var(--text-light); margin-top: 4px; }
.form-group.checkbox-group { flex-direction: row; align-items: center; gap: 8px; }
.form-group.checkbox-group input { width: auto; }

/* ===== Toast ===== */
.toast { position: fixed; top: 20px; left: 50%; transform: translateX(-50%); padding: 12px 24px; border-radius: var(--radius); color: #fff; font-size: 14px; z-index: 2000; box-shadow: var(--shadow-lg); animation: toast-in .3s ease; min-width: 200px; text-align: center; }
.toast.success { background: var(--success); }
.toast.error { background: var(--danger); }
.toast.info { background: var(--primary); }
@keyframes toast-in { from { opacity: 0; transform: translateX(-50%) translateY(-20px); } to { opacity: 1; transform: translateX(-50%) translateY(0); } }

/* ===== Loading & Empty State ===== */
.loading { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 60px; color: var(--text-light); }
.spinner { width: 32px; height: 32px; border: 3px solid var(--border); border-top-color: var(--primary); border-radius: 50%; animation: spin .8s linear infinite; margin-bottom: 12px; }
@keyframes spin { to { transform: rotate(360deg); } }
.empty-state { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 60px; color: var(--text-light); }
.empty-state p { font-size: 16px; }
.empty-state .empty-icon { font-size: 48px; margin-bottom: 12px; }

/* ===== Log Level Badges ===== */
.log-level {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}
.log-info { background: #e3f2fd; color: #1565c0; }
.log-debug { background: #e8f5e9; color: #2e7d32; }
.log-warn { background: #fff3e0; color: #e65100; }
.log-error { background: #ffebee; color: #c62828; }

/* ===== Responsive ===== */
@media (max-width: 768px) {
  .sidebar { width: 200px; }
  .main-content { margin-left: 200px; }
  .search-box input { width: 140px; }
  .search-box input:focus { width: 180px; }
  .record-form { grid-template-columns: 1fr; }
  .header-right .btn span { display: none; }
}
