* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: -apple-system, 'PingFang SC', 'Helvetica Neue', sans-serif; background: #f0f2f5; color: #1a1a2e; }

/* ══════════════════════════════════════════════════════
   Layout — Desktop first, then responsive overrides
   ══════════════════════════════════════════════════════ */
#app { display: flex; min-height: 100vh; }

/* ── Sidebar ──────────────────────────────────────────── */
.sidebar {
  width: 220px; min-height: 100vh; background: #1a1a2e;
  color: #c8d0e0; display: flex; flex-direction: column;
  position: fixed; left: 0; top: 0; bottom: 0; z-index: 200;
  transition: transform .28s cubic-bezier(.4,0,.2,1);
}
.logo {
  padding: 24px 20px 20px; font-size: 16px; font-weight: 700;
  color: #fff; border-bottom: 1px solid #2a2a42;
  display: flex; align-items: center; gap: 10px;
}
.logo-icon { font-size: 22px; }
nav { padding: 12px 0; flex: 1; overflow-y: auto; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 11px 20px; color: #8a94a8; text-decoration: none;
  font-size: 14px; transition: all .2s; cursor: pointer;
}
.nav-item:hover  { background: #252540; color: #e0e8ff; }
.nav-item.active { background: #3b4cca; color: #fff; }
.nav-item .icon  { font-size: 16px; flex-shrink: 0; }

/* ── Sidebar overlay (mobile) ─────────────────────────── */
.sidebar-overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,.45); z-index: 190;
}
.sidebar-overlay.visible { display: block; }

/* ── Main area ────────────────────────────────────────── */
.main { margin-left: 220px; flex: 1; display: flex; flex-direction: column; min-width: 0; }

/* ── Topbar ───────────────────────────────────────────── */
.topbar {
  background: #fff; padding: 12px 24px; display: flex;
  align-items: center; justify-content: space-between; gap: 12px;
  box-shadow: 0 1px 6px rgba(0,0,0,.08); position: sticky; top: 0; z-index: 100;
}
/* Hamburger — hidden on desktop */
.menu-toggle {
  display: none; background: none; border: none; cursor: pointer;
  padding: 4px 6px; color: #1a1a2e; font-size: 22px; line-height: 1;
  flex-shrink: 0;
}
.search-bar { display: flex; gap: 8px; flex: 1; max-width: 420px; }
.search-bar input {
  flex: 1; min-width: 0; padding: 8px 14px; border: 1px solid #dde3f0;
  border-radius: 8px; font-size: 14px; outline: none; transition: border .2s;
}
.search-bar input:focus { border-color: #3b4cca; }
.search-bar button {
  padding: 8px 14px; background: #3b4cca; color: #fff;
  border: none; border-radius: 8px; cursor: pointer; font-size: 14px;
  white-space: nowrap;
}
.search-bar button:hover { background: #2d3ba0; }
.topbar-right { font-size: 13px; color: #888; white-space: nowrap; flex-shrink: 0; }

.content { padding: 24px 28px; flex: 1; }

/* ── Cards ────────────────────────────────────────────── */
.card {
  background: #fff; border-radius: 12px; padding: 20px 24px;
  box-shadow: 0 1px 8px rgba(0,0,0,.06); margin-bottom: 20px;
}
.card h2 { font-size: 16px; font-weight: 600; margin-bottom: 16px; color: #1a1a2e; }
.card h3 { font-size: 14px; font-weight: 600; margin-bottom: 12px; color: #444; }

/* ── Summary Stats ────────────────────────────────────── */
.stats-grid {
  display: grid; grid-template-columns: repeat(4, 1fr);
  gap: 16px; margin-bottom: 20px;
}
.stat-card {
  background: #fff; border-radius: 12px; padding: 20px 22px;
  box-shadow: 0 1px 8px rgba(0,0,0,.06);
  display: flex; flex-direction: column; gap: 8px;
}
.stat-card .stat-num   { font-size: 30px; font-weight: 700; color: #3b4cca; }
.stat-card .stat-label { font-size: 13px; color: #888; }
.stat-card.warning .stat-num { color: #e8520a; }
.stat-card.success .stat-num { color: #0aa854; }

/* ── Tables ───────────────────────────────────────────── */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { background: #f7f8fc; padding: 10px 14px; text-align: left; font-weight: 600; color: #555; border-bottom: 2px solid #e8ebf5; white-space: nowrap; }
td { padding: 10px 14px; border-bottom: 1px solid #f0f2f5; color: #333; vertical-align: top; }
tr:hover td { background: #fafbff; }
.tag {
  display: inline-block; padding: 2px 8px; border-radius: 12px;
  font-size: 11px; font-weight: 600; white-space: nowrap;
}
.tag-blue   { background: #e8ecff; color: #3b4cca; }
.tag-green  { background: #e6f9ee; color: #0aa854; }
.tag-red    { background: #fdecea; color: #c0392b; }
.tag-gray   { background: #f0f2f5; color: #888; }
.tag-orange { background: #fef0e6; color: #e8520a; }

/* ── Pagination ───────────────────────────────────────── */
.pagination {
  display: flex; gap: 6px; align-items: center;
  margin-top: 16px; justify-content: flex-end; flex-wrap: wrap;
}
.pagination button {
  padding: 6px 12px; border: 1px solid #dde3f0; background: #fff;
  border-radius: 6px; cursor: pointer; font-size: 13px; min-width: 36px;
}
.pagination button:hover    { border-color: #3b4cca; color: #3b4cca; }
.pagination button:disabled { opacity: 0.4; cursor: not-allowed; }
.pagination button.active   { background: #3b4cca; color: #fff; border-color: #3b4cca; }
.pagination .page-info      { font-size: 13px; color: #888; }

/* ── Loading ──────────────────────────────────────────── */
.loading { text-align: center; padding: 40px; color: #aaa; font-size: 15px; }
.loading::before {
  content: ''; display: inline-block; width: 20px; height: 20px;
  border: 2px solid #dde3f0; border-top-color: #3b4cca;
  border-radius: 50%; animation: spin .7s linear infinite;
  margin-right: 10px; vertical-align: middle;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Error ────────────────────────────────────────────── */
.error-msg { color: #c0392b; background: #fdecea; padding: 12px 16px; border-radius: 8px; font-size: 13px; }

/* ── Page header ──────────────────────────────────────── */
.page-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 20px; flex-wrap: wrap; gap: 10px;
}
.page-header h1 { font-size: 22px; font-weight: 700; }
.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.toolbar input, .toolbar select {
  padding: 8px 12px; border: 1px solid #dde3f0; border-radius: 8px;
  font-size: 13px; outline: none;
}
.toolbar input:focus, .toolbar select:focus { border-color: #3b4cca; }

.btn {
  padding: 8px 16px; border: none; border-radius: 8px;
  cursor: pointer; font-size: 13px; font-weight: 600; white-space: nowrap;
}
.btn-primary { background: #3b4cca; color: #fff; }
.btn-primary:hover { background: #2d3ba0; }
.btn-outline { background: #fff; color: #3b4cca; border: 1px solid #3b4cca; }
.btn-outline:hover { background: #e8ecff; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ── Modal ────────────────────────────────────────────── */
.modal {
  position: fixed; inset: 0; background: rgba(0,0,0,.5);
  z-index: 300; display: flex; align-items: center; justify-content: center;
  padding: 16px;
}
.modal.hidden { display: none; }
.modal-box {
  background: #fff; border-radius: 14px;
  width: 680px; max-width: 100%; max-height: 88vh; overflow-y: auto;
  box-shadow: 0 8px 40px rgba(0,0,0,.2);
}
.modal-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 18px 24px; border-bottom: 1px solid #f0f2f5;
  position: sticky; top: 0; background: #fff; z-index: 1;
}
.modal-header h3 { font-size: 16px; font-weight: 600; }
.modal-header button { background: none; border: none; font-size: 18px; cursor: pointer; color: #888; }
#search-results { padding: 16px 24px; }
.search-result-item { padding: 12px 0; border-bottom: 1px solid #f0f2f5; }
.search-result-item:last-child { border-bottom: none; }
.search-result-item .result-type { font-size: 11px; font-weight: 600; color: #3b4cca; text-transform: uppercase; margin-bottom: 4px; }
.search-result-item .result-name { font-size: 14px; font-weight: 600; margin-bottom: 4px; }
.search-result-item .result-meta { font-size: 12px; color: #888; }

/* ── Two-column grid ──────────────────────────────────── */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }

/* ── Schedule list ────────────────────────────────────── */
.schedule-item { display: flex; gap: 16px; padding: 10px 0; border-bottom: 1px solid #f0f2f5; }
.schedule-item:last-child { border-bottom: none; }
.schedule-time { min-width: 90px; font-size: 12px; color: #3b4cca; font-weight: 600; }
.schedule-body .subject  { font-size: 14px; font-weight: 500; }
.schedule-body .location { font-size: 12px; color: #888; margin-top: 2px; }

/* ── Empty state ──────────────────────────────────────── */
.empty { text-align: center; padding: 40px; color: #bbb; font-size: 14px; }

/* ── AI Summary Cards ─────────────────────────────────── */
.ai-section-title {
  font-size: 14px; font-weight: 700; color: #3b4cca;
  margin: 14px 0 4px; padding-left: 8px; border-left: 3px solid #3b4cca;
}
.ai-content        { font-size: 13px; color: #444; line-height: 1.8; margin: 0 0 8px; padding-left: 11px; }
.ai-summary-body   { font-size: 13px; color: #444; line-height: 1.8; }
.ai-summary-body p { margin: 4px 0; }

/* ── Sidebar user area ────────────────────────────────── */
.sidebar-user { padding: 14px 16px 18px; border-top: 1px solid #2a2a42; margin-top: auto; }
.user-info    { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.user-avatar  { font-size: 18px; }
.user-name    { font-size: 13px; font-weight: 600; color: #d0d8f0; }
.user-actions { display: flex; gap: 14px; }
.user-action-link {
  font-size: 12px; color: #7a88a8; text-decoration: none; cursor: pointer; transition: color .2s;
}
.user-action-link:hover         { color: #d0d8f0; }
.user-action-link.logout:hover  { color: #ff7373; }


/* ══════════════════════════════════════════════════════
   iPad  (≤ 1024px)
   ══════════════════════════════════════════════════════ */
@media (max-width: 1024px) {
  .sidebar { width: 200px; }
  .main    { margin-left: 200px; }

  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .grid-2     { grid-template-columns: 1fr; }

  .content { padding: 18px 20px; }
  .topbar  { padding: 11px 18px; }

  .search-bar input { width: auto; }
}


/* ══════════════════════════════════════════════════════
   Mobile  (≤ 768px)  — sidebar drawer pattern
   ══════════════════════════════════════════════════════ */
@media (max-width: 768px) {
  /* Sidebar slides in from left as a drawer */
  .sidebar {
    width: 240px;
    transform: translateX(-100%);
    box-shadow: 4px 0 24px rgba(0,0,0,.25);
  }
  .sidebar.open { transform: translateX(0); }

  /* Content takes full width */
  .main { margin-left: 0; }

  /* Show hamburger */
  .menu-toggle { display: block; }

  /* Topbar tighter */
  .topbar { padding: 10px 14px; gap: 10px; }
  .topbar-right { display: none; } /* 手机上隐藏日期避免挤占 */

  .search-bar       { flex: 1; max-width: none; }
  .search-bar input { font-size: 14px; }

  /* Content padding tighter */
  .content { padding: 14px 12px; }

  /* Cards */
  .card { padding: 16px 14px; border-radius: 10px; }

  /* Stats: 2 columns on phone */
  .stats-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .stat-card  { padding: 14px 16px; }
  .stat-card .stat-num { font-size: 24px; }

  /* Page header: stack title and toolbar */
  .page-header { flex-direction: column; align-items: flex-start; gap: 8px; margin-bottom: 14px; }
  .page-header h1 { font-size: 18px; }

  /* Filter bars: wrap nicely */
  .card > div[style*="display:flex"] { flex-wrap: wrap !important; }

  /* Tables: horizontal scroll + compact cells */
  .table-wrap { border-radius: 8px; }
  td, th { padding: 8px 10px; }
  table  { font-size: 12px; }

  /* Buttons: slightly larger tap targets */
  .btn { padding: 9px 14px; }

  /* Modal: full-screen on mobile */
  .modal { padding: 0; align-items: flex-end; }
  .modal-box {
    width: 100%; max-width: 100%; border-radius: 16px 16px 0 0;
    max-height: 92vh;
  }

  /* Pagination: smaller buttons, wrap allowed */
  .pagination { justify-content: center; gap: 4px; }
  .pagination button { padding: 6px 9px; font-size: 12px; min-width: 32px; }

  /* Toolbar wraps */
  .toolbar { gap: 8px; }
}


/* ══════════════════════════════════════════════════════
   Small phone  (≤ 480px)
   ══════════════════════════════════════════════════════ */
@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr 1fr; gap: 8px; }
  .stat-card .stat-num   { font-size: 22px; }
  .stat-card .stat-label { font-size: 11px; }

  .content { padding: 12px 10px; }
  .card    { padding: 14px 12px; margin-bottom: 12px; }

  .search-bar button { padding: 8px 10px; font-size: 13px; }

  /* On very small screens, hide search button text */
  .search-bar button::after { content: '🔍'; }
  /* Keep button compact */

  .page-header h1 { font-size: 16px; }
}

/* ── Skeleton loading ─────────────────────────────────── */
@keyframes skel-shimmer {
  0%   { background-position: -400px 0; }
  100% { background-position: 400px 0; }
}
.skel-line {
  height: 14px; border-radius: 6px;
  background: linear-gradient(90deg, #f0f2f5 25%, #e2e8f0 50%, #f0f2f5 75%);
  background-size: 800px 100%;
  animation: skel-shimmer 1.4s infinite linear;
  width: 80%;
}
tr .skel-line { display: block; }

/* ── Search sections ──────────────────────────────────── */
.search-section { margin-bottom: 16px; }
.search-sec-hd  {
  font-size: 11px; font-weight: 700; color: #3b4cca;
  text-transform: uppercase; letter-spacing: .5px;
  padding: 6px 0 4px; border-bottom: 2px solid #e8ecff; margin-bottom: 4px;
}
.btn-sm { padding: 5px 12px; font-size: 12px; }
