:root {
  --brand: #2b6b58;
  --brand-ink: #1f4f41;
  --brand-soft: #e6efeb;
  --bg: #f6f4ef;
  --surface: #ffffff;
  --ink: #1f2a26;
  --muted: #6b756f;
  --line: #e4e0d7;
  --danger: #b4432f;
  --danger-soft: #f8e9e5;
  --warn: #9a6516;
  --warn-soft: #f7efdf;
  --info-soft: #eef1f6;
  --internal: #6d4c8f;
  --internal-soft: #f1ecf6;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(31, 42, 38, .06), 0 2px 8px rgba(31, 42, 38, .05);
  --serif: 'Prata', Georgia, serif;
  --sans: 'Jost', system-ui, -apple-system, 'Segoe UI', sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { font-family: var(--sans); font-size: 16px; line-height: 1.45; color: var(--ink); background: var(--bg); -webkit-text-size-adjust: 100%; }
a { color: var(--brand); }
h1, h2 { font-family: var(--serif); font-weight: 400; margin: 0 0 .5em; }
h1 { font-size: 1.5rem; } h2 { font-size: 1.2rem; }
h3 { font-size: .8rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 1.2em 0 .5em; font-weight: 500; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.row { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.grow { flex: 1; }
.stack > * + * { margin-top: .75rem; }
.hidden { display: none !important; }

/* ---------- chrome ---------- */
.topbar { position: sticky; top: 0; z-index: 20; background: var(--surface); border-bottom: 1px solid var(--line); }
.topbar-inner { max-width: 1280px; margin: 0 auto; display: flex; align-items: center; gap: 1rem; padding: .6rem 1rem; }
.brand { font-family: var(--serif); color: var(--brand); font-size: 1.1rem; text-decoration: none; white-space: nowrap; }
.brand small { font-family: var(--sans); color: var(--muted); font-size: .75rem; margin-left: .35rem; }
.nav { display: flex; gap: .25rem; }
.nav a { text-decoration: none; color: var(--ink); padding: .4rem .7rem; border-radius: 8px; }
.nav a[aria-current="page"] { background: var(--brand-soft); color: var(--brand-ink); }
.bell { position: relative; }
.badge { display: inline-block; min-width: 1.2rem; padding: 0 .35rem; border-radius: 99px; background: var(--danger); color: #fff; font-size: .72rem; line-height: 1.2rem; text-align: center; }
.bell .badge { position: absolute; top: -4px; right: -6px; }
main { max-width: 1280px; margin: 0 auto; padding: 1rem 1rem 6rem; }
.tabbar { display: none; }
.demo-ribbon { background: var(--warn-soft); color: var(--warn); text-align: center; font-size: .8rem; padding: .25rem; }
.status-line { position: fixed; left: 50%; transform: translateX(-50%); bottom: 1.25rem; z-index: 60; display: flex; flex-direction: column; gap: .4rem; align-items: center; pointer-events: none; }
.toast { pointer-events: auto; background: var(--ink); color: #fff; padding: .55rem .9rem; border-radius: 8px; font-size: .9rem; box-shadow: var(--shadow); max-width: 90vw; }
.toast.error { background: var(--danger); }
.toast button { margin-left: .5rem; background: transparent; border: 1px solid rgba(255,255,255,.6); color: #fff; border-radius: 6px; padding: .1rem .5rem; cursor: pointer; }
.offline { background: var(--danger); color: #fff; text-align: center; padding: .3rem; font-size: .85rem; }

@media (max-width: 760px) {
  .nav, .topbar .desk { display: none; }
  main { padding: .75rem .75rem 5.5rem; }
  .tabbar { display: flex; position: fixed; bottom: 0; left: 0; right: 0; z-index: 30; background: var(--surface); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); }
  .tabbar a { flex: 1; text-align: center; text-decoration: none; color: var(--muted); font-size: .7rem; padding: .45rem 0 .5rem; position: relative; }
  .tabbar a svg { display: block; margin: 0 auto 2px; }
  .tabbar a[aria-current="page"] { color: var(--brand); }
  .tabbar .plus { color: #fff; }
  .tabbar .plus span.ic { display: inline-flex; width: 40px; height: 40px; align-items: center; justify-content: center; background: var(--brand); border-radius: 50%; margin-top: -2px; }
  .tabbar .badge { position: absolute; top: 2px; left: 55%; }
  .status-line { bottom: 5rem; }
}

/* ---------- controls ---------- */
.btn { display: inline-flex; align-items: center; gap: .35rem; border: 1px solid var(--line); background: var(--surface); padding: .5rem .85rem; border-radius: 8px; cursor: pointer; text-decoration: none; color: var(--ink); min-height: 40px; }
.btn:hover { border-color: #cfc9bc; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: var(--brand-ink); }
.btn.danger { color: var(--danger); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.small { padding: .25rem .55rem; min-height: 32px; font-size: .88rem; }
.btn[disabled] { opacity: .55; cursor: not-allowed; }
label.f { display: block; font-size: .85rem; color: var(--muted); }
label.f > span { display: block; margin-bottom: .2rem; }
input[type=text], input[type=email], input[type=password], input[type=date], input[type=number], input[type=url], input[type=search], select, textarea {
  width: 100%; border: 1px solid var(--line); background: var(--surface); border-radius: 8px; padding: .5rem .65rem; min-height: 40px; color: var(--ink); }
textarea { min-height: 84px; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--brand); outline: none; box-shadow: 0 0 0 3px var(--brand-soft); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: .75rem; }
@media (max-width: 560px) { .grid2 { grid-template-columns: 1fr; } }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.seg button { border: 0; background: var(--surface); padding: .35rem .75rem; cursor: pointer; min-height: 36px; }
.seg button[aria-pressed="true"] { background: var(--brand-soft); color: var(--brand-ink); }
.check { display: flex; gap: .5rem; align-items: flex-start; cursor: pointer; }
.check input { width: 18px; height: 18px; margin-top: .15rem; accent-color: var(--brand); }

/* ---------- pills ---------- */
.pill { display: inline-flex; align-items: center; gap: .25rem; font-size: .75rem; padding: .08rem .5rem; border-radius: 99px; background: var(--info-soft); color: var(--ink); white-space: nowrap; }
.pill.new { background: #eef1f6; }
.pill.in_progress { background: var(--brand-soft); color: var(--brand-ink); }
.pill.waiting { background: var(--warn-soft); color: var(--warn); }
.pill.review { background: #e8eef8; color: #2d4c7c; }
.pill.done { background: #e7f2e9; color: #2f6a3a; }
.pill.cancelled { background: #eee; color: #666; }
.pill.internal { background: var(--internal-soft); color: var(--internal); }
.pill.demo { background: var(--warn-soft); color: var(--warn); }
.pill.side-doma { background: var(--brand-soft); color: var(--brand-ink); }
.pill.side-partner { background: #fdf0e3; color: #8a4b12; }
.pill.side-external { background: #efeaf8; color: #57438a; }
.prio { display: inline-block; width: 8px; height: 8px; border-radius: 50%; }
.prio.high { background: #d69e2e; } .prio.urgent { background: var(--danger); } .prio.normal { background: transparent; }
.due { font-size: .82rem; color: var(--muted); white-space: nowrap; }
.due.overdue { color: var(--danger); font-weight: 500; }
.due.today { color: var(--warn); font-weight: 500; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--brand); display: inline-block; }

/* ---------- lists & cards ---------- */
.section { margin-bottom: 1.25rem; }
.section-head { display: flex; align-items: baseline; gap: .5rem; margin: 0 0 .4rem; }
.section-head h2 { margin: 0; }
.count { color: var(--muted); font-size: .9rem; }
.tlist { list-style: none; margin: 0; padding: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.tlist li + li { border-top: 1px solid var(--line); }
.trow { display: grid; grid-template-columns: 1fr auto; gap: .2rem .75rem; padding: .65rem .8rem; text-decoration: none; color: inherit; }
.trow:hover { background: #fbfaf7; }
.trow .t1 { display: flex; gap: .45rem; align-items: center; min-width: 0; }
.trow .ttl { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; min-width: 0; }
.sid { white-space: nowrap; }
@media (max-width: 760px) {
  .trow { grid-template-columns: 1fr; }
  .trow .t1 { align-items: flex-start; }
  .trow .ttl { white-space: normal; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
  .trow .t1 .prio, .trow .t1 .dot { margin-top: .45rem; flex: none; }
  .trow .t1 .sid { margin-top: .12rem; }
  .trow > .due { order: 3; }
}
.trow .meta { grid-column: 1 / -1; display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; font-size: .82rem; color: var(--muted); }
.sid { font-size: .78rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.empty { padding: 1.25rem; text-align: center; color: var(--muted); background: var(--surface); border: 1px dashed var(--line); border-radius: var(--radius); }

.toolbar { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; margin-bottom: .75rem; }
.toolbar input[type=search] { max-width: 360px; }
.filters { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: .5rem; margin-bottom: .75rem; background: var(--surface); padding: .75rem; border: 1px solid var(--line); border-radius: var(--radius); }

.kanban { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(250px, 1fr); gap: .75rem; overflow-x: auto; padding-bottom: .5rem; }
.col { background: #efece5; border-radius: var(--radius); padding: .5rem; min-height: 120px; }
.col h2 { font-family: var(--sans); font-size: .9rem; font-weight: 500; margin: .2rem .3rem .5rem; display: flex; justify-content: space-between; }
.kcard { display: block; background: var(--surface); border-radius: 8px; padding: .6rem .65rem; margin-bottom: .5rem; text-decoration: none; color: inherit; box-shadow: var(--shadow); border-left: 3px solid transparent; }
.kcard.overdue { border-left-color: var(--danger); }
.kcard .ttl { font-weight: 500; margin: .15rem 0 .35rem; }
.kcard .meta { display: flex; justify-content: space-between; gap: .4rem; font-size: .8rem; color: var(--muted); align-items: center; }

/* ---------- card view ---------- */
.card-head { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; margin-bottom: .35rem; }
.card-title { font-family: var(--serif); font-size: 1.45rem; margin: .1rem 0 .6rem; line-height: 1.25; }
.layout { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 1rem; align-items: start; }
@media (max-width: 980px) { .layout { grid-template-columns: 1fr; } }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: .9rem; }
.panel + .panel { margin-top: .9rem; }
.nextstep { border: 1px solid var(--brand); background: linear-gradient(0deg, var(--surface), var(--surface)); }
.nextstep .label { font-size: .75rem; text-transform: uppercase; letter-spacing: .06em; color: var(--brand); }
.nextstep .what { font-size: 1.1rem; font-weight: 500; margin: .25rem 0 .4rem; }
.nextstep .who { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }
.actions { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: .75rem; }
.blocked-banner { background: var(--danger-soft); color: var(--danger); padding: .5rem .7rem; border-radius: 8px; margin-bottom: .6rem; font-size: .9rem; }
.waiting-banner { background: var(--warn-soft); color: var(--warn); padding: .5rem .7rem; border-radius: 8px; margin-bottom: .6rem; font-size: .9rem; }
.comments { list-style: none; margin: 0; padding: 0; }
.comment { padding: .6rem 0; border-top: 1px solid var(--line); }
.comment:first-child { border-top: 0; }
.comment .who { font-weight: 500; font-size: .9rem; }
.comment .body { white-space: pre-wrap; overflow-wrap: anywhere; margin-top: .15rem; }
.comment.internal { background: var(--internal-soft); margin: 0 -.9rem; padding: .6rem .9rem; border-left: 3px solid var(--internal); }
.mention { color: var(--brand); font-weight: 500; }
.composer { margin-top: .75rem; border-top: 1px solid var(--line); padding-top: .75rem; }
.composer.internal textarea { border-color: var(--internal); background: #fcfaff; }
.composer .bar { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; margin-top: .5rem; }
.suggest { position: absolute; z-index: 40; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; box-shadow: var(--shadow); list-style: none; margin: 0; padding: .25rem 0; min-width: 220px; }
.suggest li { padding: .35rem .7rem; cursor: pointer; }
.suggest li[aria-selected="true"], .suggest li:hover { background: var(--brand-soft); }
dl.kv { display: grid; grid-template-columns: 42% 58%; gap: .35rem .5rem; margin: 0; font-size: .9rem; }
dl.kv dt { color: var(--muted); }
dl.kv dd { margin: 0; overflow-wrap: anywhere; }
.history { list-style: none; margin: 0; padding: 0; font-size: .85rem; }
.history li { padding: .3rem 0; border-top: 1px dashed var(--line); }
.history li:first-child { border-top: 0; }
.files { list-style: none; margin: 0; padding: 0; }
.files li { display: flex; gap: .5rem; align-items: center; padding: .3rem 0; }
.progress { height: 4px; background: var(--line); border-radius: 4px; overflow: hidden; margin-top: .3rem; }
.progress > div { height: 100%; background: var(--brand); width: 0; transition: width .2s; }
details.more > summary { cursor: pointer; color: var(--brand); margin: .5rem 0; }

/* ---------- overview ---------- */
.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: .6rem; margin-bottom: 1rem; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: .7rem .8rem; text-decoration: none; color: inherit; }
.stat .n { font-family: var(--serif); font-size: 1.7rem; line-height: 1.1; }
.stat .l { color: var(--muted); font-size: .85rem; }
.stat.alert .n { color: var(--danger); }

/* ---------- dialogs ---------- */
dialog { border: 0; border-radius: 14px; padding: 0; width: min(560px, 94vw); max-height: 92vh; box-shadow: 0 10px 40px rgba(0,0,0,.2); }
dialog::backdrop { background: rgba(31, 42, 38, .35); }
dialog form { padding: 1.1rem; }
dialog .dhead { display: flex; justify-content: space-between; align-items: center; margin-bottom: .75rem; }
dialog .dfoot { display: flex; gap: .5rem; justify-content: flex-end; margin-top: 1rem; }
.err { color: var(--danger); font-size: .88rem; margin-top: .5rem; }
@media (max-width: 560px) {
  dialog { width: 100vw; max-width: 100vw; margin: auto 0 0; border-radius: 14px 14px 0 0; max-height: 94vh; }
}

/* ---------- auth ---------- */
.auth { max-width: 380px; margin: 8vh auto; background: var(--surface); padding: 1.5rem; border-radius: 14px; border: 1px solid var(--line); }
.auth h1 { color: var(--brand); }

/* ---------- settings ---------- */
.tabs { display: flex; gap: .25rem; flex-wrap: wrap; margin-bottom: 1rem; }
.tabs a { text-decoration: none; padding: .35rem .7rem; border-radius: 8px; color: var(--ink); background: var(--surface); border: 1px solid var(--line); font-size: .9rem; }
.tabs a[aria-current="page"] { background: var(--brand); color: #fff; border-color: var(--brand); }
table.plain { width: 100%; border-collapse: collapse; background: var(--surface); font-size: .9rem; }
table.plain th, table.plain td { text-align: left; padding: .45rem .5rem; border-bottom: 1px solid var(--line); vertical-align: top; }
table.plain th { color: var(--muted); font-weight: 500; }
.scroll-x { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); }
.ok { color: #2f6a3a; } .bad { color: var(--danger); }
.notif { display: flex; gap: .6rem; padding: .65rem .8rem; text-decoration: none; color: inherit; align-items: flex-start; }
.notif.unread { background: #fbfaf5; }
.notif.unread .k { font-weight: 600; }
