/* ==========================================================================
   LabMS 实验室管理系统 —— 样式
   设计 token 都在 :root 里，换品牌色只需要改 --brand-* 这一组
   ========================================================================== */

:root {
  /* 主色调。想换颜色改这一组 --brand-* 即可 */
  --brand-900: #0a3a2c;
  --brand-800: #0f4f3b;
  --brand-700: #14684f;
  --brand-600: #1a7f5f;
  --brand-500: #22996f;
  --brand-100: #e6f4ee;
  --brand-050: #f2faf6;

  /* 中性色 */
  --bg: #f5f7f6;
  --surface: #ffffff;
  --surface-2: #fafbfa;
  --border: #e2e8e4;
  --border-strong: #cdd8d2;
  --text: #16211c;
  --text-2: #4a5b53;
  --muted: #7b8c84;

  /* 语义色 */
  --danger: #c0392b;
  --danger-bg: #fdecea;
  --warn: #b7791f;
  --warn-bg: #fdf6e3;
  --ok: #1a7f5f;
  --ok-bg: #e6f4ee;
  --info: #2b6cb0;
  --info-bg: #eaf2fb;

  /* 尺寸 */
  --sidebar-w: 224px;
  --radius: 8px;
  --radius-sm: 5px;
  --shadow-1: 0 1px 2px rgba(16, 32, 26, .06), 0 1px 3px rgba(16, 32, 26, .04);
  --shadow-2: 0 4px 12px rgba(16, 32, 26, .10);
  --shadow-3: 0 12px 32px rgba(16, 32, 26, .16);

  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
          "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Consolas, "Liberation Mono", monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
}

body {
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

a { color: var(--brand-600); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------------------------------------------------------------- 登录页 */
.login-page {
  min-height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(140deg, var(--brand-900) 0%, var(--brand-700) 55%, var(--brand-500) 100%);
  padding: 24px;
}

.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--surface);
  border-radius: 12px;
  box-shadow: var(--shadow-3);
  padding: 36px 32px 28px;
}

.login-brand { text-align: center; margin-bottom: 26px; }
.login-brand .logo {
  /* 胶囊形而不是正方形：简称可能是 LabMS 这种 5 个字母的词，方形框会溢出 */
  height: 46px; padding: 0 18px; margin: 0 auto 14px;
  border-radius: 12px;
  background: var(--brand-600);
  display: inline-flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 700; font-size: 17px; letter-spacing: .4px;
}
.login-brand h1 { font-size: 18px; margin: 0 0 4px; font-weight: 600; }
.login-brand p { margin: 0; color: var(--muted); font-size: 12.5px; }
.login-brand p:empty { display: none; }

/* ------------------------------------------------------------------ 布局 */
.app { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w);
  flex: 0 0 var(--sidebar-w);
  background: var(--brand-900);
  color: #d8e8e1;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}

.sidebar-brand {
  padding: 18px 18px 16px;
  display: flex; align-items: center; gap: 10px;
  border-bottom: 1px solid rgba(255, 255, 255, .08);
}
.sidebar-brand .mark {
  /* 同上：胶囊形字标 */
  height: 26px; padding: 0 8px; border-radius: 7px;
  background: var(--brand-500);
  display: inline-flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 700; font-size: 11px; letter-spacing: .3px;
  flex: 0 0 auto; white-space: nowrap;
}
.sidebar-brand .name { font-size: 13.5px; font-weight: 600; color: #fff; line-height: 1.3; }
.sidebar-brand .sub { font-size: 11px; color: #8fb3a4; }

.nav { flex: 1; overflow-y: auto; padding: 10px 0; }
.nav-group { padding: 14px 18px 6px; font-size: 11px; color: #7fa596; letter-spacing: .06em; }
.nav a {
  display: flex; align-items: center; gap: 9px;
  padding: 8px 18px; color: #cfe3da; font-size: 13.5px;
  border-left: 3px solid transparent;
}
.nav a:hover { background: rgba(255, 255, 255, .06); text-decoration: none; color: #fff; }
.nav a.active {
  background: rgba(255, 255, 255, .10);
  border-left-color: var(--brand-500);
  color: #fff; font-weight: 500;
}
.nav a .ico { width: 16px; text-align: center; opacity: .85; font-size: 14px; }
.nav a .pill {
  margin-left: auto; background: var(--danger); color: #fff;
  font-size: 11px; line-height: 1; padding: 3px 6px; border-radius: 9px; font-weight: 600;
}

.sidebar-foot {
  padding: 12px 18px; border-top: 1px solid rgba(255, 255, 255, .08);
  font-size: 11.5px; color: #7fa596;
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
}
/* 侧边栏底部的退出登录。要显眼一点，但又不能抢导航的注意力 */
.sidebar-foot a {
  color: #9dc3b4; text-decoration: none; white-space: nowrap;
  border-bottom: 1px dashed rgba(255, 255, 255, .3); padding-bottom: 1px;
}
.sidebar-foot a:hover { color: #fff; border-bottom-color: #fff; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  height: 54px; flex: 0 0 54px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 14px;
  padding: 0 20px;
  position: sticky; top: 0; z-index: 20;
}
.topbar h2 { font-size: 15.5px; margin: 0; font-weight: 600; flex: 1; }
.topbar .crumbs { color: var(--muted); font-size: 12.5px; }

.user-chip {
  display: flex; align-items: center; gap: 8px;
  padding: 5px 10px 5px 6px; border-radius: 20px; cursor: pointer;
  border: 1px solid transparent;
}
.user-chip:hover { background: var(--surface-2); border-color: var(--border); }
.avatar {
  width: 26px; height: 26px; border-radius: 50%;
  background: var(--brand-100); color: var(--brand-700);
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 600;
}
.user-chip .uname { font-size: 13px; }
.user-chip .urole { font-size: 11px; color: var(--muted); }

.menu {
  position: absolute; right: 16px; top: 50px; z-index: 60;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow-2);
  min-width: 190px; padding: 5px; display: none;
}
.menu.open { display: block; }
.menu button, .menu a {
  display: block; width: 100%; text-align: left;
  padding: 8px 11px; border: 0; background: none; cursor: pointer;
  font-size: 13px; color: var(--text); border-radius: var(--radius-sm);
  font-family: inherit;
}
.menu button:hover, .menu a:hover { background: var(--surface-2); text-decoration: none; }
.menu .sep { height: 1px; background: var(--border); margin: 5px 0; }

.content { padding: 20px; flex: 1; }
.content-narrow { max-width: 940px; }

/* ------------------------------------------------------------------ 组件 */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-1);
}
.card-head {
  padding: 13px 16px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 10px;
}
.card-head h3 { margin: 0; font-size: 14px; font-weight: 600; flex: 1; }
.card-body { padding: 16px; }

.page-head { display: flex; align-items: flex-start; gap: 12px; margin-bottom: 16px; }
.page-head h1 { font-size: 19px; margin: 0 0 2px; font-weight: 650; }
.page-head .desc { color: var(--muted); font-size: 13px; margin: 0; }
.page-head .actions { margin-left: auto; display: flex; gap: 8px; }

.grid { display: grid; gap: 14px; }
.grid-4 { grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
.grid-2 { grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); }

/* 按钮 */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 7px 14px; border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong); background: var(--surface);
  color: var(--text); font-size: 13.5px; font-family: inherit; font-weight: 500;
  cursor: pointer; white-space: nowrap; transition: background .12s, border-color .12s;
}
.btn:hover:not(:disabled) { background: var(--surface-2); border-color: var(--muted); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--brand-600); border-color: var(--brand-600); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--brand-700); border-color: var(--brand-700); }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-danger:hover:not(:disabled) { filter: brightness(.93); }
.btn-ghost { border-color: transparent; background: transparent; }
.btn-ghost:hover:not(:disabled) { background: var(--surface-2); }
.btn-sm { padding: 4px 9px; font-size: 12.5px; }
.btn-lg { padding: 10px 20px; font-size: 14.5px; }
.btn-block { width: 100%; }

/* 表单 */
.field { margin-bottom: 14px; }
.field label {
  display: block; font-size: 12.5px; font-weight: 600;
  color: var(--text-2); margin-bottom: 5px;
}
.field .hint { font-size: 11.5px; color: var(--muted); margin-top: 4px; }
.field .err { font-size: 12px; color: var(--danger); margin-top: 4px; }

input[type=text], input[type=password], input[type=email], input[type=search],
input[type=date], input[type=number], select, textarea {
  width: 100%; padding: 8px 11px;
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  font-size: 13.5px; font-family: inherit; color: var(--text);
  background: var(--surface); transition: border-color .12s, box-shadow .12s;
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--brand-500);
  box-shadow: 0 0 0 3px var(--brand-100);
}
input:disabled, textarea:disabled, select:disabled { background: var(--surface-2); color: var(--muted); }
textarea { resize: vertical; min-height: 76px; line-height: 1.6; }
input.invalid, textarea.invalid { border-color: var(--danger); }

.row { display: flex; gap: 12px; }
.row > * { flex: 1; min-width: 0; }

/* 二选一的切换（归属：课题 / 公共任务）。
   选中态用 JS 打的 .on 类，不用 :has() —— 实验室的浏览器不一定够新。 */
.seg { display: inline-flex; gap: 0; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); overflow: hidden; }
.seg-item {
  display: flex; align-items: center; gap: 7px; padding: 8px 14px;
  font-size: 13.5px; cursor: pointer; background: var(--surface); white-space: nowrap;
}
.seg-item + .seg-item { border-left: 1px solid var(--border-strong); }
.seg-item input { width: auto; margin: 0; }
.seg-item.on  { background: var(--brand-100); color: var(--brand-700); font-weight: 600; }
.seg-item.off { opacity: .45; cursor: not-allowed; }

/* 发布任务页的子任务行 */
.sub-row { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; }
.sub-row .sub-title { flex: 3 1 220px; min-width: 140px; }
.sub-row .sub-type, .sub-row .sub-assignee { flex: 1 1 130px; min-width: 110px; }
/* 子任务截止日期：flex 布局下日期控件默认太窄，给个下限，不然年份都被挤掉 */
.sub-row .sub-due { flex: 1 1 150px; min-width: 130px; }
.sub-row > button { flex: none; }

/* 点缩略图看大图的灯箱（附件里的图片、胶图） */
.imgview-mask {
  position: fixed; inset: 0; z-index: 200; background: rgba(8, 12, 10, .9);
  display: flex; flex-direction: column;
}
.imgview-bar {
  flex: none; display: flex; align-items: center; gap: 9px; padding: 10px 14px;
  color: #fff; background: rgba(0, 0, 0, .35);
}
.imgview-name {
  flex: 1; min-width: 0; font-size: 13px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.imgview-stage {
  flex: 1; min-height: 0; overflow: auto; padding: 14px;
  display: flex; align-items: center; justify-content: center;
}
.imgview-stage img {
  max-width: 100%; max-height: 100%; object-fit: contain;
  cursor: zoom-in; box-shadow: 0 6px 30px rgba(0, 0, 0, .55); background: #fff;
}
/* 原尺寸模式：不缩，直接出滚动条 —— 看胶图条带就得这样 */
.imgview-stage.is-actual { align-items: flex-start; justify-content: flex-start; }
.imgview-stage.is-actual img { max-width: none; max-height: none; cursor: zoom-out; }
.imgview-hint {
  flex: none; padding: 8px; text-align: center;
  color: rgba(255, 255, 255, .55); font-size: 11.5px;
}

/* 任务详情页的子任务勾选圈 */
.sub-check {
  flex: 0 0 20px; width: 20px; height: 20px; margin-top: 1px;
  border: 1.5px solid var(--border-strong); border-radius: 50%;
  background: var(--surface); color: #fff; font-size: 11px; line-height: 1;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; padding: 0; transition: all .12s;
}
.sub-check:hover:not(:disabled) { border-color: var(--brand-500); }
.sub-check.is-done { background: var(--ok); border-color: var(--ok); }
.sub-check:disabled { cursor: default; opacity: .7; }

/* 徽章 */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 8px; border-radius: 20px;
  font-size: 11.5px; font-weight: 600; line-height: 1.7;
  background: var(--surface-2); color: var(--text-2); border: 1px solid var(--border);
}
.badge-ok      { background: var(--ok-bg);     color: var(--ok);     border-color: transparent; }
.badge-warn    { background: var(--warn-bg);   color: var(--warn);   border-color: transparent; }
.badge-danger  { background: var(--danger-bg); color: var(--danger); border-color: transparent; }
.badge-info    { background: var(--info-bg);   color: var(--info);   border-color: transparent; }
.badge-brand   { background: var(--brand-100); color: var(--brand-700); border-color: transparent; }

/* 统计块 */
.stat {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 15px 16px; box-shadow: var(--shadow-1);
}
.stat .label { font-size: 12.5px; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.stat .value { font-size: 26px; font-weight: 650; margin-top: 5px; line-height: 1.15; }
.stat .value small { font-size: 13px; font-weight: 500; color: var(--muted); margin-left: 3px; }
.stat.alert { border-color: var(--danger); background: var(--danger-bg); }
.stat.alert .value, .stat.alert .label { color: var(--danger); }
.stat.clickable { cursor: pointer; transition: border-color .12s, box-shadow .12s; }
.stat.clickable:hover { border-color: var(--brand-500); box-shadow: var(--shadow-2); }

/* 表格 */
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
table.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
table.tbl th {
  text-align: left; padding: 9px 12px; font-weight: 600; font-size: 12.5px;
  color: var(--text-2); background: var(--surface-2);
  border-bottom: 1px solid var(--border); white-space: nowrap; position: sticky; top: 0;
}
table.tbl td { padding: 9px 12px; border-bottom: 1px solid var(--border); vertical-align: top; }
table.tbl tr:last-child td { border-bottom: 0; }
table.tbl tbody tr:hover { background: var(--brand-050); }
table.tbl td.num, table.tbl th.num { text-align: right; font-variant-numeric: tabular-nums; }
table.tbl td.mono { font-family: var(--font-mono); font-size: 12.5px; }

/* 空状态 */
.empty { text-align: center; padding: 44px 20px; color: var(--muted); }
.empty .big { font-size: 30px; opacity: .35; margin-bottom: 10px; }
.empty p { margin: 0 0 4px; }
.empty .sub { font-size: 12.5px; }

/* 提示条 */
.alert-bar {
  padding: 10px 14px; border-radius: var(--radius); font-size: 13px;
  margin-bottom: 14px; display: flex; gap: 9px; align-items: flex-start;
}
.alert-warn   { background: var(--warn-bg);   color: #7a5210; }
.alert-danger { background: var(--danger-bg); color: #8c2a1f; }
.alert-info   { background: var(--info-bg);   color: #22456f; }

/* Toast */
#toasts {
  position: fixed; right: 18px; bottom: 18px; z-index: 200;
  display: flex; flex-direction: column; gap: 8px; pointer-events: none;
}
.toast {
  background: #16211c; color: #fff; padding: 10px 15px; border-radius: var(--radius);
  font-size: 13px; box-shadow: var(--shadow-3); max-width: 380px;
  animation: slideIn .18s ease-out; pointer-events: auto;
}
.toast.err { background: #8c2a1f; }
.toast.ok  { background: var(--brand-700); }
@keyframes slideIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* 模态 */
.modal-mask {
  position: fixed; inset: 0; background: rgba(12, 24, 19, .45);
  display: flex; align-items: center; justify-content: center; z-index: 150; padding: 20px;
}
.modal {
  background: var(--surface); border-radius: 10px; box-shadow: var(--shadow-3);
  width: 100%; max-width: 520px; max-height: 88vh; display: flex; flex-direction: column;
}
.modal-head { padding: 15px 18px; border-bottom: 1px solid var(--border); font-weight: 600; font-size: 15px; }
.modal-body { padding: 18px; overflow-y: auto; }
.modal-foot {
  padding: 13px 18px; border-top: 1px solid var(--border);
  display: flex; justify-content: flex-end; gap: 9px;
}

/* 加载 */
.loading { padding: 40px; text-align: center; color: var(--muted); font-size: 13px; }
.spinner {
  width: 17px; height: 17px; border: 2px solid var(--border-strong);
  border-top-color: var(--brand-600); border-radius: 50%;
  display: inline-block; animation: spin .7s linear infinite; vertical-align: -3px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ------------------------------------------------------------------ 响应式 */
@media (max-width: 860px) {
  .app { flex-direction: column; }
  .sidebar {
    width: 100%; flex: none; height: auto; position: static;
    flex-direction: row; align-items: center; overflow-x: auto;
  }
  .sidebar-brand { border-bottom: 0; border-right: 1px solid rgba(255,255,255,.08); flex: 0 0 auto; }
  .sidebar-brand .sub { display: none; }
  .nav { display: flex; padding: 0; }
  .nav-group { display: none; }
  .nav a { border-left: 0; border-bottom: 3px solid transparent; padding: 12px 13px; white-space: nowrap; }
  .nav a.active { border-left: 0; border-bottom-color: var(--brand-500); }
  .sidebar-foot { display: none; }
  .content { padding: 14px; }
  .topbar { padding: 0 14px; }
  .row { flex-direction: column; gap: 0; }
  .row > * { margin-bottom: 0; }
}

@media print {
  .sidebar, .topbar, .page-head .actions { display: none; }
  .content { padding: 0; }
  .card { box-shadow: none; border-color: #ccc; }
}
