:root {
  --bg: #f4f5f2;
  --card: #ffffff;
  --ink: #1d2320;
  --muted: #69716c;
  --line: #e3e6e1;
  --line-strong: #d3d8d1;
  --accent: #03a002;
  --accent-dark: #027a01;
  --accent-soft: #e6f6e6;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(20, 30, 20, .05), 0 6px 20px rgba(20, 30, 20, .05);
  --s-not: #7b827e;      --s-not-bg: #eef0ee;
  --s-prog: #1f63d6;     --s-prog-bg: #e7efff;
  --s-feed: #a8620a;     --s-feed-bg: #fff1db;
  --s-block: #c4312b;    --s-block-bg: #fde8e7;
  --s-done: #027a01;     --s-done-bg: #e3f5e3;
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); }
body { font-size: 15px; line-height: 1.45; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent-dark); }
code { background: #eef0ee; padding: 1px 5px; border-radius: 5px; font-size: .9em; }
.loading { padding: 80px 20px; text-align: center; color: var(--muted); }

/* Buttons and inputs */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 1px solid var(--line-strong); background: var(--card); border-radius: 999px;
  padding: 7px 14px; cursor: pointer; font-weight: 600; font-size: 14px; text-decoration: none; color: var(--ink);
  transition: background .15s, border-color .15s;
}
.btn:hover { background: #f6f7f5; border-color: #c3c9c1; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-dark); border-color: var(--accent-dark); }
.btn.danger { color: var(--s-block); }
.btn.danger.confirm { background: var(--s-block); border-color: var(--s-block); color: #fff; }
.btn.small { padding: 4px 10px; font-size: 13px; }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: #eceee9; }
.btn:disabled { opacity: .5; cursor: default; }
.btn svg { width: 16px; height: 16px; flex: none; }
.btn { white-space: nowrap; }
input[type=text], input[type=search], input[type=date], input:not([type]), input[type=password], select, textarea {
  border: 1px solid var(--line-strong); border-radius: 10px; padding: 8px 11px; background: #fff; width: 100%;
  outline: none; transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(3, 160, 2, .15); }
textarea { resize: vertical; min-height: 80px; line-height: 1.5; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Layout */
.app { max-width: 1120px; margin: 0 auto; padding: 0 20px 80px; }
.topbar { display: flex; align-items: center; gap: 16px; padding: 18px 0 14px; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 11px; min-width: 0; flex: 1; }
.brand-mark { width: 34px; height: 34px; border-radius: 10px; background: var(--accent); flex: none; display: grid; place-items: center; }
.brand-mark svg { width: 20px; height: 20px; }
.brand h1 { font-size: 19px; margin: 0; letter-spacing: -.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand .sub { font-size: 13px; color: var(--muted); }
.tabs { display: flex; gap: 4px; background: #e9ebe7; padding: 4px; border-radius: 999px; }
.tab { border: 0; background: transparent; padding: 6px 14px; border-radius: 999px; cursor: pointer; font-weight: 600; font-size: 14px; color: var(--muted); position: relative; }
.tab.on { background: #fff; color: var(--ink); box-shadow: 0 1px 2px rgba(0,0,0,.08); }
.tab .count { background: var(--accent); color: #fff; font-size: 11px; border-radius: 999px; padding: 1px 6px; margin-left: 5px; }
.me { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); }
.avatar { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; color: #fff; font-weight: 700; font-size: 13px; flex: none; }
.avatar.sm { width: 24px; height: 24px; font-size: 11px; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }

/* Summary */
.summary { display: grid; grid-template-columns: 260px 1fr; gap: 16px; margin-bottom: 16px; }
.progress-card { padding: 18px 20px; }
.progress-card .pct { font-size: 38px; font-weight: 750; letter-spacing: -.03em; line-height: 1; }
.progress-card .pct small { font-size: 16px; color: var(--muted); font-weight: 600; margin-left: 4px; }
.progress-card .lbl { color: var(--muted); font-size: 13px; margin-top: 6px; }
.bar { height: 8px; background: #e8ebe6; border-radius: 999px; overflow: hidden; margin-top: 14px; display: flex; }
.bar span { display: block; height: 100%; }
.status-card { padding: 14px; display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; }
.stat {
  border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; cursor: pointer; background: #fff; text-align: left;
  transition: border-color .15s, background .15s;
}
.stat:hover { border-color: var(--line-strong); }
.stat.on { border-color: currentColor; box-shadow: inset 0 0 0 1px currentColor; }
.stat .n { font-size: 24px; font-weight: 750; letter-spacing: -.02em; color: var(--ink); }
.stat .t { font-size: 12.5px; font-weight: 600; display: flex; align-items: center; gap: 6px; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; display: inline-block; flex: none; }

.s-not { color: var(--s-not); }   .s-not-bg { background: var(--s-not-bg); }
.s-prog { color: var(--s-prog); } .s-prog-bg { background: var(--s-prog-bg); }
.s-feed { color: var(--s-feed); } .s-feed-bg { background: var(--s-feed-bg); }
.s-block { color: var(--s-block); } .s-block-bg { background: var(--s-block-bg); }
.s-done { color: var(--s-done); } .s-done-bg { background: var(--s-done-bg); }

/* Toolbar */
.toolbar { display: flex; gap: 10px; align-items: center; margin: 4px 0 16px; flex-wrap: wrap; }
.toolbar .search { flex: 1; min-width: 200px; position: relative; }
.toolbar .search input { padding-left: 34px; border-radius: 999px; }
.toolbar .search svg { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); width: 16px; height: 16px; color: var(--muted); }
.toolbar select { width: auto; border-radius: 999px; padding-right: 30px; }
.newbar { display: flex; align-items: center; gap: 10px; background: var(--accent-soft); color: var(--accent-dark); border-radius: 12px; padding: 10px 14px; margin-bottom: 14px; font-weight: 600; font-size: 14px; }
.newbar .btn { margin-left: auto; }

/* Groups */
.group { margin-bottom: 14px; overflow: hidden; }
.group-head { display: flex; align-items: center; gap: 12px; padding: 13px 18px; border-bottom: 1px solid var(--line); cursor: pointer; user-select: none; }
.group-head h2 { font-size: 15.5px; margin: 0; }
.group-head .meta { color: var(--muted); font-size: 13px; }
.group-head .mini { width: 120px; height: 6px; margin: 0 0 0 auto; }
.group-head .frac { font-size: 13px; font-weight: 650; color: var(--muted); min-width: 44px; text-align: right; }
.group-head .chev { width: 16px; height: 16px; color: var(--muted); transition: transform .2s; }
.group.closed .chev { transform: rotate(-90deg); }
.group.closed .rows { display: none; }
.group.closed .group-head { border-bottom: 0; }
.group.today .group-head h2::after { content: "Today"; background: var(--accent); color: #fff; font-size: 11px; padding: 2px 8px; border-radius: 999px; margin-left: 8px; vertical-align: 2px; }

.row { display: grid; grid-template-columns: 158px 1fr auto; gap: 14px; align-items: center; padding: 11px 18px; border-bottom: 1px solid var(--line); cursor: pointer; transition: background .12s; position: relative; }
.row:last-child { border-bottom: 0; }
.row:hover { background: #fafbf9; }
.row.done .title { color: var(--muted); text-decoration: line-through; text-decoration-color: #b9bfb8; }
.row.unseen::before { content: ""; position: absolute; left: 6px; top: 50%; width: 6px; height: 6px; margin-top: -3px; border-radius: 50%; background: var(--accent); }
.row .title { font-weight: 560; }
.row .meta { display: flex; gap: 12px; flex-wrap: wrap; font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.row .meta span { display: inline-flex; align-items: center; gap: 4px; }
.row .meta svg { width: 13px; height: 13px; }
.row .right { display: flex; align-items: center; gap: 8px; }
.row .movers { display: flex; flex-direction: column; opacity: 0; transition: opacity .15s; }
.row:hover .movers { opacity: 1; }
.movers button { border: 0; background: none; padding: 0 3px; cursor: pointer; color: var(--muted); line-height: 1; font-size: 11px; }
.movers button:hover { color: var(--ink); }

.pill { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; font-weight: 650; padding: 4px 10px; border-radius: 999px; white-space: nowrap; }
select.pill { appearance: none; -webkit-appearance: none; border: 0; width: 100%; padding: 5px 26px 5px 12px; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%23666' stroke-width='1.5' fill='none'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center; }
select.pill:focus { box-shadow: 0 0 0 3px rgba(3, 160, 2, .2); }
.prio { font-size: 11.5px; font-weight: 700; padding: 2px 8px; border-radius: 6px; letter-spacing: .02em; }
.prio.p1 { background: #fde8e7; color: #b02a24; }
.prio.p2 { background: #fff1db; color: #925508; }
.prio.p3 { background: #eef0ee; color: #5f6762; }
.empty { padding: 40px 20px; text-align: center; color: var(--muted); }

/* Drawer */
.scrim { position: fixed; inset: 0; background: rgba(20, 25, 20, .28); opacity: 0; pointer-events: none; transition: opacity .2s; z-index: 40; }
.scrim.on { opacity: 1; pointer-events: auto; }
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(560px, 100%); background: #fff; z-index: 50; box-shadow: -10px 0 40px rgba(0,0,0,.12);
  transform: translateX(105%); transition: transform .25s cubic-bezier(.2,.8,.2,1); display: flex; flex-direction: column; }
.drawer.on { transform: none; }
.drawer-head { display: flex; align-items: flex-start; gap: 10px; padding: 18px 20px 14px; border-bottom: 1px solid var(--line); }
.drawer-head .t { flex: 1; font-size: 18px; font-weight: 700; line-height: 1.3; }
.drawer-head textarea.t { border: 1px solid transparent; padding: 4px 6px; margin: -5px -7px; min-height: 0; resize: none; }
.drawer-head textarea.t:hover { border-color: var(--line); }
.drawer-body { overflow-y: auto; padding: 18px 20px 30px; flex: 1; }
.fields { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 14px; margin-bottom: 20px; }
.fields label, .stack label { display: flex; flex-direction: column; gap: 5px; font-size: 12.5px; font-weight: 650; color: var(--muted); }
.fields .full { grid-column: 1 / -1; }
.fields .ro { font-size: 14.5px; color: var(--ink); font-weight: 500; padding: 8px 0; }
.section-title { font-size: 13px; font-weight: 750; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 22px 0 10px; display: flex; align-items: center; gap: 8px; }
.saved { font-size: 12px; color: var(--accent-dark); font-weight: 600; text-transform: none; letter-spacing: 0; }
.comment { display: flex; gap: 10px; margin-bottom: 14px; }
.comment .bubble { background: #f5f6f4; border-radius: 4px 14px 14px 14px; padding: 9px 12px; flex: 1; min-width: 0; }
.comment .who { font-size: 12.5px; font-weight: 700; display: flex; gap: 8px; align-items: baseline; }
.comment .who time { color: var(--muted); font-weight: 500; }
.comment .who button { margin-left: auto; border: 0; background: none; color: var(--muted); cursor: pointer; font-size: 12px; padding: 0; }
.comment .who button:hover { color: var(--s-block); }
.comment .body { white-space: pre-wrap; overflow-wrap: anywhere; margin-top: 3px; }
.composer { display: flex; flex-direction: column; gap: 8px; }
.composer textarea { min-height: 70px; }
.composer .hint { font-size: 12px; color: var(--muted); }
.composer .actions { display: flex; align-items: center; justify-content: space-between; }
.history { list-style: none; padding: 0; margin: 0; }
.history li, .feed li { display: flex; gap: 10px; padding: 8px 0; font-size: 13.5px; border-bottom: 1px dashed var(--line); }
.history li:last-child { border-bottom: 0; }
.history time, .feed time { color: var(--muted); font-size: 12px; white-space: nowrap; margin-left: auto; padding-left: 10px; }
.chg { font-weight: 650; }
.old { color: var(--muted); text-decoration: line-through; }

/* Activity feed */
.feed { list-style: none; margin: 0; padding: 6px 18px; }
.feed li { align-items: flex-start; padding: 12px 0; }
.feed li.new { position: relative; }
.feed li.new::before { content: ""; position: absolute; left: -11px; top: 22px; width: 6px; height: 6px; border-radius: 50%; background: var(--accent); }
.feed .txt { flex: 1; min-width: 0; }
.feed .txt a { color: inherit; font-weight: 600; text-decoration: none; border-bottom: 1px solid var(--line-strong); cursor: pointer; }
.feed .quote { color: var(--muted); margin-top: 3px; white-space: pre-wrap; overflow-wrap: anywhere; }
.feed-day { font-size: 12px; font-weight: 750; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); padding: 16px 0 4px; border-bottom: 0 !important; }

/* Team */
.team { padding: 6px 0; }
.person { display: grid; grid-template-columns: auto 1fr 130px auto; gap: 12px; align-items: center; padding: 12px 18px; border-bottom: 1px solid var(--line); }
.person:last-child { border-bottom: 0; }
.person.off { opacity: .55; }
.person .name { font-weight: 650; }
.person .sub { font-size: 12.5px; color: var(--muted); }
.person .acts { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.add-person { display: flex; gap: 10px; padding: 16px 18px; border-top: 1px solid var(--line); background: #fafbf9; flex-wrap: wrap; }
.add-person input { flex: 1; min-width: 160px; }
.add-person select { width: 130px; }
.help { font-size: 13.5px; color: var(--muted); padding: 14px 18px; border-bottom: 1px solid var(--line); }
.roles-help { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; padding: 14px 18px; font-size: 13px; color: var(--muted); }
.roles-help strong { color: var(--ink); display: block; }
.settings { padding: 16px 18px; display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; }
.settings label { flex: 1; min-width: 220px; display: flex; flex-direction: column; gap: 5px; font-size: 12.5px; font-weight: 650; color: var(--muted); }

/* Modal */
.modal-wrap { position: fixed; inset: 0; display: grid; place-items: center; z-index: 60; background: rgba(20, 25, 20, .3); padding: 20px; }
.modal { width: min(520px, 100%); padding: 22px; }
.modal h3 { margin: 0 0 14px; font-size: 18px; }
.modal .fields { margin-bottom: 18px; }
.modal .actions { display: flex; justify-content: flex-end; gap: 8px; }

/* Toasts */
.toasts { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; z-index: 80; pointer-events: none; }
.toast { background: #1d2320; color: #fff; padding: 10px 16px; border-radius: 999px; font-size: 14px; font-weight: 550; box-shadow: 0 8px 24px rgba(0,0,0,.2); animation: tin .2s ease-out; }
.toast.err { background: #b02a24; }
@keyframes tin { from { opacity: 0; transform: translateY(8px); } }

/* Auth / install pages */
body.auth { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.auth-card { background: #fff; border: 1px solid var(--line); border-radius: 18px; box-shadow: var(--shadow); padding: 32px; width: min(440px, 100%); }
.auth-card.wide { width: min(600px, 100%); }
.auth-card h1 { font-size: 22px; margin: 14px 0 8px; }
.auth-card p { color: var(--muted); }
.auth-logo { width: 42px; height: 42px; border-radius: 12px; background: var(--accent) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 32 32'%3E%3Cpath d='M9 16.5l4.5 4.5L23 11.5' stroke='white' stroke-width='3' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center/26px no-repeat; }
.stack { display: flex; flex-direction: column; gap: 14px; margin-top: 18px; }
.stack label small { font-weight: 500; }
.stack label.check { flex-direction: row; align-items: center; gap: 8px; color: var(--ink); font-weight: 500; font-size: 14px; }
.form-error { background: var(--s-block-bg); color: var(--s-block); padding: 10px 12px; border-radius: 10px; font-weight: 600; font-size: 14px; }
.link-list { list-style: none; padding: 0; display: flex; flex-direction: column; gap: 12px; }
.link-list li { display: grid; grid-template-columns: auto 1fr; gap: 6px 10px; align-items: center; }
.link-list input { grid-column: 1 / -1; font-family: ui-monospace, Menlo, monospace; font-size: 12.5px; }
.role-tag { font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }

@media (max-width: 860px) {
  .summary { grid-template-columns: 1fr; }
  .status-card { grid-template-columns: repeat(5, minmax(90px, 1fr)); overflow-x: auto; }
}
@media (max-width: 640px) {
  .app { padding: 0 12px 60px; }
  .topbar { gap: 10px; }
  .brand { flex-basis: 100%; }
  .brand .sub { display: none; }
  .tabs { flex: 1; }
  .tab { flex: 1; }
  .me .who-name { display: none; }
  .status-card { grid-template-columns: repeat(3, 1fr); overflow: visible; }
  .progress-card .pct { font-size: 32px; }
  .row { grid-template-columns: 1fr auto; gap: 8px 10px; padding: 12px 14px; }
  .row .status-cell { grid-row: 2; grid-column: 1; max-width: 170px; }
  .row .right { grid-row: 1 / span 2; grid-column: 2; flex-direction: column; align-items: flex-end; }
  .row .movers { display: none; }
  .group-head { padding: 12px 14px; }
  .group-head .mini { width: 60px; }
  .group-head .meta { display: none; }
  .fields { grid-template-columns: 1fr; }
  .person { grid-template-columns: auto 1fr; }
  .person .acts, .person select { grid-column: 1 / -1; justify-content: flex-start; }
  .roles-help { grid-template-columns: 1fr; }
}
@media print {
  .toolbar, .tabs, .drawer, .scrim, .movers, .newbar { display: none !important; }
  .group.closed .rows { display: block; }
  body { background: #fff; }
}

/* Controls inside labels should not inherit the label's weight */
label input, label select, label textarea { font-weight: 450; font-size: 14.5px; color: var(--ink); }
label select.pill { font-weight: 650; font-size: 13px; }
