:root {
  --bg: #f4f5f7;
  --surface: #ffffff;
  --surface-soft: #f8f9fa;
  --sidebar: #f7f8fa;
  --text: #1f2329;
  --text-secondary: #4e5561;
  --muted: #7a828e;
  --faint: #a2a8b2;
  --border: #e3e6ea;
  --border-strong: #d3d8de;
  --primary: #3370ff;
  --primary-hover: #245bdb;
  --primary-soft: #eaf0ff;
  --primary-soft-2: #f2f6ff;
  --danger: #f54a45;
  --danger-soft: #fff0f0;
  --success: #2ea121;
  --success-soft: #eaf7e8;
  --warning: #d97706;
  --warning-soft: #fff7e8;
  --shadow-sm: 0 1px 2px rgba(31, 35, 41, 0.04);
  --shadow-md: 0 8px 28px rgba(31, 35, 41, 0.10);
  --shadow-lg: 0 20px 60px rgba(31, 35, 41, 0.16);
  --radius-sm: 7px;
  --radius: 10px;
  --radius-lg: 14px;
  --sidebar-w: 228px;
  --topbar-h: 56px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", Arial, sans-serif;
  --mono: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
}

* { box-sizing: border-box; }
html { height: 100%; }
body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, textarea, select { font: inherit; }
button { cursor: pointer; }
::selection { background: #d9e4ff; }
:focus-visible { outline: 2px solid rgba(51, 112, 255, 0.55); outline-offset: 2px; }

/* scrollbars */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: #cfd4da; border: 3px solid transparent; background-clip: content-box; border-radius: 999px; }
::-webkit-scrollbar-thumb:hover { background: #aeb5bf; border: 3px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-track { background: transparent; }

.boot-screen {
  position: fixed;
  inset: 0;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 14px;
  background: var(--bg);
  z-index: 1000;
}
.boot-text { color: var(--muted); font-size: 13px; letter-spacing: 0.08em; }
.brand-mark {
  width: 36px;
  height: 36px;
  display: inline-grid;
  place-items: center;
  border-radius: 10px;
  background: var(--primary);
  color: #fff;
  font-weight: 700;
  font-size: 17px;
  letter-spacing: -0.03em;
  box-shadow: 0 4px 12px rgba(51, 112, 255, 0.24);
  flex: none;
}
.brand-mark-lg { width: 52px; height: 52px; border-radius: 14px; font-size: 24px; }
.brand-mark-soft { background: var(--primary-soft); color: var(--primary); box-shadow: none; }

/* ---------- generic ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 34px;
  padding: 0 13px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: #fff;
  color: var(--text);
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  transition: background .16s ease, border-color .16s ease, color .16s ease, box-shadow .16s ease, transform .06s ease;
}
.btn:hover { background: var(--surface-soft); border-color: #c6ccd4; text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: not-allowed; transform: none; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; box-shadow: 0 2px 6px rgba(51, 112, 255, .18); }
.btn-primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); color: #fff; }
.btn-ghost { border-color: transparent; background: transparent; color: var(--text-secondary); }
.btn-ghost:hover { background: rgba(31, 35, 41, .06); border-color: transparent; }
.btn-danger { color: var(--danger); border-color: #f6c6c4; background: #fff; }
.btn-danger:hover { background: var(--danger-soft); border-color: #f2aaa7; }
.btn-danger-solid { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-danger-solid:hover { background: #d93f3a; border-color: #d93f3a; color: #fff; }
.btn-sm { height: 28px; padding: 0 9px; font-size: 12px; border-radius: 6px; }
.btn-lg { height: 42px; padding: 0 18px; font-size: 14px; border-radius: 9px; }
.btn-block { width: 100%; }
.btn-icon { width: 34px; padding: 0; }
.btn-icon.btn-sm { width: 28px; }
.btn .icon { flex: none; }
.btn.is-loading { color: transparent !important; position: relative; pointer-events: none; }
.btn.is-loading::after {
  content: "";
  position: absolute;
  width: 14px; height: 14px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: spin .7s linear infinite;
  color: #fff;
}
.btn:not(.btn-primary):not(.btn-danger-solid).is-loading::after { color: var(--text); }
@keyframes spin { to { transform: rotate(360deg); } }

.icon { display: inline-block; vertical-align: -2px; }

.field { display: grid; gap: 7px; }
.field > label { font-size: 13px; font-weight: 550; color: var(--text-secondary); }
.field .hint { font-size: 12px; color: var(--muted); line-height: 1.5; }
.input, .textarea, .select {
  width: 100%;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: #fff;
  color: var(--text);
  padding: 8px 11px;
  font-size: 14px;
  transition: border-color .16s ease, box-shadow .16s ease, background .16s ease;
}
.input { height: 36px; }
.textarea { min-height: 92px; resize: vertical; line-height: 1.65; }
.input:hover, .textarea:hover, .select:hover { border-color: #c3c9d1; }
.input:focus, .textarea:focus, .select:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(51, 112, 255, .12); outline: none; }
.input::placeholder, .textarea::placeholder { color: var(--faint); }
.input:disabled, .textarea:disabled, .select:disabled { background: var(--surface-soft); color: var(--muted); cursor: not-allowed; }
.input-sm { height: 30px; font-size: 13px; padding: 0 9px; }
.input-code { letter-spacing: .4em; text-align: center; font-family: var(--mono); font-size: 20px; font-weight: 700; height: 46px; }
.form-error {
  display: none;
  padding: 9px 11px;
  border-radius: var(--radius-sm);
  background: var(--danger-soft);
  color: #c73530;
  font-size: 13px;
  line-height: 1.5;
}
.form-error.show { display: block; }
.form-notice {
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: var(--primary-soft-2);
  border: 1px solid #dce6ff;
  color: #2a5bd7;
  font-size: 13px;
  line-height: 1.55;
}
.form-notice.warn { background: var(--warning-soft); border-color: #f8e3bd; color: #a35a04; }

.switch { position: relative; display: inline-flex; width: 40px; height: 23px; flex: none; }
.switch input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; z-index: 1; }
.switch span { position: absolute; inset: 0; border-radius: 999px; background: #c9ced6; transition: background .18s ease; }
.switch span::after {
  content: "";
  position: absolute;
  top: 3px; left: 3px;
  width: 17px; height: 17px;
  background: #fff;
  border-radius: 50%;
  box-shadow: 0 1px 3px rgba(31,35,41,.25);
  transition: transform .18s ease;
}
.switch input:checked + span { background: var(--primary); }
.switch input:checked + span::after { transform: translateX(17px); }
.switch input:disabled + span { opacity: .55; }

.checkbox { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; font-size: 13px; }
.checkbox input { width: 16px; height: 16px; accent-color: var(--primary); }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 21px;
  padding: 0 7px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  line-height: 1;
  white-space: nowrap;
  background: #eef0f3;
  color: #5d6570;
}
.badge-blue { background: var(--primary-soft); color: #245bdb; }
.badge-green { background: var(--success-soft); color: #277f1c; }
.badge-orange { background: var(--warning-soft); color: #a35a04; }
.badge-red { background: var(--danger-soft); color: #c73530; }
.badge-purple { background: #f3edff; color: #6b3fd4; }

.tag {
  display: inline-flex;
  align-items: center;
  height: 22px;
  padding: 0 8px;
  border-radius: 5px;
  background: var(--surface-soft);
  border: 1px solid var(--border);
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}
.tag-btn { cursor: pointer; transition: all .15s ease; }
.tag-btn:hover, .tag-btn.active { background: var(--primary-soft); border-color: #c8d8ff; color: #245bdb; }

.avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  display: inline-grid;
  place-items: center;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: -0.02em;
  flex: none;
  user-select: none;
}
.avatar-xs { width: 22px; height: 22px; font-size: 9px; }
.avatar-sm { width: 26px; height: 26px; font-size: 10px; }
.avatar-lg { width: 52px; height: 52px; font-size: 18px; }
.avatar-stack { display: inline-flex; align-items: center; }
.avatar-stack .avatar { margin-left: -6px; border: 2px solid #fff; }
.avatar-stack .avatar:first-child { margin-left: 0; }

.muted { color: var(--muted); }
.faint { color: var(--faint); }
.small { font-size: 12px; }
.mono { font-family: var(--mono); }
.flex { display: flex; align-items: center; }
.flex-wrap { flex-wrap: wrap; }
.gap-4 { gap: 4px; } .gap-6 { gap: 6px; } .gap-8 { gap: 8px; } .gap-10 { gap: 10px; } .gap-12 { gap: 12px; } .gap-16 { gap: 16px; } .gap-20 { gap: 20px; }
.spacer { flex: 1; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.hidden { display: none !important; }
.divider { height: 1px; background: var(--border); margin: 16px 0; border: 0; }
.dot { width: 6px; height: 6px; border-radius: 50%; background: var(--primary); display: inline-block; }
.dot-red { background: var(--danger); }
.link-btn { border: 0; background: none; padding: 0; color: var(--primary); font-size: 13px; }
.link-btn:hover { text-decoration: underline; }
.icon-btn {
  width: 32px; height: 32px;
  border: 0; background: transparent; color: var(--text-secondary);
  border-radius: 7px; display: inline-grid; place-items: center;
}
.icon-btn:hover { background: rgba(31,35,41,.06); }
.top-badge {
  position: absolute;
  top: 3px; right: 2px;
  min-width: 15px; height: 15px;
  padding: 0 4px;
  border-radius: 999px;
  background: var(--danger);
  color: #fff;
  font-size: 9px;
  font-weight: 700;
  line-height: 15px;
  text-align: center;
  border: 2px solid #fff;
}

/* ---------- auth ---------- */
.auth-page {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1.05fr .95fr;
  background: var(--surface);
}
.auth-side {
  position: relative;
  overflow: hidden;
  padding: 58px 64px;
  background:
    radial-gradient(900px 500px at 10% 0%, #e8efff 0%, transparent 60%),
    radial-gradient(700px 500px at 100% 100%, #eef4ff 0%, transparent 55%),
    #f7f9fd;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  border-right: 1px solid #e9edf5;
}
.auth-side::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image: linear-gradient(rgba(51,112,255,.045) 1px, transparent 1px), linear-gradient(90deg, rgba(51,112,255,.045) 1px, transparent 1px);
  background-size: 44px 44px;
  mask-image: linear-gradient(180deg, rgba(0,0,0,.8), transparent 75%);
  pointer-events: none;
}
.auth-side > * { position: relative; z-index: 1; }
.auth-brand { display: flex; align-items: center; gap: 12px; font-size: 16px; font-weight: 700; }
.auth-side-copy { max-width: 500px; }
.auth-side-copy h1 { font-size: clamp(30px, 3vw, 46px); line-height: 1.25; letter-spacing: -0.03em; margin: 0 0 18px; font-weight: 750; }
.auth-side-copy p { color: var(--text-secondary); font-size: 15px; line-height: 1.8; margin: 0 0 28px; max-width: 430px; }
.auth-feature-list { display: grid; gap: 14px; margin: 0; padding: 0; list-style: none; }
.auth-feature-list li { display: flex; align-items: flex-start; gap: 10px; color: var(--text-secondary); font-size: 14px; }
.auth-feature-list .icon { color: var(--primary); margin-top: 2px; }
.auth-side-foot { color: var(--faint); font-size: 12px; }
.auth-main { display: grid; place-items: center; padding: 40px 32px; }
.auth-card { width: min(388px, 100%); }
.auth-card h2 { font-size: 26px; letter-spacing: -0.02em; margin: 0 0 8px; }
.auth-card .sub { color: var(--muted); font-size: 14px; margin: 0 0 26px; line-height: 1.6; }
.auth-form { display: grid; gap: 16px; }
.auth-card .btn-lg { margin-top: 4px; }
.auth-back { display: inline-flex; align-items: center; gap: 5px; color: var(--muted); font-size: 13px; margin-bottom: 20px; border: 0; background: none; padding: 0; }
.auth-back:hover { color: var(--text); }
.auth-email-chip {
  display: flex; align-items: center; gap: 8px;
  background: var(--surface-soft); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 9px 11px; font-size: 13px; color: var(--text-secondary);
}
.auth-code-actions { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.auth-foot-note { margin-top: 22px; color: var(--faint); font-size: 12px; line-height: 1.6; text-align: center; }

/* ---------- shell ---------- */
.app-shell { min-height: 100vh; }
.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: var(--sidebar-w);
  background: var(--sidebar);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 14px 12px 12px;
  z-index: 50;
}
.sidebar-head { display: flex; align-items: center; gap: 10px; padding: 5px 8px 18px; }
.sidebar-brand { font-weight: 700; font-size: 15px; letter-spacing: -0.01em; }
.sidebar-brand small { display: block; font-size: 10px; color: var(--faint); font-weight: 500; letter-spacing: .12em; margin-top: 1px; }
.nav { display: grid; gap: 2px; }
.nav-section { padding: 13px 10px 6px; font-size: 11px; color: var(--faint); font-weight: 600; letter-spacing: .06em; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  height: 36px;
  padding: 0 10px;
  border-radius: 7px;
  color: var(--text-secondary);
  font-size: 13.5px;
  font-weight: 500;
  text-decoration: none;
  position: relative;
  transition: background .14s ease, color .14s ease;
}
.nav-item:hover { background: rgba(31,35,41,.055); color: var(--text); text-decoration: none; }
.nav-item.active { background: var(--primary-soft); color: var(--primary); font-weight: 600; }
.nav-item .icon { color: var(--muted); flex: none; }
.nav-item.active .icon { color: var(--primary); }
.nav-item .nav-badge {
  margin-left: auto;
  min-width: 17px; height: 17px;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--danger);
  color: #fff;
  font-size: 10px;
  line-height: 17px;
  text-align: center;
  font-weight: 700;
}
.nav-item .nav-badge.quiet { background: #d9dde3; color: #5d6570; }
.sidebar-spacer { flex: 1; }
.sidebar-foot { border-top: 1px solid var(--border); padding-top: 10px; }
.user-card {
  display: flex; align-items: center; gap: 9px;
  width: 100%;
  padding: 8px;
  border: 0;
  background: transparent;
  border-radius: 8px;
  text-align: left;
  color: var(--text);
}
.user-card:hover { background: rgba(31,35,41,.055); }
.user-card .user-meta { min-width: 0; flex: 1; }
.user-card .user-name { font-size: 13px; font-weight: 600; }
.user-card .user-role { font-size: 11px; color: var(--faint); }

.main { margin-left: var(--sidebar-w); min-height: 100vh; display: flex; flex-direction: column; }
.topbar {
  height: var(--topbar-h);
  position: sticky; top: 0;
  z-index: 30;
  display: flex; align-items: center; gap: 14px;
  padding: 0 26px;
  background: rgba(255,255,255,.92);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.topbar-left { display: flex; align-items: center; gap: 10px; min-width: 0; flex: 1; }
.topbar-title { font-size: 14px; font-weight: 600; }
.topbar-search {
  width: min(420px, 40vw);
  position: relative;
  display: flex; align-items: center;
}
.topbar-search .icon { position: absolute; left: 10px; color: var(--faint); pointer-events: none; }
.topbar-search input {
  width: 100%; height: 32px;
  border: 1px solid transparent;
  background: var(--surface-soft);
  border-radius: 7px;
  padding: 0 12px 0 32px;
  font-size: 13px;
  color: var(--text);
}
.topbar-search input:hover { background: #f1f3f5; }
.topbar-search input:focus { background: #fff; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(51,112,255,.1); outline: none; }
.topbar-actions { display: flex; align-items: center; gap: 8px; }
.topbar-btn { position: relative; }
.topbar-sep { width: 1px; height: 20px; background: var(--border); margin: 0 2px; }
.menu-toggle { display: none; }
.content { width: 100%; padding: 26px 30px 60px; }
.page { max-width: 1240px; margin: 0 auto; }
.page-wide { max-width: 1440px; }

/* ---------- popover / menus ---------- */
.popover {
  position: fixed;
  z-index: 120;
  width: 320px;
  max-width: calc(100vw - 20px);
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  overflow: hidden;
}
.popover-head { display: flex; align-items: center; justify-content: space-between; padding: 12px 14px; border-bottom: 1px solid var(--border); }
.popover-title { font-size: 13px; font-weight: 650; }
.popover-list { max-height: 380px; overflow: auto; }
.popover-item {
  display: flex; gap: 10px; align-items: flex-start;
  padding: 11px 14px;
  border: 0; background: transparent; width: 100%; text-align: left;
  border-bottom: 1px solid #f1f3f5;
}
.popover-item:last-child { border-bottom: 0; }
.popover-item:hover { background: var(--surface-soft); }
.popover-item .pop-main { min-width: 0; flex: 1; }
.popover-item .pop-text { font-size: 12.5px; line-height: 1.5; color: var(--text-secondary); }
.popover-item .pop-time { font-size: 11px; color: var(--faint); margin-top: 2px; }
.popover-item.unread { background: #f7faff; }
.popover-item.unread:hover { background: #eff5ff; }
.popover-foot { padding: 9px 14px; border-top: 1px solid var(--border); text-align: center; }
.menu {
  position: fixed;
  z-index: 130;
  min-width: 180px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 9px;
  box-shadow: var(--shadow-md);
  padding: 5px;
}
.menu-item {
  display: flex; align-items: center; gap: 9px;
  width: 100%;
  height: 34px;
  padding: 0 9px;
  border: 0; background: transparent; border-radius: 6px;
  font-size: 13px; color: var(--text);
  text-align: left;
}
.menu-item:hover { background: var(--surface-soft); }
.menu-item.danger { color: var(--danger); }
.menu-item.danger:hover { background: var(--danger-soft); }
.menu-sep { height: 1px; background: var(--border); margin: 5px 4px; }

/* ---------- headers / sections ---------- */
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; margin-bottom: 22px; }
.page-title { font-size: 26px; line-height: 1.25; font-weight: 700; letter-spacing: -0.025em; margin: 0 0 6px; }
.page-sub { color: var(--muted); font-size: 13.5px; margin: 0; }
.page-head-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.section { margin-top: 28px; }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.section-title { font-size: 15px; font-weight: 650; margin: 0; display: flex; align-items: center; gap: 8px; }
.section-title .count { font-size: 12px; color: var(--faint); font-weight: 500; }
.section-more { font-size: 12.5px; color: var(--muted); }
.section-more:hover { color: var(--primary); text-decoration: none; }

.hero-card {
  position: relative;
  overflow: hidden;
  background: linear-gradient(120deg, #f2f6ff 0%, #fbfcff 55%, #f7f9ff 100%);
  border: 1px solid #e0e8fa;
  border-radius: var(--radius-lg);
  padding: 28px 30px;
  display: flex; align-items: center; justify-content: space-between; gap: 24px;
}
.hero-card::after {
  content: "";
  position: absolute;
  right: -40px; top: -70px;
  width: 270px; height: 270px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(51,112,255,.10), transparent 68%);
  pointer-events: none;
}
.hero-eyebrow { font-size: 12px; color: var(--primary); font-weight: 650; letter-spacing: .05em; margin-bottom: 7px; }
.hero-title { font-size: 28px; line-height: 1.3; font-weight: 720; letter-spacing: -0.03em; margin: 0 0 8px; }
.hero-sub { color: var(--text-secondary); font-size: 14px; margin: 0; }
.hero-actions { display: flex; gap: 9px; flex-wrap: wrap; position: relative; z-index: 1; }

.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-top: 16px; }
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 15px 16px;
  display: flex; align-items: center; gap: 12px;
  transition: border-color .15s ease, box-shadow .15s ease;
}
.stat-card:hover { border-color: #d4dae3; box-shadow: var(--shadow-sm); }
.stat-icon { width: 36px; height: 36px; border-radius: 9px; display: grid; place-items: center; background: var(--primary-soft); color: var(--primary); flex: none; }
.stat-icon.green { background: var(--success-soft); color: var(--success); }
.stat-icon.orange { background: var(--warning-soft); color: var(--warning); }
.stat-icon.purple { background: #f3edff; color: #6b3fd4; }
.stat-value { font-size: 22px; line-height: 1.1; font-weight: 700; letter-spacing: -0.02em; }
.stat-label { font-size: 12px; color: var(--muted); margin-top: 3px; }

/* ---------- docs list ---------- */
.toolbar-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.tabs { display: flex; align-items: center; gap: 2px; border-bottom: 1px solid var(--border); }
.tab {
  position: relative;
  height: 38px; padding: 0 13px;
  border: 0; background: none;
  color: var(--muted); font-size: 13.5px; font-weight: 500;
}
.tab:hover { color: var(--text); text-decoration: none; }
.tab.active { color: var(--primary); font-weight: 600; }
.tab.active::after { content: ""; position: absolute; left: 12px; right: 12px; bottom: -1px; height: 2px; border-radius: 2px 2px 0 0; background: var(--primary); }
.tab .tab-count { font-size: 11px; color: var(--faint); margin-left: 4px; }
.filter-bar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.search-inline { position: relative; width: 240px; }
.search-inline .icon { position: absolute; left: 9px; top: 50%; transform: translateY(-50%); color: var(--faint); }
.search-inline input { padding-left: 30px; height: 32px; font-size: 13px; }
.tag-bar { display: flex; gap: 6px; flex-wrap: wrap; margin: 0 0 14px; }

.doc-list { display: grid; gap: 8px; }
.doc-row {
  display: flex; align-items: flex-start; gap: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 15px 17px;
  cursor: pointer;
  transition: border-color .15s ease, box-shadow .15s ease, transform .08s ease;
}
.doc-row:hover { border-color: #cbd6ea; box-shadow: 0 4px 16px rgba(31,35,41,.05); text-decoration: none; }
.doc-row:active { transform: translateY(1px); }
.doc-row-icon { width: 38px; height: 38px; border-radius: 9px; background: var(--primary-soft-2); color: var(--primary); display: grid; place-items: center; flex: none; }
.doc-row-main { min-width: 0; flex: 1; }
.doc-row-title-line { display: flex; align-items: center; gap: 8px; min-width: 0; }
.doc-row-title { font-size: 14.5px; font-weight: 600; color: var(--text); margin: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.doc-row-excerpt { color: var(--muted); font-size: 12.5px; line-height: 1.6; margin: 4px 0 0; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 1; -webkit-box-orient: vertical; }
.doc-row-meta { display: flex; align-items: center; gap: 12px; margin-top: 8px; color: var(--faint); font-size: 11.5px; flex-wrap: wrap; }
.doc-row-meta > span { display: inline-flex; align-items: center; gap: 4px; }
.doc-row-side { display: flex; align-items: center; gap: 6px; padding-top: 2px; flex: none; }
.doc-row.is-favorite .doc-row-icon { background: #fff8e6; color: #d97706; }
.doc-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.doc-card {
  background: #fff; border: 1px solid var(--border); border-radius: var(--radius);
  padding: 17px; cursor: pointer; display: flex; flex-direction: column; min-height: 170px;
  transition: border-color .15s ease, box-shadow .15s ease;
}
.doc-card:hover { border-color: #cbd6ea; box-shadow: 0 6px 20px rgba(31,35,41,.06); }
.doc-card-top { display: flex; align-items: flex-start; gap: 10px; }
.doc-card-title { font-size: 14.5px; font-weight: 620; line-height: 1.45; margin: 0; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.doc-card-excerpt { color: var(--muted); font-size: 12.5px; line-height: 1.65; margin: 8px 0 14px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; flex: 1; }
.doc-card-meta { display: flex; align-items: center; gap: 8px; color: var(--faint); font-size: 11.5px; margin-top: auto; }
.doc-card-meta .avatar { margin-left: auto; }

.empty-state {
  display: grid; justify-items: center; text-align: center;
  padding: 64px 24px;
  background: #fff;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-lg);
  color: var(--muted);
}
.empty-icon { width: 52px; height: 52px; border-radius: 14px; display: grid; place-items: center; background: var(--surface-soft); color: var(--faint); margin-bottom: 14px; }
.empty-state h3 { margin: 0 0 5px; font-size: 15px; color: var(--text); font-weight: 600; }
.empty-state p { margin: 0 0 16px; font-size: 13px; line-height: 1.6; max-width: 360px; }
.skeleton { background: linear-gradient(90deg, #f0f2f5 25%, #f7f8fa 37%, #f0f2f5 63%); background-size: 400% 100%; animation: shimmer 1.2s infinite; border-radius: 6px; }
@keyframes shimmer { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }

/* ---------- document view ---------- */
.doc-view { max-width: 1440px; margin: 0 auto; }
.doc-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; margin-bottom: 18px; }
.doc-header-main { min-width: 0; flex: 1; }
.doc-title { font-size: 30px; line-height: 1.3; letter-spacing: -0.03em; font-weight: 720; margin: 0 0 8px; overflow-wrap: anywhere; }
.doc-subline { display: flex; align-items: center; gap: 9px; flex-wrap: wrap; color: var(--muted); font-size: 12.5px; }
.doc-subline .sep { width: 3px; height: 3px; border-radius: 50%; background: #c6ccd4; }
.doc-actions { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; flex: none; padding-top: 3px; }
.doc-tags { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 10px; }
.doc-layout { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 18px; align-items: start; }
.doc-main-card { background: #fff; border: 1px solid var(--border); border-radius: var(--radius-lg); min-height: 460px; }
.doc-content { padding: 34px 42px 60px; }
.doc-content .markdown-body { max-width: 820px; margin: 0 auto; }
.comments-panel {
  background: #fff; border: 1px solid var(--border); border-radius: var(--radius-lg);
  position: sticky; top: calc(var(--topbar-h) + 18px);
  max-height: calc(100vh - var(--topbar-h) - 36px);
  display: flex; flex-direction: column; overflow: hidden;
}
.comments-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 13px 15px; border-bottom: 1px solid var(--border); flex: none; }
.comments-title { font-size: 14px; font-weight: 650; display: flex; align-items: center; gap: 7px; }
.comments-body { overflow: auto; padding: 13px 15px 18px; flex: 1; }
.comments-empty { text-align: center; padding: 40px 16px; color: var(--muted); font-size: 13px; }
.comments-empty .icon { color: var(--faint); margin-bottom: 8px; }
.comment-composer { border: 1px solid var(--border-strong); border-radius: var(--radius); padding: 9px; background: #fff; transition: border-color .15s ease, box-shadow .15s ease; }
.comment-composer:focus-within { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(51,112,255,.10); }
.comment-composer textarea { width: 100%; border: 0; resize: vertical; min-height: 58px; padding: 2px; font-size: 13px; line-height: 1.6; outline: none; background: transparent; }
.composer-foot { display: flex; align-items: center; gap: 6px; margin-top: 6px; }
.composer-foot .spacer { flex: 1; }
.quote-preview { display: flex; gap: 8px; border-left: 2px solid var(--primary); background: var(--primary-soft-2); padding: 7px 9px; border-radius: 0 6px 6px 0; font-size: 12px; color: var(--text-secondary); margin-bottom: 7px; line-height: 1.5; }
.quote-preview .quote-text { overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.quote-remove { border: 0; background: none; color: var(--faint); padding: 0 2px; }
.comment-thread { padding: 15px 0; border-bottom: 1px solid #f0f2f4; }
.comment-thread:first-child { padding-top: 2px; }
.comment-thread:last-child { border-bottom: 0; padding-bottom: 2px; }
.comment { display: flex; gap: 9px; }
.comment-main { min-width: 0; flex: 1; }
.comment-head { display: flex; align-items: center; gap: 7px; min-width: 0; }
.comment-author { font-size: 12.5px; font-weight: 600; color: var(--text); }
.comment-time { font-size: 11px; color: var(--faint); }
.comment-body { font-size: 13px; line-height: 1.65; color: var(--text-secondary); margin-top: 4px; overflow-wrap: anywhere; }
.comment-body .mention { color: var(--primary); background: var(--primary-soft); border-radius: 3px; padding: 0 2px; }
.comment-quote { border-left: 2px solid #d8dde4; background: var(--surface-soft); color: var(--muted); font-size: 12px; line-height: 1.55; padding: 6px 8px; border-radius: 0 5px 5px 0; margin: 5px 0 6px; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.comment-actions { display: flex; align-items: center; gap: 10px; margin-top: 5px; opacity: .72; transition: opacity .15s ease; }
.comment:hover .comment-actions { opacity: 1; }
.comment-action { border: 0; background: none; padding: 0; color: var(--faint); font-size: 11.5px; }
.comment-action:hover { color: var(--text-secondary); }
.comment-action.danger:hover { color: var(--danger); }
.comment-resolved { color: var(--success); font-size: 11.5px; display: inline-flex; align-items: center; gap: 3px; }
.comment-replies { margin-top: 11px; padding-left: 34px; display: grid; gap: 11px; }
.comment-reply { display: flex; gap: 8px; }
.comment-reply .avatar { width: 24px; height: 24px; font-size: 9px; }
.comment-reply .comment-author { font-size: 12px; }
.comment-reply .comment-body { font-size: 12.5px; }
.comment-deleted { color: var(--faint); font-size: 12px; font-style: italic; }
.selection-comment-btn {
  position: fixed;
  z-index: 140;
  display: inline-flex; align-items: center; gap: 5px;
  height: 32px; padding: 0 11px;
  border-radius: 7px;
  border: 0;
  background: var(--text);
  color: #fff;
  font-size: 12px;
  box-shadow: var(--shadow-md);
}
.selection-comment-btn:hover { background: #000; }
.viewers-bar { display: flex; align-items: center; gap: 7px; color: var(--faint); font-size: 11.5px; }
.viewers-bar .avatar-stack .avatar { border-color: #fff; }

/* markdown */
.markdown-body { font-size: 15px; line-height: 1.85; color: #24292f; overflow-wrap: anywhere; }
.markdown-body > *:first-child { margin-top: 0 !important; }
.markdown-body > *:last-child { margin-bottom: 0 !important; }
.markdown-body h1, .markdown-body h2, .markdown-body h3, .markdown-body h4, .markdown-body h5, .markdown-body h6 { line-height: 1.4; margin: 1.6em 0 .65em; font-weight: 680; letter-spacing: -0.015em; color: #14171a; }
.markdown-body h1 { font-size: 1.7em; padding-bottom: .3em; border-bottom: 1px solid #eceff2; }
.markdown-body h2 { font-size: 1.4em; padding-bottom: .25em; border-bottom: 1px solid #f0f2f4; }
.markdown-body h3 { font-size: 1.18em; }
.markdown-body p { margin: .7em 0; }
.markdown-body ul, .markdown-body ol { padding-left: 1.55em; margin: .7em 0; }
.markdown-body li { margin: .25em 0; }
.markdown-body li > p { margin: .2em 0; }
.markdown-body blockquote { margin: 1em 0; padding: .6em 1em; color: #57606a; background: #f8f9fa; border-left: 3px solid #d0d7de; border-radius: 0 6px 6px 0; }
.markdown-body blockquote > *:first-child { margin-top: 0; }
.markdown-body blockquote > *:last-child { margin-bottom: 0; }
.markdown-body code {
  font-family: var(--mono);
  font-size: .88em;
  background: #f2f4f7;
  border: 1px solid #e5e8ec;
  border-radius: 4px;
  padding: .12em .38em;
  color: #b54708;
}
.markdown-body pre {
  position: relative;
  background: #1f2329;
  color: #e6e8eb;
  border-radius: 9px;
  padding: 16px 18px;
  overflow: auto;
  line-height: 1.6;
  margin: 1em 0;
  font-size: 13px;
}
.markdown-body pre code { background: none; border: 0; padding: 0; color: inherit; font-size: 13px; }
.markdown-body pre .code-copy {
  position: absolute; top: 7px; right: 7px;
  height: 25px; padding: 0 8px;
  border: 1px solid rgba(255,255,255,.18);
  background: rgba(255,255,255,.08);
  color: #c9ced6; border-radius: 5px; font-size: 11px;
  opacity: 0; transition: opacity .15s ease;
}
.markdown-body pre:hover .code-copy { opacity: 1; }
.markdown-body pre .code-copy:hover { background: rgba(255,255,255,.15); color: #fff; }
.markdown-body a { color: var(--primary); text-decoration: underline; text-underline-offset: 2px; }
.markdown-body img { max-width: 100%; border-radius: 8px; border: 1px solid var(--border); }
.markdown-body hr { border: 0; border-top: 1px solid var(--border); margin: 2em 0; }
.markdown-body table { border-collapse: collapse; width: 100%; margin: 1em 0; font-size: 13.5px; display: block; overflow-x: auto; }
.markdown-body th, .markdown-body td { border: 1px solid var(--border); padding: 7px 10px; text-align: left; vertical-align: top; }
.markdown-body th { background: var(--surface-soft); font-weight: 650; }
.markdown-body tr:nth-child(2n) td { background: #fbfcfd; }
.markdown-body .task-list-item { list-style: none; }
.markdown-body input[type="checkbox"] { margin-right: 6px; }

/* ---------- editor ---------- */
.editor-shell { max-width: 1440px; margin: 0 auto; }
.editor-head { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.editor-head-main { flex: 1; min-width: 260px; display: flex; align-items: center; gap: 10px; }
.editor-title-input {
  width: 100%;
  border: 1px solid transparent;
  background: transparent;
  font-size: 24px;
  line-height: 1.35;
  font-weight: 700;
  letter-spacing: -0.02em;
  padding: 4px 7px;
  border-radius: 6px;
  color: var(--text);
}
.editor-title-input:hover { background: rgba(31,35,41,.04); }
.editor-title-input:focus { background: #fff; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(51,112,255,.1); outline: none; }
.editor-status { font-size: 11.5px; color: var(--faint); white-space: nowrap; }
.editor-status.dirty { color: var(--warning); }
.editor-status.error { color: var(--danger); }
.editor-meta { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; padding-left: 7px; }
.editor-meta .tag-input {
  border: 0; background: transparent; font-size: 12px; color: var(--muted);
  border-bottom: 1px dashed transparent; padding: 3px 0; width: 180px;
}
.editor-meta .tag-input:focus { outline: none; border-bottom-color: var(--border-strong); }
.editor-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; min-height: calc(100vh - 220px); }
.editor-pane { background: #fff; border: 1px solid var(--border); border-radius: var(--radius); display: flex; flex-direction: column; min-height: 480px; overflow: hidden; }
.editor-toolbar { display: flex; align-items: center; gap: 2px; padding: 7px 9px; border-bottom: 1px solid var(--border); flex-wrap: wrap; background: var(--surface-soft); }
.toolbar-btn { width: 30px; height: 28px; border: 0; background: transparent; border-radius: 5px; color: var(--text-secondary); display: grid; place-items: center; font-size: 12px; font-weight: 700; }
.toolbar-btn:hover { background: rgba(31,35,41,.07); color: var(--text); }
.toolbar-sep { width: 1px; height: 17px; background: var(--border); margin: 0 4px; }
.editor-textarea {
  flex: 1;
  width: 100%;
  border: 0;
  resize: none;
  padding: 20px 22px 40px;
  font-family: var(--mono);
  font-size: 13px;
  line-height: 1.75;
  color: #24292f;
  background: #fff;
  outline: none;
  min-height: 420px;
}
.editor-preview { background: #fff; border: 1px solid var(--border); border-radius: var(--radius); overflow: auto; padding: 26px 30px 50px; min-height: 480px; }
.editor-preview .markdown-body { max-width: 760px; margin: 0 auto; }
.editor-grid.single { grid-template-columns: 1fr; }
.editor-grid.single .editor-preview { display: none; }
.editor-grid.preview-only .editor-pane { display: none; }
.editor-grid.preview-only { grid-template-columns: 1fr; }
.editor-hint { font-size: 11.5px; color: var(--faint); padding: 7px 12px; border-top: 1px solid var(--border); display: flex; justify-content: space-between; gap: 10px; }

/* ---------- messages ---------- */
.messages-layout { display: grid; grid-template-columns: 300px minmax(0, 1fr); gap: 0; height: calc(100vh - var(--topbar-h) - 60px); min-height: 460px; background: #fff; border: 1px solid var(--border); border-radius: var(--radius-lg); overflow: hidden; }
.conversation-list { border-right: 1px solid var(--border); display: flex; flex-direction: column; min-height: 0; }
.conversation-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 14px 15px; border-bottom: 1px solid var(--border); flex: none; }
.conversation-title { font-size: 15px; font-weight: 650; }
.conversations { overflow: auto; flex: 1; padding: 6px; }
.conversation {
  display: flex; gap: 10px; align-items: flex-start;
  padding: 11px 10px;
  border-radius: 8px;
  cursor: pointer;
  border: 0; background: transparent; width: 100%; text-align: left;
}
.conversation:hover { background: var(--surface-soft); text-decoration: none; }
.conversation.active { background: var(--primary-soft); }
.conversation-main { min-width: 0; flex: 1; }
.conversation-line { display: flex; align-items: center; gap: 8px; }
.conversation-name { font-size: 13px; font-weight: 600; min-width: 0; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conversation-time { font-size: 10.5px; color: var(--faint); flex: none; }
.conversation-preview { font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin-top: 2px; }
.conversation-unread { min-width: 17px; height: 17px; padding: 0 5px; border-radius: 999px; background: var(--danger); color: #fff; font-size: 10px; line-height: 17px; text-align: center; font-weight: 700; }
.chat-panel { display: flex; flex-direction: column; min-width: 0; min-height: 0; background: #fafbfc; }
.chat-head { display: flex; align-items: center; gap: 10px; padding: 12px 18px; border-bottom: 1px solid var(--border); background: #fff; flex: none; }
.chat-name { font-size: 14px; font-weight: 650; }
.chat-status { font-size: 11px; color: var(--faint); }
.chat-messages { flex: 1; overflow: auto; padding: 22px 24px 30px; display: flex; flex-direction: column; gap: 3px; }
.chat-empty { margin: auto; text-align: center; color: var(--muted); font-size: 13px; }
.msg-row { display: flex; gap: 8px; margin: 5px 0; align-items: flex-end; }
.msg-row.mine { flex-direction: row-reverse; }
.msg-bubble {
  max-width: min(68%, 620px);
  padding: 9px 12px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 12px 12px 12px 4px;
  font-size: 13.5px;
  line-height: 1.6;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  box-shadow: 0 1px 1px rgba(31,35,41,.03);
}
.msg-row.mine .msg-bubble { background: var(--primary); border-color: var(--primary); color: #fff; border-radius: 12px 12px 4px 12px; }
.msg-time { font-size: 10px; color: var(--faint); margin: 0 4px 2px; flex: none; }
.chat-day { text-align: center; font-size: 11px; color: var(--faint); margin: 16px 0 10px; }
.chat-composer-wrap { border-top: 1px solid var(--border); background: #fff; padding: 11px 14px; flex: none; }
.chat-composer { display: flex; align-items: flex-end; gap: 8px; }
.chat-composer textarea {
  flex: 1; min-height: 40px; max-height: 150px; resize: none;
  border: 1px solid var(--border-strong); border-radius: 9px; padding: 9px 11px;
  font-size: 13.5px; line-height: 1.5; outline: none;
}
.chat-composer textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(51,112,255,.1); }
.chat-tip { font-size: 11px; color: var(--faint); margin-top: 6px; }
.chat-placeholder { flex: 1; display: grid; place-items: center; text-align: center; color: var(--muted); font-size: 13px; padding: 30px; }
.chat-placeholder .empty-icon { margin: 0 auto 12px; }

/* ---------- notifications ---------- */
.notif-list { background: #fff; border: 1px solid var(--border); border-radius: var(--radius-lg); overflow: hidden; }
.notif-item { display: flex; gap: 12px; align-items: flex-start; padding: 15px 18px; border-bottom: 1px solid #f0f2f4; cursor: pointer; }
.notif-item:last-child { border-bottom: 0; }
.notif-item:hover { background: var(--surface-soft); }
.notif-item.unread { background: #f7faff; }
.notif-item.unread:hover { background: #eff5ff; }
.notif-icon { width: 34px; height: 34px; border-radius: 9px; background: var(--primary-soft); color: var(--primary); display: grid; place-items: center; flex: none; }
.notif-icon.green { background: var(--success-soft); color: var(--success); }
.notif-icon.orange { background: var(--warning-soft); color: var(--warning); }
.notif-main { flex: 1; min-width: 0; }
.notif-text { font-size: 13px; line-height: 1.55; color: var(--text-secondary); }
.notif-time { font-size: 11px; color: var(--faint); margin-top: 3px; }
.notif-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--primary); margin-top: 12px; flex: none; }

/* ---------- admin ---------- */
.admin-tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); margin-bottom: 20px; }
.admin-grid { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(300px, 1fr); gap: 18px; align-items: start; }
.card { background: #fff; border: 1px solid var(--border); border-radius: var(--radius-lg); }
.card-head { padding: 16px 18px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.card-title { font-size: 14px; font-weight: 650; margin: 0; }
.card-sub { font-size: 12px; color: var(--muted); margin-top: 3px; }
.card-body { padding: 18px; }
.settings-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; padding: 14px 0; border-bottom: 1px solid #f0f2f4; }
.settings-row:last-child { border-bottom: 0; padding-bottom: 0; }
.settings-row:first-child { padding-top: 0; }
.settings-label { font-size: 13.5px; font-weight: 600; margin-bottom: 3px; }
.settings-desc { font-size: 12px; color: var(--muted); line-height: 1.55; max-width: 460px; }
.settings-control { flex: none; display: flex; align-items: center; gap: 10px; }
.warn-box { display: flex; gap: 8px; align-items: flex-start; padding: 10px 12px; border-radius: 8px; background: var(--warning-soft); border: 1px solid #f8e3bd; color: #8a5006; font-size: 12.5px; line-height: 1.55; margin-top: 10px; }
.info-box { display: flex; gap: 8px; align-items: flex-start; padding: 10px 12px; border-radius: 8px; background: var(--primary-soft-2); border: 1px solid #dce6ff; color: #2a5bd7; font-size: 12.5px; line-height: 1.55; }
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th { text-align: left; font-size: 11.5px; font-weight: 600; color: var(--faint); padding: 9px 12px; border-bottom: 1px solid var(--border); background: var(--surface-soft); white-space: nowrap; }
.table td { padding: 11px 12px; border-bottom: 1px solid #f0f2f4; vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tr:hover td { background: #fcfcfd; }
.member-cell { display: flex; align-items: center; gap: 9px; min-width: 170px; }
.member-name { font-weight: 600; font-size: 13px; }
.member-username { font-size: 11px; color: var(--faint); }
.row-actions { display: flex; gap: 5px; align-items: center; flex-wrap: wrap; }
.mail-chip { font-size: 12px; color: var(--text-secondary); overflow-wrap: anywhere; }
.mail-chip.unbound { color: var(--warning); }
.log-list { display: grid; }
.log-row { display: flex; gap: 10px; align-items: flex-start; padding: 10px 0; border-bottom: 1px solid #f0f2f4; font-size: 12.5px; }
.log-row:last-child { border-bottom: 0; }
.log-main { flex: 1; min-width: 0; }
.log-title { color: var(--text-secondary); }
.log-meta { font-size: 11px; color: var(--faint); margin-top: 2px; }
.status-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--success); flex: none; margin-top: 7px; }
.status-dot.fail { background: var(--danger); }
.credential-box { background: var(--surface-soft); border: 1px dashed var(--border-strong); border-radius: 8px; padding: 13px; display: flex; align-items: center; gap: 10px; }
.credential-code { font-family: var(--mono); font-size: 18px; font-weight: 700; letter-spacing: .08em; flex: 1; overflow-wrap: anywhere; }

/* ---------- modal ---------- */
.modal-overlay {
  position: fixed; inset: 0; z-index: 200;
  background: rgba(15, 18, 23, .42);
  display: grid; place-items: center;
  padding: 24px;
  animation: fadeIn .14s ease;
}
.modal {
  width: min(560px, 100%);
  max-height: min(86vh, 900px);
  background: #fff;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  display: flex; flex-direction: column;
  animation: popIn .16s ease;
  overflow: hidden;
}
.modal.modal-lg { width: min(880px, 100%); }
.modal.modal-xl { width: min(1080px, 100%); }
.modal.modal-sm { width: min(420px, 100%); }
.modal-head { display: flex; align-items: flex-start; gap: 12px; padding: 18px 20px 14px; border-bottom: 1px solid var(--border); flex: none; }
.modal-title-wrap { flex: 1; min-width: 0; }
.modal-title { font-size: 16px; font-weight: 680; margin: 0; line-height: 1.4; }
.modal-sub { font-size: 12.5px; color: var(--muted); margin-top: 3px; line-height: 1.5; }
.modal-close { width: 30px; height: 30px; border: 0; background: transparent; border-radius: 6px; color: var(--muted); display: grid; place-items: center; flex: none; }
.modal-close:hover { background: var(--surface-soft); color: var(--text); }
.modal-body { padding: 20px; overflow: auto; flex: 1; }
.modal-body.flush { padding: 0; }
.modal-foot { display: flex; align-items: center; justify-content: flex-end; gap: 8px; padding: 13px 20px; border-top: 1px solid var(--border); flex: none; background: #fcfcfd; }
.modal-foot .spacer { flex: 1; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes popIn { from { opacity: 0; transform: translateY(6px) scale(.985); } to { opacity: 1; transform: none; } }
.modal-form { display: grid; gap: 15px; }
.modal-actions-grid { display: grid; gap: 8px; }
.choice-card { display: flex; gap: 10px; align-items: flex-start; border: 1px solid var(--border); border-radius: 9px; padding: 11px 12px; cursor: pointer; }
.choice-card:hover { border-color: #c5d4f5; background: #fafcff; }
.choice-card.selected { border-color: var(--primary); background: var(--primary-soft-2); box-shadow: 0 0 0 2px rgba(51,112,255,.08); }
.choice-card input { margin-top: 3px; accent-color: var(--primary); }
.choice-title { font-size: 13px; font-weight: 600; }
.choice-desc { font-size: 11.5px; color: var(--muted); line-height: 1.5; margin-top: 1px; }
.acl-list { border: 1px solid var(--border); border-radius: 9px; max-height: 260px; overflow: auto; }
.acl-row { display: flex; align-items: center; gap: 9px; padding: 8px 10px; border-bottom: 1px solid #f1f3f5; }
.acl-row:last-child { border-bottom: 0; }
.acl-row:hover { background: var(--surface-soft); }
.acl-main { display: flex; align-items: center; gap: 8px; min-width: 0; flex: 1; }
.acl-name { font-size: 12.5px; font-weight: 550; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.acl-select { width: 100px; height: 28px; font-size: 12px; padding: 0 6px; }
.revision-list { display: grid; gap: 2px; }
.revision-row { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 7px; cursor: pointer; border: 0; background: transparent; width: 100%; text-align: left; }
.revision-row:hover, .revision-row.active { background: var(--primary-soft-2); }
.revision-version { font-family: var(--mono); font-size: 12px; color: var(--primary); font-weight: 600; width: 44px; flex: none; }
.revision-main { flex: 1; min-width: 0; }
.revision-title { font-size: 12.5px; font-weight: 550; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.revision-meta { font-size: 11px; color: var(--faint); }
.revision-preview { border-left: 1px solid var(--border); padding-left: 18px; min-height: 300px; max-height: 56vh; overflow: auto; }
.revision-split { display: grid; grid-template-columns: 280px minmax(0, 1fr); gap: 12px; }
.history-modal-body { display: grid; grid-template-columns: 280px minmax(0, 1fr); gap: 14px; min-height: 340px; }
.user-picker { display: grid; gap: 2px; max-height: 280px; overflow: auto; }
.user-picker-item { display: flex; align-items: center; gap: 9px; padding: 9px 10px; border: 0; background: transparent; border-radius: 7px; width: 100%; text-align: left; }
.user-picker-item:hover { background: var(--surface-soft); text-decoration: none; }
.user-picker-name { font-size: 13px; font-weight: 550; }
.user-picker-sub { font-size: 11px; color: var(--faint); }

/* ---------- toast ---------- */
.toast-root { position: fixed; z-index: 300; top: 18px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; width: min(420px, calc(100vw - 32px)); }
.toast {
  display: flex; align-items: center; gap: 8px;
  max-width: 100%;
  padding: 10px 14px;
  border-radius: 8px;
  background: #1f2329;
  color: #fff;
  font-size: 13px;
  line-height: 1.5;
  box-shadow: var(--shadow-md);
  animation: toastIn .18s ease;
}
.toast.success { background: #1f7a17; }
.toast.error { background: #b8322e; }
.toast.warning { background: #9a5b07; }
.toast .icon { flex: none; }
@keyframes toastIn { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }

/* ---------- responsive ---------- */
@media (max-width: 1280px) {
  .doc-layout { grid-template-columns: minmax(0, 1fr) 330px; }
  .doc-content { padding: 30px 34px 52px; }
  .content { padding: 24px 24px 52px; }
}
@media (max-width: 1120px) {
  .auth-side { padding: 44px 42px; }
  .editor-grid { grid-template-columns: 1fr 1fr; }
  .admin-grid { grid-template-columns: 1fr; }
  .doc-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .doc-layout { grid-template-columns: minmax(0, 1fr) 310px; }
  .doc-title { font-size: 26px; }
}
@media (max-width: 960px) {
  :root { --sidebar-w: 0px; }
  .sidebar { transform: translateX(-100%); width: 240px; transition: transform .2s ease; box-shadow: var(--shadow-lg); }
  body.sidebar-open .sidebar { transform: translateX(0); }
  .sidebar-backdrop { position: fixed; inset: 0; background: rgba(15,18,23,.36); z-index: 45; display: none; }
  body.sidebar-open .sidebar-backdrop { display: block; }
  .main { margin-left: 0; }
  .menu-toggle { display: inline-grid; }
  .content { padding: 20px 18px 48px; }
  .topbar { padding: 0 14px; gap: 8px; }
  .topbar-search { width: min(320px, 44vw); }
  .doc-layout { grid-template-columns: 1fr; }
  .comments-panel { position: fixed; inset: auto 0 0 0; top: auto; max-height: min(78vh, 640px); z-index: 160; border-radius: 16px 16px 0 0; border-bottom: 0; transform: translateY(105%); transition: transform .22s ease; box-shadow: var(--shadow-lg); }
  body.comments-open .comments-panel { transform: translateY(0); }
  .comments-close { display: inline-grid !important; }
  .doc-content { padding: 26px 24px 44px; }
  .editor-grid { grid-template-columns: 1fr; }
  .editor-preview { display: none; }
  .editor-grid.show-preview .editor-pane { display: none; }
  .editor-grid.show-preview .editor-preview { display: block; }
  .messages-layout { grid-template-columns: 250px minmax(0, 1fr); }
  .auth-page { grid-template-columns: 1fr; }
  .auth-side { display: none; }
  .auth-main { min-height: 100vh; padding: 32px 20px; }
}
@media (max-width: 720px) {
  .page-head { flex-direction: column; align-items: stretch; gap: 12px; }
  .page-title { font-size: 23px; }
  .hero-card { flex-direction: column; align-items: flex-start; padding: 22px; }
  .hero-title { font-size: 23px; }
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .doc-grid { grid-template-columns: 1fr; }
  .doc-row { padding: 13px; gap: 10px; }
  .doc-row-icon { width: 34px; height: 34px; }
  .doc-header { flex-direction: column; align-items: stretch; }
  .doc-actions { padding-top: 0; }
  .doc-title { font-size: 23px; }
  .doc-content { padding: 22px 18px 38px; }
  .comment-replies { padding-left: 20px; }
  .messages-layout { grid-template-columns: 1fr; height: calc(100vh - var(--topbar-h) - 40px); }
  .conversation-list { border-right: 0; }
  .messages-layout.has-active .conversation-list { display: none; }
  .messages-layout:not(.has-active) .chat-panel { display: none; }
  .chat-messages { padding: 16px 14px 22px; }
  .msg-bubble { max-width: 82%; }
  .chat-head { padding: 10px 12px; }
  .modal-overlay { padding: 10px; align-items: end; }
  .modal { max-height: 92vh; border-radius: 14px; }
  .modal-head { padding: 15px 16px 12px; }
  .modal-body { padding: 16px; }
  .modal-foot { padding: 11px 16px; }
  .history-modal-body, .revision-split { grid-template-columns: 1fr; }
  .revision-preview { border-left: 0; border-top: 1px solid var(--border); padding-left: 0; padding-top: 14px; }
  .topbar-search { display: none; }
  .topbar-title { font-size: 13px; }
  .content { padding: 16px 12px 40px; }
  .section { margin-top: 22px; }
  .editor-title-input { font-size: 20px; }
  .editor-head { gap: 8px; }
  .editor-toolbar { overflow-x: auto; flex-wrap: nowrap; }
  .toolbar-btn { flex: none; }
  .stat-grid { gap: 8px; }
  .stat-card { padding: 12px; }
  .stat-value { font-size: 19px; }
  .doc-row-side .badge { display: none; }
  .admin-tabs { overflow-x: auto; }
  .tab { flex: none; }
}
@media (max-width: 480px) {
  .auth-main { padding: 24px 16px; }
  .auth-card h2 { font-size: 23px; }
  .stat-grid { grid-template-columns: 1fr 1fr; }
  .doc-title { font-size: 21px; }
  .modal-foot { flex-wrap: wrap; }
  .modal-foot .btn { flex: 1; }
  .doc-actions .btn span.btn-label { display: none; }
  .doc-actions .btn { width: 34px; padding: 0; }
  .doc-actions .btn .icon { margin: 0; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* ---------- supplemental responsive controls ---------- */
.comments-toggle,
.comments-close,
.chat-back { display: none; }
.choice-title,
.choice-desc { display: block; }
.editor-grid.no-preview { grid-template-columns: 1fr; }
.editor-grid.no-preview .editor-preview { display: none; }
.doc-subline .viewers-bar { margin-left: 2px; }
.comment-thread.is-resolved > .comment > .comment-main > .comment-head .comment-author { color: var(--muted); }
.notif-item { user-select: none; }
.selection-comment-btn { white-space: nowrap; }
.admin-grid > .card { min-width: 0; }
.member-email { overflow-wrap: anywhere; }
@media (max-width: 960px) {
  .comments-toggle { display: inline-flex !important; }
  .comments-close { display: inline-grid !important; }
  .chat-back { display: inline-grid !important; }
  .doc-actions .comments-toggle { display: inline-flex !important; }
}
@media (max-width: 720px) {
  .editor-meta .tag-input { width: 140px; }
  .doc-subline .viewers-bar { width: 100%; margin-top: 2px; }
  .settings-row { flex-direction: column; gap: 10px; }
  .settings-control { width: 100%; flex-wrap: wrap; }
  .settings-control .input { flex: 1; }
  .site-name-row { flex-wrap: wrap; }
}

/* text stacking fixes */
.popover-item .pop-main,
.notif-main {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.popover-item .pop-text,
.popover-item .pop-time,
.notif-text,
.notif-time,
.revision-title,
.revision-meta,
.user-picker-name,
.user-picker-sub {
  display: block;
}
.user-card .user-meta {
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.user-card .user-name,
.user-card .user-role {
  display: block;
}
.revision-main {
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.user-picker-item > span:not(.avatar) {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.auth-code-row { display: flex; align-items: stretch; gap: 8px; }
.auth-code-row .input { flex: 1; min-width: 0; }
.auth-code-row .btn { flex: none; height: 36px; white-space: nowrap; }
.auth-foot-note a { color: var(--primary); }
