/* Home portal, what GAKA noticed, the company at a glance, and Ask Claude.
   Owned by public/js/home.js and loaded after /styles.css. Class names here belong to this module;
   a look shared by several modules goes in /styles.css (npm run check-styles enforces this). */

/* ---------- home portal ---------- */
/* The greeting: a calm band, the words on the left and the quote on the right */
.home-hero { background: var(--brand-gradient); color: #fff; border-radius: var(--radius); padding: 1.2rem 1.4rem; display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); gap: 1.5rem; align-items: center; }
.home-hero h1 { color: #fff; font-size: 1.45rem; font-weight: 650; letter-spacing: -.02em; margin: .35rem 0 .4rem; }
.mc-top { display: flex; justify-content: space-between; align-items: center; gap: .5rem; }
.mc-date { font-size: .85rem; opacity: .85; }
.mc-next { background: rgb(255 255 255 / .15); color: #fff; border-color: transparent; }
.mc-next:hover { background: rgb(255 255 255 / .25); }
.mc-line { margin: .25rem 0; font-size: .98rem; line-height: 1.45; }
.home-hero blockquote { margin: 0; padding: .7rem 1rem; border-left: 3px solid var(--copper); background: rgb(255 255 255 / .1); border-radius: 0 8px 8px 0; font-style: italic; line-height: 1.45; }
.home-hero blockquote span { font-style: normal; font-weight: 700; }
@media (max-width: 860px) { .home-hero { grid-template-columns: minmax(0, 1fr); gap: .8rem; padding: 1rem; } }

/* ---------- Ask Claude ---------- */
.ai-suggest { display: flex; flex-wrap: wrap; gap: .4rem; margin-bottom: 1rem; }
.ai-suggest .chip { white-space: normal; text-align: left; }
.ai-thread { display: grid; gap: .8rem; margin-bottom: 1rem; }
.ai-msg { padding: .7rem .9rem; border-radius: 12px; max-width: 100%; overflow-x: auto; }
.ai-msg.you { justify-self: end; background: var(--accent); color: #fff; max-width: 85%; }
.ai-msg.you p { margin: 0; }
.ai-msg.claude { background: var(--surface); border: 1px solid var(--border); }
.ai-msg.claude p { margin: .35rem 0; }
.ai-msg.claude h3 { margin: .6rem 0 .3rem; font-size: 1rem; }
.ai-msg.error { border-color: var(--danger); color: var(--danger); }
.ai-msg.thinking p { animation: ai-pulse 1.4s ease-in-out infinite; }
@keyframes ai-pulse { 50% { opacity: .45; } }
@media (prefers-reduced-motion: reduce) { .ai-msg.thinking p { animation: none; } }
.ai-compose { display: flex; gap: .5rem; align-items: flex-end; position: sticky; bottom: calc(var(--nav-h) + 8px); background: var(--bg); padding: .4rem 0; }
.ai-compose textarea { flex: 1; resize: vertical; }
@media (min-width: 900px) { .ai-compose { bottom: 8px; } }

/* ---------- Home: the page ---------- */
/* One column of bands, each on the same left and right edges; inside a band, an even grid */
.home-body { display: grid; grid-template-columns: minmax(0, 1fr); gap: 1rem; }
.home-body > * { margin: 0; min-width: 0; }
.home-body .card { margin: 0; }
.home-actions { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }
.home-actions .search-pill { flex: 1 1 260px; width: auto; min-width: 0; }
.home-pair { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 460px), 1fr)); gap: 1rem; }
.home-pair:not(:has(> :not([hidden]))) { display: none; }
/* Panels of figures: two to a row, level with each other; a last one on its own takes the full row */
.home-panels { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; }
.home-panels > :last-child:nth-child(odd) { grid-column: 1 / -1; }
.home-panel { display: flex; flex-direction: column; gap: .7rem; }
.home-panel h2 { margin: 0; font-size: 1.1rem; }
.home-note { margin: 0; font-size: .95rem; color: var(--muted); }
.home-stats { margin: auto 0 0; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.home-stats .stat { background: var(--surface-2); border-color: transparent; }
.home-stats a.stat.link:hover { border-color: var(--accent); }
@media (max-width: 1000px) { .home-panels { grid-template-columns: minmax(0, 1fr); } }
/* The company at a glance: three level cards */
.home-strip { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 280px), 1fr)); gap: 1rem; }
.home-strip > .card { display: grid; gap: .5rem; align-content: start; }
.challenge-card h2 { margin: 0; }
.challenge-card .btn { justify-self: start; }
.home-goal { display: grid; gap: .25rem; }

/* Most profitable manufacturers (ranked), in two columns on a wide screen */
.best-makers h2 { margin: 0 0 .2rem; font-size: 1.1rem; }
.maker-rank { list-style: none; margin: .4rem 0 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 420px), 1fr)); column-gap: 2rem; }
.maker-rank li { display: grid; grid-template-columns: 2rem minmax(0, 1fr) auto; align-items: center; gap: .6rem; padding: .5rem .2rem; border-top: 1px solid var(--border); }
.mr-pos { width: 1.7rem; height: 1.7rem; border-radius: 50%; display: grid; place-items: center; font-weight: 700; background: var(--accent-soft); color: var(--accent); }
.maker-rank li:first-child .mr-pos { background: var(--accent); color: var(--accent-ink); }
.mr-figure { text-align: right; }

/* ---------- Needs attention: panels by area (public/js/home/attention.js) ---------- */
.attention { display: grid; gap: .8rem; }
.att-head { display: flex; align-items: baseline; gap: .75rem; flex-wrap: wrap; }
.att-head h2 { margin: 0; }
.attention .att-head h2 { font-size: 1.25rem; }
.att-count { color: var(--muted); font-size: .95rem; }
.att-head .link-btn { margin-left: auto; font-weight: 500; }
/* The tabs: All, Urgent and each area, with their counts */
.att-tabs { padding: 0; flex-wrap: wrap; }
.att-tabs .chip { font-size: .9rem; padding: .32rem .8rem; }
.att-tabs .att-n { margin-left: .4rem; padding: 0 .4rem; border-radius: 999px; background: var(--surface-2); font-size: .76rem; font-weight: 700; }
.att-tabs .chip.active .att-n { background: rgb(255 255 255 / .25); }
.att-tabs .att-tab-bad { border-color: var(--danger); color: var(--danger); }
.att-tabs .att-tab-bad.active { background: var(--danger); color: #fff; }
/* Urgent: one full-width panel */
.att-urgent { border: 1px solid color-mix(in srgb, var(--danger) 45%, transparent); background: color-mix(in srgb, var(--danger) 8%, var(--surface)); border-radius: 10px; padding: .7rem .9rem; display: grid; gap: .4rem; }
.att-urgent h3 { margin: 0; font-size: 1rem; color: var(--danger); display: flex; align-items: center; gap: .45rem; }
/* The areas: two panels to a row, level with each other; a last one on its own takes the full row */
.att-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .8rem; }
.att-grid > :last-child:nth-child(odd) { grid-column: 1 / -1; }
@media (max-width: 1000px) { .att-grid { grid-template-columns: minmax(0, 1fr); } }
.att-group { border: 1px solid var(--border); border-radius: 10px; padding: .7rem .9rem; background: var(--surface); display: flex; flex-direction: column; gap: .3rem; }
.att-group-head { display: flex; align-items: center; gap: .5rem; padding-bottom: .15rem; }
.att-group-head h3 { margin: 0; font-size: 1rem; flex: 1; }
.att-icon { width: 18px; height: 18px; opacity: .85; flex: none; }
.att-badge { min-width: 1.6rem; text-align: center; padding: .05rem .45rem; border-radius: 999px; background: var(--surface-2); font-size: .78rem; font-weight: 700; }
.att-group.att-bad .att-badge { background: var(--danger); color: #fff; }
.att-group.att-warn .att-badge { background: var(--copper); color: #fff; }
.att-group.att-good .att-badge { background: var(--ok); color: #fff; }
/* Rows: dot, words, and the two buttons in the same place on every row */
.att-group ul, .att-list { list-style: none; margin: 0; padding: 0; display: grid; }
.att-item { display: grid; grid-template-columns: .6rem minmax(0, 1fr) auto; align-items: start; gap: .65rem; padding: .55rem 0; border-top: 1px solid var(--border); }
.att-urgent .att-item { border-top-color: color-mix(in srgb, var(--danger) 25%, transparent); }
.att-item.later { opacity: .55; }
.att-dot { width: .6rem; height: .6rem; border-radius: 50%; margin-top: .42rem; background: var(--accent); }
.att-item.lv-bad .att-dot { background: var(--danger); }
.att-item.lv-warn .att-dot { background: var(--copper); }
.att-item.lv-good .att-dot { background: var(--ok); }
.att-text { font-size: .95rem; line-height: 1.45; }
.att-text strong { font-weight: 700; }
.att-actions { display: flex; gap: .3rem; }
.att-item .btn.sm { font-size: .84rem; }
.att-more { align-self: flex-start; margin-top: auto; padding-top: .3rem; font-size: .86rem; font-weight: 600; }
@media (max-width: 520px) { .att-item { grid-template-columns: .6rem minmax(0, 1fr); } .att-actions { grid-column: 2; } }

/* Who is online now (GAKA 1.63.0): a row of names with green dots under the greeting */
.online-strip { display: flex; flex-wrap: wrap; align-items: center; gap: .35rem .6rem; margin: .7rem 0 0; }
.online-chip { display: inline-flex; align-items: center; gap: .3rem; padding: .2rem .6rem; border: 1px solid var(--border); border-radius: 999px;
  background: var(--surface); font-size: .88rem; font-weight: 600; }
/* GAKA 1.88.4: Clear notifications beside Another one */
.mc-buttons { display: flex; gap: .4rem; flex-wrap: wrap; justify-content: flex-end; }

/* ---------- Home redesign (GAKA 1.94.0): the CEO, "decisions first, then the rest … make it beautiful" ---------- */
/* The greeting: slimmer, so what needs a decision is higher up the page */
.home-hero { padding: 1rem 1.3rem; gap: 1.2rem; }
.home-hero h1 { font-size: 1.3rem; margin: .25rem 0 .3rem; }
.home-hero .mc-line { font-size: .93rem; margin: .15rem 0; }
.home-hero blockquote { font-size: .92rem; }
.home-h { margin: 0 0 .6rem; font-size: 1.05rem; }

/* Figures at a glance: equal cards in the Loads look, each opening its page */
.home-figs { display: grid; grid-template-columns: repeat(auto-fit, minmax(175px, 1fr)); gap: .7rem; }
.home-figs > span { display: contents; }
.hf { position: relative; display: grid; align-content: start; gap: .35rem; min-width: 0; padding: .85rem 1rem .8rem 1.1rem; border: 1px solid var(--border); border-radius: 14px;
  background: var(--surface); box-shadow: var(--shadow-sm); color: var(--text); font: inherit; text-align: left; text-decoration: none; cursor: pointer; overflow: hidden;
  transition: border-color .15s ease, box-shadow .15s ease, transform .15s ease; }
.hf::before { content: ""; position: absolute; inset: 0 auto 0 0; width: 4px; background: var(--tone); }
.hf:hover { border-color: var(--tone); transform: translateY(-1px); box-shadow: 0 6px 16px rgba(0, 0, 0, .1); text-decoration: none; }
.hf:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.hf-top { display: flex; align-items: center; gap: .55rem; min-width: 0; }
.hf-ic { flex: none; display: grid; place-items: center; width: 1.9rem; height: 1.9rem; border-radius: 9px; background: var(--tone-soft); color: var(--tone-ink); }
.hf-ic svg { width: 1.05rem; height: 1.05rem; }
.hf-label { font-size: .8rem; font-weight: 600; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hf strong { font-size: 1.45rem; font-weight: 750; letter-spacing: -.01em; font-variant-numeric: tabular-nums; line-height: 1.15; white-space: nowrap; }
.hf-sub { display: block; min-width: 0; font-size: .76rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hf.blue, .dec-item.t-blue, .dec-kind.t-blue { --tone: #2a6fdb; --tone-soft: #dfe9ff; --tone-ink: #2846a0; }
.hf.violet, .dec-item.t-violet, .dec-kind.t-violet { --tone: #7c4ddb; --tone-soft: #e6dcff; --tone-ink: #5530a8; }
.hf.copper, .dec-item.t-copper, .dec-kind.t-copper { --tone: #d4844f; --tone-soft: #fbe5d6; --tone-ink: #8a4a1f; }
.hf.slate, .dec-item.t-slate, .dec-kind.t-slate { --tone: #64748b; --tone-soft: #e8edf4; --tone-ink: #3b4a5f; }
.hf.green, .dec-item.t-green, .dec-kind.t-green { --tone: #1f8a57; --tone-soft: #d8f3e4; --tone-ink: #17633e; }
.hf.amber, .dec-item.t-amber, .dec-kind.t-amber { --tone: #e0a100; --tone-soft: #fff1c2; --tone-ink: #7a5600; }
.hf.red, .dec-item.t-red, .dec-kind.t-red { --tone: #d1242f; --tone-soft: #fde2df; --tone-ink: #9b2218; }
.hf.amber strong { color: #9a6b00; }
.hf.red strong { color: #b4232c; }

/* Your decisions: every item in full, with Approve and Reject beside it */
.dec { display: grid; gap: .8rem; border-color: color-mix(in srgb, #e0a100 40%, var(--border)); }
.dec-head { display: flex; align-items: flex-start; justify-content: space-between; gap: .8rem; flex-wrap: wrap; }
.dec-head h2 { margin: 0; font-size: 1.25rem; }
.dec-lead { margin: .2rem 0 0; font-size: .92rem; }
.dec-tabs { padding: 0; flex-wrap: wrap; }
.dec-chip { font-size: .88rem; }
.dec-n { margin-left: .4rem; padding: 0 .4rem; border-radius: 999px; background: var(--surface-2); font-size: .74rem; font-weight: 700; }
.dec-chip.active .dec-n { background: rgb(255 255 255 / .25); }
.dec-list { display: grid; gap: .6rem; }
.dec-item { position: relative; display: grid; grid-template-columns: minmax(0, 1fr); gap: .65rem; padding: .9rem 1.1rem .85rem 1.3rem;
  border: 1px solid var(--border); border-radius: 12px; background: var(--surface); overflow: hidden; }
.dec-item::before { content: ""; position: absolute; inset: 0 auto 0 0; width: 4px; background: var(--tone); }
.dec-item.busy { opacity: .55; pointer-events: none; }
.dec-main { display: grid; gap: .35rem; min-width: 0; }
.dec-top { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; }
.dec-kind { display: inline-flex; align-items: center; gap: .35rem; padding: .15rem .55rem; border-radius: 999px; background: var(--tone-soft); color: var(--tone-ink); font-size: .74rem; font-weight: 650; }
.dec-kind svg { width: .9rem; height: .9rem; }
.dec-wait { font-size: .76rem; color: var(--muted); }
.dec-title { margin: 0; font-size: 1rem; font-weight: 650; line-height: 1.35; overflow-wrap: anywhere; }
.dec-sub { margin: 0; font-size: .86rem; color: var(--muted); }
/* Before → after: the old figure crossed out, the new one bold */
.dec-changes { list-style: none; margin: .1rem 0; padding: 0; display: flex; flex-wrap: wrap; gap: .4rem; }
.dec-changes li { display: inline-flex; align-items: center; gap: .45rem; padding: .3rem .65rem; border: 1px solid color-mix(in srgb, var(--tone) 35%, var(--border)); border-radius: 9px; background: var(--tone-soft); font-size: .88rem; }
.dec-ch-label { font-weight: 600; color: var(--tone-ink); }
.dec-from { color: var(--muted); }
.dec-arrow { color: var(--tone-ink); font-weight: 700; }
.dec-to { font-variant-numeric: tabular-nums; }
/* GAKA 1.94.1: the details over the full width of the card, a long value over two columns */
.dec-facts { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: .55rem 1.4rem; margin: 0; padding: .7rem .9rem; border-radius: 10px; background: var(--surface-2); }
.dec-facts .dec-wide { grid-column: span 2; }
.dec-facts div { min-width: 0; }
.dec-facts dt { font-size: .7rem; font-weight: 650; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); }
.dec-facts dd { margin: 0; font-size: .88rem; overflow-wrap: anywhere; }
.dec-reason { margin: 0; padding: .45rem .7rem; border-left: 3px solid var(--tone); border-radius: 0 8px 8px 0; background: var(--surface-2); font-size: .88rem; }
.dec-note { margin: 0; font-size: .82rem; color: var(--muted); font-style: italic; }
.dec-files { display: flex; flex-wrap: wrap; align-items: center; gap: .3rem .7rem; margin: 0; font-size: .86rem; }
.dec-files svg { width: 1rem; height: 1rem; color: var(--muted); }
/* Top band: what it is, the amount on the right; bottom band: the note on the left, the buttons on the right */
.dec-ihead { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; }
.dec-foot { display: flex; align-items: center; justify-content: space-between; gap: .6rem 1rem; flex-wrap: wrap; padding-top: .55rem; border-top: 1px solid var(--border); }
.dec-amount { font-size: 1.3rem; font-weight: 750; font-variant-numeric: tabular-nums; white-space: nowrap; }
.dec-btns { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: .35rem; }
.dec-yes { background: #1f8a57; border-color: #1f8a57; color: #fff; font-weight: 650; }
.dec-yes:hover { background: #17633e; border-color: #17633e; }
.dec-no { color: #b4232c; border-color: color-mix(in srgb, #d1242f 45%, var(--border)); }
.dec-no:hover { background: #fde2df; }
.dec-elsewhere { margin: 0; }

/* Quick actions: an even grid of tiles with their icons, the search under them */
.home-actions { display: grid; gap: .6rem; }
.home-actions .home-h { margin: 0; }
.home-act-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: .5rem; }
.home-act { display: flex; align-items: center; justify-content: flex-start; gap: .6rem; min-height: 2.9rem; padding: .55rem .85rem; font-weight: 600; text-align: left; }
.home-act svg { flex: none; width: 1.15rem; height: 1.15rem; color: var(--accent); }
.home-actions .search-pill { width: 100%; }

@media (prefers-color-scheme: dark) {
  .hf.blue, .dec-item.t-blue, .dec-kind.t-blue { --tone: #5b8def; --tone-soft: #1c2b52; --tone-ink: #9db6ff; }
  .hf.violet, .dec-item.t-violet, .dec-kind.t-violet { --tone: #9b7bf0; --tone-soft: #2f2153; --tone-ink: #c3adff; }
  .hf.copper, .dec-item.t-copper, .dec-kind.t-copper { --tone: #e39a68; --tone-soft: #3d2718; --tone-ink: #f2b88f; }
  .hf.slate, .dec-item.t-slate, .dec-kind.t-slate { --tone: #8a9bb4; --tone-soft: #232d40; --tone-ink: #b8c4d6; }
  .hf.green, .dec-item.t-green, .dec-kind.t-green { --tone: #3fbf7f; --tone-soft: #143d29; --tone-ink: #7fe0ae; }
  .hf.amber, .dec-item.t-amber, .dec-kind.t-amber { --tone: #ffd866; --tone-soft: #4a3a0c; --tone-ink: #ffd866; }
  .hf.red, .dec-item.t-red, .dec-kind.t-red { --tone: #ff7a70; --tone-soft: #4a1a15; --tone-ink: #ff9d92; }
  .hf.amber strong { color: #ffd866; }
  .hf.red strong { color: #ff9d92; }
  .hf { box-shadow: none; }
  .hf:hover { box-shadow: 0 6px 16px rgba(0, 0, 0, .35); }
  .dec { border-color: rgba(255, 216, 102, .25); }
  .dec-yes { background: #2fa86c; border-color: #2fa86c; color: #06130c; }
  .dec-yes:hover { background: #3fbf7f; border-color: #3fbf7f; }
  .dec-no { color: #ff9d92; border-color: rgba(255, 157, 146, .35); }
  .dec-no:hover { background: rgba(255, 157, 146, .12); }
}
@media (max-width: 720px) {
  .home-figs { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .hf strong { font-size: 1.2rem; }
  .dec-facts { grid-template-columns: repeat(2, minmax(0, 1fr)); padding: .6rem .7rem; gap: .5rem .9rem; }
  .dec-facts .dec-wide { grid-column: 1 / -1; }
  .dec-ihead { flex-direction: column; gap: .35rem; }
  .dec-btns { justify-content: flex-start; }
  .home-act-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
.dec-more { justify-self: center; min-width: 14rem; font-weight: 600; }
.dec-ihead .dec-amount { flex: none; }
.dec-foot .dec-note { flex: 1 1 280px; }

/* A long quick-action label wraps on a phone instead of running off the edge (GAKA 1.154.2) */
.home-act { min-width: 0; }
.home-act span { min-width: 0; white-space: normal; line-height: 1.2; overflow-wrap: anywhere; }
