/* GuildNet console (A3, sidebar). Colours, type and radii come from
   tokens.css; this file is layout and components only. */

body { font-size: 15px; line-height: 1.5; }
h1 { font-size: 30px; line-height: 1.15; letter-spacing: -.5px; margin: 0; }
h2 { font-size: 19px; line-height: 1.25; margin: 0; }
p { margin: 0; }

/* Frame: sidebar, page, and an optional panel on the right. */
.app { display: grid; grid-template-columns: 248px minmax(0, 1fr) auto; min-height: 100vh; }
.sidebar { position: sticky; top: 0; height: 100vh; background: var(--rail); border-right: 1px solid var(--line); padding: 20px 14px; display: flex; flex-direction: column; gap: 4px; }
.sidebar .network { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 18px; padding: 0 8px 16px; overflow-wrap: anywhere; }
.sidebar .hire { height: 42px; margin-bottom: 14px; }
.sidebar > a:not(.button) { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: var(--radius); color: var(--muted); text-decoration: none; }
.sidebar > a:not(.button):hover { background: var(--selected); color: var(--text); }
.sidebar > a.here { background: var(--tonal); color: var(--on-tonal); font-weight: 600; }
.sidebar .count { margin-left: auto; }
.me { margin-top: auto; display: flex; align-items: center; gap: 10px; padding: 8px 4px 0 6px; color: var(--muted); }
.me .who { display: flex; flex-direction: column; flex-grow: 1; min-width: 0; font-size: 14px; line-height: 1.3; overflow-wrap: anywhere; }
.me .who form { margin: 0; }
.me .who button.link { font-size: 13px; color: var(--faint); }

main { padding: 30px 32px 48px; display: flex; flex-direction: column; gap: 20px; max-width: 1100px; }

/* Avatars are rounded squares; agents' are tonal. */
.avatar { width: 38px; height: 38px; border-radius: var(--radius); background: var(--selected); color: var(--text); display: inline-flex; align-items: center; justify-content: center; font-weight: 700; flex-shrink: 0; }
.avatar.agent { background: var(--tonal); color: var(--on-tonal); }
.me .avatar { width: 32px; height: 32px; }
.avatar.big { width: 56px; height: 56px; font-size: 24px; border-radius: var(--radius-card); }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-card); padding: 20px; display: flex; flex-direction: column; gap: 14px; }

/* Teams and the people in them. */
.teams { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; }
.team header { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.team .channel { margin-left: auto; font-family: var(--mono); font-size: 13px; color: var(--faint); }
.people { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 14px; }
.people li { display: flex; align-items: center; gap: 12px; }
.people .name { font-weight: 500; }
.people .name a { color: var(--text); text-decoration: none; }
.people .name a:hover { color: var(--accent); text-decoration: underline; }
.people .role { color: var(--faint); font-size: 14px; }
.people .amount { margin-left: auto; font-family: var(--mono); font-size: 13px; color: var(--muted); }

/* Forms. */
.fields { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 14px; align-items: end; }
.fields .wide { grid-column: 1 / -1; }
.fields button { justify-self: start; }
.danger-zone { border-color: var(--danger); flex-direction: row; align-items: end; flex-wrap: wrap; }
.danger-zone label { flex-grow: 1; }
.profile { display: flex; align-items: center; gap: 16px; }
.facts { display: grid; grid-template-columns: max-content 1fr; gap: 8px 20px; margin: 0; }
.facts dt { color: var(--faint); }
.facts dd { margin: 0; }

/* Getting started: the owner's checklist on the org chart. */
.getting-started-head { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.getting-started-head form { margin: 0 0 0 auto; }
.steps { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 12px; }
.step { display: flex; align-items: flex-start; gap: 12px; }
.step .tick { width: 24px; height: 24px; flex-shrink: 0; border-radius: 999px; border: 1.5px solid var(--line); display: inline-flex; align-items: center; justify-content: center; font-size: 14px; font-weight: 700; }
.step.done .tick { background: var(--tonal); color: var(--on-tonal); border-color: transparent; }
.step .what { display: flex; flex-direction: column; flex-grow: 1; min-width: 0; }
.step .title { font-weight: 600; }
.step.done .title { color: var(--muted); font-weight: 400; text-decoration: line-through; }
.step .hint { color: var(--muted); font-size: 14px; }
.step .go { display: flex; gap: 12px; align-items: center; white-space: nowrap; font-size: 14px; }
.step .go form { margin: 0; }
td.said { white-space: pre-wrap; overflow-wrap: anywhere; min-width: 240px; }
table.feedback tr.read td { color: var(--muted); }
td.row-actions { white-space: nowrap; }
td.row-actions form { display: inline; margin-left: 10px; }
@media (max-width: 520px) { .step { flex-wrap: wrap; } .step .go { margin-left: 36px; } }

/* Charts, drawn by charts.js: two side by side where there's room. */
.tile meter { width: 100%; height: 8px; margin-top: 4px; }
.charts { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 420px), 1fr)); gap: 16px; }
.chart { position: relative; height: 260px; min-width: 0; }
.chart.chart-short { height: auto; min-height: 120px; aspect-ratio: 4 / 1; }

/* People: invite and reset links, shown once to copy. */
.link-box { width: 100%; font-family: var(--mono); font-size: 13px; }
label.check { flex-direction: row; align-items: center; gap: 8px; align-self: end; height: 44px; }
label.check input { width: auto; height: auto; accent-color: var(--accent); }
.people .push { margin-left: auto; }
.me .who a.account-link { color: inherit; text-decoration: none; }
.me .who a.account-link:hover, .me .who a.account-link[aria-current] { color: var(--text); text-decoration: underline; }
details.card > summary { cursor: pointer; font-weight: 600; }

/* Approvals: tonal banners with the decision right there. */
.waiting { width: 320px; background: var(--rail); border-left: 1px solid var(--line); padding: 28px 20px; display: flex; flex-direction: column; gap: 14px; }
.waiting h2 { font-size: 16px; }
.waiting > a { font-size: 14px; }
.banner { background: var(--tonal); color: var(--on-tonal); border-radius: var(--radius-card); padding: 16px 18px; display: flex; flex-direction: column; gap: 10px; line-height: 1.45; }
.banner .small { font-size: 13px; opacity: .85; }
.banner .badge.ai { vertical-align: 1px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.actions form { margin: 0; display: flex; gap: 8px; }
.banner button { height: 36px; }
.banner button.outline { border-color: var(--on-tonal); color: var(--on-tonal); }
.deny input { height: 36px; min-width: 240px; }

/* Signed out: one card in the middle. */
.bare { display: flex; align-items: center; justify-content: space-between; padding: 20px clamp(16px, 5vw, 48px); }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 20px; }
main.narrow { max-width: 440px; margin: 8vh auto; padding: 0 16px; }
.signin form { display: flex; flex-direction: column; gap: 14px; }
.signin h1 { font-size: 26px; }

@media (max-width: 1100px) {
  .app { grid-template-columns: 220px minmax(0, 1fr); }
  .waiting { grid-column: 2; width: auto; border-left: 0; border-top: 1px solid var(--line); background: transparent; padding: 0 32px 32px; }
}

@media (max-width: 760px) {
  .app { display: flex; flex-direction: column; }
  .sidebar { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; gap: 4px 6px; padding: 12px 16px; border-right: 0; border-bottom: 1px solid var(--line); }
  .sidebar .network { padding: 0 8px 0 0; }
  .sidebar .hire { order: 4; width: 100%; margin: 6px 0 0; height: 40px; }
  .sidebar > a:not(.button) { order: 3; gap: 6px; padding: 6px 8px; font-size: 14px; }
  .sidebar > a:not(.button) svg { display: none; }
  .me { order: 1; margin: 0 0 0 auto; padding: 0; }
  .me .avatar { display: none; }
  .me .who { flex-direction: row; align-items: center; gap: 10px; }
  .waiting { padding: 16px 16px 0; }
  main { order: 1; padding: 20px 16px 40px; }
  .teams { grid-template-columns: 1fr; }
  .deny input { min-width: 0; flex-grow: 1; }
  h1 { font-size: 26px; }
}

/* Chat, docked beside every console page so it stays connected as you move
   between them: a column on the right where there's room, a panel over the
   page where there isn't, and a sheet from the bottom on a phone. Hidden, a
   button brings it back. The Chat page widens it to fill the page. The
   page's own parts sit directly in the .app grid (#page is only a wrapper
   for swapping). */
div#page { display: contents; } /* not the sign-in page's main#page, which keeps its own box */
.app.with-chat { grid-template-columns: 248px minmax(0, 1fr) auto auto; }
.chat-dock { grid-column: -2; grid-row: 1; position: sticky; top: 0; height: 100vh; width: var(--chat-width, clamp(400px, 28vw, 640px)); display: flex; flex-direction: column; background: var(--bg); border-left: 1px solid var(--line); z-index: 5; }
/* Its left edge: drag to make the chat wider or narrower. */
.chat-dock-resize { position: absolute; left: -4px; top: 0; bottom: 0; width: 8px; cursor: col-resize; z-index: 1; touch-action: none; }
.chat-dock-resize:hover, .chat-dock-resize:focus-visible { background: var(--accent); opacity: .5; outline: none; }
.chat-resizing, .chat-resizing * { cursor: col-resize; user-select: none; }
.chat-resizing .chat-app { pointer-events: none; }
.chat-dock-bar { display: flex; align-items: center; justify-content: space-between; padding: 10px 14px; border-bottom: 1px solid var(--line); background: var(--rail); }
.chat-dock-bar .title { display: flex; align-items: center; gap: 8px; font-weight: 700; }
.chat-app { display: block; width: 100%; flex: 1; min-height: 0; border: 0; background: var(--bg); }
.chat-open { display: none; position: fixed; right: 20px; bottom: 20px; z-index: 6; box-shadow: var(--shadow); border-radius: 999px; }
:root[data-chat="hidden"] .chat-dock { display: none; }
:root[data-chat="hidden"] .chat-open { display: inline-flex; }
.chat-missing { padding: 30px 32px; display: flex; flex-direction: column; gap: 12px; }

/* The Chat page: the dock fills the page, whether or not it's hidden. */
#page[data-chat="wide"] > main { display: none; }
.app:has(#page[data-chat="wide"]) .chat-dock { display: flex; grid-column: 2 / -1; width: auto; border-left: 0; }
.app:has(#page[data-chat="wide"]) .chat-dock-bar,
.app:has(#page[data-chat="wide"]) .chat-dock-resize,
.app:has(#page[data-chat="wide"]) .chat-open { display: none; }

@media (max-width: 1100px) {
  .app.with-chat { grid-template-columns: 220px minmax(0, 1fr); }
  .chat-dock { position: fixed; top: 0; right: 0; bottom: 0; height: auto; width: min(var(--chat-width, 400px), 92vw); box-shadow: var(--shadow); }
  .app:has(#page[data-chat="wide"]) .chat-dock { position: sticky; height: 100vh; width: auto; box-shadow: none; }
}
@media (max-width: 760px) {
  .chat-dock { top: auto; left: 0; width: auto; height: 70vh; border-left: 0; border-top: 1px solid var(--line); }
  .chat-dock-resize { display: none; }
  .app:has(#page[data-chat="wide"]) { height: 100dvh; }
  .app:has(#page[data-chat="wide"]) .chat-dock { position: static; order: 2; flex: 1; height: auto; min-height: 0; }
}

/* The home page for people signed in with Google: their networks, and
   creating one. */
main.home { max-width: 720px; margin: 4vh auto 48px; padding: 0 16px; }
.bare .brand { color: var(--text); text-decoration: none; }
.bare .actions form { margin: 0; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.small { font-size: 13px; }
.button.google, .button.create, button.create { align-self: flex-start; }
.network-card { flex-direction: row; align-items: center; flex-wrap: wrap; gap: 6px 14px; color: var(--text); text-decoration: none; }
.network-card:hover { border-color: var(--accent); color: var(--text); }
.network-name { font-weight: 700; font-size: 18px; }
.status { margin-left: auto; font-size: 13px; font-weight: 600; padding: 2px 10px; border-radius: 999px; background: var(--selected); }
.status-ready { background: var(--tonal); color: var(--on-tonal); }
.status-failed { background: var(--danger-soft); color: var(--on-danger-soft); }
.create-network { display: flex; flex-direction: column; gap: 16px; }
.address { flex-direction: row; align-items: center; gap: 0; }
.address input { flex-grow: 1; min-width: 0; border-radius: var(--radius) 0 0 var(--radius); font-family: var(--mono); }
.address .suffix { height: 44px; display: inline-flex; align-items: center; padding: 0 12px; border: 1px solid var(--line); border-left: 0; border-radius: 0 var(--radius) var(--radius) 0; background: var(--rail); font-family: var(--mono); font-size: 14px; color: var(--muted); }
.templates { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px; }
.template { position: relative; border: 1px solid var(--line); border-radius: var(--radius-card); padding: 14px 14px 14px 42px; gap: 4px; color: var(--text); font-size: 14px; cursor: pointer; }
.template input { position: absolute; left: 14px; top: 14px; height: auto; margin: 2px 0 0; accent-color: var(--accent); }
.template .title { font-weight: 700; font-size: 15px; }
.template:has(input:checked) { border-color: var(--accent); background: var(--tonal); color: var(--on-tonal); }
.template:has(input:checked) .muted { color: inherit; opacity: .85; }
.template:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; }
.setup.ready { border-color: var(--accent); }
.setup.failed { border-color: var(--danger); }
@media (max-width: 520px) {
  .bare .actions .muted { display: none; }
  .status { margin-left: 0; }
}

/* The admin section: wider pages, tabs, tiles of numbers, and tables that
   scroll sideways on their own on a phone rather than the page. */
main.home.admin { max-width: 1180px; margin-top: 3vh; }
.admin-nav { display: flex; flex-wrap: wrap; gap: 4px; border-bottom: 1px solid var(--line); padding-bottom: 8px; }
.admin-nav a { padding: 6px 12px; border-radius: var(--radius); color: var(--muted); text-decoration: none; }
.admin-nav a:hover { background: var(--selected); color: var(--text); }
.admin-nav a.here { background: var(--tonal); color: var(--on-tonal); font-weight: 600; }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; }
.tile { gap: 4px; color: var(--text); text-decoration: none; }
a.tile:hover { border-color: var(--accent); color: var(--text); }
.tile .label { font-size: 13px; font-weight: 600; color: var(--muted); }
.tile .n { font-size: 26px; font-weight: 700; line-height: 1.2; }
.table-wrap { overflow-x: auto; margin: 0 -4px; }
table.data { width: 100%; border-collapse: collapse; font-size: 14px; }
table.data th { text-align: left; font-size: 12px; font-weight: 600; color: var(--faint); text-transform: uppercase; letter-spacing: .4px; padding: 6px 8px; border-bottom: 1px solid var(--line); white-space: nowrap; }
table.data td { padding: 10px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.data tr:last-child td { border-bottom: 0; }
table.data td.when { white-space: nowrap; }
table.data form { margin: 0; }
form.inline { display: inline; }
.badge { display: inline-block; font-size: 12px; font-weight: 600; padding: 1px 8px; border-radius: 999px; background: var(--tonal); color: var(--on-tonal); }
.badge.danger { background: var(--danger-soft); color: var(--on-danger-soft); }
button.link.danger { color: var(--danger); }
.small-button { height: 30px; padding: 0 12px; font-size: 13px; }
.status-suspended { background: var(--danger-soft); color: var(--on-danger-soft); }
.status-deleting, .status-creating { background: var(--selected); }
details.delete summary { cursor: pointer; color: var(--danger); font-size: 14px; }
details.delete form { display: flex; flex-direction: column; gap: 8px; margin-top: 8px; min-width: 180px; }
details.delete input { height: 36px; }
.log { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.table-wrap .status { margin-left: 0; }

/* Managing the org: page heads with a link beside the title, team trees,
   groups of checkboxes, goals with where they stand. */
.page-head { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.page-head .push { margin-left: auto; }
.page-head p { margin: 4px 0 0; }
.lede { font-size: 17px; max-width: 70ch; margin: 0; }
.tree .depth-1 { padding-left: 24px; }
.tree .depth-2 { padding-left: 48px; }
.tree .depth-3, .tree .depth-4, .tree .depth-5 { padding-left: 72px; }
fieldset.checks { border: 1px solid var(--line); border-radius: var(--radius); padding: 8px 12px 12px; display: flex; flex-wrap: wrap; gap: 4px 16px; }
fieldset.checks legend { color: var(--faint); font-size: 13px; padding: 0 4px; }
fieldset.checks label.check { height: auto; }
.goal-progress input { width: 7em; height: 32px; padding: 4px 8px; }
.goals li { flex-wrap: wrap; }
/* The org chart as a reporting tree: each person's reports indented under
   them on a guide line, collapsible. */
.view-switch { display: flex; gap: 4px; flex-wrap: wrap; align-items: center; }
.view-switch a { padding: 6px 12px; border-radius: var(--radius); color: var(--muted); text-decoration: none; }
.view-switch a:hover { background: var(--selected); color: var(--text); }
.view-switch a[aria-current] { background: var(--tonal); color: var(--on-tonal); font-weight: 600; }
.view-switch .push { margin-left: auto; }
.org-tree { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.org-tree .org-tree { margin: 10px 0 0 17px; padding-left: 18px; border-left: 1px solid var(--line); }
.org-tree summary { list-style: none; cursor: pointer; }
.org-tree summary::-webkit-details-marker { display: none; }
.org-tree details:not([open]) > summary .node::after { content: "+"; margin-left: 6px; color: var(--faint); }
.org-tree .node { display: inline-flex; align-items: center; gap: 12px; }
.org-tree .name { font-weight: 500; }
.org-tree .name a { color: var(--text); text-decoration: none; }
.org-tree .name a:hover { color: var(--accent); text-decoration: underline; }
.org-tree .role { display: block; color: var(--faint); font-size: 14px; }
.org-tree li.you > .node, .org-tree li.you > details > summary .node { outline: 2px solid var(--accent); outline-offset: 4px; border-radius: var(--radius); }
/* The org chart as a picture: boxes top-down, joined by lines, coloured by
   team. Drawn with CSS only: each level is a row of boxes, and each box's
   ::before and ::after draw its half of the line above it. */
.org-picture-card { gap: 10px; }
main:has(.org-picture) { max-width: none; }
.org-picture-scroll { overflow: auto; padding: 8px 0 4px; }
.org-picture, .org-picture ul { list-style: none; margin: 0; padding: 0; display: flex; justify-content: center; }
.org-picture { min-width: max-content; margin: 0 auto; }
.org-picture ul { padding-top: 22px; position: relative; }
.org-picture ul::before { content: ""; position: absolute; top: 0; left: 50%; height: 22px; border-left: 2px solid var(--line); }
.org-picture li { display: flex; flex-direction: column; align-items: center; position: relative; padding: 22px 8px 0; }
.org-picture > li { padding-top: 0; }
.org-picture li::before, .org-picture li::after { content: ""; position: absolute; top: 0; width: 50%; height: 22px; border-top: 2px solid var(--line); }
.org-picture li::before { right: 50%; }
.org-picture li::after { left: 50%; border-left: 2px solid var(--line); }
.org-picture li:only-child::before, .org-picture li:only-child::after { border-top: 0; }
.org-picture li:first-child::before, .org-picture li:last-child::after { border-top: 0; }
.org-picture li:last-child::before { border-right: 2px solid var(--line); border-top-right-radius: 8px; }
.org-picture li:first-child::after { border-top-left-radius: 8px; }
.org-picture > li::before, .org-picture > li::after { display: none; }
.org-picture .box { display: grid; justify-items: center; gap: 2px; width: 150px; padding: 12px 10px 10px; border-radius: var(--radius-card);
  background: var(--surface); border: 1px solid var(--line); border-top: 4px solid var(--team, var(--line)); color: var(--text); text-decoration: none; text-align: center;
  transition: transform .12s ease, box-shadow .12s ease; }
.org-picture .box:hover { transform: translateY(-2px); box-shadow: 0 6px 18px rgba(0,0,0,.18); }
.org-picture .box.ai { border-style: dashed; border-top-style: solid; }
.org-picture .box.you { outline: 2px solid var(--accent); outline-offset: 3px; }
.org-picture .box .avatar { margin-bottom: 4px; }
.org-picture .who { font-weight: 600; }
.org-picture .what { font-size: 13px; color: var(--muted); }
.org-picture .where { font-size: 12px; color: var(--team, var(--faint)); font-weight: 600; }
.org-picture .reports { font-size: 12px; color: var(--faint); }
.legend { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 13px; color: var(--muted); }
.legend li { display: flex; align-items: center; gap: 6px; }
.swatch { width: 12px; height: 12px; border-radius: 3px; background: var(--team); display: inline-block; }
.swatch.ai { background: transparent; border: 1.5px dashed var(--muted); }
.tc-0 { --team: #6b73ff; } .tc-1 { --team: #1fa38a; } .tc-2 { --team: #d98a1c; } .tc-3 { --team: #d4537e; }
.tc-4 { --team: #3b8fd9; } .tc-5 { --team: #8f63d6; } .tc-6 { --team: #5c9e2e; } .tc-7 { --team: #c2562c; }
@media (prefers-reduced-motion: reduce) { .org-picture .box { transition: none; } .org-picture .box:hover { transform: none; } }