:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --surface-2: #f0f2f5;
  --border: #e2e5ea;
  --text: #1c2230;
  --muted: #6a7282;
  --primary: #2f5bd3;
  --primary-hover: #244bb5;
  --primary-soft: #e8eefc;
  --danger: #c93a3a;
  --danger-soft: #fbeaea;
  --ok: #1f8a5b;
  --ok-soft: #e4f4ec;
  --warn: #b7791f;
  --warn-soft: #fbf1df;
  --gray-soft: #eceef2;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
  --font: "Inter", "Noto Sans SC", "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { font-family: var(--font); background: var(--bg); color: var(--text); font-size: 14px; line-height: 1.5; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0; line-height: 1.25; }
h1 { font-size: 22px; font-weight: 700; }
h2 { font-size: 16px; font-weight: 600; }
h3 { font-size: 14px; font-weight: 600; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.boot { padding: 40px; text-align: center; color: var(--muted); }

/* ---------- Buttons & inputs ---------- */
button, .btn {
  font: inherit; font-weight: 500; cursor: pointer; border-radius: 8px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  padding: 7px 14px; display: inline-flex; align-items: center; gap: 6px; white-space: nowrap;
}
button:hover { background: var(--surface-2); }
button:disabled { opacity: .55; cursor: not-allowed; }
button svg { width: 18px; height: 18px; flex: none; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-danger { color: var(--danger); border-color: #efc4c4; }
.btn-danger:hover { background: var(--danger-soft); }
.btn-ghost { border-color: transparent; background: transparent; }
.btn-sm { padding: 4px 10px; font-size: 13px; }
.btn-block { width: 100%; justify-content: center; padding: 10px; }

label { display: block; font-weight: 500; margin-bottom: 4px; font-size: 13px; }
input, select, textarea {
  font: inherit; width: 100%; padding: 8px 10px; border: 1px solid var(--border);
  border-radius: 8px; background: var(--surface); color: var(--text);
}
input:focus, select:focus, textarea:focus, button:focus-visible {
  outline: 2px solid var(--primary); outline-offset: 1px; border-color: var(--primary);
}
textarea { min-height: 80px; resize: vertical; }
.field { margin-bottom: 14px; }
.row { display: flex; gap: 12px; }
.row > * { flex: 1; min-width: 0; }
.checkbox { display: inline-flex; align-items: center; gap: 6px; font-weight: 400; margin: 0; cursor: pointer; }
.checkbox input { width: auto; }

/* ---------- Auth ---------- */
.auth-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px 16px; }
.auth-card { width: 100%; max-width: 400px; background: var(--surface); border-radius: 14px; box-shadow: var(--shadow); padding: 32px 28px; }
.auth-head { text-align: center; margin-bottom: 24px; }
.auth-head .logo { margin: 0 auto 12px; }
.auth-foot { margin-top: 16px; text-align: center; font-size: 13px; }
.auth-lang { display: flex; justify-content: center; margin-top: 20px; }
.notice { padding: 10px 12px; border-radius: 8px; font-size: 13px; margin-bottom: 14px; }
.notice-info { background: var(--primary-soft); color: #1e3f99; }
.notice-error { background: var(--danger-soft); color: var(--danger); }
.notice-ok { background: var(--ok-soft); color: var(--ok); }

.logo { width: 36px; height: 36px; border-radius: 9px; background: var(--primary); display: grid; place-items: center; flex: none; }
.logo svg { width: 20px; height: 20px; }

/* ---------- Shell ---------- */
.shell { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }
.sidebar { background: var(--surface); border-right: 1px solid var(--border); padding: 18px 12px; display: flex; flex-direction: column; gap: 4px; position: sticky; top: 0; height: 100vh; }
.brand { display: flex; align-items: center; gap: 10px; padding: 0 8px 18px; font-weight: 700; font-size: 15px; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px; color: var(--text); font-weight: 500; }
.nav a:hover { background: var(--surface-2); text-decoration: none; }
.nav a.active { background: var(--primary-soft); color: var(--primary); }
.nav svg { width: 18px; height: 18px; flex: none; }
.sidebar-foot { margin-top: auto; border-top: 1px solid var(--border); padding-top: 12px; display: flex; flex-direction: column; gap: 10px; }
.me { display: flex; align-items: center; gap: 10px; padding: 0 6px; min-width: 0; }
.me-text { min-width: 0; }
.sidebar-foot .lang-switch { align-self: flex-start; margin-left: 6px; }
.sidebar-foot > button { justify-content: flex-start; }
.me-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.lang-switch { display: inline-flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.lang-switch button { border: 0; border-radius: 0; padding: 5px 12px; font-size: 13px; }
.lang-switch button.on { background: var(--primary); color: #fff; }

.main { padding: 28px 32px 48px; min-width: 0; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 22px; flex-wrap: wrap; }
.page-head .sub { margin-top: 4px; }
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 16px; }
.toolbar input, .toolbar select { width: auto; min-width: 160px; }
.toolbar input[type=checkbox] { min-width: 0; }

.topbar { display: none; }

/* ---------- Cards / grid ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; }
.card-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; gap: 8px; }
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 22px; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; }
.stat .num { font-size: 28px; font-weight: 700; margin-top: 4px; font-variant-numeric: tabular-nums; }
.stat.alert .num { color: var(--danger); }
.grid-2 { display: grid; grid-template-columns: 3fr 2fr; gap: 18px; }
.project-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 14px; }
.project-card { display: block; color: inherit; transition: border-color .15s, box-shadow .15s; }
.project-card:hover { text-decoration: none; border-color: #c5cdea; box-shadow: var(--shadow); }
.project-card p { margin: 6px 0 14px; color: var(--muted); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; min-height: 42px; }
.meta { display: flex; justify-content: space-between; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); margin-top: 10px; }

.bar { height: 6px; background: var(--gray-soft); border-radius: 99px; overflow: hidden; }
.bar > span { display: block; height: 100%; background: var(--primary); border-radius: 99px; }

/* ---------- Badges / avatars ---------- */
.badge { display: inline-block; padding: 2px 8px; border-radius: 99px; font-size: 12px; font-weight: 500; white-space: nowrap; }
.b-gray { background: var(--gray-soft); color: #4a5262; }
.b-blue { background: var(--primary-soft); color: var(--primary); }
.b-green { background: var(--ok-soft); color: var(--ok); }
.b-amber { background: var(--warn-soft); color: var(--warn); }
.b-red { background: var(--danger-soft); color: var(--danger); }
.avatar { width: 28px; height: 28px; border-radius: 50%; background: var(--primary-soft); color: var(--primary); display: inline-grid; place-items: center; font-weight: 600; font-size: 12px; flex: none; }
.avatar.sm { width: 22px; height: 22px; font-size: 11px; }

/* ---------- Lists / tables ---------- */
.list { list-style: none; margin: 0; padding: 0; }
.list li { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-top: 1px solid var(--border); }
.list li:first-child { border-top: 0; }
.list .grow { flex: 1; min-width: 0; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.empty { padding: 28px 12px; text-align: center; color: var(--muted); }

.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
th { font-size: 12px; color: var(--muted); font-weight: 600; background: var(--surface-2); }
tr:last-child td { border-bottom: 0; }
td select { width: auto; padding: 5px 8px; }
.user-cell { display: flex; align-items: center; gap: 10px; }

/* ---------- Tabs ---------- */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 16px; }
.tabs a { padding: 8px 14px; color: var(--muted); font-weight: 500; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs a:hover { text-decoration: none; color: var(--text); }
.tabs a.active { color: var(--primary); border-color: var(--primary); }

/* ---------- Kanban ---------- */
.board { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; align-items: start; }
.column { background: var(--surface-2); border-radius: var(--radius); padding: 12px; min-height: 120px; }
.column.drag-over { outline: 2px dashed var(--primary); outline-offset: -2px; }
.column-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; font-weight: 600; }
.task { background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; margin-bottom: 8px; cursor: pointer; }
.task:hover { border-color: #c5cdea; }
.task[draggable="true"] { cursor: grab; }
.task .t-title { font-weight: 500; word-break: break-word; }
.task .t-meta { display: flex; justify-content: space-between; align-items: center; gap: 6px; margin-top: 8px; font-size: 12px; color: var(--muted); }
.overdue-text { color: var(--danger); font-weight: 500; }

.project-header { margin-bottom: 18px; }
.project-header .desc { margin: 8px 0 0; color: var(--muted); max-width: 760px; white-space: pre-wrap; }
.facts { display: flex; gap: 22px; flex-wrap: wrap; margin-top: 14px; font-size: 13px; }
.facts div span { display: block; color: var(--muted); font-size: 12px; }
.back { display: inline-flex; align-items: center; gap: 4px; margin-bottom: 10px; font-size: 13px; color: var(--muted); }

/* ---------- Modal ---------- */
dialog { border: 0; border-radius: 14px; padding: 0; width: min(520px, calc(100vw - 32px)); box-shadow: 0 20px 50px rgba(16, 24, 40, .25); color: var(--text); }
dialog::backdrop { background: rgba(16, 24, 40, .45); }
.modal-head { padding: 18px 22px 0; display: flex; justify-content: space-between; align-items: center; }
.modal-body { padding: 18px 22px; max-height: 70vh; overflow-y: auto; }
.modal-foot { padding: 14px 22px; border-top: 1px solid var(--border); display: flex; gap: 8px; justify-content: flex-end; }
.modal-foot .left { margin-right: auto; }

/* ---------- Toasts ---------- */
#toasts { position: fixed; bottom: 20px; right: 20px; display: flex; flex-direction: column; gap: 8px; z-index: 50; }
.toast { background: #1c2230; color: #fff; padding: 10px 14px; border-radius: 8px; box-shadow: var(--shadow); max-width: 360px; font-size: 13px; animation: slide .2s ease-out; }
.toast.err { background: var(--danger); }
@keyframes slide { from { transform: translateY(8px); opacity: 0; } }

/* ---------- Responsive ---------- */
@media (max-width: 1000px) {
  .stats { grid-template-columns: repeat(2, 1fr); }
  .grid-2 { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { display: none; position: fixed; inset: 0 30% 0 0; z-index: 40; height: 100vh; box-shadow: 0 0 40px rgba(0,0,0,.2); }
  .shell.nav-open .sidebar { display: flex; }
  .topbar { display: flex; align-items: center; justify-content: space-between; padding: 10px 16px; background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 30; }
  .topbar .brand { padding: 0; }
  .main { padding: 18px 16px 40px; }
  .board { grid-template-columns: 1fr; }
  .row { flex-direction: column; gap: 0; }
  .toolbar input:not([type=checkbox]), .toolbar select { flex: 1; min-width: 0; }
  h1 { font-size: 19px; }
  #toasts { left: 16px; right: 16px; }
}
