:root {
  --ink: #17212b; --ink2: #44505c; --muted: #6b7682; --line: #dfe4ea; --mist: #f3f5f8; --paper: #fff;
  --brand: #0f6b5c; --brand-d: #0b4f44; --brand-l: #e3f2ee; --accent: #e07a1f; --danger: #b3261e; --ok: #1a7f4b;
  --radius: 10px;
}
* { box-sizing: border-box; }
html { font-size: 15px; }
body { margin: 0; font-family: "Segoe UI", system-ui, -apple-system, Roboto, Helvetica, Arial, sans-serif; color: var(--ink); background: var(--mist); line-height: 1.45; }
a { color: var(--brand); text-decoration: none; } a:hover { text-decoration: underline; }
h1 { font-size: 1.6rem; margin: 0 0 .2rem; letter-spacing: -.01em; } h2 { font-size: 1.05rem; margin: 0 0 .7rem; } h3 { font-size: .95rem; margin: 1.1rem 0 .4rem; }
p { margin: .3rem 0 .7rem; }
.muted { color: var(--muted); } .small { font-size: .85rem; } .r { text-align: right; } .nowrap { white-space: nowrap; }

/* shell */
.side { position: fixed; inset: 0 auto 0 0; width: 228px; background: var(--ink); color: #cfd8e0; display: flex; flex-direction: column; padding: 16px 12px; overflow-y: auto; }
.brand { display: flex; gap: 10px; align-items: center; color: #fff; font-weight: 650; font-size: .95rem; line-height: 1.15; margin-bottom: 18px; }
.brand:hover { text-decoration: none; } .brand small { display: block; font-weight: 400; color: #9fb0bf; font-size: .78rem; }
.brand.big { color: var(--ink); font-size: 1.1rem; margin-bottom: 22px; } .brand.big small { color: var(--muted); }
.mark { background: var(--brand); color: #fff; border-radius: 9px; padding: 8px 7px; font-size: .8rem; font-weight: 800; letter-spacing: .04em; }
.side nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.side nav a { color: #cfd8e0; padding: 7px 10px; border-radius: 7px; font-size: .93rem; }
.side nav a:hover { background: #24313d; text-decoration: none; } .side nav a.on { background: var(--brand); color: #fff; }
.side .sep { height: 1px; background: #2c3a47; margin: 8px 4px; }
.me { border-top: 1px solid #2c3a47; padding-top: 10px; font-size: .85rem; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.me a { color: #fff; width: 100%; overflow: hidden; text-overflow: ellipsis; }
.role { font-size: .72rem; padding: 1px 7px; border-radius: 99px; background: #2c3a47; color: #cfd8e0; } .role-admin { background: var(--accent); color: #fff; }
.linkish { background: none; border: 0; padding: 0; color: #9fb0bf; cursor: pointer; font: inherit; font-size: .85rem; } .linkish:hover { text-decoration: underline; }
.main { margin-left: 228px; padding: 26px 34px 60px; max-width: 1280px; } .main.wide-main { max-width: none; }
.main.bare { margin: 0 auto; max-width: 420px; padding-top: 9vh; }
.auth-box { background: var(--paper); border: 1px solid var(--line); border-radius: 14px; padding: 28px; }
.head { display: flex; justify-content: space-between; gap: 20px; align-items: flex-start; margin-bottom: 16px; }
.tools { display: flex; gap: 8px; align-items: center; flex-shrink: 0; }
.crumbs { font-size: .85rem; color: var(--muted); margin-bottom: 2px; }
.tabs { display: flex; gap: 4px; flex-wrap: wrap; margin: -4px 0 14px; position: sticky; top: 0; background: var(--mist); padding: 6px 0; z-index: 5; }
.tabs a { padding: 4px 11px; border-radius: 99px; background: var(--paper); border: 1px solid var(--line); font-size: .85rem; color: var(--ink2); }
.tabs a:hover { border-color: var(--brand); color: var(--brand); text-decoration: none; }

/* cards, tables */
.card { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; margin-bottom: 16px; scroll-margin-top: 52px; }
.card.flush { padding: 0; overflow: hidden; } .card.narrow { max-width: 620px; } .pad { padding: 14px 18px 0; } .actions.pad { padding: 12px 18px; }
.scroll-x { overflow-x: auto; }
.card h2 .count { background: var(--mist); border-radius: 99px; padding: 0 8px; font-size: .8rem; color: var(--muted); font-weight: 600; }
.card h2 .more, h3 .more { float: right; font-size: .82rem; font-weight: 500; }
.lead { font-size: 1.05rem; color: var(--ink2); }
.cols { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; align-items: start; }
.tiles { display: grid; grid-template-columns: repeat(5, 1fr); gap: 12px; margin-bottom: 16px; }
.tile { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; color: var(--ink); display: flex; flex-direction: column; }
.tile:hover { border-color: var(--brand); text-decoration: none; } .tile b { font-size: 1.7rem; line-height: 1.1; } .tile span { color: var(--ink2); font-size: .9rem; } .tile small { color: var(--muted); }
table.grid { width: 100%; border-collapse: collapse; }
.grid th { text-align: left; font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; padding: 9px 12px; border-bottom: 1px solid var(--line); background: #fafbfc; vertical-align: bottom; }
.grid th.r { text-align: right; }
.grid td { padding: 9px 12px; border-bottom: 1px solid #edf0f3; vertical-align: top; }
.grid tr:last-child td { border-bottom: 0; }
.grid.compact td, .grid.compact th { padding: 6px 10px; }
.grid tr.child td:first-child { padding-left: 34px; } .grid tr.off td { opacity: .55; }
.grid tr.total td { font-weight: 700; background: #fafbfc; border-top: 2px solid var(--line); }
.grid td.arrow, .arrow { color: var(--muted); font-weight: 600; }
.grid.diff td.pre { white-space: pre-wrap; font-size: .88rem; width: 42%; } .diff .del { background: #fdf1f0; } .diff .add { background: #eff8f2; }
.matrix th.rot { font-size: .72rem; text-align: center; min-width: 46px; } .matrix td.cell { text-align: center; font-weight: 700; border-left: 1px solid #edf0f3; }
.cell.a-master { background: var(--brand); color: #fff; } .cell.a-create { background: #bfe3d9; } .cell.a-update { background: #d9eef9; } .cell.a-read { background: #f1f3f6; } .cell.a-sync { background: #fdebd3; }
.row-item { padding: 5px 0; border-bottom: 1px solid #edf0f3; } .row-item:last-child { border-bottom: 0; }
.code { font: 600 .72rem ui-monospace, Consolas, monospace; background: var(--mist); border: 1px solid var(--line); border-radius: 5px; padding: 1px 5px; color: var(--ink2); vertical-align: middle; }

/* chips */
.chips { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; margin: .4rem 0 0; }
.chip { display: inline-block; font-size: .76rem; font-weight: 600; padding: 2px 9px; border-radius: 99px; background: var(--mist); color: var(--ink2); border: 1px solid var(--line); white-space: nowrap; }
.chip.rel { background: color-mix(in srgb, var(--c) 12%, white); color: var(--c); border-color: color-mix(in srgb, var(--c) 35%, white); }
.tag { display: inline-block; font-size: .76rem; padding: 1px 8px; border-radius: 5px; background: var(--brand-l); color: var(--brand-d); margin: 1px 0; }
.c-existing, .c-agreed, .c-accepted, .c-done, .c-live, .c-resolved { background: #e6f4ec; color: #17633c; border-color: #bfe0cd; }
.c-replace, .c-must, .c-risk, .c-question, .c-open { background: #fdf0e3; color: #9a4f0c; border-color: #f3d3ae; }
.c-planned, .c-proposed, .c-idea, .c-should, .c-decision { background: #e8effd; color: #2748a8; border-color: #c6d5f7; }
.c-design, .c-build, .c-defined, .c-designed, .c-building, .c-assumption { background: #f1eafc; color: #5b2da3; border-color: #d9c8f4; }
.c-retired, .c-dropped, .c-wont, .c-rejected, .c-superseded { background: #eef0f2; color: #6b7682; text-decoration: line-through; }

/* forms */
input, select, textarea, button { font: inherit; color: inherit; }
input[type=text], input[type=email], input[type=password], input[type=url], input[type=search], input[type=number], input[type=date], input:not([type]), select, textarea {
  width: 100%; padding: 7px 9px; border: 1px solid #c9d0d8; border-radius: 7px; background: #fff; }
input:focus, select:focus, textarea:focus { outline: 2px solid color-mix(in srgb, var(--brand) 45%, white); border-color: var(--brand); }
input:disabled { background: var(--mist); color: var(--muted); }
textarea { resize: vertical; font-family: inherit; }
label > span { display: block; font-size: .82rem; font-weight: 600; color: var(--ink2); margin-bottom: 3px; } label em { color: var(--danger); font-style: normal; }
label small { display: block; color: var(--muted); font-size: .78rem; margin-top: 2px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 18px; } .form-grid .wide { grid-column: 1 / -1; } .form-grid.narrow { max-width: 620px; }
.stack { display: grid; gap: 12px; margin-bottom: 14px; }
.checks { display: flex; flex-wrap: wrap; gap: 6px 16px; } .check { display: inline-flex; gap: 5px; align-items: center; font-weight: 400; } .check input { width: auto; }
.actions { display: flex; gap: 8px; margin-top: 12px; }
.btn { display: inline-block; padding: 7px 14px; border-radius: 7px; border: 1px solid #c9d0d8; background: #fff; color: var(--ink); cursor: pointer; font-weight: 600; font-size: .9rem; }
.btn:hover { border-color: var(--brand); color: var(--brand); text-decoration: none; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; } .btn.primary:hover { background: var(--brand-d); color: #fff; }
.btn.danger { color: var(--danger); border-color: #e7c1be; } .btn.danger:hover { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn.small { padding: 4px 10px; font-size: .82rem; } .btn.active { background: var(--accent); border-color: var(--accent); color: #fff; }
form.inline { display: inline; }
.filters { display: flex; gap: 8px; align-items: center; margin-bottom: 12px; flex-wrap: wrap; } .filters input, .filters select { width: auto; min-width: 150px; }
.sizing input { padding: 4px 6px; } .sizing input.n, input.n { text-align: right; width: 7.5em; } .sizing input.unit { width: 5em; } .sizing .newrow input[name=new_label] { width: 12em; }
.newrow td { background: #fafbfc; }
.flash { padding: 10px 14px; border-radius: 8px; margin-bottom: 12px; border: 1px solid; }
.flash.ok { background: #e6f4ec; border-color: #bfe0cd; color: #17633c; } .flash.error { background: #fdecea; border-color: #f3c3bf; color: #8f1d17; } .flash.info { background: #e8effd; border-color: #c6d5f7; color: #2748a8; }
.linkbox { border-color: var(--accent); background: #fff8f0; } .linkbox input { margin-top: 8px; font-family: ui-monospace, Consolas, monospace; font-size: .85rem; }

/* detail fields, notes, markdown */
.fields { display: grid; gap: 12px; } .field .k { font-size: .78rem; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin-bottom: 2px; }
.md p:first-child { margin-top: 0; } .md p:last-child { margin-bottom: 0; } .md ul, .md ol { margin: .3rem 0 .6rem; padding-left: 1.3rem; }
.md code { background: var(--mist); padding: 1px 4px; border-radius: 4px; font-size: .88em; } .md pre { background: var(--mist); padding: 10px; border-radius: 7px; overflow-x: auto; }
.md blockquote { margin: .4rem 0; padding-left: 10px; border-left: 3px solid var(--line); color: var(--ink2); } .md h3, .md h4, .md h5, .md h6 { margin: .8rem 0 .3rem; font-size: .98rem; }
.note { border: 1px solid #edf0f3; border-radius: 8px; padding: 9px 12px; margin-bottom: 8px; background: #fbfcfd; } .note-head { font-size: .85rem; margin-bottom: 3px; }
.note-form { margin-top: 10px; display: grid; gap: 8px; justify-items: start; }

/* map */
.map-bar { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; margin-bottom: 8px; } .map-bar select { width: auto; }
.legend { display: flex; gap: 6px; flex-wrap: wrap; }
.legend label { display: inline-flex; gap: 5px; align-items: center; font-size: .8rem; padding: 2px 9px; border-radius: 99px; border: 1px solid var(--line); background: #fff; cursor: pointer; user-select: none; }
.legend label i { width: 14px; height: 3px; border-radius: 2px; background: var(--c); display: inline-block; } .legend input { display: none; } .legend label.off { opacity: .4; }
.map-wrap { position: relative; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); height: calc(100vh - 215px); min-height: 460px; overflow: hidden; }
#map { width: 100%; height: 100%; display: block; cursor: grab; background-image: radial-gradient(#dfe4ea 1px, transparent 1px); background-size: 22px 22px; }
#map.panning { cursor: grabbing; } #map.connecting, #map.connecting .node { cursor: crosshair; }
.node { cursor: move; } .node rect { fill: #fff; stroke: #9aa6b2; stroke-width: 1.5; } .node.module rect { stroke-dasharray: 4 3; }
.node text { font-size: 13px; fill: var(--ink); pointer-events: none; } .node .sub { font-size: 10.5px; fill: var(--muted); }
.node .bar { stroke: none; } .node.sel rect.box { stroke: var(--accent); stroke-width: 3; } .node.dim, .edge.dim { opacity: .15; }
.node.life-retired text { text-decoration: line-through; }
.edge path.line { fill: none; stroke-width: 2; } .edge path.hit { fill: none; stroke: transparent; stroke-width: 14; cursor: pointer; }
.edge.status-proposed path.line { stroke-dasharray: 7 5; } .edge.sel path.line { stroke-width: 4; }
.edge text { font-size: 11px; paint-order: stroke; stroke: #fff; stroke-width: 4px; pointer-events: none; }
.map-info { position: absolute; top: 12px; right: 12px; width: 300px; max-height: calc(100% - 24px); overflow: auto; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; box-shadow: 0 6px 24px rgba(23,33,43,.12); }
.map-info h3 { margin: 0 0 6px; } .map-info .x { float: right; cursor: pointer; border: 0; background: none; font-size: 1.1rem; color: var(--muted); }

@media (max-width: 900px) {
  .side { position: static; width: auto; flex-direction: row; flex-wrap: wrap; align-items: center; }
  .side nav { flex-direction: row; flex-wrap: wrap; } .side .sep { display: none; } .brand { margin: 0 10px 0 0; } .me { border: 0; padding: 0; } .me a { width: auto; }
  .main { margin: 0; padding: 16px; } .cols, .form-grid { grid-template-columns: 1fr; } .tiles { grid-template-columns: repeat(2, 1fr); } .head { flex-direction: column; }
}
@media print { .side, .tools, .tabs, .note-form, .filters { display: none !important; } .main { margin: 0; padding: 0; } .card { break-inside: avoid; } }
