/* DocGen UI: a calm dashboard (web-app UI standard, copied from app-intake). Colours are tokens; dark mode follows the system. */
:root {
  /* Aminess (aminess.com): white and sand surfaces, warm charcoal text, the brand teal for the primary
     action. Light only, as asked. The teal is too light for white text (1.85:1), so primary buttons
     carry charcoal text on it (6.49:1) and links use a darker teal; every pair below is 4.5:1 or better. */
  --bg: #f9f5ee;
  --surface: #ffffff;
  --surface-2: #f4f1ea;
  --fg: #383635;
  --muted: #6b6764;
  --line: #e6e1d8;
  --accent: #23696f;
  --accent-fg: #ffffff;
  --accent-soft: #e4f4f5;
  --brand: #78ccd0;
  --brand-hover: #6bbfc4;
  --brand-fg: #383635;
  --ok: #2f7a4a;
  --ok-soft: #e9f4ec;
  --bad: #c61736;
  --bad-soft: #fbeaed;
  --warn: #9a5b06;
  --warn-soft: #fbf1e1;
  --info-soft: #eef4f4;
  --radius: 4px;
  --shadow: 0 1px 2px rgba(56, 54, 53, 0.05);
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--fg);
  font: 14px/1.55 "Helvetica Neue", Arial, system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
code, pre { font-family: var(--mono); font-size: 12.5px; }
h1 { font-size: 24px; line-height: 1.3; margin: 0; font-weight: 500; letter-spacing: -0.01em; overflow-wrap: anywhere; }
h2 { font-size: 12px; margin: 0; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); }

/* --- layout --- */
.app { display: grid; grid-template-columns: 220px minmax(0, 1fr); min-height: 100vh; }
.sidebar {
  position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column; gap: 20px;
  padding: 20px 14px; background: var(--surface); border-right: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 16px; color: var(--fg); padding: 0 8px; }
.brand:hover { text-decoration: none; }
.logo { height: 30px; width: auto; display: block; }
.brand-name { font-size: 12px; font-weight: 600; letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted); padding-top: 6px; }
nav { display: flex; flex-direction: column; gap: 2px; }
.nav-link { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: var(--radius); color: var(--muted); font-weight: 500; }
.nav-link:hover { background: var(--surface-2); color: var(--fg); text-decoration: none; }
.nav-link.active { background: var(--accent-soft); color: var(--fg); box-shadow: inset 3px 0 0 var(--brand); }
.nav-icon { width: 16px; text-align: center; }
.sidebar footer { margin-top: auto; padding: 0 8px; }
.content { padding: 28px 32px 48px; max-width: 1240px; width: 100%; }
.page { display: flex; flex-direction: column; gap: 18px; }
.page-head { display: flex; flex-direction: column; gap: 6px; }
.page-head p { margin: 0; }
.split { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 18px; align-items: start; }
.main-col, .side { display: flex; flex-direction: column; gap: 18px; min-width: 0; }
.grid-2 { display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); gap: 18px; }
.board { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; align-items: start; }

@media (max-width: 1100px) {
  .board { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .split, .grid-2 { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 720px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .sidebar { position: static; height: auto; flex-direction: row; align-items: center; flex-wrap: wrap; gap: 8px; padding: 10px 16px; border-right: 0; border-bottom: 1px solid var(--line); }
  .sidebar nav { flex-direction: row; }
  .sidebar footer { display: none; }
  .content { padding: 18px 16px 40px; }
  .board { grid-template-columns: minmax(0, 1fr); }
}

/* --- cards --- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; min-width: 0; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.card > h2 { margin: 18px 0 10px; }
.card.attention { border-color: var(--bad); }
.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; display: flex; flex-direction: column; box-shadow: var(--shadow); }
.stat-value { font-size: 20px; font-weight: 650; font-variant-numeric: tabular-nums; }
.stat-label { color: var(--muted); font-size: 12px; }
@media (max-width: 720px) { .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.big-number { font-size: 34px; font-weight: 700; margin: 0 0 4px; font-variant-numeric: tabular-nums; }

/* --- items --- */
.item-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.item-card { border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 12px; background: var(--surface); display: flex; flex-direction: column; gap: 6px; }
.item-card:hover { border-color: var(--accent); }
.item-title { font-weight: 600; color: var(--fg); overflow-wrap: anywhere; }
.item-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; color: var(--muted); font-size: 12.5px; }
.target code { font-size: 12px; }
.pill { display: inline-block; padding: 1px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; background: var(--surface-2); color: var(--muted); text-transform: lowercase; }
.state-shaping { background: var(--accent-soft); color: var(--accent); }
.state-ready { background: var(--info-soft); color: var(--accent); }
.state-running { background: var(--warn-soft); color: var(--warn); }
.state-done, .state-live, .state-active { background: var(--ok-soft); color: var(--ok); }
.state-failed { background: var(--bad-soft); color: var(--bad); }
.chip { display: inline-block; padding: 1px 8px; border-radius: 6px; font-size: 12px; background: var(--surface-2); color: var(--muted); border: 1px solid var(--line); }

/* --- forms --- */
input[type=text], input[type=password], input[type=date], input[type=number], textarea, select {
  width: 100%; font: inherit; color: var(--fg); background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--radius); padding: 8px 10px;
  transition: border-color 0.15s, box-shadow 0.15s;
}
textarea { resize: vertical; min-height: 44px; }
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.stack { display: flex; flex-direction: column; gap: 10px; }
.row { display: flex; gap: 10px; align-items: center; }
.row.wrap { flex-wrap: wrap; }
.row.end { align-items: flex-end; }
.row > .field { flex: 1; }
.grow { flex: 1; min-width: 0; }
.field { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); font-weight: 500; }
.actions { display: flex; justify-content: flex-end; }
form.inline { display: inline; }
.btn {
  font: inherit; font-weight: 550; padding: 7px 14px; border-radius: var(--radius); cursor: pointer; white-space: nowrap;
  border: 1px solid var(--line); background: var(--surface); color: var(--fg);
  transition: background 0.15s, border-color 0.15s, opacity 0.15s;
}
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--brand); border-color: var(--brand); color: var(--brand-fg); }
.btn.primary:hover { background: var(--brand-hover); border-color: var(--brand-hover); }
.btn.danger { color: var(--bad); }
.btn.danger:hover { background: var(--bad-soft); border-color: var(--bad); }
.btn.wide { width: 100%; }
.btn:disabled { opacity: 0.6; cursor: progress; }
@media (max-width: 720px) { .row { flex-wrap: wrap; } }

/* --- messages --- */
.banner { padding: 10px 14px; border-radius: var(--radius); background: var(--info-soft); border: 1px solid var(--line); }
.content > .banner { margin-bottom: 12px; }
.banner.busy { background: var(--accent-soft); color: var(--accent); border-color: transparent; }
.banner.bad { background: var(--bad-soft); color: var(--bad); border-color: transparent; }
.flash { padding: 10px 14px; border-radius: var(--radius); margin-bottom: 18px; font-weight: 500; border: 1px solid transparent; }
.flash-ok, .flash-saved { background: var(--ok-soft); color: var(--ok); }
.flash-info { background: var(--info-soft); color: var(--fg); border-color: var(--line); }
.flash-bad { background: var(--bad-soft); color: var(--bad); }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.bad { color: var(--bad); }
.ok { color: var(--ok); }
.empty { margin: 4px 0; }

/* --- content blocks --- */
pre.text { white-space: pre-wrap; overflow-wrap: anywhere; background: var(--surface-2); border-radius: var(--radius); padding: 12px; margin: 0 0 12px; font-family: inherit; font-size: 14px; }
pre.scroll { max-height: 420px; overflow: auto; font-family: var(--mono); font-size: 12.5px; }
pre.log { background: #0b0d12; color: #d6dae3; border-radius: var(--radius); padding: 12px 14px; margin: 0; max-height: 60vh; overflow: auto; white-space: pre-wrap; overflow-wrap: anywhere; }
.criteria { margin: 0; padding-left: 20px; }
.question { padding: 10px 0; border-top: 1px solid var(--line); display: flex; flex-direction: column; gap: 6px; }
.question:first-of-type { border-top: 0; padding-top: 0; }
.chat { display: flex; flex-direction: column; gap: 8px; margin-bottom: 12px; }
.bubble { max-width: 85%; padding: 8px 12px; border-radius: 12px; white-space: pre-wrap; overflow-wrap: anywhere; }
.bubble .who { display: block; font-size: 11px; font-weight: 600; color: var(--muted); margin-bottom: 2px; }
.bubble.me { align-self: flex-end; background: var(--accent-soft); }
.bubble.them { align-self: flex-start; background: var(--surface-2); }
.status-list { margin: 0; padding-left: 18px; color: var(--muted); font-size: 13px; }
.details { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px 18px; margin: 0; }
.details dt { font-size: 12px; color: var(--muted); }
.details dd { margin: 0; overflow-wrap: anywhere; }
.queue { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.queue-row { display: flex; align-items: center; gap: 14px; padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--radius); flex-wrap: wrap; }
.position { width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); font-weight: 700; }

/* --- tables --- */
.table-wrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-size: 13px; }
th { text-align: left; font-weight: 600; color: var(--muted); font-size: 12px; padding: 8px 10px; border-bottom: 1px solid var(--line); }
td { padding: 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
tr:last-child td { border-bottom: 0; }
td.links { display: flex; flex-direction: column; gap: 2px; }

/* --- the narrow side column: fields stack, neighbouring forms keep their distance --- */
.side .row { flex-wrap: wrap; }
.side .row > .field { flex-basis: 100%; }
.card > form + form { margin-top: 10px; }

/* --- DocGen additions --- */
.landing { max-width: 560px; margin: 12vh auto; padding: 0 16px; }
.landing h1 { margin-bottom: 8px; }
.landing-logo { height: 54px; width: auto; display: block; margin-bottom: 18px; }
.landing .btn { display: inline-block; }
.crumbs { font-size: 12.5px; color: var(--muted); }
.title-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.head-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.head-actions .btn:hover { text-decoration: none; }
.note { margin: 0 0 12px; }
.link-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.link-list li { display: flex; flex-direction: column; gap: 2px; padding: 9px 0; border-top: 1px solid var(--line); }
.link-list li:first-child { border-top: 0; padding-top: 0; }
.link-list a { font-weight: 600; }
.hint { color: var(--muted); font-weight: 400; }
fieldset.checks { border: 1px solid var(--line); border-radius: var(--radius); padding: 8px 10px 10px; margin: 0; gap: 6px; }
fieldset.checks legend { padding: 0 4px; }
.check { display: flex; align-items: center; gap: 8px; color: var(--fg); font-size: 13.5px; font-weight: 400; }
.check input { accent-color: var(--accent); }
.row-actions { white-space: nowrap; text-align: right; }
.row-actions form + form { margin-left: 6px; }
.btn.danger.primary { background: var(--bad); border-color: var(--bad); color: #ffffff; }
.state-inactive, .state-void, .state-retired { background: var(--surface-2); color: var(--muted); }
.sidebar footer div + div { margin-top: 4px; }
.state-planned, .state-checked, .state-update { background: var(--accent-soft); color: var(--accent); }
.state-generated { background: var(--warn-soft); color: var(--warn); }
.state-signed, .state-new, .state-committed, .state-ended { background: var(--ok-soft); color: var(--ok); }
.state-rejected { background: var(--bad-soft); color: var(--bad); }
.state-archived, .state-reverted, .state-discarded { background: var(--surface-2); color: var(--muted); }
.state-draft { background: var(--surface-2); color: var(--fg); }
.state-review { background: var(--warn-soft); color: var(--warn); }
.state-published { background: var(--ok-soft); color: var(--ok); }
.doc-preview { background: var(--surface-2); border-radius: var(--radius); padding: 18px 22px; font-family: "Times New Roman", Georgia, serif; font-size: 14.5px; line-height: 1.6; overflow-wrap: anywhere; }
.doc-preview p { margin: 0 0 8px; min-height: 1em; white-space: pre-wrap; }
mark { background: var(--warn-soft); color: var(--warn); border-radius: 3px; padding: 0 3px; font-family: var(--mono); font-size: 12.5px; }
.row-actions form.inline { display: inline-flex; gap: 6px; align-items: flex-end; flex-wrap: wrap; }
.row-actions .field { min-width: 140px; text-align: left; }
.state-ready, .state-generated, .state-done { background: var(--ok-soft); color: var(--ok); }
.state-blocked, .state-failed { background: var(--bad-soft); color: var(--bad); }
.state-excluded { background: var(--surface-2); color: var(--muted); }
.state-running { background: var(--warn-soft); color: var(--warn); }
.state-issued { background: var(--accent-soft); color: var(--accent); }
@media (max-width: 720px) {
  .sidebar nav { flex-wrap: wrap; gap: 2px 4px; }
  .sidebar .nav-link { padding: 6px 8px; }
  .sidebar .nav-icon { display: none; }
}

/* --- the phone: a top bar (logo = home, account), a tab bar at the bottom, rows as cards --- */
.me, .tabbar { display: none; }
.nav-icon { display: inline-flex; width: 20px; justify-content: center; }
.nav-icon svg { width: 18px; height: 18px; }
details.fold > summary { cursor: pointer; list-style: none; }
details.fold > summary::-webkit-details-marker { display: none; }
details.fold > summary::after { content: "\25BE"; color: var(--muted); font-size: 14px; }
details.fold:not([open]) > summary { margin-bottom: 0; }
details.fold:not([open]) > summary::after { content: "\25B8"; }
@media (max-width: 720px) {
  /* The top bar keeps its height on a short page; the content takes what is left. */
  .app { grid-template-rows: auto 1fr; }
  .sidebar { position: sticky; top: 0; z-index: 10; flex-wrap: nowrap; justify-content: space-between; padding: 8px 16px; }
  .sidebar nav { display: none; }
  .me { display: grid; place-items: center; flex: none; width: 38px; height: 38px; border-radius: 50%;
    background: var(--accent-soft); color: var(--fg); font-weight: 600; font-size: 13px; }
  .me:hover { text-decoration: none; }
  .tabbar { display: flex; flex-direction: row; position: fixed; left: 0; right: 0; bottom: 0; z-index: 10; gap: 2px;
    background: var(--surface); border-top: 1px solid var(--line); padding: 4px 4px calc(4px + env(safe-area-inset-bottom)); }
  .tab { flex: 1 1 0; min-width: 0; min-height: 52px; display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 3px; padding: 4px 2px; border-radius: var(--radius); color: var(--muted); font-size: 11px; font-weight: 500; }
  .tab:hover { text-decoration: none; color: var(--fg); }
  .tab.active { color: var(--fg); background: var(--accent-soft); }
  .tab-icon { display: inline-flex; }
  .tab-label { max-width: 100%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .content { padding-bottom: calc(88px + env(safe-area-inset-bottom)); }

  .table-wrap { overflow: visible; }
  .table-wrap table, .table-wrap tbody, .table-wrap tr, .table-wrap td { display: block; width: 100%; }
  .table-wrap thead { display: none; }
  .table-wrap tr { border: 1px solid var(--line); border-radius: var(--radius); padding: 8px 12px; margin-bottom: 8px; }
  .table-wrap td { display: flex; justify-content: space-between; gap: 12px; padding: 3px 0; border: 0; text-align: right;
    overflow-wrap: anywhere; }
  .table-wrap td::before { content: attr(data-label); flex: none; max-width: 45%; color: var(--muted); font-size: 12px; text-align: left; }
  .table-wrap td:first-child { font-size: 14px; font-weight: 600; text-align: left; }
  .table-wrap td:first-child::before, .table-wrap td.row-actions::before { content: none; }
  .table-wrap td:empty { display: none; }
  .table-wrap td.row-actions { justify-content: flex-end; padding-top: 8px; white-space: normal; }

  .split { display: flex; flex-direction: column; align-items: stretch; }
  .split > .side { display: contents; }
  .split > .side > .fold { order: -1; }
  .split > .side > :not(.fold) { order: 1; }
  .btn { min-height: 44px; }
}
