:root {
  --brand: #2864F0;
  --brand-600: #1F54D8;
  --violet: #7B3FF2;
  --gradient: linear-gradient(100deg, #2864F0 0%, #7B3FF2 100%);
  --text: #101114;
  --text-2: #292B31;
  --text-3: #62666F;
  --text-4: #858A94;
  --border: #E9EBEF;
  --border-strong: #D9DCE2;
  --surface: #F3F4F6;
  --bg: #F8F9FA;
  --white: #fff;
  --ok: #169B55;
  --warn: #E99A17;
  --err: #D94343;
  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 20px;
  --r-xl: 28px;
  --shadow: 0 12px 32px rgb(16 17 20 / 6%);
  --font: Inter, "Segoe UI Variable Text", "Segoe UI", system-ui, sans-serif;
  --mono: "Cascadia Mono", Consolas, monospace;
}
* { box-sizing: border-box; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 15px/23px var(--font); -webkit-font-smoothing: antialiased;
}
a { color: inherit; }
button, input, select, textarea { font: inherit; }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; border-radius: 8px; }

.app { display: grid; grid-template-columns: 216px minmax(0, 1fr); min-height: 100vh; }
.rail {
  position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 20px;
  padding: 16px 12px; background: var(--white); border-right: 1px solid var(--border);
}
.brand { display: flex; gap: 10px; align-items: center; padding: 2px 6px; text-decoration: none; }
.brand b { width: 34px; height: 34px; border-radius: 10px; background: var(--gradient); display: grid; place-items: center; color: #fff; font-size: 15px; }
.brand div { display: grid; line-height: 1.15; }
.brand strong { font-size: 16px; font-weight: 600; }
.brand em { font-style: normal; font-size: 10.5px; color: var(--text-4); margin-top: 3px; }
.nav { display: grid; gap: 2px; }
.nav button {
  display: flex; align-items: center; gap: 10px; min-height: 34px; padding: 5px 10px;
  border: 0; border-radius: var(--r-md); background: transparent; color: var(--text-3);
  font-size: 13px; text-align: left; cursor: pointer;
}
.nav button:hover { background: var(--surface); color: var(--text); }
.nav button.active { background: var(--text); color: #fff; }
.rail-foot { margin-top: auto; display: grid; gap: 10px; }
.sync { font-size: 11px; line-height: 15px; color: var(--text-3); display: flex; gap: 7px; }
.sync i { width: 7px; height: 7px; border-radius: 50%; background: var(--ok); margin-top: 4px; flex: none; }
.sync.stale i { background: var(--warn); }
.who { border-top: 1px solid var(--border); padding-top: 10px; display: flex; gap: 8px; align-items: center; font-size: 12.5px; }
.who small { display: block; color: var(--text-4); font-size: 11px; }
.av { width: 26px; height: 26px; border-radius: 50%; background: var(--surface); color: var(--text-3); display: grid; place-items: center; font-size: 10px; font-weight: 600; flex: none; }
.av.lg { width: 34px; height: 34px; font-size: 12px; }
.av.sm { width: 22px; height: 22px; font-size: 9px; border: 2px solid var(--white); margin-left: -5px; }
.av.sm:first-child { margin-left: 0; }

.main { padding: 22px clamp(16px, 3vw, 30px) 48px; min-width: 0; }
.head { display: flex; flex-wrap: wrap; gap: 14px; align-items: flex-end; justify-content: space-between; margin-bottom: 18px; }
.eyebrow { font-size: 10.5px; letter-spacing: .04em; text-transform: uppercase; color: var(--text-4); }
h1 { font-size: clamp(22px, 2.4vw, 28px); line-height: 1.2; font-weight: 600; letter-spacing: -.02em; margin: 4px 0 0; }
.sub { color: var(--text-3); font-size: 13px; margin: 4px 0 0; max-width: 640px; }
h2 { font-size: 16px; line-height: 22px; margin: 0; font-weight: 600; }
.muted { color: var(--text-3); }
.faint { color: var(--text-4); }
.small { font-size: 11.5px; }
.mono { font-family: var(--mono); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 38px; padding: 0 16px; border: 1px solid transparent; border-radius: 999px;
  background: var(--gradient); color: #fff; font-size: 13.5px; font-weight: 600;
  text-decoration: none; cursor: pointer; transition: 200ms ease-out;
}
.btn:hover { transform: translateY(-1px); box-shadow: var(--shadow); }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; box-shadow: none; }
.btn.ghost { height: 32px; padding: 0 12px; background: var(--white); border-color: var(--border-strong); color: var(--text); font-size: 12.5px; font-weight: 500; }
.btn.ghost:hover { border-color: var(--text-4); box-shadow: none; }
.btn.sm { height: 28px; padding: 0 10px; font-size: 12px; }
.btn.icon { width: 28px; height: 28px; padding: 0; background: transparent; border: 0; color: var(--text-3); }
.btn.icon:hover { background: var(--surface); color: var(--text); }

.kpi { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin-bottom: 18px; }
.kpi-card { background: var(--white); border: 1px solid var(--border); border-radius: var(--r-md); padding: 12px 14px; display: grid; gap: 3px; }
.kpi-card span { font-size: 10.5px; text-transform: uppercase; letter-spacing: .01em; color: var(--text-4); }
.kpi-card b { font-size: 30px; line-height: 34px; font-weight: 600; letter-spacing: -.03em; }
.kpi-card small { font-size: 12px; color: var(--text-3); }

.grid2 { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); gap: 14px; align-items: start; }
@media (max-width: 1040px) { .grid2 { grid-template-columns: minmax(0, 1fr); } }
.panel { background: var(--white); border: 1px solid var(--border); border-radius: var(--r-md); }
.panel + .panel { margin-top: 12px; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 14px; border-bottom: 1px solid var(--border); }
.panel-body { padding: 4px 10px 10px; }

.project { background: var(--white); border: 1px solid var(--border); border-radius: var(--r-md); margin: 4px 0; }
.project.open { box-shadow: var(--shadow); }
.p-head { width: 100%; display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 10px; align-items: center; padding: 10px 12px; border: 0; background: transparent; text-align: left; color: inherit; cursor: pointer; border-radius: var(--r-md); }
.p-head h3 { font-size: 15px; line-height: 20px; margin: 0 0 3px; font-weight: 600; }
.meta { display: flex; flex-wrap: wrap; gap: 3px 10px; align-items: center; font-size: 12px; color: var(--text-3); }
.pill { display: inline-flex; align-items: center; gap: 5px; min-height: 22px; padding: 0 8px; border-radius: 999px; background: var(--surface); color: var(--text-2); font-size: 11.5px; line-height: 18px; text-decoration: none; white-space: nowrap; }
.pill.type { background: #ECEFFD; color: var(--brand-600); }
.pill.ok { background: rgb(22 155 85 / 10%); color: #0F7C43; }
.pill.warn { background: rgb(233 154 23 / 14%); color: #9A6400; }
.pill.danger { background: rgb(217 67 67 / 10%); color: #B02F2F; }
.pill.plain { background: transparent; border: 1px solid var(--border); }
.p-right { display: flex; align-items: center; gap: 10px; }
.ring { --p: 0; width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; position: relative; background: conic-gradient(var(--brand) calc(var(--p) * 1%), var(--border) 0); }
.ring::after { content: ""; position: absolute; inset: 4px; border-radius: 50%; background: #fff; }
.ring b { position: relative; z-index: 1; font: 600 9.5px/1 var(--mono); }
.chev { color: var(--text-4); font-size: 10px; transition: transform 200ms; }
.project.open .chev { transform: rotate(90deg); }
.p-body { display: none; padding: 2px 12px 10px; border-top: 1px solid var(--border); }
.project.open .p-body { display: block; padding-top: 10px; }
.fields { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 5px; }
.field { background: var(--bg); border: 1px solid var(--border); border-radius: 6px; padding: 6px 8px; display: grid; gap: 1px; }
.field span { font-size: 10px; color: var(--text-4); }
.field b { font-size: 12.5px; font-weight: 500; overflow-wrap: anywhere; }
.field b.empty { color: var(--text-4); font-weight: 400; }

.task { display: flex; align-items: center; gap: 7px; padding: 5px 6px; border-radius: 6px; font-size: 12.5px; border: 1px solid transparent; }
.task:hover { background: var(--bg); border-color: var(--border); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--text-4); flex: none; }
.dot.s2 { background: var(--warn); } .dot.s3 { background: var(--brand); } .dot.s4 { background: var(--violet); }
.dot.s5 { background: var(--ok); } .dot.s7 { background: var(--err); }
.task .t { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.task time, .task .state { font-size: 10.5px; color: var(--text-4); white-space: nowrap; }
.subtasks { margin-left: 12px; padding-left: 8px; border-left: 1px solid var(--border); }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
th { text-align: left; padding: 7px 10px; font-size: 10.5px; text-transform: uppercase; color: var(--text-4); border-bottom: 1px solid var(--border); font-weight: 500; }
td { padding: 7px 10px; border-bottom: 1px solid var(--border); }
tr:last-child td { border-bottom: 0; }
td.num { font-family: var(--mono); font-size: 11.5px; white-space: nowrap; }
tbody tr:hover { background: var(--bg); }

.layout { display: grid; grid-template-columns: minmax(0, 1fr) 280px; gap: 14px; align-items: start; }
@media (max-width: 1100px) { .layout { grid-template-columns: minmax(0, 1fr); } }
.frow { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr) auto; gap: 10px; padding: 8px 6px; border-bottom: 1px solid var(--border); align-items: start; }
.frow:last-child { border-bottom: 0; }
.frow:hover { background: var(--bg); border-radius: 6px; }
.frow .label { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; font-size: 12.5px; font-weight: 600; }
.frow .value { font-size: 12.5px; overflow-wrap: anywhere; }
.frow .actions { display: flex; gap: 6px; align-items: center; }
.req { color: var(--err); }
.tag { padding: 1px 7px; border-radius: 999px; background: rgb(233 154 23 / 14%); color: #9A6400; font-size: 9.5px; }
.who-sees { display: flex; flex-wrap: wrap; gap: 3px; margin-top: 2px; }
.who-sees .chip { padding: 1px 7px; border-radius: 999px; background: var(--surface); color: var(--text-3); font-size: 10.5px; }

.stat-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 5px; }
.stat { background: var(--bg); border-radius: 6px; padding: 7px 9px; }
.stat b { display: block; font-size: 20px; line-height: 25px; font-weight: 600; }
.stat span { font-size: 10.5px; color: var(--text-3); }
.progress-line { height: 5px; margin-top: 10px; border-radius: 999px; background: var(--surface); overflow: hidden; }
.progress-line i { display: block; height: 100%; background: var(--gradient); }
.people { display: grid; gap: 1px; padding: 4px 8px 8px; }
.person { display: flex; gap: 8px; align-items: center; padding: 4px 6px; border-radius: 6px; text-decoration: none; font-size: 12.5px; }
.person:hover { background: var(--bg); }
.person small { display: block; font-size: 10.5px; color: var(--text-4); }

.type-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 10px; }
.type-card { background: var(--white); border: 1px solid var(--border); border-radius: var(--r-md); padding: 14px 16px; display: grid; gap: 8px; align-content: start; }
.type-card h2 { font-size: 16px; }
.type-card ul { margin: 0; padding-left: 16px; display: grid; gap: 2px; font-size: 12px; color: var(--text-3); }
.type-card li.muted { color: var(--text-4); }

.toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 10px; }
.search input { height: 34px; padding: 0 12px; border: 1px solid var(--border-strong); border-radius: 999px; background: #fff; font-size: 12.5px; min-width: 240px; }
.empty { border: 1px dashed var(--border-strong); border-radius: var(--r-md); padding: 32px 20px; text-align: center; display: grid; gap: 8px; justify-items: center; background: rgb(255 255 255 / 60%); }
.empty .mark { font-size: 26px; color: var(--border-strong); }

.modal-root { position: fixed; inset: 0; z-index: 40; display: grid; place-items: center; padding: 20px; background: rgb(16 17 20 / 40%); overflow: auto; }
.modal-root[hidden] { display: none; }
.modal { width: min(640px, 100%); max-height: calc(100vh - 40px); overflow: auto; background: #fff; border-radius: var(--r-lg); box-shadow: 0 24px 64px rgb(16 17 20 / 18%); }
.modal.wide { width: min(880px, 100%); }
.modal-head { position: sticky; top: 0; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 20px 8px; background: #fff; }
.modal-head h2 { font-size: 18px; line-height: 24px; }
.modal-body { padding: 2px 20px 12px; display: grid; gap: 10px; }
.modal-foot { position: sticky; bottom: 0; display: flex; justify-content: flex-end; gap: 6px; padding: 10px 20px 14px; background: #fff; border-top: 1px solid var(--border); }
label.f { display: grid; gap: 4px; font-size: 12.5px; }
label.f > span { font-weight: 600; color: var(--text-2); }
input[type=text], input[type=date], input[type=number], select, textarea {
  width: 100%; min-height: 40px; padding: 8px 12px; border: 1px solid var(--border-strong);
  border-radius: var(--r-sm); background: #fff; color: var(--text); font-size: 13.5px;
}
textarea { min-height: 64px; resize: vertical; }
select { height: 40px; }
select[multiple] { height: auto; padding: 5px; }
.note { padding: 8px 12px; border: 1px solid var(--border); border-radius: var(--r-sm); background: var(--bg); color: var(--text-3); font-size: 12px; line-height: 17px; }
.error-box { padding: 8px 12px; border-radius: var(--r-sm); background: rgb(217 67 67 / 8%); border: 1px solid rgb(217 67 67 / 25%); color: #B02F2F; font-size: 12px; }

.kpi-error { padding: 10px 14px; border-radius: var(--r-sm); background: rgb(233 154 23 / 10%); border: 1px solid rgb(233 154 23 / 30%); color: #9A6400; font-size: 12.5px; margin-bottom: 12px; }
.toasts { position: fixed; right: 20px; bottom: 20px; z-index: 60; display: grid; gap: 6px; }
.toast { background: var(--text); color: #fff; padding: 8px 12px; border-radius: var(--r-sm); font-size: 12.5px; box-shadow: var(--shadow); }
.toast.error { background: #6d2a1d; }
.boot { padding: 60px; text-align: center; color: var(--text-3); }
.login { max-width: 460px; margin: 10vh auto; background: #fff; border: 1px solid var(--border); border-radius: var(--r-lg); padding: 32px; display: grid; gap: 16px; }
.login h1 { font-size: 26px; }
.login .logo { width: 44px; height: 44px; border-radius: 12px; background: var(--gradient); display: grid; place-items: center; color: #fff; font-size: 18px; }
.tpl-fields { display: grid; gap: 5px; max-height: 48vh; overflow: auto; padding-right: 2px; }
.tpl-field { display: grid; gap: 7px; padding: 9px 10px; border: 1px solid var(--border); border-radius: var(--r-sm); }
.tpl-field.has-task { border-color: var(--brand); }
.tpl-head { display: flex; justify-content: space-between; gap: 8px; align-items: center; }
.tpl-head b { font-size: 12.5px; }
.tpl-head span { font-size: 10.5px; color: var(--text-4); }
.tpl-task-opts { display: grid; grid-template-columns: minmax(0, 1fr) 150px; gap: 5px; }
.tpl-task-opts[hidden] { display: none; }
.task-toggle { display: inline-flex; gap: 6px; align-items: center; font-size: 12px; color: var(--text-3); cursor: pointer; }

@media (max-width: 900px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .rail { position: relative; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; gap: 12px; padding: 10px 14px; border-right: 0; border-bottom: 1px solid var(--border); }
  .nav { display: flex; flex-wrap: wrap; }
  .rail-foot { margin: 0; display: flex; align-items: center; }
  .rail-foot .sync { display: none; }
  .main { padding: 16px 14px 40px; }
  .p-head { grid-template-columns: minmax(0, 1fr); }
  .frow { grid-template-columns: minmax(0, 1fr); }
  .layout { grid-template-columns: minmax(0, 1fr); }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
.member-picker {
  border: 1px solid var(--border-strong);
  border-radius: var(--r-md);
  background: var(--white);
  overflow: hidden;
}

.member-search {
  width: 100%;
  border: 0;
  border-bottom: 1px solid var(--border);
  padding: 9px 12px;
  font: inherit;
  background: transparent;
  outline: none;
}

.member-list {
  max-height: 220px;
  overflow: auto;
}

.member-opt {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 12px;
  cursor: pointer;
}

.member-opt:hover {
  background: var(--surface);
}

.member-opt input {
  width: 16px;
  height: 16px;
  accent-color: var(--brand);
}

.member-opt small {
  margin-left: auto;
  color: #8A8F98;
  font-size: 12px;
}

.btn.danger {
  color: var(--err);
}

.file-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 8px;
}

.file-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  background: var(--surface);
}

.file-item a {
  color: var(--brand);
  text-decoration: none;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-item .btn {
  margin-left: auto;
}

.tpl-list {
  list-style: none;
  padding: 0;
  margin: 8px 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.tpl-list li {
  display: flex;
  align-items: center;
  gap: 8px;
  justify-content: space-between;
  padding: 4px 6px;
  border-radius: var(--r-sm);
}

.tpl-list li:hover {
  background: var(--surface);
}

.tpl-actions {
  display: flex;
  gap: 2px;
  flex-shrink: 0;
}

.split {
  display: grid;
  grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}

.tasks-feed .panel-body {
  padding-top: 6px;
}

.feed {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: 560px;
  overflow: auto;
}

.feed-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 8px 10px;
  border: 1px solid transparent;
  border-radius: var(--r-sm);
  background: transparent;
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.feed-item:hover {
  background: var(--surface);
  border-color: var(--border);
}

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

.feed-title {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.feed-item time {
  color: #8A8F98;
  font-size: 12px;
  white-space: nowrap;
}

@media (max-width: 980px) {
  .split {
    grid-template-columns: 1fr;
  }
}
