/* Go Beyond Product Portal v2.
   Swiss-editorial instrument: paper ground, hairline rules, Helvetica Neue with
   hard weight contrast (700 headings / 300 light for large numerals), one red.
   Colour is meaning: red = brand + attention, cyan = visible to agents, amber =
   late or carried. Nothing else gets colour. */

:root {
  --paper: #f7f5f1;
  --card: #fffdf9;
  --ink: #1c1a17;
  --muted: #837d73;
  --faint: #a8a297;
  --line: #e5dfd4;
  --line-strong: #cfc8ba;
  --red: #e21f26;
  --red-soft: #fcebe9;
  --cyan: #007a7b;          /* darkened brand cyan, AA on paper */
  --cyan-soft: #e2f1f0;
  --amber: #b26a00;
  --amber-soft: #f9efdd;
  --green: #2e7d43;
  --green-soft: #e5f1e4;
  --shadow: 0 14px 40px rgba(28, 26, 23, .12);
  --sans: "Helvetica Neue", Helvetica, Arial, system-ui, sans-serif;
}
:root:not([data-theme="light"]) { color-scheme: light dark; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #161511; --card: #1f1d18; --ink: #ece7dd; --muted: #9d968a;
    --faint: #6f695f; --line: #302d26; --line-strong: #454138;
    --red: #f0463f; --red-soft: #3a1d1a; --cyan: #35b3b0; --cyan-soft: #12312f;
    --amber: #d99a3d; --amber-soft: #33290f; --green: #6cbf7d; --green-soft: #1c2f1c;
    --shadow: 0 14px 40px rgba(0, 0, 0, .5);
  }
}
:root[data-theme="dark"] {
  --paper: #161511; --card: #1f1d18; --ink: #ece7dd; --muted: #9d968a;
  --faint: #6f695f; --line: #302d26; --line-strong: #454138;
  --red: #f0463f; --red-soft: #3a1d1a; --cyan: #35b3b0; --cyan-soft: #12312f;
  --amber: #d99a3d; --amber-soft: #33290f; --green: #6cbf7d; --green-soft: #1c2f1c;
  --shadow: 0 14px 40px rgba(0, 0, 0, .5);
}

* { box-sizing: border-box; margin: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--sans);
  background: var(--paper);
  color: var(--ink);
  font-size: 15px;
  line-height: 1.45;
  font-weight: 400;
}
button { font-family: inherit; font-size: inherit; color: inherit; }
input, select, textarea { font-family: inherit; font-size: 14px; color: var(--ink); }
a { color: var(--cyan); text-decoration: none; }
a:hover { text-decoration: underline; }
::selection { background: var(--red); color: #fff; }
:focus-visible { outline: 2px solid var(--red); outline-offset: 2px; }

/* ------------------------------------------------------------- layout */
#shell { display: none; min-height: 100vh; }
#shell.on { display: flex; }

.spine {
  width: 216px; flex: none; position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column; padding: 26px 0 18px;
  border-right: 1px solid var(--line);
}
.wordmark { padding: 0 24px 22px; }
.wordmark img { width: 128px; display: block; }
.wordmark .sub {
  font-size: 10px; letter-spacing: .24em; text-transform: uppercase;
  color: var(--muted); margin-top: 7px; font-weight: 700;
}
nav.mainnav { display: flex; flex-direction: column; gap: 2px; padding: 8px 12px; }
nav.mainnav button {
  display: flex; align-items: center; gap: 10px;
  background: none; border: 0; text-align: left; cursor: pointer;
  padding: 9px 12px; border-radius: 8px; font-size: 14.5px; font-weight: 400;
  color: var(--ink);
}
nav.mainnav button:hover { background: var(--card); }
nav.mainnav button.on { background: var(--ink); color: var(--paper); font-weight: 700; }
nav.mainnav .badge {
  margin-left: auto; background: var(--red); color: #fff; border-radius: 99px;
  font-size: 11px; font-weight: 700; padding: 1px 7px; min-width: 18px; text-align: center;
}
nav.mainnav button.on .badge { background: var(--red); }
.spine .foot { margin-top: auto; padding: 14px 24px 0; border-top: 1px solid var(--line); }
.spine .foot .who { font-weight: 700; font-size: 13px; }
.spine .foot .org { color: var(--muted); font-size: 12px; margin-bottom: 8px; }
.spine .foot .row { display: flex; gap: 10px; }
.linklike { background: none; border: 0; padding: 0; color: var(--muted); font-size: 12px; cursor: pointer; }
.linklike:hover { color: var(--ink); text-decoration: underline; }

main { flex: 1; min-width: 0; padding: 30px 40px 90px; max-width: 1080px; }

.viewhead { margin-bottom: 22px; }
.viewhead .kicker {
  font-size: 11px; letter-spacing: .24em; text-transform: uppercase;
  color: var(--red); font-weight: 700;
}
.viewhead h1 { font-size: 30px; font-weight: 700; letter-spacing: -.02em; margin-top: 2px; }
.viewhead .lede { color: var(--muted); margin-top: 4px; max-width: 60ch; }

/* ------------------------------------------------------------- pieces */
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: 12px;
  padding: 18px 20px;
}
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.seclabel {
  font-size: 11px; letter-spacing: .22em; text-transform: uppercase;
  font-weight: 700; color: var(--muted); display: flex; align-items: baseline; gap: 8px;
  margin: 26px 0 8px;
}
.seclabel:first-child { margin-top: 0; }
.seclabel .n { color: var(--red); }
.seclabel.hot { color: var(--red); }

.btn {
  border: 1px solid var(--line-strong); background: var(--card); border-radius: 8px;
  padding: 7px 14px; cursor: pointer; font-size: 13.5px; font-weight: 700;
}
.btn:hover { border-color: var(--ink); }
.btn.primary { background: var(--red); border-color: var(--red); color: #fff; }
.btn.primary:hover { filter: brightness(.92); }
.btn.ghost { border-color: transparent; background: none; color: var(--muted); font-weight: 400; }
.btn.ghost:hover { color: var(--ink); }
.btn.sm { padding: 4px 10px; font-size: 12.5px; border-radius: 7px; }
.btn[disabled] { opacity: .45; cursor: not-allowed; }

.chip {
  display: inline-block; font-size: 10.5px; font-weight: 700; letter-spacing: .08em;
  text-transform: uppercase; border-radius: 5px; padding: 2px 7px;
  border: 1px solid var(--line-strong); color: var(--muted); background: transparent;
}
.chip.red { color: var(--red); border-color: var(--red); background: var(--red-soft); }
.chip.cyan { color: var(--cyan); border-color: var(--cyan); background: var(--cyan-soft); }
.chip.amber { color: var(--amber); border-color: var(--amber); background: var(--amber-soft); }
.chip.green { color: var(--green); border-color: var(--green); background: var(--green-soft); }
.chip.fill { background: var(--ink); border-color: var(--ink); color: var(--paper); }

.dot { width: 8px; height: 8px; border-radius: 99px; display: inline-block; flex: none; }
.dot.cyan { background: var(--cyan); }
.dot.faint { background: var(--line-strong); }

.avatar {
  width: 26px; height: 26px; border-radius: 99px; flex: none;
  background: var(--ink); color: var(--paper); font-size: 10.5px; font-weight: 700;
  display: inline-flex; align-items: center; justify-content: center;
}
.avatar.agent { background: var(--cyan); }

.progress { height: 4px; background: var(--line); border-radius: 4px; overflow: hidden; width: 90px; }
.progress i { display: block; height: 100%; background: var(--ink); border-radius: 4px; }
.progress.done i { background: var(--green); }

/* rows */
.rows { border-top: 1px solid var(--line); }
.row-item {
  display: flex; align-items: center; gap: 14px; padding: 11px 6px;
  border-bottom: 1px solid var(--line); cursor: pointer;
}
.row-item:hover { background: var(--card); }
.row-item .title { font-weight: 700; font-size: 14.5px; }
.row-item .meta { color: var(--muted); font-size: 12.5px; margin-top: 1px; display:flex; gap:8px; flex-wrap:wrap; align-items:center;}
.row-item .grow { flex: 1; min-width: 0; }
.row-item .right { display: flex; align-items: center; gap: 12px; flex: none; color: var(--muted); font-size: 12.5px; }
.due { font-variant-numeric: tabular-nums; }
.due.over { color: var(--red); font-weight: 700; }

.empty { color: var(--faint); padding: 18px 4px; font-size: 14px; }

/* filters */
.filters { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; align-items: center; }
.filters select, .filters input[type="search"] {
  background: var(--card); border: 1px solid var(--line-strong); border-radius: 8px;
  padding: 6px 10px;
}
.filters input[type="search"] { min-width: 200px; }

/* ------------------------------------------------------------- agenda */
.agenda-entry {
  display: flex; gap: 16px; padding: 15px 4px; border-bottom: 1px solid var(--line);
}
.agenda-entry.dropped { opacity: .45; }
.agenda-entry .num {
  font-size: 26px; font-weight: 300; color: var(--faint); width: 42px; flex: none;
  font-variant-numeric: tabular-nums; line-height: 1.1; letter-spacing: -.03em;
}
.agenda-entry.decided .num { color: var(--red); font-weight: 700; }
.agenda-entry .body { flex: 1; min-width: 0; }
.agenda-entry .t { font-weight: 700; font-size: 15.5px; }
.agenda-entry .m { color: var(--muted); font-size: 12.5px; margin-top: 2px; display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.agenda-entry .note-in {
  width: 100%; margin-top: 8px; border: 1px solid var(--line); background: var(--paper);
  border-radius: 7px; padding: 6px 9px; font-size: 13px;
}
.decisions { display: flex; gap: 6px; margin-top: 9px; flex-wrap: wrap; }
.dec {
  border: 1px solid var(--line-strong); background: none; border-radius: 6px;
  font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase;
  padding: 4px 10px; cursor: pointer; color: var(--muted);
}
.dec:hover { border-color: var(--ink); color: var(--ink); }
.dec.on { background: var(--ink); border-color: var(--ink); color: var(--paper); }
.dec.on.d-delivered { background: var(--green); border-color: var(--green); color: #fff; }
.dec.on.d-carried { background: var(--amber); border-color: var(--amber); color: #fff; }
.entry-tools { display: flex; flex-direction: column; gap: 4px; flex: none; }
.entry-tools button { border: 0; background: none; color: var(--faint); cursor: pointer; font-size: 13px; padding: 2px 6px; border-radius: 5px; }
.entry-tools button:hover { color: var(--ink); background: var(--card); }

.meeting-top { display: flex; align-items: flex-start; gap: 16px; flex-wrap: wrap; margin-bottom: 8px; }
.meeting-top .grow { flex: 1; min-width: 220px; }
.statebar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.state-pill {
  font-size: 11px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase;
  padding: 3px 10px; border-radius: 99px; border: 1px solid var(--line-strong); color: var(--muted);
}
.state-pill.live { background: var(--red); border-color: var(--red); color: #fff; }
.state-pill.scheduled { background: var(--cyan-soft); border-color: var(--cyan); color: var(--cyan); }
.state-pill.closed { background: var(--ink); border-color: var(--ink); color: var(--paper); }

/* ------------------------------------------------------------- drawer */
#drawer-back {
  position: fixed; inset: 0; background: rgba(20, 18, 15, .38); z-index: 40;
  opacity: 0; pointer-events: none; transition: opacity .18s ease;
}
#drawer-back.on { opacity: 1; pointer-events: auto; }
#drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(560px, 100vw);
  background: var(--paper); border-left: 1px solid var(--line); z-index: 41;
  transform: translateX(102%); transition: transform .22s cubic-bezier(.3,.9,.3,1);
  overflow-y: auto; padding: 26px 28px 60px; box-shadow: var(--shadow);
}
#drawer.on { transform: none; }
@media (prefers-reduced-motion: reduce) {
  #drawer, #drawer-back { transition: none; }
}
.drawer-head { display: flex; align-items: flex-start; gap: 10px; margin-bottom: 14px; }
.drawer-head h2 { font-size: 20px; font-weight: 700; flex: 1; letter-spacing: -.01em; }
.fieldgrid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 14px; margin: 14px 0; }
.field label { display: block; font-size: 10.5px; letter-spacing: .16em; text-transform: uppercase; font-weight: 700; color: var(--muted); margin-bottom: 3px; }
.field input, .field select, .field textarea {
  width: 100%; background: var(--card); border: 1px solid var(--line-strong);
  border-radius: 8px; padding: 7px 10px;
}
.field.wide { grid-column: 1 / -1; }
textarea { resize: vertical; min-height: 60px; }

.milestone { display: flex; align-items: center; gap: 10px; padding: 7px 2px; border-bottom: 1px solid var(--line); }
.milestone input[type="checkbox"] { width: 16px; height: 16px; accent-color: var(--red); }
.milestone .lbl { flex: 1; }
.milestone.done .lbl { color: var(--muted); text-decoration: line-through; }
.milestone .when { color: var(--faint); font-size: 12px; font-variant-numeric: tabular-nums; }

.comment { display: flex; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.comment .b { flex: 1; min-width: 0; }
.comment .who { font-weight: 700; font-size: 13px; display: flex; gap: 8px; align-items: baseline; }
.comment .when { color: var(--faint); font-size: 11.5px; font-weight: 400; }
.comment .txt { margin-top: 2px; font-size: 14px; white-space: pre-wrap; }
.comment.internal { background: var(--paper); }
.comment.internal .txt::before { content: ""; }

.composer { margin-top: 12px; }
.composer textarea { width: 100%; background: var(--card); border: 1px solid var(--line-strong); border-radius: 8px; padding: 9px 11px; }
.composer .foot { display: flex; align-items: center; gap: 10px; margin-top: 7px; }
.hint { color: var(--faint); font-size: 12px; }

.hist { font-size: 12.5px; color: var(--muted); padding: 5px 0; border-bottom: 1px solid var(--line); display: flex; gap: 8px; }
.hist .at { color: var(--faint); flex: none; font-variant-numeric: tabular-nums; }

/* ------------------------------------------------------------- media */
.media-tabs { display: flex; gap: 6px; margin-bottom: 16px; }
.media-tabs button {
  border: 1px solid var(--line-strong); background: none; border-radius: 99px;
  padding: 6px 16px; cursor: pointer; font-weight: 700; font-size: 13px;
}
.media-tabs button.on { background: var(--ink); border-color: var(--ink); color: var(--paper); }
.post { border: 1px solid var(--line); border-radius: 12px; background: var(--card); padding: 16px 18px; margin-bottom: 12px; }
.post.pinned { border-color: var(--red); }
.post .head { display: flex; gap: 10px; align-items: baseline; flex-wrap: wrap; }
.post .head .t { font-weight: 700; font-size: 15.5px; flex: 1; min-width: 200px; }
.post .meta { color: var(--muted); font-size: 12.5px; margin-top: 3px; }
.post .ex { margin-top: 8px; font-size: 14px; color: var(--ink); white-space: pre-wrap; }
.post .foot { display: flex; gap: 12px; align-items: center; margin-top: 10px; flex-wrap: wrap; }
.post .cwrap { margin-top: 10px; border-top: 1px solid var(--line); padding-top: 4px; }

/* ------------------------------------------------------------- modal */
#modal-back { position: fixed; inset: 0; background: rgba(20,18,15,.45); z-index: 50; display: none; align-items: center; justify-content: center; padding: 20px; }
#modal-back.on { display: flex; }
#modal {
  background: var(--paper); border-radius: 14px; box-shadow: var(--shadow);
  max-width: 720px; width: 100%; max-height: 86vh; overflow-y: auto; padding: 24px 26px;
  border: 1px solid var(--line);
}
#modal h3 { font-size: 18px; font-weight: 700; margin-bottom: 12px; }
.mailframe { border: 1px solid var(--line); border-radius: 10px; background: #fff; padding: 18px; max-height: 46vh; overflow-y: auto; color: #1c1a17; }
.modal-actions { display: flex; gap: 10px; margin-top: 16px; justify-content: flex-end; flex-wrap: wrap; align-items: center; }

/* ------------------------------------------------------------- signin */
#signin {
  min-height: 100vh; display: none; align-items: center; justify-content: center; padding: 24px;
  background:
    radial-gradient(1200px 500px at 85% -10%, var(--red-soft), transparent 60%),
    var(--paper);
}
#signin.on { display: flex; }
.signin-card { width: 100%; max-width: 400px; }
.signin-card img { width: 168px; margin-bottom: 10px; }
.signin-card .sub { font-size: 11px; letter-spacing: .26em; text-transform: uppercase; color: var(--muted); font-weight: 700; margin-bottom: 34px; }
.signin-card h1 { font-size: 26px; font-weight: 700; letter-spacing: -.02em; margin-bottom: 6px; }
.signin-card p { color: var(--muted); margin-bottom: 20px; }
.signin-card input {
  width: 100%; font-size: 16px; padding: 12px 14px; border-radius: 10px;
  border: 1px solid var(--line-strong); background: var(--card); margin-bottom: 10px;
}
.signin-card input.code { letter-spacing: .5em; font-size: 22px; text-align: center; font-weight: 700; }
.signin-card .btn { width: 100%; padding: 11px; font-size: 15px; border-radius: 10px; }
.signin-card .msg { margin-top: 12px; font-size: 13.5px; color: var(--muted); min-height: 20px; }
.signin-card .msg.bad { color: var(--red); }

/* ------------------------------------------------------------- toast */
#toast {
  position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%) translateY(20px);
  background: var(--ink); color: var(--paper); border-radius: 10px; padding: 10px 18px;
  font-size: 14px; opacity: 0; pointer-events: none; transition: all .2s ease; z-index: 60;
  max-width: min(560px, 90vw);
}
#toast.on { opacity: 1; transform: translateX(-50%); }
#toast.bad { background: var(--red); color: #fff; }

/* ------------------------------------------------------------- mobile */
#mobilebar { display: none; }
@media (max-width: 860px) {
  #shell.on { display: block; }
  .spine { display: none; }
  main { padding: 18px 16px 96px; max-width: none; }
  .grid2 { grid-template-columns: 1fr; }
  .fieldgrid { grid-template-columns: 1fr; }
  #mobilebar {
    display: flex; position: fixed; bottom: 0; left: 0; right: 0; z-index: 30;
    background: var(--card); border-top: 1px solid var(--line);
    padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
  }
  #mobilebar button {
    flex: 1; background: none; border: 0; font-size: 11px; font-weight: 700;
    color: var(--muted); padding: 6px 2px; cursor: pointer; border-radius: 8px;
    display: flex; flex-direction: column; gap: 2px; align-items: center;
  }
  #mobilebar button.on { color: var(--red); }
  #mobilebar .badge { background: var(--red); color:#fff; border-radius:99px; font-size:9.5px; padding:0 5px; }
  .viewhead h1 { font-size: 24px; }
  .row-item .right { display: none; }
  .agenda-entry .num { width: 30px; font-size: 20px; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
