/* ADF London — application brand stylesheet
   Palette from ADF Brand Guidelines June 2026:
   Pine #182C24 · Gold #CCB27F · Moss #738069 · Ruby #8B3926 · Cream #F2E9D1
   Typography: Kinfolk (display) ~ tracked serif caps fallback; Baskerville headlines; Avenir body. */
@import url('https://fonts.googleapis.com/css2?family=Libre+Baskerville:ital,wght@0,400;0,700;1,400&family=Nunito+Sans:opsz,wght@6..12,300;6..12,400;6..12,600;6..12,700&display=swap');

:root {
  --pine: #182C24; --pine-90: #22392f; --pine-soft: #2b463a;
  --gold: #CCB27F; --gold-soft: #dcc9a0;
  --moss: #738069; --moss-soft: #a9b3a1;
  --ruby: #8B3926;
  --cream: #F2E9D1; --cream-soft: #f8f3e6; --paper: #FCFAF4;
  --ink: #21251f; --ink-soft: #5c6157;
  --serif: 'Libre Baskerville', Baskerville, 'Baskerville Old Face', Georgia, serif;
  --sans: 'Avenir Next', Avenir, 'Nunito Sans', 'Segoe UI', system-ui, sans-serif;
  --radius: 3px;
  --shadow: 0 1px 3px rgba(24,44,36,.10), 0 4px 14px rgba(24,44,36,.06);
}
* { box-sizing: border-box; }
html { font-size: 15px; }
body { margin: 0; font-family: var(--sans); color: var(--ink); background: var(--paper); }

/* ---------- Shell ---------- */
.shell { display: flex; min-height: 100vh; }
.sidebar { width: 232px; flex-shrink: 0; background: var(--pine); color: var(--cream); display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.sidebar .logo { padding: 26px 20px 18px; text-align: center; border-bottom: 1px solid rgba(204,178,127,.25); }
.sidebar .logo img { width: 128px; display: block; margin: 0 auto; }
.sidebar .logo .diamond { color: var(--gold); font-size: .7rem; letter-spacing: .3em; margin-top: 10px; }
.sidebar nav { padding: 14px 0; flex: 1; }
.sidebar .navgroup { font-size: .62rem; letter-spacing: .22em; text-transform: uppercase; color: var(--gold); padding: 14px 20px 5px; }
.sidebar a.navlink { display: block; padding: 7px 20px; color: var(--cream); text-decoration: none; font-size: .88rem; border-left: 3px solid transparent; }
.sidebar a.navlink:hover { background: var(--pine-90); }
.sidebar a.navlink.active { background: var(--pine-90); border-left-color: var(--gold); color: var(--gold-soft); }
.sidebar .foot { padding: 14px 20px; font-size: .72rem; color: var(--moss-soft); border-top: 1px solid rgba(204,178,127,.2); }
.sidebar .foot form { display: inline; }
.sidebar .foot button { background: none; border: 0; color: var(--gold); cursor: pointer; font-size: .72rem; padding: 0; text-decoration: underline; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar { background: #fff; border-bottom: 1px solid #e6e0d0; padding: 12px 28px; display: flex; align-items: center; gap: 16px; }
.topbar h1 { font-family: var(--serif); font-size: 1.18rem; font-weight: 400; letter-spacing: .06em; text-transform: uppercase; color: var(--pine); margin: 0; flex: 1; }
.topbar .crumb { font-size: .78rem; color: var(--ink-soft); }
.content { padding: 24px 28px 60px; max-width: 1240px; width: 100%; }

/* ---------- Typography ---------- */
h2 { font-family: var(--serif); font-weight: 400; letter-spacing: .08em; text-transform: uppercase; font-size: 1rem; color: var(--pine); margin: 28px 0 10px; padding-bottom: 6px; border-bottom: 2px solid var(--gold); display: inline-block; }
h3 { font-family: var(--serif); font-weight: 700; font-size: .92rem; color: var(--pine); margin: 18px 0 8px; }
a { color: var(--pine); }
.small { font-size: .78rem; color: var(--ink-soft); }
.gold { color: var(--gold); }
.diamond-sep { color: var(--gold); text-align: center; letter-spacing: .4em; margin: 8px 0; }

/* ---------- Cards, grids ---------- */
.card { background: #fff; border: 1px solid #e8e2d2; border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px 20px; margin-bottom: 18px; }
.card.pine { background: var(--pine); color: var(--cream); border: 0; }
.card.cream { background: var(--cream-soft); }
.grid { display: grid; gap: 14px; }
.grid.cols-2 { grid-template-columns: repeat(2, 1fr); }
.grid.cols-3 { grid-template-columns: repeat(3, 1fr); }
.grid.cols-4 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 1000px) { .grid.cols-3, .grid.cols-4 { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 700px) { .grid.cols-2, .grid.cols-3, .grid.cols-4 { grid-template-columns: 1fr; } .content { padding: 16px; } .sidebar { display: none; } .topbar { padding: 12px 16px; } }

.stat { background: #fff; border: 1px solid #e8e2d2; border-top: 3px solid var(--gold); border-radius: var(--radius); padding: 12px 14px; }
.stat .n { font-family: var(--serif); font-size: 1.6rem; color: var(--pine); }
.stat .l { font-size: .72rem; letter-spacing: .1em; text-transform: uppercase; color: var(--ink-soft); }
.stat.warn { border-top-color: var(--ruby); } .stat.warn .n { color: var(--ruby); }

/* ---------- Tables ---------- */
table.tbl { width: 100%; border-collapse: collapse; background: #fff; font-size: .85rem; }
.tbl th { background: var(--pine); color: var(--cream); font-weight: 600; text-align: left; padding: 8px 10px; font-size: .72rem; letter-spacing: .08em; text-transform: uppercase; }
.tbl td { padding: 8px 10px; border-bottom: 1px solid #eee7d6; vertical-align: top; }
.tbl tr:nth-child(even) td { background: var(--cream-soft); }
.tbl tr:hover td { background: #f3edda; }

/* ---------- Forms & buttons ---------- */
label { display: block; font-size: .72rem; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-soft); margin: 10px 0 3px; }
input[type=text], input[type=email], input[type=password], input[type=date], input[type=number], select, textarea {
  width: 100%; padding: 8px 10px; border: 1px solid #d5cdb8; border-radius: var(--radius); font-family: var(--sans); font-size: .88rem; background: #fff; color: var(--ink);
}
textarea { min-height: 90px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--gold); outline-offset: 0; border-color: var(--gold); }
.btn { display: inline-block; background: var(--pine); color: var(--cream); border: 1px solid var(--pine); padding: 8px 18px; border-radius: var(--radius); font-family: var(--sans); font-size: .8rem; letter-spacing: .1em; text-transform: uppercase; cursor: pointer; text-decoration: none; }
.btn:hover { background: var(--pine-soft); }
.btn.gold { background: var(--gold); border-color: var(--gold); color: var(--pine); font-weight: 700; }
.btn.gold:hover { background: var(--gold-soft); }
.btn.ghost { background: transparent; color: var(--pine); border-color: var(--pine); }
.btn.ruby { background: var(--ruby); border-color: var(--ruby); }
.btn.sm { padding: 4px 10px; font-size: .7rem; }
.inline-form { display: inline; }
.row { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; }
.row > div { flex: 1; min-width: 140px; }

/* ---------- Badges & states ---------- */
.badge { display: inline-block; padding: 2px 9px; border-radius: 10px; font-size: .68rem; letter-spacing: .06em; text-transform: uppercase; font-weight: 700; }
.badge.green { background: #e4ecdf; color: #2f4a2c; }
.badge.amber { background: #f3e6c8; color: #7a5c14; }
.badge.red { background: #f0ded7; color: var(--ruby); }
.badge.pine { background: var(--pine); color: var(--cream); }
.badge.gold { background: var(--gold); color: var(--pine); }
.badge.grey { background: #e8e6df; color: var(--ink-soft); }
.rag { width: 14px; height: 14px; border-radius: 50%; display: inline-block; vertical-align: middle; }
.rag.GREEN { background: #4a7d43; } .rag.AMBER { background: #c99a2e; } .rag.RED { background: var(--ruby); }

/* ---------- Report workspace ---------- */
.section-card { background: #fff; border: 1px solid #e8e2d2; border-left: 4px solid var(--moss); border-radius: var(--radius); margin-bottom: 14px; }
.section-card.state-approved { border-left-color: #4a7d43; }
.section-card.state-ai_draft { border-left-color: var(--gold); }
.section-card.state-user_edited { border-left-color: var(--pine); }
.section-card.state-not_started { border-left-color: #cfc9b8; }
.section-card.excluded { opacity: .5; }
.section-head { display: flex; align-items: center; gap: 10px; padding: 10px 14px; cursor: grab; background: var(--cream-soft); border-bottom: 1px solid #eee7d6; }
.section-head h3 { margin: 0; flex: 1; }
.section-body { padding: 12px 14px; }
.facts { background: var(--cream-soft); border: 1px dashed var(--moss-soft); padding: 8px 10px; font-size: .82rem; white-space: pre-wrap; border-radius: var(--radius); }
.facts .lbl, .draft .lbl { font-size: .65rem; letter-spacing: .14em; text-transform: uppercase; color: var(--moss); display: block; margin-bottom: 4px; }
.draft { background: #fbf7ec; border: 1px solid var(--gold-soft); padding: 8px 10px; font-size: .85rem; white-space: pre-wrap; border-radius: var(--radius); margin-top: 8px; }
.state-tag { font-size: .64rem; letter-spacing: .1em; text-transform: uppercase; }

.brain { background: var(--pine); color: var(--cream); border-radius: var(--radius); padding: 18px 20px; margin-bottom: 20px; }
.brain h2 { color: var(--gold); border-color: var(--gold); margin-top: 0; }
.brain textarea { background: rgba(252,250,244,.96); min-height: 110px; font-size: .95rem; }
.brain .small { color: var(--moss-soft); }

.thumbs { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 8px; }
.thumbs .th { width: 130px; }
.thumbs img { width: 100%; height: 86px; object-fit: cover; border: 1px solid #ddd6c2; border-radius: var(--radius); }
.thumbs input { font-size: .72rem; padding: 3px 6px; }

/* ---------- Delay timeline ---------- */
.timeline { overflow-x: auto; }
.timeline table { border-collapse: collapse; font-size: .74rem; }
.timeline th, .timeline td { border: 1px solid #e2dbc8; padding: 4px 8px; min-width: 46px; text-align: center; }
.timeline th { background: var(--pine); color: var(--cream); position: sticky; left: auto; }
.timeline td.on { background: var(--gold); color: var(--pine); font-weight: 700; }
.timeline td.res { background: #e4ecdf; }
.timeline .evt { text-align: left; font-weight: 600; color: var(--pine); background: var(--cream-soft); min-width: 200px; }

/* ---------- Preview (branded document look) ---------- */
.doc-preview { background: #fff; max-width: 860px; margin: 0 auto; padding: 60px 70px; box-shadow: var(--shadow); border-top: 6px solid var(--pine); }
.doc-preview .cover { text-align: center; padding: 60px 0 40px; border-bottom: 1px solid var(--gold); margin-bottom: 30px; }
.doc-preview .cover img { width: 200px; margin-bottom: 26px; }
.doc-preview .cover h1 { font-family: var(--serif); font-weight: 400; letter-spacing: .14em; text-transform: uppercase; color: var(--pine); font-size: 1.7rem; }
.doc-preview .cover .sub { font-family: var(--serif); font-style: italic; color: var(--moss); }
.doc-preview h2 { display: block; border-bottom: 1px solid var(--gold); }
.doc-preview .meta { margin: 24px auto; max-width: 480px; text-align: left; font-size: .85rem; }
.doc-preview .meta td { padding: 3px 8px; }
.doc-preview .meta td:first-child { color: var(--moss); font-weight: 600; width: 45%; }
.doc-preview p { line-height: 1.65; }
.doc-preview .imgrid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin: 14px 0; }
.doc-preview .imgrid figure { margin: 0; }
.doc-preview .imgrid img { width: 100%; border: 1px solid #ddd; }
.doc-preview .imgrid figcaption { font-size: .75rem; font-style: italic; color: var(--moss); text-align: center; padding-top: 4px; }

/* ---------- Login ---------- */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: var(--pine); background-image: radial-gradient(rgba(204,178,127,.08) 1px, transparent 1px); background-size: 26px 26px; }
.login-card { background: var(--paper); width: 380px; padding: 40px 36px; border-radius: var(--radius); border-top: 4px solid var(--gold); text-align: center; }
.login-card img { width: 170px; margin-bottom: 8px; }
.login-card .tag { font-family: var(--serif); font-style: italic; color: var(--moss); font-size: .82rem; margin-bottom: 22px; }
.login-card form { text-align: left; }
.error-note { background: #f6e7e1; color: var(--ruby); border: 1px solid #e4c4b8; padding: 8px 12px; border-radius: var(--radius); font-size: .82rem; margin-bottom: 10px; }
.ok-note { background: #e9efe4; color: #2f4a2c; border: 1px solid #c9d8bf; padding: 8px 12px; border-radius: var(--radius); font-size: .82rem; margin-bottom: 10px; }
.ai-note { background: #fbf4e2; border: 1px solid var(--gold-soft); color: #7a5c14; padding: 6px 12px; font-size: .76rem; border-radius: var(--radius); margin-bottom: 14px; }

details.acc { margin-bottom: 8px; } details.acc summary { cursor: pointer; font-weight: 600; color: var(--pine); padding: 6px 0; }
.suggestion { border-left: 4px solid var(--gold); background: #fbf7ec; padding: 10px 14px; margin-bottom: 10px; border-radius: var(--radius); }
.clar { border-left: 4px solid var(--moss); background: var(--cream-soft); padding: 10px 14px; margin-bottom: 10px; border-radius: var(--radius); }
.tabs { display: flex; gap: 2px; margin-bottom: -1px; flex-wrap: wrap; }
.tabs a { padding: 8px 16px; background: var(--cream-soft); border: 1px solid #e6e0d0; border-bottom: 0; text-decoration: none; font-size: .8rem; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-soft); border-radius: 3px 3px 0 0; }
.tabs a.active { background: #fff; color: var(--pine); font-weight: 700; border-top: 3px solid var(--gold); }
.pagey { background: #fff; border: 1px solid #e6e0d0; padding: 18px 20px; }

/* ---- Overflow & responsiveness hardening ---- */
/* Long unbroken strings (error payloads, keys, URLs, refs) must wrap, never overflow */
.error-note, .clar, .suggestion, .facts, .draft, .small, td, th, .section-body, .ai-note { overflow-wrap: anywhere; }
pre, code { overflow-wrap: anywhere; white-space: pre-wrap; }
/* Toolbars and inline action rows wrap on narrow screens instead of running off */
.report-toolbar, .actions, .btn-row, .topbar { flex-wrap: wrap; }
.inline-form { display: inline-block; }
/* Tables scroll within their own container rather than widening the page */
.tbl { display: block; max-width: 100%; overflow-x: auto; }
.tbl tr { display: table-row; }
/* keep table semantics on wide screens */
@media (min-width: 900px) { .tbl { display: table; width: 100%; } }
/* Images and previews never exceed their column */
img { max-width: 100%; height: auto; }
.doc-preview { max-width: 100%; overflow-x: hidden; }
@media (max-width: 900px) { .doc-preview .imgrid { grid-template-columns: 1fr; } }
/* The whole page must never scroll sideways */
body { overflow-x: hidden; }
.content > * { min-width: 0; }
