:root { --accent: #2a5db0; --muted: #666; }
* { box-sizing: border-box; }
body { margin: 0; font-family: system-ui, -apple-system, sans-serif; color: #222; }
header { display: flex; justify-content: space-between; align-items: center; padding: 0.6rem 1.2rem; background: #123; color: #fff; }
header a { color: #fff; text-decoration: none; margin-left: 1rem; }
header .brand { font-weight: 700; font-size: 1.1rem; }
header .brand a { margin: 0; }
main { max-width: 1100px; margin: 1.2rem auto; padding: 0 1.2rem; }
main.wide { max-width: none; }
h1 { font-size: 1.5rem; margin-bottom: 0.4rem; }
h2 { font-size: 1.05rem; border-bottom: 1px solid #ddd; padding-bottom: 0.2rem; margin-top: 1.6rem; }
p.hint, p.meta { color: var(--muted); font-size: 0.9rem; }
.status { font-size: 0.75rem; padding: 2px 8px; border-radius: 10px; vertical-align: middle; }
.status.active { background: #cdeccd; color: #174; }
.status.inactive { background: #f8d7da; color: #7a2a2a; }
.status.unknown { background: #eee; color: #555; }
table { border-collapse: collapse; width: 100%; margin: 0.5rem 0; }
th, td { border: 1px solid #ddd; padding: 5px 8px; text-align: left; font-size: 0.9rem; vertical-align: top; }
th { background: #f4f4f4; }
.empty { color: var(--muted); font-style: italic; }
.flashes { max-width: 1100px; margin: 0.8rem auto; padding: 0 1.2rem; }
.flash { padding: 6px 10px; border-radius: 4px; margin-bottom: 4px; font-size: 0.9rem; }
.flash.ok { background: #d4edda; }
.flash.error { background: #f8d7da; }
form.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 6px; margin: 6px 0; }
form.form { display: flex; flex-direction: column; gap: 8px; max-width: 640px; }
form.form label { display: flex; flex-direction: column; gap: 3px; font-size: 0.85rem; color: var(--muted); }
form.form input, form.form select, form.form textarea { padding: 6px; font-size: 0.95rem; color: #222; }
form.form fieldset { border: 1px solid #ddd; border-radius: 4px; display: flex; flex-direction: column; gap: 6px; }
form.form .pair { display: flex; gap: 8px; }
form.form .pair label { flex: 1; }
form.grid input, form.grid select, form.grid button { padding: 5px; }
form.inline { display: inline; }
details { margin: 0.5rem 0; }
details summary { cursor: pointer; color: var(--accent); }
a { color: var(--accent); }
.btn, button { background: var(--accent); color: #fff; border: 0; padding: 6px 12px; border-radius: 4px; cursor: pointer; font-size: 0.9rem; text-decoration: none; }
button.link { background: none; color: var(--accent); padding: 0; text-decoration: underline; }
.kind { color: var(--muted); font-size: 0.8rem; }
section ul { margin: 0.3rem 0; }
.prec { font-size: 0.7rem; background: #eee; border-radius: 8px; padding: 1px 6px; color: #555; margin-left: 4px; }
.prec[title] { cursor: help; }

/* ---- graph page tabs ---- */
.tabs { display: flex; gap: 4px; margin-top: 0.6rem; border-bottom: 1px solid #ddd; }
.tabs button { background: none; border: 1px solid transparent; border-bottom: 0; border-radius: 4px 4px 0 0; color: var(--muted); padding: 6px 14px; }
.tabs button.active { color: var(--accent); border-color: #ddd; background: #fff; font-weight: 600; margin-bottom: -1px; }
.tabpanel { padding-top: 0.6rem; }

/* ---- tree view (cytoscape) ---- */
#tree-toolbar { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; margin-bottom: 6px; font-size: 0.85rem; color: var(--muted); }
#tree-toolbar label { display: flex; gap: 4px; align-items: center; }
#tree-search { padding: 5px 8px; font-size: 0.9rem; min-width: 200px; }
#tree-hint { font-style: italic; }
#tree-fit { margin-left: auto; padding: 5px 10px; font-size: 0.85rem; border: 1px solid #bbb; border-radius: 4px; background: #fff; cursor: pointer; }
#tree { height: 78vh; border: 1px solid #ddd; background: #fafafa; }

/* ---- timeline graph (SVG) ---- */
.filterbar { margin: 0.5rem 0; display: flex; align-items: center; gap: 8px; }
.filterbar input { padding: 6px 10px; font-size: 0.95rem; width: 280px; border: 1px solid #bbb; border-radius: 4px; }
.filterbar .hint { font-size: 0.85rem; }
.filterbar .legend { margin-left: auto; font-size: 0.8rem; color: var(--muted); white-space: nowrap; }
.legend .lg { border-bottom: 3px solid; padding-bottom: 1px; margin-left: 8px; }
.legend .lg.ty-acquisition { border-color: #777; }
.legend .lg.ty-merger { border-color: #2a5db0; }
.legend .lg.ty-rename { border-color: #7a3aa0; }
.legend .lg.ty-split { border-color: #c07000; }
svg.tg { display: block; min-width: 100%; }
svg.tg text.tg-year { font-size: 10px; fill: #888; }
svg.tg line.tg-tick { stroke: #ccc; stroke-width: 1; }
svg.tg path.tg-edge { fill: none; stroke: #777; stroke-width: 1.4; }
svg.tg text.tg-edge-label { font-size: 10px; fill: #555; }
svg.tg path.tg-arrowhead { fill: #777; }
/* transition-type colours (edges, arrowheads, legend swatches) */
svg.tg path.tg-edge.ty-merger { stroke: #2a5db0; }
svg.tg path.tg-edge.ty-rename { stroke: #7a3aa0; }
svg.tg path.tg-edge.ty-split { stroke: #c07000; }
svg.tg path.tg-arrowhead.ty-merger { fill: #2a5db0; }
svg.tg path.tg-arrowhead.ty-rename { fill: #7a3aa0; }
svg.tg path.tg-arrowhead.ty-split { fill: #c07000; }
svg.tg text.tg-label { font-size: 12px; fill: #222; font-weight: 600; pointer-events: none; }
svg.tg text.tg-yearlabel { font-size: 9px; fill: #888; pointer-events: none; }
svg.tg path.st-active { stroke: #2a7a2a; stroke-width: 2.5; }
svg.tg path.st-inactive { stroke: #a03a3a; stroke-width: 2.5; }
svg.tg path.st-unknown { stroke: #888; stroke-width: 2.5; }
svg.tg path.st-placeholder { stroke-dasharray: 5 4; opacity: 0.75; }
svg.tg path.st-extends { stroke-dasharray: 2 3; }
svg.tg path.st-alive { stroke-width: 4; }
svg.tg g.tg-line:hover path { filter: brightness(0.8); }
svg.tg g.tg-line:hover text.tg-label { text-decoration: underline; }
/* date-precision badges (year label has pointer-events:none; badges re-enable it) */
.prec-approx { color: #b8860b; }
.prec-by { color: #2a5db0; }
.prec-unknown { color: #a03a3a; }
svg.tg tspan.tg-prec { font-weight: 700; pointer-events: all; cursor: help; }
svg.tg tspan.tg-prec.prec-approx { fill: #b8860b; }
svg.tg tspan.tg-prec.prec-by { fill: #2a5db0; }
svg.tg tspan.tg-prec.prec-unknown { fill: #a03a3a; }
/* era overlays: translucent background bands behind the data */
svg.tg rect.tg-era { pointer-events: none; }
svg.tg text.tg-era-label { font-size: 10px; fill: #445; font-weight: 600; pointer-events: none; }
/* era multi-select dropdown */
.era-picker { position: relative; display: inline-block; margin-left: 10px; }
.era-btn { background: #fff; color: var(--accent); border: 1px solid #ccc; border-radius: 4px; padding: 3px 10px; font-size: 0.85rem; cursor: pointer; }
.era-btn:hover { border-color: var(--accent); }
.era-btn.has-selection { background: var(--accent); color: #fff; border-color: var(--accent); font-weight: 600; }
.era-menu { position: absolute; right: 0; top: calc(100% + 4px); background: #fff; border: 1px solid #ddd; border-radius: 4px; box-shadow: 0 2px 8px rgba(0,0,0,.15); padding: 6px; z-index: 20; min-width: 230px; max-height: 60vh; overflow: auto; display: flex; flex-direction: column; gap: 2px; }
.era-menu[hidden] { display: none; }
.era-menu .era-master { display: flex; gap: 6px; align-items: center; cursor: pointer; font-size: 0.85rem; font-weight: 600; padding: 3px 6px; border-bottom: 1px solid #eee; margin-bottom: 4px; }
.era-menu .era-row { display: flex; gap: 6px; align-items: center; cursor: pointer; font-size: 0.85rem; padding: 3px 6px; border-radius: 3px; }
.era-menu .era-row:hover { background: #f0f4fa; }
.era-menu .era-row, .era-menu .era-master { white-space: nowrap; }
.era-menu input[type="checkbox"] { width: 14px; height: 14px; margin: 0; flex: none; }
.era-swatch { display: inline-block; width: 12px; height: 12px; border-radius: 2px; border: 1px solid rgba(0,0,0,0.15); flex: none; }
/* sticky year-axis + era-title band pinned to the top of the scrolling SVG */
.era-header { position: sticky; top: 0; background: #fff; border-bottom: 1px solid #ddd; box-shadow: 0 2px 6px rgba(0,0,0,0.08); z-index: 5; overflow: hidden; min-height: 40px; }
.era-header span { position: absolute; white-space: nowrap; pointer-events: none; }
.era-header span.tg-h-year { top: 3px; font-size: 10px; color: #888; }
.era-header span.tg-h-era { top: 27px; font-size: 10px; font-weight: 600; color: #445; }
.era-header span.tg-h-tick { top: 20px; width: 1px; height: 6px; background: #ccc; }
