:root {
  --bg: #f4f6fb;
  --panel: #ffffff;
  --ink: #1f2733;
  --muted: #6b7688;
  --line: #e6eaf2;
  --primary: #2f6bff;
  --primary-d: #1f4fd6;
  --danger: #e5484d;
  --ok: #18a058;
  --shadow: 0 6px 24px rgba(31, 39, 51, .08);
  --radius: 12px;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: -apple-system, "PingFang SC", "Microsoft YaHei", "Segoe UI", Roboto, sans-serif;
  background: var(--bg); color: var(--ink); font-size: 14px;
}
.hidden { display: none !important; }
button { font-family: inherit; cursor: pointer; }

/* ---------- 登录/注册 ---------- */
.auth-view { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px;
  background: linear-gradient(135deg, #eaf0ff 0%, #f4f6fb 60%); }
.auth-card { width: 380px; max-width: 100%; background: var(--panel); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 28px; }
.brand { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; }
.brand-logo { width: 46px; height: 46px; border-radius: 12px; background: var(--primary); color: #fff;
  display: grid; place-items: center; font-size: 22px; font-weight: 700; }
.brand h1 { font-size: 20px; margin: 0; }
.brand-sub { margin: 2px 0 0; color: var(--muted); font-size: 12px; }
.tabs { display: flex; gap: 6px; background: #eef1f7; padding: 4px; border-radius: 10px; margin-bottom: 16px; }
.tab { flex: 1; border: 0; background: transparent; padding: 9px; border-radius: 8px; color: var(--muted); font-weight: 600; }
.tab.active { background: #fff; color: var(--primary); box-shadow: 0 1px 3px rgba(0,0,0,.08); }
.form { display: flex; flex-direction: column; gap: 12px; }
.form label { display: flex; flex-direction: column; gap: 5px; font-size: 12px; color: var(--muted); }
.form input, .form select, .form textarea {
  border: 1px solid var(--line); border-radius: 9px; padding: 10px 12px; font-size: 14px; color: var(--ink);
  background: #fff; outline: none; transition: border-color .15s; }
.form input:focus, .form select:focus, .form textarea:focus { border-color: var(--primary); }
.btn { border: 0; border-radius: 9px; padding: 11px 16px; font-weight: 600; font-size: 14px; }
.btn.primary { background: var(--primary); color: #fff; }
.btn.primary:hover { background: var(--primary-d); }
.btn.ghost { background: transparent; color: var(--muted); border: 1px solid var(--line); }
.btn.ghost:hover { color: var(--ink); }
.msg { margin-top: 12px; font-size: 13px; min-height: 18px; }
.msg.err { color: var(--danger); }
.msg.ok { color: var(--ok); }

/* ---------- 主应用 ---------- */
.app-view { display: flex; min-height: 100vh; }
.sidebar { width: 220px; background: #0f1b34; color: #cdd6ea; display: flex; flex-direction: column;
  padding: 18px 14px; position: sticky; top: 0; height: 100vh; }
.side-logo { font-size: 17px; font-weight: 700; color: #fff; margin-bottom: 22px; padding-left: 6px; }
#side-nav { display: flex; flex-direction: column; gap: 4px; flex: 1; }
.nav-item { text-align: left; border: 0; background: transparent; color: #cdd6ea; padding: 11px 12px;
  border-radius: 9px; font-size: 14px; }
.nav-item:hover { background: rgba(255,255,255,.06); }
.nav-item.active { background: var(--primary); color: #fff; }
.user-box { border-top: 1px solid rgba(255,255,255,.1); padding-top: 14px; }
.ub-name { color: #fff; font-weight: 600; }
.ub-meta { color: #8a96b3; font-size: 12px; margin: 2px 0 10px; }

.content { flex: 1; padding: 24px 30px; overflow: auto; }
.content-head { display: flex; align-items: baseline; gap: 12px; margin-bottom: 18px; }
.content-head h2 { margin: 0; font-size: 22px; }
.hint { color: var(--muted); font-size: 13px; }

.row-form { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; background: var(--panel);
  padding: 14px; border-radius: var(--radius); box-shadow: var(--shadow); margin-bottom: 16px; }
.row-form input, .row-form select, .row-form textarea {
  border: 1px solid var(--line); border-radius: 9px; padding: 9px 11px; font-size: 14px; background: #fff; outline: none; }
.row-form input:focus, .row-form select:focus, .row-form textarea:focus { border-color: var(--primary); }
.row-form textarea { flex: 1; min-width: 240px; resize: vertical; }

.table-wrap { background: var(--panel); border-radius: var(--radius); box-shadow: var(--shadow); overflow: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; padding: 11px 14px; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { color: var(--muted); font-weight: 600; background: #fafbfe; position: sticky; top: 0; }
tbody tr:hover { background: #f8faff; }
.stage { padding: 2px 9px; border-radius: 20px; font-size: 12px; background: #eef3ff; color: var(--primary); }
.prio-high { color: var(--danger); font-weight: 600; }
.prio-medium { color: #d98a00; }
.prio-low { color: var(--muted); }
.line-actions { display: flex; gap: 8px; }
.link-btn { border: 0; background: transparent; color: var(--primary); padding: 0; font-size: 13px; }
.link-btn.del { color: var(--danger); }
.done td:not(:first-child):not(:last-child) { text-decoration: line-through; color: var(--muted); }

.note-list { display: grid; gap: 12px; }
.note-card { background: var(--panel); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px 16px;
  display: flex; justify-content: space-between; gap: 12px; }
.note-card .nc-body { white-space: pre-wrap; line-height: 1.5; }
.note-card .nc-time { color: var(--muted); font-size: 12px; margin-top: 6px; }

/* ---------- 弹窗 ---------- */
.modal { position: fixed; inset: 0; background: rgba(15,27,52,.45); display: grid; place-items: center; z-index: 50; }
.modal-card { width: 460px; max-width: 92vw; background: #fff; border-radius: var(--radius); padding: 22px; box-shadow: var(--shadow); }
.modal-card h3 { margin: 0 0 14px; }
.modal-card label { display: flex; flex-direction: column; gap: 5px; font-size: 12px; color: var(--muted); margin-bottom: 10px; }
.modal-card input, .modal-card select, .modal-card textarea {
  border: 1px solid var(--line); border-radius: 9px; padding: 9px 11px; font-size: 14px; outline: none; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 8px; }

.toast { position: fixed; bottom: 26px; left: 50%; transform: translateX(-50%); background: #0f1b34; color: #fff;
  padding: 11px 18px; border-radius: 10px; box-shadow: var(--shadow); z-index: 60; font-size: 14px; }
.toast.err { background: var(--danger); }
.toast.ok { background: var(--ok); }

@media (max-width: 720px) {
  .app-view { flex-direction: column; }
  .sidebar { width: 100%; height: auto; position: static; flex-direction: row; flex-wrap: wrap; align-items: center; }
  #side-nav { flex-direction: row; flex-wrap: wrap; }
  .user-box { border: 0; margin-left: auto; padding: 0; display: flex; align-items: center; gap: 10px; }
  .content { padding: 16px; }
}

/* ---------- 单据打印 / 导出 PDF ---------- */
#print-area { display: none; }
@media print {
  body * { visibility: hidden; }
  #print-area, #print-area * { visibility: visible; }
  #print-area { display: block; position: absolute; left: 0; top: 0; width: 100%; padding: 24px; color: #000; font-size: 13px; }
  .doc-head { text-align: center; margin-bottom: 16px; }
  .doc-head h1 { font-size: 20px; margin: 0 0 4px; }
  .doc-head h2 { font-size: 16px; margin: 0; font-weight: 600; }
  .doc-code { margin: 4px 0 0; color: #333; }
  .doc-table { width: 100%; border-collapse: collapse; margin: 10px 0; }
  .doc-table th, .doc-table td { border: 1px solid #444; padding: 6px 10px; text-align: left; vertical-align: top; }
  .doc-table th { background: #f2f2f2; width: 22%; white-space: nowrap; }
  .doc-foot { margin-top: 18px; color: #666; font-size: 12px; }
}
