:root {
  --bg: #f0f2f5;
  --surface: #fff;
  --text: #333;
  --text-secondary: #666;
  --border: #e0e0e0;
  --primary: #1a73e8;
  --primary-hover: #1557b0;
  --sidebar-bg: #1a2332;
  --sidebar-text: #b0bec5;
  --sidebar-active: #4fc3f7;
  --header-bg: #0d1b2e;
  --success: #137333;
  --warning: #e37400;
  --danger: #c5221f;
}
* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: "Microsoft YaHei", "PingFang SC", sans-serif;
  background: var(--bg); color: var(--text); height: 100vh; overflow: hidden;
}

/* ═══ App Shell ═══ */
.app-shell { display: flex; flex-direction: column; height: 100vh; }

/* ═══ Header ═══ */
.app-header {
  display: flex; align-items: center; gap: 20px;
  padding: 0 20px; height: 52px; background: var(--header-bg);
  color: #fff; flex-shrink: 0;
}
.app-logo { font-size: 16px; font-weight: 600; white-space: nowrap; }
.header-center { flex: 1; text-align: center; }
.header-center select {
  padding: 6px 12px; border-radius: 4px; border: 1px solid rgba(255,255,255,.2);
  background: rgba(255,255,255,.1); color: #fff; font-size: 14px; min-width: 240px;
}
.header-center select option {
  background: #1a2332; color: #e0e0e0;
}
.header-right { display: flex; align-items: center; gap: 8px; }
.user-badge { font-size: 13px; color: #8ab4f8; }
.btn-header {
  background: rgba(255,255,255,.1); color: #fff; border: 1px solid rgba(255,255,255,.15);
  padding: 5px 12px; border-radius: 4px; font-size: 13px; cursor: pointer;
  text-decoration: none;
}
.btn-header:hover { background: rgba(255,255,255,.2); }

/* ═══ Body: sidebar + main ═══ */
.app-body { display: flex; flex: 1; min-height: 0; }

/* ═══ Sidebar ═══ */
.sidebar {
  width: 200px; background: var(--sidebar-bg); flex-shrink: 0;
  display: flex; flex-direction: column; padding: 12px 0; overflow-y: auto;
}
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 20px; color: var(--sidebar-text); cursor: pointer;
  font-size: 14px; border: none; background: none; text-align: left;
  transition: background .15s, color .15s;
  border-left: 3px solid transparent;
}
.nav-item:hover { background: rgba(255,255,255,.05); color: #fff; }
.nav-item.active {
  background: rgba(79,195,247,.12); color: var(--sidebar-active);
  border-left-color: var(--sidebar-active);
}
.nav-icon { font-size: 18px; width: 24px; text-align: center; }

/* ═══ Main Content ═══ */
.main-content { flex: 1; overflow-y: auto; padding: 16px 20px; }

/* ═══ Pages ═══ */
.page { display: none; }
.page.active { display: block; }

/* ═══ Stat Cards ═══ */
.stat-cards { display: flex; gap: 12px; margin-bottom: 16px; }
.stat-card {
  flex: 1; background: var(--surface); border-radius: 8px;
  padding: 16px; text-align: center;
  border-top: 3px solid var(--primary);
  box-shadow: 0 1px 3px rgba(0,0,0,.08);
}
.stat-card.card-done { border-top-color: var(--success); }
.stat-card.card-progress { border-top-color: var(--primary); }
.stat-card.card-pending { border-top-color: #78909c; }
.stat-card.card-alerts { border-top-color: var(--danger); }
.stat-card.card-alerts.has-alerts { animation: pulse 2s infinite; }
@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(197,34,31,.3); }
  50% { box-shadow: 0 0 0 8px rgba(197,34,31,0); }
}
.stat-num { font-size: 28px; font-weight: bold; }
.stat-label { font-size: 12px; color: var(--text-secondary); margin-top: 4px; }

/* ═══ Dashboard Grid ═══ */
.dash-grid { display: flex; gap: 14px; min-height: 0; }
.dash-panel { background: var(--surface); border-radius: 8px; padding: 14px; box-shadow: 0 1px 3px rgba(0,0,0,.08); }
.dash-panel h3 { font-size: 14px; color: var(--primary); margin-bottom: 10px; border-bottom: 1px solid var(--border); padding-bottom: 8px; }
.dash-chart { flex: 1.2; }
.chart-wrap { height: 280px; }
.dash-alerts { flex: 0.8; overflow-y: auto; max-height: 340px; }
.dash-feed { flex: 0.8; overflow-y: auto; max-height: 340px; }
.dash-side { display: contents; }
#dash-statusbar { display: none; }
.dash-alerts ul, .dash-feed ul { list-style: none; font-size: 13px; }
.dash-alerts li, .dash-feed li { padding: 5px 0; border-bottom: 1px solid #f0f0f0; }
.alert-warning { color: var(--warning); }
.alert-danger { color: var(--danger); }
.empty { color: #999; text-align: center; padding: 20px; }
.feed-time { color: #999; margin-right: 8px; font-size: 12px; }
.feed-op { color: var(--success); margin-right: 6px; }
.feed-desc { margin-right: 6px; }
.feed-loc { color: #999; font-size: 12px; }

/* ═══ Toolbar ═══ */
.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 14px; }
.toolbar input[type="text"], .toolbar select {
  padding: 7px 12px; border: 1px solid #d0d5dd; border-radius: 6px; font-size: 14px;
}
.toolbar input[type="text"] { width: 200px; }

/* ═══ Buttons ═══ */
.btn {
  padding: 7px 14px; border: 1px solid transparent; border-radius: 6px;
  font-size: 13px; cursor: pointer; text-decoration: none; display: inline-block;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-outline { background: #fff; color: #333; border-color: #d0d5dd; }
.btn-outline:hover { background: #f5f7fa; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #a50e0e; }
.btn-sm { padding: 3px 8px; font-size: 12px; }

/* ═══ Table ═══ */
.table-wrap { background: #fff; border-radius: 8px; border: 1px solid var(--border); overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
thead { background: #f7f8fa; }
th, td { padding: 9px 12px; text-align: left; white-space: nowrap; }
th { font-weight: 600; color: #555; border-bottom: 1px solid var(--border); }
td { border-bottom: 1px solid #f0f0f0; }
tr:hover td { background: #f0f6ff; }
td.code { font-family: monospace; font-weight: 600; color: var(--primary); }
td.actions { display: flex; gap: 5px; }
.badge {
  font-size: 12px; padding: 2px 8px; border-radius: 10px; white-space: nowrap;
}
.badge-done { background: #e6f4ea; color: var(--success); }
.badge-progress { background: #e8f0fe; color: var(--primary); }
.badge-pending { background: #fef7e0; color: var(--warning); }

/* ═══ Pagination ═══ */
.pagination { display: flex; gap: 6px; justify-content: center; margin-top: 14px; font-size: 13px; }
.pagination button {
  padding: 5px 10px; border: 1px solid #d0d5dd; border-radius: 4px;
  background: #fff; cursor: pointer;
}
.pagination button.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.pagination button:disabled { opacity: .4; cursor: default; }
.pagination span { padding: 5px 4px; color: #888; }

/* ═══ QR Grid ═══ */
.qr-grid { display: flex; flex-wrap: wrap; gap: 12px; max-height: 65vh; overflow-y: auto; }
.qr-card {
  background: #fff; border: 1px solid var(--border); border-radius: 8px;
  padding: 12px; text-align: center; width: 150px; cursor: pointer;
}
.qr-card:hover { border-color: var(--primary); }
.qr-card img { width: 110px; height: 110px; }
.qr-card .qr-label { font-size: 11px; font-family: monospace; margin-top: 4px; word-break: break-all; }
.qr-preview { text-align: center; }
.qr-preview img { width: 200px; height: 200px; }

/* ═══ Import ═══ */
.panel { background: #fff; border-radius: 8px; border: 1px solid var(--border); padding: 24px; max-width: 600px; }
.panel h3 { margin-bottom: 8px; }
.panel .desc { color: #888; font-size: 13px; margin-bottom: 16px; }
.import-row { display: flex; gap: 12px; align-items: center; }
#import-result { margin-top: 14px; padding: 10px; border-radius: 6px; }
#import-result.success { background: #e6f4ea; color: var(--success); }
#import-result.error { background: #fce8e6; color: var(--danger); }

/* ═══ Modal ═══ */
.modal-overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,.45); z-index: 1000;
  justify-content: center; align-items: center;
}
.modal-overlay.show { display: flex; }
.modal {
  background: #fff; border-radius: 10px; padding: 24px;
  min-width: 520px; max-width: 640px; max-height: 85vh; overflow-y: auto;
}
.modal-sm { min-width: 360px; max-width: 420px; }
.modal h3 { margin-bottom: 14px; font-size: 17px; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 18px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.form-grid label { display: flex; flex-direction: column; gap: 3px; font-size: 13px; color: #555; }
.form-grid input {
  padding: 7px 10px; border: 1px solid #d0d5dd; border-radius: 4px; font-size: 14px;
}
.form-group { margin-bottom: 12px; }
.form-group label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: #555; }
.form-group input, .form-group select {
  padding: 8px 10px; border: 1px solid #d0d5dd; border-radius: 4px; font-size: 14px;
}

/* ════════════════════════════════════════════════
   FULLSCREEN BIG-SCREEN MODE (投屏大屏)
   ════════════════════════════════════════════════ */
body.fullscreen-mode {
  background: #0a1628; color: #e0e0e0;
}
body.fullscreen-mode .app-header { display: none; }
body.fullscreen-mode .sidebar { display: none; }
body.fullscreen-mode .main-content {
  padding: 12px 20px 6px;
  background: #0a1628;
  display: flex; flex-direction: column;
}

/* Hide non-dashboard pages */
body.fullscreen-mode .page:not(#page-dashboard) { display: none !important; }
body.fullscreen-mode #page-dashboard { display: flex; flex-direction: column; flex: 1; min-height: 0; }

/* Stat cards: compact dark row */
body.fullscreen-mode .stat-cards { gap: 10px; margin-bottom: 10px; flex-shrink: 0; }
body.fullscreen-mode .stat-card {
  background: #0f1f3d;
  border-radius: 8px;
  border-top: none;
  border-left: 4px solid #4fc3f7;
  padding: 10px 8px;
  box-shadow: none;
}
body.fullscreen-mode .stat-card.card-done { border-left-color: #66bb6a; }
body.fullscreen-mode .stat-card.card-progress { border-left-color: #ffa726; }
body.fullscreen-mode .stat-card.card-pending { border-left-color: #78909c; }
body.fullscreen-mode .stat-card.card-alerts { border-left-color: #ef5350; }
body.fullscreen-mode .stat-card.card-alerts.has-alerts {
  animation: pulse-dark 2s infinite;
}
@keyframes pulse-dark {
  0%, 100% { box-shadow: 0 0 0 0 rgba(239,83,80,.5); }
  50% { box-shadow: 0 0 0 10px rgba(239,83,80,0); }
}
body.fullscreen-mode .stat-num { font-size: 32px; font-weight: 700; color: #fff; }
body.fullscreen-mode .stat-label { font-size: 12px; color: #90a4ae; margin-top: 2px; }

/* Dashboard grid: chart (60%) + side panel (40%) */
body.fullscreen-mode .dash-grid {
  flex: 1; min-height: 0; gap: 12px; display: flex;
}
body.fullscreen-mode .dash-panel {
  background: #0f1f3d;
  border-radius: 8px;
  box-shadow: none;
  padding: 12px;
}
body.fullscreen-mode .dash-panel h3 {
  color: #4fc3f7;
  border-bottom-color: rgba(255,255,255,.1);
  font-size: 15px;
  margin-bottom: 8px;
  padding-bottom: 6px;
}
body.fullscreen-mode .dash-chart { flex: 1.5; min-height: 0; position: relative; display: flex; flex-direction: column; }
body.fullscreen-mode .chart-wrap { flex: 1; position: relative; overflow: hidden; }

/* Side panel: alerts + feed stacked */
body.fullscreen-mode .dash-side {
  flex: 1; min-height: 0; display: flex; flex-direction: column; gap: 10px;
}
body.fullscreen-mode .dash-alerts { flex: 1; min-height: 0; overflow-y: auto; }
body.fullscreen-mode .dash-feed { flex: 1; min-height: 0; overflow-y: auto; }

/* Status bar */
body.fullscreen-mode #dash-statusbar {
  display: flex; justify-content: space-between; align-items: center;
  height: 28px; margin-top: 6px; flex-shrink: 0;
  font-size: 13px; color: #78909c;
}
body.fullscreen-mode #dash-statusbar .status-project { color: #4fc3f7; font-weight: 500; }
body.fullscreen-mode #dash-statusbar .status-time { color: #546e7a; }

/* Lists in dark */
body.fullscreen-mode .dash-alerts li,
body.fullscreen-mode .dash-feed li {
  padding: 6px 0; border-bottom-color: rgba(255,255,255,.05); font-size: 14px;
}
body.fullscreen-mode .alert-warning { color: #ffa726; }
body.fullscreen-mode .alert-danger { color: #ef5350; }
body.fullscreen-mode .empty { color: #546e7a; }
body.fullscreen-mode .feed-time { color: #78909c; }
body.fullscreen-mode .feed-op { color: #66bb6a; }
body.fullscreen-mode .feed-desc { color: #4fc3f7; }
body.fullscreen-mode .feed-loc { color: #78909c; }
