:root {
  --bg: #f0f2f5;
  --card: #ffffff;
  --primary: #2c5f8a;
  --primary-hover: #1e4a70;
  --primary-light: #e3eff8;
  --accent: #27ae60;
  --success: #27ae60;
  --danger: #e74c3c;
  --danger-light: #fdedec;
  --warn: #e67e22;
  --text: #2c3e50;
  --text-muted: #7f8c8d;
  --border: #dde3ec;
  --shadow: 0 2px 12px rgba(44,95,138,0.10);
  --shadow-header: 0 2px 8px rgba(44,95,138,0.3);
  --shadow-elevated: 0 8px 30px rgba(44,95,138,0.12);
  --radius: 12px;
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --spacing-xs: 4px;
  --spacing-sm: 8px;
  --spacing-md: 16px;
  --spacing-lg: 24px;
  --spacing-xl: 32px;
}


  * { box-sizing: border-box; margin: 0; padding: 0; }
  body {
    font-family: 'PingFang SC', 'Helvetica Neue', Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
  }

  /* Header */
  header {
    background: var(--primary);
    color: #fff;
    padding: 0 32px;
    height: 60px;
    display: flex;
    align-items: center;
    gap: 16px;
    box-shadow: 0 2px 8px rgba(44,95,138,0.3);
  }
  header .logo { font-size: 22px; }
  header h1 { font-size: 18px; font-weight: 600; flex: 1; }
  header a {
    color: rgba(255,255,255,0.85);
    text-decoration: none;
    font-size: 13px;
    padding: 6px 14px;
    border-radius: 16px;
    border: 1px solid rgba(255,255,255,0.4);
    transition: background .15s;
  }
  header a:hover { background: rgba(255,255,255,0.15); }
  .header-actions { display: flex; align-items: center; gap: 10px; margin-left: auto; }
  .header-actions a { color: rgba(255,255,255,0.85); text-decoration: none; font-size: 13px; padding: 6px 14px; border-radius: 16px; border: 1px solid rgba(255,255,255,0.4); transition: background .15s; white-space: nowrap; }
  .header-actions a:hover { background: rgba(255,255,255,0.15); }
  /* 账户下拉：把「修改密码 / 退出登录」聚合为一个入口 */
  .account-menu { position: relative; }
  .account-btn {
    color: rgba(255,255,255,0.85); background: transparent; cursor: pointer;
    font-size: 13px; padding: 6px 14px; border-radius: 16px;
    border: 1px solid rgba(255,255,255,0.4); transition: background .15s; white-space: nowrap;
    font-family: inherit;
  }
  .account-btn:hover { background: rgba(255,255,255,0.15); }
  .account-dropdown {
    display: none; position: absolute; right: 0; top: calc(100% + 8px); z-index: 9999;
    min-width: 132px; padding: 6px; border-radius: 10px;
    background: #fff; box-shadow: 0 8px 24px rgba(0,0,0,0.18); border: 1px solid #e3e8ef;
  }
  .account-dropdown a {
    display: block; color: #2c3e50 !important; text-decoration: none; font-size: 13px;
    padding: 9px 12px; border-radius: 7px; border: none !important; white-space: nowrap;
  }
  .account-dropdown a:hover { background: #f1f5fb; }

  .main { max-width: 960px; margin: 0 auto; padding: 32px 24px; }

  /* Section card */
  .section {
    background: var(--card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin-bottom: 24px;
    overflow: hidden;
  }
  .section-header {
    padding: 18px 24px 14px;
    border-bottom: 1px solid var(--border);
    display: flex; align-items: center; gap: 10px;
  }
  .section-header h2 { font-size: 15px; font-weight: 600; flex: 1; }
  .io-header-actions { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
  .section-header .btn-sm { flex-shrink: 0; white-space: nowrap; }
  .section-body { padding: 24px; }

  /* 导入 / 导出 */
  .io-export-row {
    display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 4px 0;
  }
  .io-export-row label { font-size: 13px; color: var(--text-muted); }
  .io-export-row input[type="date"] {
    padding: 6px 10px; border: 1px solid var(--border); border-radius: 6px;
    font-size: 13px; cursor: pointer;
  }

  .import-preview-panel { margin-top: 16px; }
  .import-preview-toolbar {
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
    flex-wrap: wrap; margin-bottom: 10px;
  }
  .import-preview-summary { font-size: 13px; color: var(--text-muted); }
  .import-preview-table-wrap {
    max-height: 360px; overflow: auto; border: 1px solid var(--border); border-radius: 8px;
  }
  .import-preview-table {
    width: 100%; border-collapse: collapse; font-size: 13px;
  }
  .import-preview-table th {
    position: sticky; top: 0; background: var(--bg); z-index: 1;
    text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--border);
    font-weight: 600; font-size: 12px; color: var(--text-muted);
  }
  .import-preview-table td { padding: 8px 10px; border-bottom: 1px solid var(--border); vertical-align: top; }
  .import-preview-table tr.import-row-invalid { background: #fff5f5; }
  .import-preview-table tr.import-row-invalid td { border-bottom-color: #fecaca; }
  .import-preview-table input[type="text"] {
    width: 100%; box-sizing: border-box; padding: 5px 8px; font-size: 12px;
    border: 1px solid var(--border); border-radius: 4px; background: var(--card);
  }
  .import-preview-table tr.import-row-invalid input[type="text"] { border-color: #f87171; }
  .import-status-ok { color: var(--accent); font-weight: 600; white-space: nowrap; }
  .import-status-bad { color: var(--danger); font-weight: 600; white-space: nowrap; }
  .import-error-hint { display: block; font-size: 11px; color: var(--danger); margin-top: 4px; }
  .btn-danger-ghost {
    background: transparent; color: var(--danger); border: 1px solid #fecaca;
    padding: 4px 10px; border-radius: 6px; font-size: 12px; cursor: pointer;
  }
  .btn-danger-ghost:hover { background: #fff5f5; }

  /* Drop zone (legacy, unused) */
  .drop-zone {
    border: 2.5px dashed var(--border);
    border-radius: var(--radius);
    padding: 48px 24px;
    text-align: center;
    cursor: pointer;
    transition: border-color .2s, background .2s;
    background: var(--bg);
    position: relative;
  }
  .drop-zone:hover, .drop-zone.dragover {
    border-color: var(--primary);
    background: var(--primary-light);
  }
  .drop-zone input[type=file] {
    position: absolute; inset: 0; opacity: 0; cursor: pointer;
  }
  .drop-zone .dz-icon { font-size: 44px; margin-bottom: 14px; }
  .drop-zone .dz-text { font-size: 16px; font-weight: 600; color: var(--text); margin-bottom: 6px; }
  .drop-zone .dz-sub { font-size: 13px; color: var(--text-muted); }

  /* Upload progress */
  .upload-progress { margin-top: 12px; display: none; }
  .progress-bar-wrap {
    background: var(--border); border-radius: 8px; height: 10px; overflow: hidden; margin-bottom: 8px;
  }
  .progress-bar {
    height: 100%; background: var(--primary);
    border-radius: 8px;
    transition: width .3s;
    width: 0%;
  }
  .progress-label { font-size: 13px; color: var(--text-muted); text-align: center; }

  /* Result alert */
  .alert {
    padding: 14px 18px;
    border-radius: 10px;
    margin-top: 16px;
    font-size: 14px;
    display: none;
  }
  .alert.success { background: #eafaf1; color: #1a7a4a; border: 1px solid #a9dfbf; }
  .alert.error   { background: #fdedec; color: #922b21; border: 1px solid #f1948a; }

  /* Import history table */
  table {
    width: 100%; border-collapse: collapse;
  }
  thead th {
    background: #f7f9fc;
    font-size: 12px; font-weight: 600; color: var(--text-muted);
    padding: 10px 14px;
    text-align: left;
    border-bottom: 1px solid var(--border);
  }
  tbody tr { border-bottom: 1px solid var(--border); }
  tbody tr:last-child { border-bottom: none; }
  tbody td {
    padding: 10px 14px;
    font-size: 13px;
    vertical-align: middle;
  }
  .badge {
    display: inline-flex; align-items: center;
    padding: 2px 10px; border-radius: 12px;
    font-size: 11px; font-weight: 600;
  }
  .badge-ok  { background: #eafaf1; color: #1a7a4a; }
  .badge-err { background: #fdedec; color: #922b21; }

  /* Btn */
  .btn {
    padding: 10px 22px; border-radius: 22px; border: none;
    font-size: 14px; font-weight: 600; cursor: pointer;
    display: inline-flex; align-items: center; gap: 6px;
    transition: background .15s, transform .1s;
  }
  .btn:active { transform: scale(0.97); }
  .btn-primary { background: var(--primary); color: #fff; }
  .btn-primary:hover { background: #1e4a70; }
  .btn-danger { background: var(--danger); color: #fff; }
  .btn-danger:hover { background: #c0392b; }
  .btn-sm { padding: 6px 14px; font-size: 12px; }

  /* Danger zone */
  .danger-zone {
    border: 1.5px solid #f5b7b1;
    border-radius: var(--radius);
    padding: 18px 20px;
    display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap;
  }
  .danger-zone p { font-size: 13px; color: var(--text-muted); max-width: 520px; }
  .danger-zone strong { color: var(--danger); }

  .empty-hint { text-align: center; color: var(--text-muted); padding: 28px; font-size: 14px; }

  /* Records table */
  .records-table { width: 100%; border-collapse: collapse; }
  .records-table th {
    background: #f7f9fc; font-size: 12px; font-weight: 600; color: var(--text-muted);
    padding: 10px 14px; text-align: left; border-bottom: 1px solid var(--border);
    position: sticky; top: 0;
  }
  .records-table td { padding: 8px 14px; font-size: 13px; vertical-align: middle; border-bottom: 1px solid var(--border); }
  .records-table tbody tr:nth-child(even) td { background: #f7f9fc; }
  .records-table tbody tr:nth-child(odd) td { background: #ffffff; }
  .records-table tbody tr:hover td { background: #eef3f8; }
  .records-table .col-id { width: 60px; color: var(--text-muted); }
  .records-table .col-time { width: 160px; font-family: "Courier New", monospace; font-size: 14px; white-space: nowrap; text-align: left; }
  .records-table .col-time .time-year { display: inline; text-align: left; }
  .records-table .col-content { }
  .records-table .col-actions { width: 120px; text-align: center; }
  #trash-container .trash-actions {
    width: auto;
    min-width: 130px;
    white-space: nowrap;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    flex-wrap: nowrap;
  }
  #trash-container .trash-actions .btn-sm {
    padding: 4px 10px;
    font-size: 11px;
    flex-shrink: 0;
  }
  .edit-inline { display: none; }
  .edit-inline input, .edit-inline textarea {
    width: 100%; padding: 6px 8px; border: 1px solid var(--border); border-radius: 6px;
    font-size: 13px; font-family: inherit; box-sizing: border-box;
  }
  .edit-inline textarea { min-height: 40px; resize: vertical; }
  .edit-actions { display: flex; gap: 6px; margin-top: 4px; }
  .edit-actions button {
    padding: 4px 12px; border: none; border-radius: 4px; font-size: 12px; cursor: pointer;
  }
  .edit-actions .save-btn { background: var(--primary); color: #fff; }
  .edit-actions .cancel-btn { background: #eee; color: #666; }
  .view-mode { display: flex; align-items: center; gap: 6px; }
  .search-bar { display: flex; gap: 8px; margin-bottom: 12px; }
  .search-bar input { flex: 1; padding: 8px 14px; border: 1px solid var(--border); border-radius: 8px; font-size: 14px; }
  .search-bar button { padding: 8px 18px; border: none; border-radius: 8px; background: var(--primary); color: #fff; cursor: pointer; font-size: 13px; }
  .pagination { display: flex; justify-content: center; gap: 6px; padding: 16px; }
  .pagination button { padding: 6px 14px; border: 1px solid var(--border); border-radius: 6px; background: #fff; cursor: pointer; font-size: 13px; }
  .pagination button.active { background: var(--primary); color: #fff; border-color: var(--primary); }
  .month-arrow {
    width: 24px; height: 24px; border: none; border-radius: 50%; background: transparent;
    color: var(--primary); font-size: 14px; font-weight: 700; cursor: pointer;
    display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0;
    transition: background .12s;
  }
  .month-arrow:hover { background: var(--primary-light); }
  .date-display {
    font-size: 13px; font-weight: 600; color: var(--text); cursor: pointer;
    padding: 2px 10px; border-radius: 6px; min-width: 86px; text-align: center; user-select: none;
  }
  .date-display:hover { background: var(--primary-light); }
  .date-input-hidden { position: absolute; top: 0; left: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; }
  .btn-month-reset { background: none; border: none; cursor: pointer; font-size: 12px; color: var(--primary); padding: 4px 8px; border-radius: 12px; }
  .btn-month-reset:hover { background: var(--primary-light); }
  .btn-month-quick { background: var(--card); border: 1px solid var(--border); cursor: pointer; font-size: 12px; color: var(--text-muted); padding: 4px 10px; border-radius: 12px; transition: all .15s; }
  .btn-month-quick:hover { background: var(--primary-light); border-color: var(--primary); color: var(--primary); }
  .btn-month-quick.active { background: var(--primary); border-color: var(--primary); color: #fff; }

  /* ── Change password modal dropdown ── */
  #change-pwd-modal {
    position: fixed;
    top: 70px; right: 16px;
    z-index: 999999;
    display: none;
  }
  #change-pwd-modal.active { display: block; }
  .modal-card {
    background: #fff; border-radius: 12px;
    box-shadow: 0 8px 32px rgba(44,95,138,0.25);
    padding: 24px 22px; width: 360px; max-width: calc(100vw - 32px);
    border: 1px solid var(--border);
  }
  .modal-card .modal-title { font-size: 17px; font-weight: 600; margin-bottom: 20px; }
  .modal-card .form-group { margin-bottom: 14px; }
  .modal-card .form-group label { display: block; font-size: 13px; color: var(--text-muted); margin-bottom: 4px; }
  .modal-card .form-group input {
    width: 100%; padding: 10px 14px;
    border: 2px solid var(--border); border-radius: 8px;
    font-size: 14px; outline: none; box-sizing: border-box;
    transition: border-color .2s;
  }
  .modal-card .form-group input:focus { border-color: var(--primary); }
  .modal-card .modal-actions { display: flex; gap: 10px; margin-top: 20px; }
  .modal-card .modal-actions button {
    flex: 1; padding: 10px; border-radius: 8px; border: none;
    font-size: 14px; font-weight: 600; cursor: pointer;
    transition: background .15s;
  }
  .modal-card .modal-actions .btn-confirm { background: var(--primary); color: #fff; }
  .modal-card .modal-actions .btn-confirm:hover { background: #1e4a70; }
  .modal-card .modal-actions .btn-cancel { background: #f0f0f0; color: #666; }
  .modal-card .modal-actions .btn-cancel:hover { background: #e0e0e0; }
  .modal-card .modal-msg { font-size: 13px; margin-top: 12px; display: none; }
  .modal-card .modal-msg.success { color: var(--accent); display: block; }
  .modal-card .modal-msg.error { color: var(--danger); display: block; }

  /* Alert modal filter buttons */
  .modal-filter-btn, .alert-filter-btn {
    padding: 4px 12px; border-radius: 14px; border: 1.5px solid var(--border);
    font-size: 12px; cursor: pointer; background: var(--bg);
    transition: all .15s; white-space: nowrap;
  }
  .modal-filter-btn.active, .alert-filter-btn.active { background: var(--primary); color: #fff; border-color: var(--primary); }
  .modal-filter-btn:hover:not(.active), .alert-filter-btn:hover:not(.active) { background: var(--hover-bg); }

  /* Login overlay */
  #login-overlay {
    position: fixed; top: 0; left: 0; right: 0; bottom: 0;
    background: var(--bg, #f0f2f5); z-index: 99999;
    display: flex; align-items: center; justify-content: center;
  }
  #login-overlay.hidden { display: none; }
  .login-card {
    background: #fff; border-radius: 12px;
    box-shadow: 0 8px 32px rgba(44,95,138,0.15);
    padding: 40px 36px; max-width: 380px; width: 90%; text-align: center;
  }
  .login-card .lock-icon { font-size: 48px; margin-bottom: 12px; }
  .login-card h2 { font-size: 20px; margin-bottom: 6px; color: var(--text, #2c3e50); }
  .login-card p { font-size: 13px; color: var(--text-muted, #7f8c8d); margin-bottom: 24px; }
  .login-card input {
    width: 100%; padding: 12px 16px;
    border: 2px solid var(--border, #dde3ec); border-radius: 10px;
    font-size: 16px; outline: none; text-align: center;
    transition: border-color .2s; box-sizing: border-box;
  }
  .login-card input:focus { border-color: var(--primary, #2c5f8a); }
  .login-card .login-btn {
    width: 100%; padding: 12px; margin-top: 14px;
    background: var(--primary, #2c5f8a); color: #fff; border: none;
    border-radius: 10px; font-size: 16px; font-weight: 600;
    cursor: pointer; transition: background .15s;
  }
  .login-card .login-btn:hover { background: #1e4a70; }
  .login-card .login-btn:disabled { opacity: 0.6; cursor: not-allowed; }
  .login-card .login-error { color: #e74c3c; font-size: 13px; margin-top: 10px; display: none; }
  .login-card .login-error { color: #e74c3c; font-size: 13px; margin-top: 10px; display: none; }
  .login-card .login-remaining { color: #e67e22; font-size: 12px; margin-top: 6px; display: none; }

  /* ── Health cards (clickable) ── */
  .health-row {
    display: flex;
    flex-direction: row;
    gap: 6px;
    flex-wrap: wrap;
  }
  .health-row:first-child > .health-card {
    flex: 1 1 0;
  }
  .health-row-second { margin-top: 6px; }
  .health-checked-at {
    font-size: 10px;
    color: var(--text-muted);
    margin-top: 6px;
    text-align: right;
  }
  .health-card {
    background: #f7f9fc;
    border-radius: 6px;
    padding: 8px 10px;
    cursor: pointer;
    border: 2px solid transparent;
    transition: all .15s;
    flex: 1;
    min-width: 0;
  }
  .health-card:hover {
    background: #eef3f9;
    border-color: var(--primary);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(74,111,165,0.12);
  }
  .health-card.active {
    background: #e8eef7;
    border-color: var(--primary);
  }
  .health-card .h-label {
    font-size: 11px;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 4px;
    line-height: 1.2;
  }
  .health-card .h-value {
    font-size: 16px;
    font-weight: 700;
    margin-top: 1px;
    display: block;
    line-height: 1.2;
  }
  .health-card .hc-status { font-size: 15px; }
  .health-card .hc-meta {
    font-size: 11px;
    font-weight: 600;
    margin-top: 1px;
    line-height: 1.3;
  }
  .health-card .hc-meta-last { margin-top: 2px; font-weight: 500; }
  .health-card .hc-list {
    font-size: 11px;
    margin-top: 2px;
    line-height: 1.35;
  }
  .health-card .hc-earliest-line {
    font-size: 12px;
    font-weight: 600;
    margin-top: 2px;
    line-height: 1.35;
  }
  .health-card .hc-earliest-line + .hc-earliest-line { margin-top: 4px; }
  .health-card .hc-cam-row {
    margin-top: 6px;
    padding-top: 6px;
    border-top: 1px dashed #ddd;
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
  }
  .health-card .hc-cam-label {
    font-size: 11px;
    color: var(--text-muted);
    flex-shrink: 0;
  }
  .health-card .hc-cam-value {
    font-size: 11px;
    font-weight: 600;
    flex: 0 1 auto;
  }
  .health-card .hc-cam-window {
    font-size: 11px;
    font-weight: 600;
    color: var(--primary);
    flex-shrink: 0;
  }
  .health-card .hc-cam-btn {
    margin-left: auto;
    padding: 3px 8px;
    font-size: 11px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: #fff;
    cursor: pointer;
    color: var(--primary);
    flex-shrink: 0;
  }
  .health-card-wide {
    flex: 2 !important;
    min-width: 220px;
  }
  .health-card-alerts {
    flex: 1;
  }
  .alert-count-btn {
    font-size: 11px;
    border: 1px solid var(--border);
    background: #f7f9fc;
    color: var(--accent);
    white-space: nowrap;
  }
  .alert-count-btn.has-alerts {
    background: #fde8e4;
    color: #e74c3c;
    border-color: #e74c3c;
  }
  .alert-count-btn.active {
    background: #e8eef7;
    border-color: var(--primary);
    color: var(--primary);
  }
  .alert-count-btn:hover {
    border-color: var(--primary);
  }
  .health-card-new {
    flex: 1;
    cursor: default;
  }
  .health-card-new:hover {
    background: #f7f9fc;
    border-color: transparent;
    transform: none;
    box-shadow: none;
  }
  .health-card-edit {
    flex: 1;
  }
  .health-card-earliest {
    flex: 1 1 100%;
  }
  .health-card .h-monotab {
    font-family: 'Courier New', monospace;
    font-size: 11px;
    color: var(--text-muted);
  }

  /* ── 月历：每日记录数 ── */
  #calendar-area { margin-bottom: 10px; }
  /* 月历位于「最早/录像」卡片内、窗口期之下：加顶部分隔线 */
  .health-card-earliest #calendar-area {
    margin-top: 10px; padding-top: 10px; border-top: 1px dashed var(--border);
  }
  #calendar-area.loading { position: relative; opacity: .6; pointer-events: none; transition: opacity .15s ease; }
  .cal-box {
    background: #f7f9fc;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 10px 12px 8px;
  }
  /* 月历平滑滑动的持久包裹层（换月/换年时做 transform 过渡） */
  #cal-anim { will-change: transform, opacity; }
  .cal-head {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
    margin-bottom: 8px;
  }
  .cal-nav, .cal-today-btn {
    border: 1px solid var(--border);
    background: #fff;
    color: var(--primary);
    border-radius: 6px;
    cursor: pointer;
    font-size: 12px;
    line-height: 1;
    padding: 5px 8px;
  }
  .cal-nav:hover, .cal-today-btn:hover { background: var(--primary-light); border-color: var(--primary); }
  .cal-title {
    font-size: 14px;
    font-weight: 700;
    color: var(--text);
    min-width: 96px;
    text-align: center;
  }
  .cal-sum { font-size: 11px; color: var(--text-muted); margin-left: 4px; }
  .cal-sum b { color: var(--primary); }
  .cal-sum .cal-sum-warn { color: var(--danger); }
  .cal-metrics { display: flex; gap: 4px; margin-left: auto; }
  .cal-mbtn {
    border: 1px solid var(--border);
    background: #fff;
    color: var(--text-muted);
    border-radius: 12px;
    cursor: pointer;
    font-size: 11px;
    padding: 4px 10px;
    line-height: 1;
  }
  .cal-mbtn:hover { border-color: var(--primary); color: var(--primary); }
  .cal-mbtn.active { background: var(--primary); border-color: var(--primary); color: #fff; font-weight: 600; }
  .cal-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 3px;
  }
  .cal-dow {
    font-size: 11px;
    color: var(--text-muted);
    text-align: center;
    padding: 2px 0 4px;
    font-weight: 600;
  }
  .cal-dow-weekend { color: #c0392b; }
  .cal-cell {
    position: relative;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 5px;
    min-height: 42px;
    padding: 3px 4px 2px;
    cursor: pointer;
    transition: transform .1s, box-shadow .1s, border-color .1s;
    overflow: hidden;
  }
  .cal-cell:hover {
    border-color: var(--primary);
    transform: translateY(-1px);
    box-shadow: 0 3px 10px rgba(44,95,138,.16);
    z-index: 2;
  }
  .cal-cell.cal-blank {
    background: transparent;
    border-color: transparent;
    cursor: default;
    box-shadow: none;
  }
  .cal-cell.cal-blank:hover { transform: none; box-shadow: none; border-color: transparent; }
  .cal-d {
    display: block;
    font-size: 14px;
    color: var(--text-muted);
    line-height: 1.1;
    font-weight: 600;
  }
  .cal-weekend .cal-d { color: #c0392b; }
  .cal-n {
    display: block;
    font-size: 20px;
    font-weight: 700;
    color: var(--primary);
    line-height: 1.15;
    text-align: center;
    margin-top: 1px;
    letter-spacing: -0.3px;
  }
  /* 计数色深：0–4 档，按当月峰值分位 */
  .cal-l1 { background: #eaf2fa; }
  .cal-l2 { background: #d3e5f5; }
  .cal-l3 { background: #b3d2ee; }
  .cal-l4 { background: #8fbde5; }
  .cal-l3 .cal-n, .cal-l4 .cal-n { color: #1e4a70; }
  .cal-zero { background: #fbfcfd; }
  .cal-zero .cal-n { color: var(--border); }
  .cal-is-today { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
  .cal-selected {
    border-color: var(--primary);
    box-shadow: inset 0 0 0 2px var(--primary);
  }
  /* 月历标注：最早未存 / 最早未剪 / 录像机时间（颜色边框/内环 + 底部小标签） */
  .cal-cell.cal-flag-unchecked, .cal-cell.cal-flag-unedited, .cal-cell.cal-flag-both, .cal-cell.cal-flag-cam {
    padding-bottom: 13px;
    border-width: 2px;
  }
  .cal-flag {
    position: absolute; left: 0; right: 0; bottom: 0;
    font-size: 8px; line-height: 1.25; text-align: center; color: #fff;
    padding: 1px 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  }
  .cal-flag-unchecked { border-color: #e74c3c; }
  .cal-flag-unchecked .cal-flag { background: #e74c3c; }
  .cal-flag-unedited { border-color: #2c5f8a; }
  .cal-flag-unedited .cal-flag { background: #2c5f8a; }
  .cal-flag-both { border-color: #e67e22; }
  .cal-flag-both .cal-flag { background: #e67e22; }
  /* 录像机时间：用绿色内环，避免与 bordered 标注冲突（可叠加显示） */
  .cal-flag-cam { box-shadow: inset 0 0 0 2px #27ae60; }
  .cal-flag-cam .cal-flag { background: #27ae60; }
  .cal-foot {
    font-size: 10px;
    color: var(--text-muted);
    margin-top: 6px;
    line-height: 1.5;
  }
  /* 标题作为按钮：点击弹出年月选择窗 */
  .cal-title {
    border: 1px solid transparent;
    background: transparent;
    border-radius: 6px;
    cursor: pointer;
    padding: 4px 6px;
    transition: background .12s, border-color .12s;
  }
  .cal-title:hover, .cal-title:active { background: #fff; border-color: var(--border); }
  /* 移动端手势：左右滑改月、上下滑改年（禁止页面在此区域滚动，由 JS 接管） */
  .cal-grid { touch-action: none; }
  /* 年月选择窗 */
  body.cal-picker-lock { overflow: hidden; }
  .cal-picker-overlay {
    display: none;
    position: fixed; inset: 0; z-index: 1200;
    background: rgba(0,0,0,.45);
    align-items: center; justify-content: center;
    padding: 16px;
  }
  .cal-picker-overlay.open { display: flex; }
  .cal-picker-panel {
    width: 320px; max-width: 92vw;
    background: #fff; border-radius: 12px;
    padding: 16px; box-shadow: 0 12px 40px rgba(0,0,0,.25);
  }
  .cal-picker-head {
    display: flex; align-items: center; justify-content: center; gap: 14px;
    margin-bottom: 14px;
  }
  .cal-picker-year { font-size: 17px; font-weight: 700; color: var(--text); min-width: 90px; text-align: center; }
  .cal-picker-nav {
    border: 1px solid var(--border); background: #fff; color: var(--primary);
    border-radius: 8px; cursor: pointer; font-size: 16px; line-height: 1;
    width: 38px; height: 38px;
  }
  .cal-picker-nav:hover { background: var(--primary-light); border-color: var(--primary); }
  .cal-picker-months {
    display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px;
  }
  .cal-picker-mbtn {
    border: 1px solid var(--border); background: #fff; color: var(--text);
    border-radius: 8px; cursor: pointer; font-size: 14px; padding: 10px 0;
  }
  .cal-picker-mbtn:hover:not(.disabled) { border-color: var(--primary); color: var(--primary); }
  .cal-picker-mbtn.active { background: var(--primary); border-color: var(--primary); color: #fff; font-weight: 700; }
  .cal-picker-mbtn.disabled { color: #c4c9d2; background: #f6f7f9; cursor: not-allowed; }
  .cal-picker-foot {
    display: flex; justify-content: flex-end; gap: 10px; margin-top: 16px;
  }
  .cal-picker-ok {
    border: 1px solid var(--primary); background: var(--primary); color: #fff;
    border-radius: 8px; cursor: pointer; font-size: 13px; padding: 8px 18px; font-weight: 600;
  }
  .cal-picker-ok:hover { background: var(--primary-dark, #244e72); }
  /* 月曲线图（月历下方） */
  #cal-chart-area {
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px dashed #e0e3ea;
  }
  .cal-chart-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 4px;
  }
  .cal-chart-title { font-size: 12px; font-weight: 600; color: var(--text); }
  .cal-chart-title b { color: #2c5f8a; }
  .cal-chart-ranges { display: flex; gap: 4px; }
  .cal-chart-svg-wrap { width: 100%; overflow: hidden; max-height: 180px; position: relative; }
  .cal-chart-tip {
    position: absolute; display: none; transform: translate(-50%, 0);
    background: #1f2d3d; color: #fff; font-size: 11px; line-height: 1.4;
    padding: 4px 8px; border-radius: 5px; white-space: nowrap; pointer-events: none;
    box-shadow: 0 2px 8px rgba(0,0,0,.25); z-index: 5;
  }
  .cal-chart-tip b { color: #ffd9a0; }
  .cam-time-picker { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; margin: 6px 0; }
  .cam-time-picker input[type="date"], .cam-time-picker input[type="time"] {
    width: 130px; padding: 4px 6px; border: 1px solid #ddd; border-radius: 6px; font-size: 14px; box-sizing: border-box;
  }
  .cam-time-picker input[type="number"] {
    width: 56px; padding: 4px; border: 1px solid #ddd; border-radius: 6px;
    font-size: 14px; text-align: center; box-sizing: border-box;
    -moz-appearance: textfield; appearance: textfield;
  }
  .cam-time-picker input[type="number"]::-webkit-outer-spin-button,
  .cam-time-picker input[type="number"]::-webkit-inner-spin-button {
    -webkit-appearance: none; margin: 0;
  }
  .modal-2 .modal-btns {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 18px;
  }
  .modal-2 .modal-btns button {
    padding: 8px 16px;
    border-radius: 6px;
    font-size: 14px;
    cursor: pointer;
    border: none;
  }
  .modal-2 .modal-btns .btn-secondary {
    background: #f0f0f0;
    color: #666;
    border: 1px solid var(--border);
  }
  /* detail editable */
  .detail-content-editable {
    border-bottom: 1px dashed var(--primary);
    cursor: text;
    min-width: 80px;
  }
  .detail-content-editable:focus {
    background: #fff8e1;
    outline: none;
    border-bottom-color: #e67e22;
  }

  /* ── Wheel picker (录像机时间设置) ── */
  .cam-modal { max-width: 380px; width: 92vw; min-width: 300px; }
  .cam-preview {
    margin: 10px 0 10px;
    padding: 8px 12px;
    background: #fafbfc;
    border-radius: 6px;
    font-size: 15px;
    font-family: monospace;
    color: var(--primary);
    text-align: center;
    letter-spacing: 0.5px;
  }
  .cam-wheels {
    display: flex;
    gap: 6px;
    padding: 6px 4px;
    background: #fafbfc;
    border: 1px solid var(--border);
    border-radius: 8px;
    position: relative;
    min-height: 170px;
  }
  .cam-col {
    flex: 1;
    height: 170px;
    overflow: hidden;
    position: relative;
    text-align: center;
    border-radius: 6px;
    background: #fff;
  }
  .cam-col-track {
    display: flex;
    flex-direction: column;
    will-change: transform;
    transition: transform .25s cubic-bezier(.22,.61,.36,1);
  }
  .cam-col-item {
    height: 34px;
    line-height: 34px;
    font-size: 15px;
    color: var(--text-muted);
    cursor: pointer;
    user-select: none;
    -webkit-user-select: none;
    transition: font-size .15s, color .15s, font-weight .15s;
  }
  .cam-col-item.cam-col-active {
    color: var(--primary);
    font-weight: 700;
    font-size: 18px;
  }
  .cam-col-ind {
    position: absolute;
    left: 4px; right: 4px;
    top: calc(50% - 17px);
    height: 34px;
    border-top: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
    pointer-events: none;
    z-index: 1;
  }
  .cam-quick {
    display: flex;
    gap: 6px;
    margin-top: 12px;
    flex-wrap: wrap;
    justify-content: center;
  }
  .cam-quick button {
    font-size: 12px;
    padding: 5px 12px;
    border-radius: 12px;
    background: #fff;
    color: var(--primary);
    border: 1px solid var(--primary);
    cursor: pointer;
  }
  .cam-quick button:active { background: var(--primary); color: #fff; }
  @media (max-width: 480px) {
    .cam-wheels { gap: 3px; padding: 6px 2px; }
    .cam-col-item { font-size: 13px; }
    .cam-col-item.cam-col-active { font-size: 16px; }
  }
  /* ── Health detail panel ── */
  #health-detail {
    margin-top: 12px;
    border-top: 1px solid var(--border);
    padding-top: 10px;
    opacity: 1;
    transition: opacity 0.18s ease;
    will-change: opacity;
  }
  #health-detail.fade-out {
    opacity: 0;
  }
  #health-detail .detail-title {
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
  }
  #health-detail .detail-empty {
    font-size: 12px;
    color: var(--accent);
    padding: 8px 0;
  }
  #health-detail .detail-list {
    max-height: 260px;
    overflow-y: auto;
    font-size: 12px;
  }
  #health-detail .detail-list .detail-row {
    padding: 6px 8px;
    border-bottom: 1px solid #f0f0f0;
    display: flex;
    gap: 8px;
    align-items: center;
  }
  #health-detail .detail-list .detail-row:last-child { border-bottom: none; }
  #health-detail .detail-list .detail-time { white-space: nowrap; min-width: 110px; color: var(--text-muted); }
  #health-detail .detail-list .detail-type { white-space: nowrap; color: #e67e22; min-width: 70px; }
  #health-detail .detail-list .detail-content { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  #health-detail .detail-list .detail-status { text-align: center; min-width: 50px; }
  #health-detail .detail-list .pending-row .detail-time-display { white-space: nowrap; min-width: 110px; color: var(--text-muted); }
  #health-detail .detail-list .pending-row .detail-time-input { min-width: 110px; }
  #health-detail .detail-list .pending-row .detail-content-display { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  #health-detail .detail-list .pending-row .detail-content-input { flex: 1; }
  #health-detail .detail-list .detail-row.state-saved { background: #ecf7ef; }
  #health-detail .detail-list .detail-row.state-saved-edited { background: #e3f2fd; }
  #health-detail .detail-list .detail-row.detail-header {
    font-weight: 600;
    color: var(--text-muted);
    background: #f8f9fa;
    border-bottom: 2px solid #e0e0e0;
    position: sticky;
    top: 0;
    z-index: 1;
  }
  #health-detail .detail-meta { font-size: 11px; color: var(--text-muted); margin-top: 6px; text-align: right; }

  /* --- Mobile responsive --- */
  @media (max-width: 768px) {
    .login-card { padding: 28px 20px !important; margin: 0 12px; }
    .login-card .lock-icon { font-size: 36px; }
    .login-card h2 { font-size: 17px; }
    .login-card p { font-size: 12px; margin-bottom: 16px; }
    .login-card input { padding: 10px 12px; font-size: 14px; }

    /* ── Header：隐藏长标题，导航可横向滑动 ── */
    /* v66：移动端 header 改 grid：h1「管理后台」占满第一行，按钮第二行；
       同步 .account-btn 媒体查询（之前 999 行只覆盖 a 不覆盖 button，
       导致账户按钮在移动端保持桌面 13px 尺寸，比其他按钮大一截） */
    /* v126：去掉 h1 后移动端 header 改 flex wrap 让 4 个按钮自然分布 */
    header {
      padding: 8px 10px;
      height: auto;
      min-height: 50px;
      display: flex;
      flex-wrap: wrap;
      gap: 6px;
      justify-content: center;
    }
    .header-actions {
      width: 100%;
      gap: 6px;
      margin-left: 0;
      flex-wrap: wrap;
      justify-content: center;
    }
    .header-actions a { font-size: 11px !important; padding: 5px 8px !important; white-space: nowrap; flex-shrink: 0; }
    .account-btn { font-size: 11px !important; padding: 5px 8px !important; white-space: nowrap; flex-shrink: 0; }

    /* ── Main ── */
    .main { padding: 12px 8px; }
    .section-header {
      padding: 12px 14px 10px;
      flex-wrap: wrap;
      row-gap: 8px;
    }
    .section-header h2 { font-size: 13px; flex: 1 1 auto; min-width: 0; }
    .section-header .btn-sm { font-size: 10px !important; padding: 4px 8px !important; }
    .io-header-actions { flex-wrap: wrap; gap: 6px; }
    .section-body { padding: 12px; }

    /* ── Health cards ── */
    #health-area .health-row { gap: 4px !important; }
    #health-area .health-row-second { margin-top: 4px !important; }
    #health-area .health-card { padding: 6px 8px !important; }
    #health-area .health-card .h-value,
    #health-area .health-card .hc-status { font-size: 13px !important; }
    #health-area .health-row:first-child > .health-card {
      flex: 1 1 calc(33.333% - 3px) !important;
    }
    #health-area .health-row-second > .health-card {
      flex: 1 1 100% !important;
    }
    #health-area .health-checked-at {
      margin-top: 4px !important;
      font-size: 9px !important;
    }
    .section-header .alert-count-btn {
      font-size: 10px !important;
      padding: 4px 8px !important;
    }

    /* ── 月历（移动端） ── */
    .cal-box { padding: 8px 8px 6px; }
    .cal-head { gap: 4px; }
    .cal-title { font-size: 13px; min-width: 84px; }
    .cal-sum { flex: 1 1 100%; margin-left: 0; order: 5; font-size: 10px; }
    .cal-metrics { margin-left: auto; }
    .cal-mbtn { padding: 4px 8px; font-size: 10px; }
    .cal-grid { gap: 2px; }
    .cal-cell { min-height: 36px; padding: 2px 2px 1px; border-radius: 4px; }
    .cal-cell.cal-flag-unchecked, .cal-cell.cal-flag-unedited, .cal-cell.cal-flag-both, .cal-cell.cal-flag-cam { padding-bottom: 11px; }
    .cal-d { font-size: 13px; }
    .cal-n { font-size: 16px; letter-spacing: -0.2px; }
    .cal-flag { font-size: 7px; padding: 1px 0; }
    .cal-foot { font-size: 9px; }
    .cal-chart-title { font-size: 11px; }
    .cal-chart-ranges .cal-mbtn { padding: 4px 7px; font-size: 10px; }
    .cal-title { padding: 4px 4px; font-size: 13px; }
    .cal-picker-panel { width: 300px; padding: 14px; }
    .cal-picker-year { font-size: 16px; min-width: 76px; }
    .cal-picker-nav { width: 34px; height: 34px; font-size: 15px; }
    .cal-picker-months { gap: 6px; grid-template-columns: repeat(4, 1fr); }
    .cal-picker-mbtn { font-size: 13px; padding: 9px 0; }

    /* ── Health detail ── */
    #health-detail { margin-top: 10px; padding-top: 8px; }
    #health-detail .detail-title { font-size: 13px; flex-wrap: wrap; gap: 6px; }
    .alert-filter-bar {
      gap: 4px !important;
      margin-bottom: 10px !important;
    }
    .alert-filter-btn {
      font-size: 10px !important;
      padding: 4px 8px !important;
    }
    .alert-filter-bar button[onclick*="acknowledgeAllAlertsFromDetail"] {
      margin-left: 0 !important;
      flex: 1 1 100%;
      margin-top: 2px;
      padding: 6px 10px !important;
    }
    #health-detail .detail-list {
      max-height: 50vh;
      overflow: auto;
      -webkit-overflow-scrolling: touch;
    }
    #health-detail .detail-list .detail-row {
      min-width: 480px;
      flex-wrap: nowrap !important;
      gap: 6px !important;
      padding: 6px 4px !important;
    }
    #health-detail .detail-list .detail-time { min-width: 92px !important; font-size: 10px !important; }
    #health-detail .detail-list .detail-type { min-width: 52px !important; font-size: 10px !important; }
    #health-detail .detail-list .detail-content { font-size: 10px !important; white-space: normal !important; overflow: visible !important; text-overflow: unset !important; line-height: 1.35; }
    #health-detail .detail-list .detail-status { min-width: 32px !important; font-size: 10px !important; }
    #health-detail .detail-list .pending-row { flex-wrap: wrap !important; gap: 4px !important; min-width: 0 !important; }
    #health-detail .detail-list .pending-row .detail-time-display { min-width: 70px !important; font-size: 10px !important; }
    #health-detail .detail-list .pending-row .detail-time-input { min-width: 90px !important; width: 100% !important; }
    #health-detail .detail-list .pending-row .detail-content-display { flex: 1 1 100% !important; font-size: 10px !important; }
    #health-detail .detail-list .pending-row .detail-content-input { flex: 1 1 100% !important; width: 100% !important; }
    #health-detail .detail-list .pending-row .btn-group-normal,
    #health-detail .detail-list .pending-row .btn-group-edit { white-space: nowrap !important; }

    /* ── Date filter bar ── */
    div[style*="flex-wrap"] { flex-wrap: wrap !important; gap: 4px !important; row-gap: 6px !important; }
    div[style*="flex-wrap"] > label:first-child { display: none !important; }
    .btn-month-reset { font-size: 10px !important; padding: 3px 8px !important; white-space: nowrap !important; }
    .btn-month-quick { font-size: 10px !important; padding: 3px 8px !important; white-space: nowrap !important; }
    .date-display { font-size: 11px !important; padding: 2px 6px !important; min-width: 72px !important; }
    .month-arrow { width: 20px !important; height: 20px !important; font-size: 11px !important; }

    /* ── Records table ── */
    #records-container table { font-size: 11px !important; }
    #records-container { max-height: 400px !important; }
    .records-table th, .records-table td { padding: 6px 8px !important; }
    .col-time { width: 80px !important; font-size: 11px !important; white-space: normal !important; }
    .time-year { display: none !important; }
    .col-id { display: none !important; }
    .col-actions { width: 80px !important; text-align: center !important; white-space: nowrap !important; }
    .col-actions button { padding: 5px 8px !important; font-size: 11px !important; }
    #trash-container .trash-actions {
      width: auto !important;
      min-width: 120px !important;
      display: flex !important;
      flex-wrap: nowrap !important;
      gap: 4px !important;
    }
    #trash-container .trash-actions .btn-sm {
      padding: 4px 8px !important;
      font-size: 10px !important;
    }
    .records-table .edit-inline input[type="text"] { font-size: 11px !important; padding: 4px !important; }
    .records-table .edit-inline textarea { font-size: 11px !important; padding: 4px !important; min-height: 32px !important; }
    .edit-actions button { padding: 4px 10px !important; font-size: 11px !important; }

    /* ── Search bar ── */
    .search-bar { flex-direction: column; gap: 6px; }
    .search-bar button { display: none !important; }
    .search-bar input { width: 100%; box-sizing: border-box; }

    /* ── Pagination ── */
    .pagination button { padding: 5px 10px; font-size: 11px; }

    /* ── Drop zone ── */
    .drop-zone { padding: 20px 12px !important; }
    .drop-zone .dz-icon { font-size: 22px !important; margin-bottom: 8px !important; }
    .drop-zone .dz-text { font-size: 12px !important; }

    /* ── Export section ── */
    div[style*="padding:4px 0"] { flex-direction: column !important; align-items: stretch !important; }
    .io-export-row { flex-direction: column !important; align-items: stretch !important; gap: 6px !important; }
    .io-export-row input[type="date"] { width: 100% !important; box-sizing: border-box !important; }
    div[style*="padding:4px 0"] input[type="date"],
    .io-export-row button { width: 100% !important; justify-content: center !important; }

    /* ── Modals ── */
    #change-pwd-modal { top: auto !important; right: auto !important; left: 50% !important; top: 50% !important; transform: translate(-50%, -50%) !important; }
    .modal-card { width: 90vw; max-width: 340px; padding: 20px 16px !important; }
    .modal-card .modal-title { font-size: 15px; }
    .modal-2 { width: 94vw !important; padding: 16px !important; }
    #alert-modal > div { max-width: 98% !important; padding: 12px !important; }
    #alert-modal table { font-size: 11px !important; }
    #alert-modal th, #alert-modal td { padding: 4px 4px !important; }
  }

  /* ── Very small screens (max-width: 420px) ── */
  @media (max-width: 420px) {
    .header-actions a { font-size: 10px !important; padding: 4px 6px !important; }
    .account-btn { font-size: 10px !important; padding: 4px 6px !important; }
    #health-area .health-row:first-child > .health-card {
      flex: 1 1 calc(50% - 2px) !important;
    }
    #health-area .health-row:first-child > .health-card:nth-child(3) {
      flex: 1 1 100% !important;
    }
    .col-actions { width: 70px !important; }
    .col-actions button { font-size: 10px !important; padding: 4px 6px !important; }
    #trash-container .trash-actions { min-width: 110px !important; }
    .records-table th, .records-table td { padding: 4px 4px !important; }
    .col-time { width: 65px !important; font-size: 10px !important; }
    .date-display { font-size: 10px !important; min-width: 60px !important; }
    .btn-month-reset { font-size: 9px !important; padding: 2px 6px !important; }
    .btn-month-quick { font-size: 9px !important; padding: 2px 6px !important; }
    .month-arrow { width: 18px !important; height: 18px !important; font-size: 10px !important; }
    .section-body { padding: 8px !important; }
    .pagination button { padding: 4px 8px; font-size: 10px; }
  }

/* ── 回收站窄屏修复（v156）：时间列不折行、按钮单行，容器横向滚动 ── */
@media (max-width: 768px) {
  #trash-container table {
    min-width: 560px !important;
  }
  #trash-container .col-time {
    width: auto !important;
    min-width: 118px !important;
    font-size: 11px !important;
    white-space: nowrap !important;
  }
  #trash-container .col-content {
    min-width: 140px !important;
  }
  #trash-container .trash-actions {
    width: auto !important;
    min-width: 104px !important;
  }
}

