/* ============================================================
   个人工作平台 · 双主题设计系统（深色为主 / 可切换浅色）
   ============================================================ */

:root[data-theme="dark"] {
  --bg: #0b1020;
  --bg-grad: radial-gradient(1200px 600px at 80% -10%, rgba(59,130,246,.16), transparent 60%),
              radial-gradient(900px 500px at -10% 10%, rgba(34,211,238,.10), transparent 55%);
  --surface: #131c31;
  --surface-2: #1a2440;
  --surface-3: #223057;
  --border: rgba(255, 255, 255, .08);
  --border-strong: rgba(255, 255, 255, .16);
  --text: #e7eefb;
  --muted: #93a1bd;
  --faint: #64748b;
  --primary: #3b82f6;
  --primary-2: #60a5fa;
  --accent: #22d3ee;
  --ok: #34d399;
  --warn: #fbbf24;
  --bad: #f87171;
  --ring-track: rgba(255, 255, 255, .08);
  --shadow: 0 14px 36px rgba(0, 0, 0, .38);
  --shadow-sm: 0 6px 18px rgba(0, 0, 0, .28);
  --nav-bg: rgba(10, 15, 30, .72);
  --glass: rgba(19, 28, 49, .72);
}

:root[data-theme="light"] {
  --bg: #eef2f9;
  --bg-grad: radial-gradient(1200px 600px at 80% -10%, rgba(59,130,246,.14), transparent 60%),
              radial-gradient(900px 500px at -10% 10%, rgba(34,211,238,.10), transparent 55%);
  --surface: #ffffff;
  --surface-2: #f4f7fc;
  --surface-3: #e9eff9;
  --border: #e6eaf2;
  --border-strong: #d4dbe8;
  --text: #1f2937;
  --muted: #5b6678;
  --faint: #94a3b8;
  --primary: #2563eb;
  --primary-2: #3b82f6;
  --accent: #0891b2;
  --ok: #059669;
  --warn: #d97706;
  --bad: #dc2626;
  --ring-track: #e5e9f2;
  --shadow: 0 14px 36px rgba(31, 41, 55, .12);
  --shadow-sm: 0 6px 18px rgba(31, 41, 55, .08);
  --nav-bg: rgba(255, 255, 255, .82);
  --glass: rgba(255, 255, 255, .82);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  background-image: var(--bg-grad);
  background-attachment: fixed;
  color: var(--text);
  font-size: 14px;
  line-height: 1.55;
  transition: background-color .3s, color .3s;
}

/* ---------- Sidebar ---------- */
.sidebar {
  position: fixed; inset: 0 auto 0 0; width: 244px;
  background: var(--nav-bg);
  backdrop-filter: blur(18px) saturate(140%);
  -webkit-backdrop-filter: blur(18px) saturate(140%);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column; padding: 20px 14px; z-index: 20;
}
.brand { display: flex; align-items: center; gap: 11px; padding: 4px 8px 18px; }
.logo {
  width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center;
  font-weight: 800; font-size: 20px; color: #fff;
  background: linear-gradient(135deg, var(--accent), var(--primary));
  box-shadow: 0 6px 16px rgba(59, 130, 246, .4);
}
.brand-name { font-weight: 800; font-size: 15px; letter-spacing: .3px; }
.brand-sub { font-size: 11px; color: var(--muted); letter-spacing: 1px; text-transform: uppercase; }
#nav { display: flex; flex-direction: column; gap: 3px; margin-top: 6px; }
#nav a {
  position: relative; display: flex; align-items: center; gap: 11px;
  padding: 10px 13px; border-radius: 11px; color: var(--muted);
  text-decoration: none; font-size: 14px; transition: .18s; font-weight: 500;
}
#nav a:hover { background: var(--surface-2); color: var(--text); }
#nav a.active {
  background: linear-gradient(90deg, rgba(59,130,246,.22), rgba(59,130,246,.04));
  color: #fff; font-weight: 700;
}
#nav a.active::before {
  content: ""; position: absolute; left: -14px; top: 50%; transform: translateY(-50%);
  width: 4px; height: 22px; border-radius: 0 4px 4px 0; background: var(--primary-2);
  box-shadow: 0 0 12px var(--primary);
}
.side-foot { margin-top: auto; font-size: 11px; color: var(--faint); padding: 10px 6px 0; }

/* ---------- Main / Topbar ---------- */
.main { margin-left: 244px; min-height: 100vh; }
.topbar {
  position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 12px;
  padding: 14px 26px; background: var(--glass); backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
}
.topbar h1 { font-size: 18px; margin: 0; font-weight: 800; letter-spacing: .3px; }
.menu-btn { display: none; background: none; border: none; font-size: 22px; cursor: pointer; color: var(--text); }
.spacer { flex: 1; }
.icon-btn {
  display: inline-grid; place-items: center; width: 38px; height: 38px; border-radius: 10px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text); cursor: pointer;
  font-size: 17px; transition: .15s;
}
.icon-btn:hover { border-color: var(--border-strong); transform: translateY(-1px); }

/* ---------- Cards / Stats ---------- */
.view { padding: 24px 26px 64px; }
.grid { display: grid; gap: 16px; }
.stats { grid-template-columns: repeat(auto-fit, minmax(168px, 1fr)); }
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: 16px;
  padding: 18px; box-shadow: var(--shadow-sm); transition: transform .18s, box-shadow .18s, border-color .18s;
  animation: rise .45s ease both;
}
.card:hover { transform: translateY(-3px); box-shadow: var(--shadow); border-color: var(--border-strong); }
.stat .label { color: var(--muted); font-size: 13px; }
.stat .value { font-size: 30px; font-weight: 800; margin-top: 6px; letter-spacing: .5px; }
.stat .sub { font-size: 12px; color: var(--muted); margin-top: 4px; }
.panel { margin-top: 22px; }
.panel-title { font-size: 15px; font-weight: 800; margin: 0 0 12px; display: flex; align-items: center; gap: 10px; }
.panel-title .accent-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 10px var(--accent); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 6px; cursor: pointer;
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  padding: 8px 14px; border-radius: 10px; font-size: 13px; font-weight: 600; transition: .15s;
}
.btn:hover { border-color: var(--border-strong); transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn-primary { background: linear-gradient(135deg, var(--primary), var(--primary-2)); border-color: transparent; color: #fff; box-shadow: 0 6px 16px rgba(59,130,246,.35); }
.btn-primary:hover { box-shadow: 0 8px 22px rgba(59,130,246,.5); }
.btn-danger { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 35%, transparent); }
.btn-danger:hover { background: color-mix(in srgb, var(--bad) 12%, transparent); }
.btn-sm { padding: 5px 11px; font-size: 12px; border-radius: 9px; }

/* ---------- Toolbar / Inputs ---------- */
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 16px; }
.inp {
  padding: 9px 13px; border: 1px solid var(--border); border-radius: 10px; font-size: 13px;
  font-family: inherit; background: var(--surface); color: var(--text); transition: .15s;
}
.inp:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 25%, transparent); }

/* ---------- Table ---------- */
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: 16px; background: var(--surface); box-shadow: var(--shadow-sm); }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; padding: 12px 15px; border-bottom: 1px solid var(--border); white-space: nowrap; }
th { background: var(--surface-2); color: var(--muted); font-weight: 700; font-size: 12px; letter-spacing: .3px; }
tbody tr { transition: background .12s; }
tbody tr:hover { background: var(--surface-2); }
td.actions { display: flex; gap: 6px; }
.muted { color: var(--muted); }
.overdue { color: var(--bad); font-weight: 700; }

/* ---------- Badges ---------- */
.badge { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 700; }
.b-todo, .b-recruiting, .b-pending { background: color-mix(in srgb, var(--primary) 18%, transparent); color: var(--primary-2); }
.b-doing, .b-active { background: color-mix(in srgb, var(--ok) 18%, transparent); color: var(--ok); }
.b-done, .b-completed { background: var(--surface-3); color: var(--muted); }
.b-high { background: color-mix(in srgb, var(--bad) 20%, transparent); color: var(--bad); }
.b-medium { background: color-mix(in srgb, var(--warn) 20%, transparent); color: var(--warn); }
.b-low { background: color-mix(in srgb, var(--primary) 16%, transparent); color: var(--primary-2); }

/* ---------- Link cards ---------- */
.links-grid { grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); }
.link-card {
  display: block; text-decoration: none; color: var(--text); cursor: pointer;
  background: var(--surface); border: 1px solid var(--border); border-left: 4px solid var(--primary);
  border-radius: 14px; padding: 16px; box-shadow: var(--shadow-sm); transition: .18s;
}
.link-card:hover { transform: translateY(-3px); box-shadow: var(--shadow); border-color: var(--border-strong); }
.link-card .lc-title { font-weight: 800; font-size: 15px; }
.link-card .lc-note { font-size: 12px; color: var(--muted); margin-top: 6px; }
.link-card .lc-url { font-size: 11px; color: var(--faint); margin-top: 8px; word-break: break-all; }

/* ---------- Journal ---------- */
.journal-list { display: flex; flex-direction: column; gap: 14px; }
.journal-item { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 16px; box-shadow: var(--shadow-sm); animation: rise .4s ease both; }
.journal-date { font-weight: 800; font-size: 13px; color: var(--primary-2); }
.journal-meta { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.journal-text { white-space: pre-wrap; font-size: 14px; line-height: 1.65; }
.journal-actions { margin-top: 10px; display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- Form / Modal ---------- */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.field { display: flex; flex-direction: column; gap: 5px; }
.field.full { grid-column: 1 / -1; }
.field label { font-size: 12px; color: var(--muted); font-weight: 700; }
.field input, .field select, .field textarea {
  border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; font-size: 14px;
  font-family: inherit; background: var(--surface); color: var(--text); width: 100%; transition: .15s;
}
.field input:focus, .field select:focus, .field textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 25%, transparent); }
.modal-root { position: fixed; inset: 0; background: rgba(5, 8, 18, .6); backdrop-filter: blur(4px); display: grid; place-items: center; z-index: 60; padding: 16px; animation: fade .2s ease; }
.modal { background: var(--surface); width: min(620px, 100%); max-height: 90vh; overflow: auto; border: 1px solid var(--border-strong); border-radius: 18px; box-shadow: var(--shadow); animation: rise .25s ease; }
.modal-head { display: flex; align-items: center; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.modal-head h3 { margin: 0; font-size: 16px; font-weight: 800; flex: 1; }
.modal-close { background: none; border: none; font-size: 18px; cursor: pointer; color: var(--muted); }
.modal-body { padding: 20px; }
.modal-foot { display: flex; gap: 10px; justify-content: flex-end; margin-top: 18px; }

.hidden { display: none !important; }
.empty { text-align: center; color: var(--muted); padding: 46px 16px; }
.empty .empty-ico { font-size: 38px; margin-bottom: 10px; opacity: .6; }

/* ---------- 用户区 / 登录 ---------- */
.user-area { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.user-name { font-weight: 700; }
.user-role { background: color-mix(in srgb, var(--primary) 18%, transparent); color: var(--primary-2); border-radius: 999px; padding: 2px 10px; font-size: 12px; font-weight: 700; }
.login-root { position: fixed; inset: 0; z-index: 100; background: linear-gradient(135deg, #0b1020, #131c31 60%, #0e7490); display: flex; align-items: center; justify-content: center; padding: 20px; }
.login-card { background: var(--surface); border: 1px solid var(--border-strong); border-radius: 20px; padding: 32px 28px; width: 360px; max-width: 100%; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 8px; animation: rise .35s ease; }
.login-card label { font-size: 13px; color: var(--muted); margin-top: 8px; font-weight: 700; }
.login-card input { padding: 11px 13px; border: 1px solid var(--border); border-radius: 11px; font-size: 14px; background: var(--surface-2); color: var(--text); }
.login-card input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 30%, transparent); }
.login-brand { padding: 0 0 4px; }
.login-err { color: var(--bad); font-size: 13px; min-height: 18px; }

/* ---------- 权限矩阵 开关 ---------- */
.matrix { table-layout: fixed; }
.matrix th:first-child, .matrix td:first-child { width: 34%; text-align: left; }
.matrix .group-row { background: var(--surface-2); font-weight: 800; color: var(--text); }
.switch { position: relative; display: inline-block; width: 42px; height: 23px; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch .slider { position: absolute; cursor: pointer; inset: 0; background: var(--surface-3); border-radius: 999px; transition: .18s; }
.switch .slider::before { content: ""; position: absolute; height: 17px; width: 17px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: .18s; box-shadow: 0 1px 3px rgba(0,0,0,.3); }
.switch input:checked + .slider { background: var(--ok); }
.switch input:checked + .slider::before { transform: translateX(19px); }
.switch.disabled { opacity: .5; }
.switch.disabled .slider { cursor: not-allowed; }

/* ---------- Calendar ---------- */
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 14px; box-shadow: var(--shadow-sm); margin-bottom: 18px; }
.cal-wk { text-align: center; font-size: 12px; color: var(--muted); font-weight: 700; padding-bottom: 4px; }
.cal-cell { min-height: 58px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface-2); padding: 6px; cursor: pointer; transition: .12s; position: relative; }
.cal-cell:hover { border-color: var(--primary); }
.cal-empty { background: transparent; border: none; cursor: default; }
.cal-d { font-size: 13px; font-weight: 700; }
.cal-has { background: color-mix(in srgb, var(--primary) 14%, transparent); border-color: color-mix(in srgb, var(--primary) 30%, transparent); }
.cal-today .cal-d { color: var(--primary-2); }
.cal-today { outline: 2px solid var(--primary); }
.cal-sel { background: var(--primary); border-color: var(--primary); }
.cal-sel .cal-d { color: #fff; }
.cal-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); position: absolute; right: 8px; bottom: 8px; }
.cal-sel .cal-dot { background: #fff; }

/* ---------- Markdown ---------- */
.md h3 { font-size: 15px; margin: 8px 0 4px; }
.md h4 { font-size: 14px; margin: 6px 0 3px; }
.md p { margin: 4px 0; }
.md ul { margin: 4px 0; padding-left: 20px; }
.md code { background: var(--surface-2); padding: 1px 6px; border-radius: 5px; font-size: 12px; }

/* ---------- Toast ---------- */
.toast { position: fixed; left: 50%; bottom: 30px; transform: translateX(-50%); background: #0f172a; color: #fff; padding: 11px 18px; border-radius: 11px; font-size: 13px; z-index: 120; box-shadow: var(--shadow); border: 1px solid var(--border-strong); }

/* ============================================================
   亮点组件：晨间简报 / 进度环 / 命令面板 / 热力图
   ============================================================ */

/* 晨间简报卡 */
.briefing {
  position: relative; overflow: hidden; border-radius: 18px; padding: 22px 24px;
  background: linear-gradient(120deg, color-mix(in srgb, var(--primary) 22%, var(--surface)), color-mix(in srgb, var(--accent) 14%, var(--surface)));
  border: 1px solid var(--border-strong); box-shadow: var(--shadow-sm); animation: rise .45s ease both;
}
.briefing::after { content: ""; position: absolute; right: -40px; top: -40px; width: 180px; height: 180px; border-radius: 50%; background: radial-gradient(circle, color-mix(in srgb, var(--accent) 40%, transparent), transparent 70%); opacity: .5; }
.briefing .b-greet { font-size: 13px; color: var(--muted); font-weight: 700; letter-spacing: .5px; text-transform: uppercase; }
.briefing .b-text { font-size: 17px; font-weight: 700; margin: 8px 0 14px; line-height: 1.6; position: relative; z-index: 1; }
.briefing .b-tag { display: inline-block; font-size: 11px; font-weight: 800; padding: 2px 9px; border-radius: 999px; background: var(--surface); color: var(--muted); margin-left: 8px; }
.focus-list { display: flex; flex-direction: column; gap: 8px; position: relative; z-index: 1; }
.focus-item { display: flex; align-items: center; gap: 10px; padding: 9px 13px; border-radius: 11px; background: var(--surface); border: 1px solid var(--border); cursor: pointer; transition: .15s; font-size: 13px; font-weight: 600; }
.focus-item:hover { border-color: var(--primary); transform: translateX(3px); }
.focus-item .fi-idx { width: 22px; height: 22px; border-radius: 7px; display: grid; place-items: center; background: linear-gradient(135deg, var(--primary), var(--accent)); color: #fff; font-size: 12px; font-weight: 800; flex: 0 0 auto; }

/* 进度环 */
.ring { display: inline-grid; place-items: center; position: relative; }
.ring svg { transform: rotate(-90deg); }
.ring .ring-num { position: absolute; font-weight: 800; font-size: 15px; }

/* 命令面板 */
.palette-root { position: fixed; inset: 0; z-index: 130; background: rgba(5, 8, 18, .55); backdrop-filter: blur(6px); display: flex; align-items: flex-start; justify-content: center; padding-top: 12vh; animation: fade .15s ease; }
.palette { width: min(620px, 94vw); background: var(--surface); border: 1px solid var(--border-strong); border-radius: 16px; box-shadow: var(--shadow); overflow: hidden; animation: rise .2s ease; }
.palette input { width: 100%; border: none; outline: none; background: transparent; color: var(--text); font-size: 16px; padding: 18px 20px; border-bottom: 1px solid var(--border); font-family: inherit; }
.palette .p-results { max-height: 52vh; overflow-y: auto; padding: 8px; }
.p-item { display: flex; align-items: center; gap: 12px; padding: 11px 14px; border-radius: 11px; cursor: pointer; font-size: 14px; }
.p-item .p-ico { width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center; background: var(--surface-2); font-size: 15px; flex: 0 0 auto; }
.p-item .p-meta { color: var(--faint); font-size: 12px; margin-left: auto; }
.p-item.active, .p-item:hover { background: var(--surface-2); }
.p-group { font-size: 11px; font-weight: 800; color: var(--faint); text-transform: uppercase; letter-spacing: .6px; padding: 12px 14px 4px; }
.p-empty { text-align: center; color: var(--muted); padding: 28px; font-size: 13px; }

/* 热力图 */
.heatmap { display: flex; gap: 4px; overflow-x: auto; padding: 6px 2px 10px; }
.heat-col { display: grid; grid-template-rows: repeat(7, 14px); gap: 4px; }
.heat-cell { width: 14px; height: 14px; border-radius: 4px; background: var(--ring-track); transition: .12s; cursor: pointer; }
.heat-cell:hover { outline: 2px solid var(--accent); transform: scale(1.18); }
.heat-legend { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); margin-top: 4px; }
.heat-legend .heat-cell { cursor: default; }
.heat-tip { font-size: 12px; color: var(--muted); margin-top: 8px; min-height: 18px; }

/* ---------- Animations ---------- */
@keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: .4; } }

/* ---------- Responsive ---------- */
@media (max-width: 768px) {
  .sidebar { inset: 0 0 auto 0; width: 100%; height: auto; flex-direction: row; align-items: center; padding: 10px; overflow-x: auto; border-right: none; border-bottom: 1px solid var(--border); }
  .brand { flex: 0 0 auto; padding: 0 10px 0 4px; }
  .brand-sub, .side-foot { display: none; }
  #nav { flex-direction: row; margin: 0; gap: 5px; }
  #nav a { padding: 8px 12px; white-space: nowrap; }
  #nav a.active::before { display: none; }
  .main { margin-left: 0; padding-top: 60px; }
  .view { padding: 16px 14px 50px; }
  .form-grid { grid-template-columns: 1fr; }
}
