/* ============================================================
   Shivah Web Tech — stylesheet
   (design system ported from the prototype; light + dark)
   ============================================================ */

*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; }
img { max-width: 100%; }
[hidden] { display: none !important; }

.boot {
  position: fixed; inset: 0; display: grid; place-items: center;
  font-family: "IBM Plex Sans", system-ui, sans-serif; color: #6c776f;
  background: #eceff2;
}
@media (prefers-color-scheme: dark) { .boot { background: #0e130f; color: #899287; } }


  :root {
    --ground:      #eceff2;
    --surface:     #ffffff;
    --surface-2:   #f4f6f8;
    --surface-3:   #eef1f4;
    --ink:         #17211d;
    --ink-soft:    #43514b;
    --muted:       #6c776f;
    --line:        #d9ded8;
    --line-strong: #bcc4bb;
    --accent:      #1892c9;
    --accent-ink:  #12699c;
    --accent-soft: #deeff7;
    --good:        #1f7a52;
    --good-soft:   #dcefe3;
    --warn:        #9a6b00;
    --warn-soft:   #f6ecd2;
    --bad:         #b23c26;
    --bad-soft:    #f4ddd5;
    --info:        #2f5aa8;
    --info-soft:   #dde6f4;
    --input-tint:  #fffaf0;
    --input-edge:  #e6c86a;
    --shadow-sm:   0 1px 2px rgba(23,33,29,.06);
    --shadow-md:   0 1px 2px rgba(23,33,29,.05), 0 10px 26px -12px rgba(23,33,29,.22);
    --radius:      8px;
    --chart-1:     #2f6e52;
    --chart-2:     #1892c9;
    --chart-3:     #c98a18;
    --chart-4:     #8a4fc9;
    --chart-5:     #c94f6e;
    --chart-6:     #4f9fc9;
    --chart-7:     #6ea34a;
  }
  @media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
      --ground:      #0e1310;
      --surface:     #161c18;
      --surface-2:   #1c231e;
      --surface-3:   #232b25;
      --ink:         #e6ece6;
      --ink-soft:    #b4beb5;
      --muted:       #899287;
      --line:        #2c352e;
      --line-strong: #3c463d;
      --accent:      #5bbfed;
      --accent-ink:  #8ed4f5;
      --accent-soft: #17303c;
      --good:        #55bd8e;
      --good-soft:   #16281f;
      --warn:        #d5a53e;
      --warn-soft:   #2c2413;
      --bad:         #e28a71;
      --bad-soft:    #2f1c16;
      --info:        #7ba7e6;
      --info-soft:   #182233;
      --input-tint:  #221f13;
      --input-edge:  #6a5a2a;
      --shadow-sm:   0 1px 2px rgba(0,0,0,.4);
      --shadow-md:   0 1px 2px rgba(0,0,0,.4), 0 16px 36px -16px rgba(0,0,0,.6);
      --chart-1:     #55bd8e;
      --chart-2:     #5bbfed;
      --chart-3:     #d5a53e;
      --chart-4:     #b98ce6;
      --chart-5:     #e2789a;
      --chart-6:     #7cc9ea;
      --chart-7:     #a4d178;
  }
  }
  :root[data-theme="dark"] {
    --ground:#0e1310; --surface:#161c18; --surface-2:#1c231e; --surface-3:#232b25;
    --ink:#e6ece6; --ink-soft:#b4beb5; --muted:#899287; --line:#2c352e; --line-strong:#3c463d;
    --accent:#5bbfed; --accent-ink:#8ed4f5; --accent-soft:#17303c;
    --good:#55bd8e; --good-soft:#16281f; --warn:#d5a53e; --warn-soft:#2c2413;
    --bad:#e28a71; --bad-soft:#2f1c16; --info:#7ba7e6; --info-soft:#182233;
    --input-tint:#221f13; --input-edge:#6a5a2a;
    --shadow-sm:0 1px 2px rgba(0,0,0,.4);
    --shadow-md:0 1px 2px rgba(0,0,0,.4), 0 16px 36px -16px rgba(0,0,0,.6);
    --chart-1:#55bd8e; --chart-2:#5bbfed; --chart-3:#d5a53e; --chart-4:#b98ce6;
    --chart-5:#e2789a; --chart-6:#7cc9ea; --chart-7:#a4d178;
  }

  * { box-sizing: border-box; }
  html, body { height: 100%; }
  body {
    margin: 0;
    background: var(--ground);
    color: var(--ink);
    font-family: "IBM Plex Sans", ui-sans-serif, system-ui, sans-serif;
    font-size: 14px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
  }
  h1,h2,h3 { font-family: "Fraunces", Georgia, serif; font-weight: 500; margin: 0; text-wrap: balance; }
  a { color: var(--accent-ink); }
  .mono { font-family: "IBM Plex Mono", ui-monospace, monospace; font-variant-numeric: tabular-nums; }
  [hidden] { display: none !important; }

  /* ---------------- login ---------------- */
  .login-shell {
    min-height: 100%;
    display: grid;
    place-items: center;
    padding: 2rem 1rem;
  }
  .login-card {
    width: min(560px, 100%);
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 14px;
    box-shadow: var(--shadow-md);
    overflow: hidden;
  }
  .login-head {
    padding: 1.6rem 1.6rem 1.3rem;
    border-bottom: 1px solid var(--line);
    background: linear-gradient(180deg, var(--accent-soft), transparent);
  }
  .login-head .login-logo { max-width: 220px; margin-bottom: .5rem; }
  .login-head h1 { font-size: 1.75rem; margin: .2rem 0 .15rem; }
  .login-head p { margin: 0; color: var(--muted); font-size: .85rem; }
  .login-body { padding: 1.4rem 1.6rem 1.6rem; }
  .login-body .prompt {
    font-family: "IBM Plex Mono", monospace;
    font-size: .7rem; letter-spacing: .12em; text-transform: uppercase; color: var(--muted);
    margin-bottom: .75rem;
  }
  .people {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: .6rem;
    max-height: 340px; overflow-y: auto; padding-right: .2rem;
  }
  .person {
    display: flex; align-items: center; gap: .6rem; text-align: left;
    padding: .6rem .7rem; border: 1px solid var(--line); border-radius: var(--radius);
    background: var(--surface-2); color: var(--ink); cursor: pointer; font: inherit;
    transition: border-color .12s, background .12s, transform .06s;
  }
  .person:hover { border-color: var(--accent); background: var(--surface); }
  .person:active { transform: translateY(1px); }
  .avatar {
    width: 30px; height: 30px; flex: none; border-radius: 50%;
    display: grid; place-items: center; color: #fff; font-weight: 600; font-size: .78rem;
    font-family: "IBM Plex Mono", monospace;
  }
  .person .who { min-width: 0; }
  .person .nm { display: block; font-weight: 600; font-size: .82rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .person .dp { display: block; font-size: .7rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .tag-admin {
    font-family: "IBM Plex Mono", monospace; font-size: .58rem; letter-spacing: .1em;
    padding: .1rem .3rem; border-radius: 4px; background: var(--info-soft); color: var(--info);
    text-transform: uppercase;
  }

  .pin-view { text-align: center; padding: .5rem 0 0; }
  .pin-view .pin-name { font-weight: 700; font-size: 1rem; }
  .pin-view .pin-sub { color: var(--muted); font-size: .8rem; margin-bottom: 1rem; }
  .pin-dots { display: flex; gap: .55rem; justify-content: center; margin: .8rem 0 1rem; }
  .pin-dot { width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--line-strong); background: transparent; }
  .pin-dot.filled { background: var(--accent); border-color: var(--accent); }
  .pinpad { display: grid; grid-template-columns: repeat(3, 1fr); gap: .5rem; max-width: 260px; margin: 0 auto; }
  .pinpad button {
    font-family: "IBM Plex Mono", monospace; font-size: 1.15rem; padding: .7rem 0;
    border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface-2);
    color: var(--ink); cursor: pointer;
  }
  .pinpad button:hover { border-color: var(--accent); }
  .pinpad button.ghost { background: transparent; border-color: transparent; font-size: .8rem; color: var(--muted); }
  .pin-err { color: var(--bad); font-size: .8rem; min-height: 1.2em; margin-top: .4rem; }
  .totp-secret, .totp-codes {
    padding: .9rem 1rem; border: 1px solid var(--line); border-radius: var(--radius);
    background: var(--surface-2); color: var(--ink); word-break: break-all;
    font-size: 1rem; letter-spacing: .04em; line-height: 1.6; text-align: center;
  }
  .disclaimer {
    margin-top: 1.2rem; padding-top: 1rem; border-top: 1px dashed var(--line);
    font-size: .74rem; color: var(--muted); line-height: 1.45;
  }
  .link-btn { background: none; border: 0; color: var(--accent-ink); font: inherit; cursor: pointer; text-decoration: underline; padding: 0; }

  /* ---------------- app frame ---------------- */
  .app { min-height: 100%; display: grid; grid-template-columns: 244px 1fr; }
  @media (max-width: 880px) { .app { grid-template-columns: 1fr; } }

  .sidebar {
    background: var(--surface);
    border-right: 1px solid var(--line);
    display: flex; flex-direction: column;
    position: sticky; top: 0; height: 100vh; overflow-y: auto;
  }
  @media (max-width: 880px) { .sidebar { position: static; height: auto; } }
  .side-id { padding: 1rem 1rem .9rem; border-bottom: 1px solid var(--line); }
  .side-id .id-top { display: flex; align-items: flex-start; justify-content: space-between; gap: .5rem; }
  .side-id .co { font-family: "Fraunces", serif; font-size: 1.05rem; font-weight: 600; line-height: 1.15; }
  .brand-logo { display: block; width: 100%; max-width: 172px; height: auto; }
  .side-id .co small { display:block; font-family: "IBM Plex Mono", monospace; font-size: .6rem; letter-spacing: .16em; text-transform: uppercase; color: var(--muted); font-weight: 400; margin-top: .2rem; }
  .id-icons { display: flex; gap: .25rem; flex: none; }
  .icon-bell {
    position: relative; width: 30px; height: 30px; border-radius: 7px; padding: 0;
    border: 1px solid var(--line); background: var(--surface-2); color: var(--ink-soft);
    cursor: pointer; display: grid; place-items: center;
  }
  .icon-bell:hover { border-color: var(--accent); color: var(--accent-ink); }
  .icon-bell .ic-badge {
    position: absolute; top: -6px; right: -6px; min-width: 15px; height: 15px; padding: 0 3px;
    border-radius: 8px; background: var(--bad); color: #fff; border: 1.5px solid var(--surface);
    font-family: "IBM Plex Mono", monospace; font-size: .56rem; font-weight: 700;
    display: flex; align-items: center; justify-content: center;
  }
  #runTimer {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 900; display: flex; align-items: center; gap: .6rem;
    padding: .45rem .9rem; font-size: .8rem; color: #fff; background: var(--bad);
    box-shadow: 0 -4px 18px rgba(0,0,0,.18);
  }
  #runTimer .rt-dot { width: 9px; height: 9px; border-radius: 50%; background: #fff; flex: none; }
  @media (prefers-reduced-motion: no-preference) { #runTimer .rt-dot { animation: pulse 1.2s ease-in-out infinite; } }
  #runTimer .rt-what { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  #runTimer .rt-time { margin-left: auto; font-variant-numeric: tabular-nums; font-weight: 600; }
  #runTimer .btn { flex: none; border-color: rgba(255,255,255,.6); color: #fff; background: rgba(255,255,255,.12); }
  #toast {
    position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%) translateY(18px);
    background: var(--ink); color: var(--ground); padding: .7rem 1.1rem; border-radius: 8px;
    font-size: .85rem; box-shadow: 0 10px 34px rgba(0,0,0,.28); opacity: 0; pointer-events: none;
    transition: opacity .2s ease, transform .2s ease; z-index: 2000; max-width: 90vw; text-align: center;
  }
  #toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

  #noteModal {
    position: fixed; inset: 0; z-index: 2100; background: rgba(15,22,26,.55);
    display: flex; align-items: center; justify-content: center; padding: 1rem;
  }
  #noteModal .nm-card {
    width: 430px; max-width: 100%; background: var(--surface); color: var(--ink);
    border: 1px solid var(--line); border-radius: 14px; padding: 1.2rem 1.25rem;
    box-shadow: 0 22px 64px rgba(0,0,0,.4);
  }
  #noteModal h3 { margin: 0 0 .7rem; font-size: 1.02rem; }
  #noteModal textarea { width: 100%; font: inherit; font-size: .86rem; resize: vertical; min-height: 4.5rem; }
  #noteModal .nm-actions { display: flex; gap: .5rem; align-items: center; margin-top: .95rem; }

  /* ---- clock in / out modal (also reused, by id, for the quick-add-customer
     and post-announcement modals — same look, different content) ---- */
  #clockModal, #quickCustModal, #annModal {
    position: fixed; inset: 0; z-index: 2100; background: rgba(15,22,26,.55);
    display: flex; align-items: center; justify-content: center; padding: 1rem;
  }
  #clockModal .cm-card, #quickCustModal .cm-card, #annModal .cm-card {
    width: 440px; max-width: 100%; max-height: 88vh; overflow-y: auto;
    background: var(--surface); color: var(--ink);
    border: 1px solid var(--line); border-radius: 14px; padding: 1.2rem 1.25rem;
    box-shadow: 0 22px 64px rgba(0,0,0,.4);
  }
  #clockModal .cm-card.cm-wide { width: 560px; }
  #clockModal h3, #quickCustModal h3, #annModal h3 { margin: 0 0 .3rem; font-size: 1.05rem; }
  #clockModal .cm-sub, #quickCustModal .cm-sub, #annModal .cm-sub { margin: 0 0 .8rem; font-size: .82rem; color: var(--muted); }
  #clockModal .cm-l, #quickCustModal .cm-l, #annModal .cm-l { display: block; margin: .75rem 0 .25rem; font-size: .78rem; font-weight: 600; color: var(--muted); }
  #clockModal .cm-opt, #annModal .cm-opt { font-weight: 400; opacity: .8; }
  #clockModal select, #clockModal input, #clockModal textarea,
  #quickCustModal select, #quickCustModal input, #quickCustModal textarea,
  #annModal select, #annModal input, #annModal textarea { width: 100%; font: inherit; font-size: .88rem; }
  #clockModal textarea, #annModal textarea { resize: vertical; min-height: 3rem; }
  #clockModal .cm-actions, #quickCustModal .cm-actions, #annModal .cm-actions { display: flex; gap: .5rem; align-items: center; margin-top: 1rem; }
  #quickCustModal .qc-err, #annModal .qc-err { color: var(--bad, #c0392b); font-size: .8rem; margin: .3rem 0 0; }
  #clockModal .cm-warn {
    background: var(--warn-soft, #fdf1df); color: var(--warn-ink, #8a5a10);
    border: 1px solid var(--warn, #e6b877); border-radius: 8px; padding: .55rem .7rem;
    font-size: .8rem; margin: .2rem 0 .7rem;
  }
  #clockModal .cm-repwrap { margin: .3rem 0 .2rem; }
  #clockModal table.cm-rep { width: 100%; border-collapse: collapse; font-size: .82rem; }
  #clockModal table.cm-rep th, #clockModal table.cm-rep td { text-align: left; padding: .35rem .4rem; border-bottom: 1px solid var(--line); }
  #clockModal table.cm-rep .num { text-align: right; white-space: nowrap; }
  #clockModal table.cm-rep tfoot td { font-weight: 700; border-bottom: none; }
  #clockModal .cm-dim { color: var(--muted); font-size: .74rem; }
  .task-filter { font: inherit; font-size: .82rem; padding: .2rem .4rem; }

  /* ---- dashboard: announcements ---- */
  .ann-item { padding: .7rem 1rem; border-bottom: 1px solid var(--line); }
  .ann-item:last-child { border-bottom: none; }
  .ann-head { display: flex; align-items: center; gap: .4rem; font-size: .88rem; }
  .ann-head .icon-btn { margin-left: auto; }
  .ann-body { font-size: .84rem; color: var(--ink); margin-top: .25rem; white-space: pre-wrap; }
  .ann-meta { font-size: .72rem; color: var(--muted); margin-top: .35rem; }

  /* ---- dashboard: sticky notes ---- */
  .note-add { display: flex; gap: .4rem; flex-wrap: wrap; padding: .8rem 1rem; border-bottom: 1px solid var(--line); }
  .note-add input#note-text { flex: 1 1 200px; font: inherit; font-size: .86rem; }
  .note-add input#note-time { flex: 0 0 auto; width: 110px; font: inherit; font-size: .86rem; }
  .note-add select#note-remind { flex: 0 0 auto; width: 140px; font: inherit; font-size: .86rem; }
  .note-list { max-height: 320px; overflow-y: auto; }
  .note-item { display: flex; align-items: flex-start; gap: .5rem; padding: .55rem 1rem; border-bottom: 1px solid var(--line); font-size: .86rem; }
  .note-item:last-child { border-bottom: none; }
  .note-item label { display: flex; align-items: flex-start; gap: .5rem; flex: 1; min-width: 0; }
  .note-item label input { margin-top: .2rem; flex: 0 0 auto; }
  .note-item label span { white-space: normal; word-break: break-word; line-height: 1.35; }
  .note-when { flex: 0 0 auto; font-size: .74rem; color: var(--muted); font-family: "IBM Plex Mono", ui-monospace, monospace; white-space: nowrap; }
  .note-overdue { color: var(--bad, #c0392b); }

  /* ---- sticky notes bubble (right edge, vertically centered — clear of the
     AI bubble (bottom-left) and team chat (bottom-right)) ---- */
  #notesWrap { position: fixed; right: 18px; top: 50%; transform: translateY(-50%); z-index: 950; }
  /* Vertically centering on the viewport means it can land on top of
     whatever happens to be scrolled to the middle — fine on a wide desktop
     layout with room to spare, but on a narrow one it was landing on
     dashboard cards/controls. Stack it above the chat bubble instead. */
  @media (max-width: 880px) {
    #notesWrap { top: auto; bottom: 90px; transform: none; }
  }
  .notes-fab {
    width: 46px; height: 46px; border-radius: 50%; border: none; cursor: pointer;
    background: var(--accent); color: #fff; display: flex; align-items: center; justify-content: center;
    font-size: 1.2rem; box-shadow: 0 6px 20px rgba(0,0,0,.28); transition: transform .12s ease;
  }
  .notes-fab-urgent { animation: notes-blink 1s ease-in-out infinite; }
  @keyframes notes-blink {
    0%, 100% { background: var(--accent); box-shadow: 0 6px 20px rgba(0,0,0,.28); }
    50% { background: var(--bad, #c0392b); box-shadow: 0 0 0 8px rgba(192,57,43,.28); }
  }
  .notes-fab:hover { transform: scale(1.06); }
  .notes-pop {
    width: 340px; max-width: calc(100vw - 32px); max-height: min(74vh, 560px); display: flex; flex-direction: column;
    background: var(--surface); color: var(--ink); border: 1px solid var(--line); border-radius: 14px;
    overflow: hidden; box-shadow: 0 14px 44px rgba(0,0,0,.32);
  }
  .notes-pop .note-add { flex-wrap: wrap; }
  .notes-pop .note-list { flex: 1; overflow-y: auto; }

  /* --- dashboard charts (hand-drawn SVG) --- */
  .chart-b { padding: 1rem 1.1rem 1.2rem; }
  .hbar { display: flex; flex-direction: column; gap: .5rem; }
  .hbar-row { display: grid; grid-template-columns: minmax(5rem, 8.5rem) 1fr auto; align-items: center; gap: .6rem; font-size: .8rem; }
  .hbar-lab { color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .hbar-track { height: .7rem; background: var(--surface-3); border-radius: 999px; overflow: hidden; }
  .hbar-fill { display: block; height: 100%; border-radius: 999px; transition: width .4s ease; }
  .hbar-val { font-family: "IBM Plex Mono", monospace; font-variant-numeric: tabular-nums; font-size: .78rem; }
  svg.vbars { width: 100%; height: 130px; display: block; }
  .vbars-x { display: flex; margin-top: .3rem; }
  .vbars-x span { flex: 1; text-align: center; font-size: .66rem; color: var(--muted); display: flex; flex-direction: column; gap: .1rem; }
  .vbars-x span b { color: var(--ink); font-size: .74rem; font-variant-numeric: tabular-nums; }
  .donut-wrap { display: flex; gap: 1.2rem; align-items: center; flex-wrap: wrap; }
  svg.donut { width: 120px; height: 120px; flex: none; }
  svg.donut .donut-mid { font-size: 8px; text-anchor: middle; dominant-baseline: central; fill: var(--ink); font-weight: 700; font-family: "Fraunces", serif; }
  .dn-legend { display: flex; flex-direction: column; gap: .35rem; font-size: .8rem; }
  .dn-li { display: flex; align-items: center; gap: .45rem; }
  .dn-li i { width: .65rem; height: .65rem; border-radius: 3px; flex: none; }

  /* inline multi-field filter bar */
  .filterbar {
    display: flex; align-items: flex-end; gap: .7rem; flex-wrap: wrap;
    margin: 0 0 1rem; padding: .6rem .85rem;
    border: 1px solid var(--line); border-radius: 9px; background: var(--surface-2, rgba(0,0,0,.02));
  }
  .filterbar .fb-label { font-family: "IBM Plex Mono", monospace; font-size: .66rem; letter-spacing: .09em;
    text-transform: uppercase; color: var(--muted); align-self: center; }
  .filterbar .fb-field { display: flex; flex-direction: column; gap: .2rem; font-size: .72rem; color: var(--muted); }
  .filterbar .fb-field span { text-transform: uppercase; letter-spacing: .04em; font-size: .64rem; }
  .filterbar .fb-field select,
  .filterbar .fb-field input { font: inherit; font-size: .82rem; padding: .28rem .4rem; min-width: 8.5rem; }
  .filterbar .fb-count { align-self: center; font-family: "IBM Plex Mono", monospace; font-size: .72rem;
    color: var(--muted); margin-left: auto; }
  .filterbar .fb-chips { display: flex; flex-wrap: wrap; gap: .35rem; align-items: center; }
  .filterbar .fb-chip {
    font: inherit; font-size: .72rem; padding: .18rem .5rem; border-radius: 999px; cursor: pointer;
    border: 1px solid var(--accent); background: var(--accent-soft); color: var(--accent);
  }
  .filterbar .fb-chip:hover { background: var(--accent); color: #fff; }
  tr.dwr-detail > td { background: var(--surface-2, rgba(0,0,0,.02)); }

  /* running-timer bar on the Tasks screen */
  .timer-bar {
    display: flex; align-items: center; gap: .55rem; flex-wrap: wrap;
    margin: 0 0 1rem; padding: .55rem .85rem; font-size: .85rem;
    border: 1px solid var(--line-strong); border-radius: 9px; background: var(--surface);
  }
  .timer-bar .tb-dot {
    width: 8px; height: 8px; border-radius: 50%; background: #e5484d;
    box-shadow: 0 0 0 0 rgba(229,72,77,.6); animation: tb-pulse 1.8s infinite;
  }
  @keyframes tb-pulse { 70% { box-shadow: 0 0 0 7px rgba(229,72,77,0); } 100% { box-shadow: 0 0 0 0 rgba(229,72,77,0); } }

  /* @mention autocomplete popup */
  #mentionPop {
    background: var(--surface); border: 1px solid var(--line); border-radius: 8px;
    box-shadow: 0 12px 32px rgba(0,0,0,.28); overflow: hidden; max-height: 210px; overflow-y: auto;
  }
  #mentionPop button {
    display: block; width: 100%; text-align: left; border: none; background: none;
    padding: .45rem .7rem; font: inherit; font-size: .85rem; color: var(--ink); cursor: pointer;
  }
  #mentionPop button span { color: var(--muted); font-size: .74rem; margin-left: .4rem; }
  #mentionPop button:hover { background: var(--accent-soft); }

  /* ---- content calendar ---- */
  .cc-agenda { display: flex; flex-direction: column; gap: 1rem; }
  .cc-day { border-left: 3px solid var(--accent-soft); padding-left: .9rem; }
  .cc-daylabel { font-family: "IBM Plex Mono", monospace; font-size: .68rem; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); margin-bottom: .4rem; }
  .cc-item { background: var(--surface-2); border: 1px solid var(--line-soft); border-radius: 8px; padding: .6rem .75rem; margin-bottom: .5rem; font-size: .86rem; }
  .cc-item .cc-plat { font-weight: 600; margin-right: .5rem; }
  .cc-item .cc-title { margin-right: .5rem; }
  .cc-item .cc-body { margin-top: .4rem; color: var(--ink-soft); font-size: .82rem; white-space: pre-wrap; }
  #topBar { position: fixed; top: 14px; right: 18px; z-index: 850; display: flex; gap: .4rem; align-items: center; }
  /* Below the desktop breakpoint the sidebar stops being a fixed side column
     and stacks inline above the page content (see .app / .sidebar), so a
     bar that's still just floating icons with no backing would sit right on
     top of the logo instead of beside it. Turn it into a proper full-width
     header bar and reserve matching clearance above the logo. */
  @media (max-width: 880px) {
    #topBar { left: 0; top: 0; right: 0; justify-content: flex-end; padding: 10px 14px; background: var(--surface); border-bottom: 1px solid var(--line); }
    .side-id { padding-top: 64px; }
  }
  #topBar .user-menu { position: relative; }
  #topBar .user-menu > .avatar {
    width: 34px; height: 34px; border: none; cursor: pointer; font-size: .74rem;
    box-shadow: 0 3px 12px rgba(0,0,0,.14); color: #fff;
  }
  #topBar .user-pop {
    position: absolute; top: 42px; right: 0; min-width: 180px; background: var(--surface);
    border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 14px 40px rgba(0,0,0,.22);
    padding: .35rem; display: flex; flex-direction: column;
  }
  #topBar .user-pop .up-who { padding: .5rem .6rem .55rem; border-bottom: 1px solid var(--line); margin-bottom: .3rem; }
  #topBar .user-pop .up-who b { display: block; font-size: .85rem; }
  #topBar .user-pop .up-who span { font-size: .72rem; color: var(--muted); }
  #topBar .user-pop .up-item {
    text-align: left; background: none; border: none; cursor: pointer; font: inherit; font-size: .84rem;
    color: var(--ink); padding: .5rem .6rem; border-radius: 7px;
  }
  #topBar .user-pop .up-item:hover { background: var(--surface-2); }
  #topBar .icon-bell { width: 34px; height: 34px; border-radius: 9px; background: var(--surface); box-shadow: 0 3px 12px rgba(0,0,0,.14); }

  .search-overlay {
    position: fixed; inset: 0; z-index: 960; background: rgba(20,24,22,.45);
    display: flex; align-items: flex-start; justify-content: center; padding-top: 12vh;
  }
  .search-box {
    width: min(560px, 92vw); max-height: 70vh; display: flex; flex-direction: column;
    background: var(--surface); border-radius: var(--radius); box-shadow: 0 20px 60px rgba(0,0,0,.3);
    overflow: hidden;
  }
  .search-box input {
    border: none; border-bottom: 1px solid var(--line); padding: .95rem 1.1rem; font-size: 1rem;
    background: transparent; color: var(--ink); outline: none;
  }
  .search-results { overflow-y: auto; padding: .4rem 0; }
  .search-empty { padding: 1.2rem; color: var(--muted); font-size: .85rem; text-align: center; }
  .search-group-h {
    padding: .5rem 1.1rem .2rem; font-family: "IBM Plex Mono", monospace; font-size: .66rem;
    letter-spacing: .1em; text-transform: uppercase; color: var(--muted);
  }
  .search-result {
    display: block; width: 100%; text-align: left; border: none; background: none; cursor: pointer;
    padding: .5rem 1.1rem; font: inherit; color: var(--ink);
  }
  .search-result:hover { background: var(--surface-2); }
  .search-result span { color: var(--muted); font-size: .82rem; margin-left: .4rem; }
  .side-user { display: flex; align-items: center; gap: .55rem; margin-top: .8rem; }
  .side-user .who { min-width: 0; }
  .side-user .nm { display: block; font-weight: 600; font-size: .82rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .side-user .rl { display: block; font-size: .68rem; color: var(--muted); }
  .side-user button { margin-left: auto; }

  nav { padding: .6rem .5rem 1.5rem; flex: 1; }
  .nav-group {
    display: flex; align-items: center; gap: .4rem; width: 100%; border: 0; background: none; cursor: pointer;
    font-family: "IBM Plex Mono", monospace; font-size: .6rem; letter-spacing: .16em; text-transform: uppercase;
    color: var(--muted); padding: .8rem .6rem .4rem; text-align: left; border-radius: 6px;
  }
  .nav-group:hover { color: var(--ink-soft); }
  .nav-group.has-cur { color: var(--accent-ink); }
  .nav-group .ng-caret { font-size: .7rem; letter-spacing: 0; width: .8rem; display: inline-block; }
  .nav-items { display: flex; flex-direction: column; gap: 1px; }
  .nav-items.nav-loose { margin-bottom: .5rem; padding-bottom: .5rem; border-bottom: 1px solid var(--line); }
  .nav-item {
    display: flex; align-items: center; gap: .5rem; width: 100%;
    padding: .48rem .6rem; border: 0; border-radius: 6px; background: none; color: var(--ink-soft);
    font: inherit; font-size: .84rem; text-align: left; cursor: pointer;
  }
  .nav-item:hover { background: var(--surface-2); color: var(--ink); }
  .nav-item[aria-current="true"] { background: var(--accent-soft); color: var(--accent-ink); font-weight: 600; }
  .nav-item .lvl { margin-left: auto; font-family: "IBM Plex Mono", monospace; font-size: .58rem; color: var(--muted); letter-spacing: .06em; }
  .nav-badge { margin-left: auto; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--bad); color: #fff; font-family: "IBM Plex Mono", monospace; font-size: .62rem; font-weight: 600; display: inline-flex; align-items: center; justify-content: center; }
  .nav-item[aria-current="true"] .nav-badge { background: var(--bad); }

  .main { min-width: 0; padding: 1.9rem clamp(1.15rem, 3.5vw, 2.85rem) 5rem; }
  .alert-banner {
    display: flex; align-items: center; gap: .6rem; cursor: pointer;
    background: var(--bad-soft); border: 1px solid color-mix(in srgb, var(--bad) 35%, transparent);
    color: var(--bad); border-radius: var(--radius); padding: .6rem .85rem; margin-bottom: 1.1rem;
    font-size: .84rem;
  }
  .alert-banner .ab-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--bad); flex: none; }
  .alert-banner b { font-weight: 600; color: var(--ink); }
  .alert-banner .ab-go { margin-left: auto; font-weight: 600; font-size: .78rem; }
  @media (prefers-reduced-motion: no-preference) { .alert-banner .ab-dot { animation: pulse 1.6s ease-in-out infinite; } }

  tr.row-unread td { background: color-mix(in srgb, var(--info-soft) 55%, transparent); }
  tr.row-unread td:first-child { box-shadow: inset 3px 0 0 var(--info); }
  tr.row-danger td { background: color-mix(in srgb, var(--bad-soft) 55%, transparent); }
  tr.row-danger td:first-child { box-shadow: inset 3px 0 0 var(--bad); }

  /* full-row status tints (tasks / projects / leads) */
  tr.row-tint-good td { background: color-mix(in srgb, var(--good-soft) 45%, transparent); }
  tr.row-tint-good td:first-child { box-shadow: inset 3px 0 0 var(--good); }
  tr.row-tint-warn td { background: color-mix(in srgb, var(--warn-soft) 45%, transparent); }
  tr.row-tint-warn td:first-child { box-shadow: inset 3px 0 0 var(--warn); }
  tr.row-tint-bad td  { background: color-mix(in srgb, var(--bad-soft) 45%, transparent); }
  tr.row-tint-bad td:first-child { box-shadow: inset 3px 0 0 var(--bad); }
  tr.row-tint-info td { background: color-mix(in srgb, var(--info-soft) 40%, transparent); }
  tr.row-tint-info td:first-child { box-shadow: inset 3px 0 0 var(--info); }

  .cmt-list { display: flex; flex-direction: column; gap: .7rem; margin-bottom: 1rem; max-height: 420px; overflow-y: auto; }
  .cmt { border: 1px solid var(--line); border-radius: var(--radius); padding: .6rem .8rem; background: var(--surface-2); }
  .cmt-head { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; margin-bottom: .25rem; }
  .cmt-who { font-weight: 600; font-size: .82rem; }
  .cmt-ts { font-size: .68rem; color: var(--muted); }
  .cmt-body { font-size: .86rem; white-space: pre-wrap; overflow-wrap: anywhere; }
  .cmt-form { display: flex; gap: .6rem; align-items: flex-start; }
  .cmt-form textarea { flex: 1; resize: vertical; min-height: 2.4rem; font-family: inherit; }
  .cmt-form .btn { flex: none; }

  /* ---- chat / messages ---- */
  .chat-wrap { display: grid; grid-template-columns: 280px 1fr; gap: 1rem; align-items: stretch; min-height: 460px; }
  @media (max-width: 820px) { .chat-wrap { grid-template-columns: 1fr; } }
  .chat-list {
    background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
    box-shadow: var(--shadow-sm); overflow-y: auto; max-height: 620px; padding: .35rem;
  }
  .chat-person {
    display: flex; align-items: center; gap: .6rem; width: 100%; text-align: left;
    padding: .55rem .6rem; border: 0; background: transparent; color: var(--ink);
    font: inherit; cursor: pointer; border-radius: 6px;
  }
  .chat-person:hover { background: var(--surface-2); }
  .chat-person.active { background: var(--accent-soft); }
  .chat-person .cp-body { min-width: 0; flex: 1; }
  .chat-person .cp-top { display: flex; justify-content: space-between; gap: .5rem; align-items: baseline; }
  .chat-person .cp-name { font-weight: 600; font-size: .84rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .chat-person .cp-time { font-size: .6rem; color: var(--muted); flex: none; }
  .chat-person .cp-prev { display: block; font-size: .74rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

  .chat-thread {
    display: flex; flex-direction: column; background: var(--surface);
    border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-sm);
    max-height: 620px; overflow: hidden;
  }
  .chat-th-head { display: flex; align-items: center; gap: .6rem; padding: .8rem 1rem; border-bottom: 1px solid var(--line); }
  .chat-msgs { flex: 1; overflow-y: auto; padding: 1rem; display: flex; flex-direction: column; gap: .5rem; }
  .bubble-row { display: flex; }
  .bubble-row.me { justify-content: flex-end; }
  .bubble {
    max-width: min(78%, 460px); padding: .5rem .7rem; border-radius: 12px;
    font-size: .86rem; line-height: 1.4; white-space: pre-wrap; overflow-wrap: anywhere;
    background: var(--surface-2); border: 1px solid var(--line);
  }
  .bubble-row.me .bubble { background: var(--accent); border-color: var(--accent); color: #fff; }
  :root[data-theme="dark"] .bubble-row.me .bubble, :root:not([data-theme="light"]) .bubble-row.me .bubble { color: #0c130f; }
  .bubble .b-time { display: block; font-size: .58rem; opacity: .65; margin-top: .2rem; }
  .bubble .b-file { display: inline-block; margin-top: .15rem; font-size: .8rem; text-decoration: underline; color: inherit; word-break: break-all; }
  .chat-compose { display: flex; gap: .6rem; padding: .7rem; border-top: 1px solid var(--line); align-items: flex-end; }
  .chat-compose textarea { flex: 1; resize: none; min-height: 2.3rem; max-height: 120px; font-family: inherit; }
  .chat-compose .btn { flex: none; }

  tr.subtask-row td { background: color-mix(in srgb, var(--surface-2) 70%, transparent); }
  tr.subtask-row td:first-child { padding-left: 1.4rem; }
  tr.subtask-row input.wide { max-width: 240px; font-size: .78rem; }
  .sub-caret { color: var(--muted); font-size: .8rem; margin-right: .1rem; }
  .modhead { display: flex; flex-wrap: wrap; align-items: flex-end; gap: .7rem 1.1rem; margin-bottom: 1.9rem; padding-bottom: 1.15rem; border-bottom: 2px solid var(--ink); }
  .modhead h2 { font-size: 1.7rem; }
  .modhead p { margin: .3rem 0 0; color: var(--muted); font-size: .86rem; max-width: 62ch; line-height: 1.5; }
  .modhead .spacer { flex: 1; }
  .clock-head { display: flex; align-items: center; flex-wrap: wrap; gap: .5rem; }
  .clock-head .ch-time { font-family: "IBM Plex Mono", monospace; font-weight: 600; font-size: 1.25rem; font-variant-numeric: tabular-nums; }
  .clock-head .ch-lbl { font-family: "IBM Plex Mono", monospace; font-size: .58rem; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); }
  .clock-head .ch-btns { display: flex; flex-wrap: wrap; gap: .4rem; margin-left: .4rem; }
  .clock-head .ch-btns .btn { padding: .5rem .95rem; font-size: .85rem; }
  .clock-head .ch-btns .btn--sm { padding: .35rem .6rem; font-size: .74rem; }
  .readonly-note {
    font-family: "IBM Plex Mono", monospace; font-size: .64rem; letter-spacing: .08em; text-transform: uppercase;
    color: var(--warn); background: var(--warn-soft); padding: .3rem .55rem; border-radius: 5px;
  }

  /* ---------------- KPI cards ---------------- */
  .kpigrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 1rem; margin-bottom: 2rem; }
  .kpi { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem 1.15rem; box-shadow: var(--shadow-sm); position: relative; overflow: hidden; }
  .kpi::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--line-strong); }
  .kpi.good::before { background: var(--good); }
  .kpi.warn::before { background: var(--warn); }
  .kpi.bad::before  { background: var(--bad); }
  .kpi.accent::before { background: var(--accent); }
  .kpi .k-label { font-family: "IBM Plex Mono", monospace; font-size: .6rem; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
  .kpi .k-value { font-family: "Fraunces", serif; font-weight: 600; font-size: 1.6rem; line-height: 1.1; margin-top: .25rem; font-variant-numeric: tabular-nums; }
  .kpi .k-value.neg { color: var(--bad); }
  .kpi .k-sub { font-size: .72rem; color: var(--muted); margin-top: .2rem; }

  /* ---------------- cards / sections ---------------- */
  .card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-sm); margin-bottom: 1.8rem; }
  .card > .card-h { padding: 1rem 1.25rem; border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: .7rem; flex-wrap: wrap; }
  .card > .card-h h3 { font-size: 1.05rem; }
  .card > .card-h .sub { color: var(--muted); font-size: .78rem; }
  .card > .card-b { padding: 1.25rem; }
  .card > .card-b > *:first-child { margin-top: 0; }
  .card > .card-b > *:last-child { margin-bottom: 0; }
  .card > .card-b.flush { padding: 0; }

  /* ---------------- tables ---------------- */
  .tablewrap { overflow-x: auto; }
  table.grid { width: 100%; border-collapse: collapse; font-size: .8rem; }
  table.grid th, table.grid td { padding: .62rem .85rem; text-align: left; border-bottom: 1px solid var(--line); white-space: nowrap; }
  table.grid th:first-child, table.grid td:first-child { padding-left: 1.1rem; }
  table.grid th:last-child, table.grid td:last-child { padding-right: 1.1rem; }
  table.grid thead th {
    position: sticky; top: 0; z-index: 2; background: var(--surface-3);
    font-family: "IBM Plex Mono", monospace; font-size: .58rem; letter-spacing: .07em; text-transform: uppercase; color: var(--muted); font-weight: 600;
  }
  table.grid tbody tr:hover { background: var(--surface-2); }
  table.grid td.num, table.grid th.num { text-align: right; font-family: "IBM Plex Mono", monospace; font-variant-numeric: tabular-nums; }
  table.grid td.calc { color: var(--ink-soft); background: color-mix(in srgb, var(--surface-2) 60%, transparent); }
  table.grid tfoot td { padding: .7rem .85rem; border-top: 2px solid var(--line-strong); font-weight: 700; font-family: "IBM Plex Mono", monospace; font-variant-numeric: tabular-nums; }
  .t-neg { color: var(--bad); }
  .t-pos { color: var(--good); }

  /* Heaviest tables (Projects, Tasks, Leads — many columns, used daily on a
     phone) stack into one label/value card per record below 640px instead
     of forcing a sideways scroll. Add class="grid grid--stack" to the
     <table> and data-label="Column name" on every <td> to opt a table in;
     the rest of the app's tables already reflow fine via .tablewrap. */
  @media (max-width: 640px) {
    table.grid.grid--stack thead { display: none; }
    table.grid.grid--stack, table.grid.grid--stack tbody, table.grid.grid--stack tr, table.grid.grid--stack td { display: block; width: 100%; }
    table.grid.grid--stack tr {
      border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface);
      margin-bottom: .6rem; padding: .3rem .9rem; box-shadow: var(--shadow-sm);
    }
    table.grid.grid--stack tr:hover { background: var(--surface); }
    table.grid.grid--stack td {
      display: flex; justify-content: space-between; align-items: center; gap: .75rem;
      padding: .45rem 0; border-bottom: 1px solid var(--line); text-align: right; white-space: normal;
    }
    table.grid.grid--stack td:last-child { border-bottom: none; }
    table.grid.grid--stack td[data-label]::before {
      content: attr(data-label); font-family: "IBM Plex Mono", monospace; font-size: .62rem; letter-spacing: .05em;
      text-transform: uppercase; color: var(--muted); text-align: left; flex: 0 0 auto; font-weight: 600;
    }
    /* A td with no data-label is a checkbox or the row's action buttons
       (shared helpers used by many tables, not worth threading a label
       through) — keep it visible and usable, just without a label slot. */
    table.grid.grid--stack td:not([data-label]) { justify-content: flex-end; }
    table.grid.grid--stack td.rowsel { justify-content: flex-start; }
    table.grid.grid--stack td.num { font-family: "IBM Plex Mono", monospace; }
  }

  /* inputs */
  input, select, textarea {
    font: inherit; font-size: .8rem; color: var(--ink);
    background: var(--surface-2); border: 1px solid var(--line); border-radius: 6px;
    padding: .5rem .65rem; width: 100%;
  }
  input.mono, td input, td select { font-family: "IBM Plex Mono", monospace; }
  td input, td select, td textarea { min-width: 84px; padding: .3rem .4rem; }
  td input.wide, td select.wide { min-width: 150px; }
  input[type="number"] { text-align: right; }
  .cell-edit { background: var(--input-tint); border-color: var(--input-edge); }
  input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
  input:disabled, select:disabled { opacity: .65; cursor: not-allowed; }
  :focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
  label.fld { display: block; }
  label.fld > span { display: block; font-family: "IBM Plex Mono", monospace; font-size: .6rem; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); margin-bottom: .4rem; }

  /* pills */
  .pill { display: inline-block; font-family: "IBM Plex Mono", monospace; font-size: .62rem; letter-spacing: .05em; text-transform: uppercase; padding: .16rem .45rem; border-radius: 999px; border: 1px solid transparent; }
  .pill.good { background: var(--good-soft); color: var(--good); }
  .pill.warn { background: var(--warn-soft); color: var(--warn); }
  .pill.bad  { background: var(--bad-soft); color: var(--bad); }
  .pill.mute { background: var(--surface-3); color: var(--muted); }
  .pill.info { background: var(--info-soft); color: var(--info); }
  /* strong status badge (deadline-aware) for table status columns */
  .pill--st { font-size: .64rem; padding: .22rem .55rem; font-weight: 700; border-color: currentColor;
    display: inline-flex; align-items: center; gap: .35rem; white-space: nowrap; }
  .pill--st i { width: .5rem; height: .5rem; border-radius: 50%; background: currentColor; flex: none; }
  .pill--st.good { background: var(--good-soft); color: var(--good); }
  .pill--st.warn { background: var(--warn-soft); color: var(--warn); }
  .pill--st.bad  { background: var(--bad-soft);  color: var(--bad); }
  .pill--st.info { background: var(--info-soft); color: var(--info); }
  .pill--st.mute { background: var(--surface-3); color: var(--muted); border-color: var(--line); }

  /* buttons */
  .btn {
    font: inherit; font-size: .8rem; font-weight: 600; cursor: pointer;
    padding: .52rem .95rem; border-radius: 7px; border: 1px solid var(--line-strong);
    background: var(--surface); color: var(--ink); display: inline-flex; align-items: center; gap: .4rem;
  }
  .btn:hover { border-color: var(--accent); color: var(--accent-ink); }
  .btn--primary { background: var(--accent); border-color: var(--accent); color: #fff; }
  .btn--primary:hover { background: var(--accent-ink); color: #fff; }
  .btn--ghost { border-color: transparent; background: transparent; color: var(--muted); }
  .btn--sm { padding: .28rem .5rem; font-size: .72rem; }
  .btn--danger:hover { border-color: var(--bad); color: var(--bad); }
  .icon-btn { border: 1px solid var(--line); background: var(--surface-2); color: var(--muted); border-radius: 5px; width: 26px; height: 26px; padding: 0; cursor: pointer; font-size: .9rem; line-height: 1; }
  .icon-btn:hover { border-color: var(--bad); color: var(--bad); }
  .timer-badge { display: inline-block; background: var(--good-bg, #e6f7ee); color: var(--good, #1a9c5c); border-radius: 5px; padding: .1rem .4rem; font-size: .74rem; font-weight: 600; }

  /* 3-way access control */
  .seg3 { display: inline-flex; border: 1px solid var(--line); border-radius: 5px; overflow: hidden; }
  .seg3 button { border: 0; background: var(--surface-2); color: var(--muted); font: inherit; font-size: .68rem; padding: .28rem .5rem; cursor: pointer; }
  .seg3 button[aria-pressed="true"] { background: var(--accent); color: #fff; font-weight: 600; }
  .seg3 button[data-v="none"][aria-pressed="true"] { background: var(--surface-3); color: var(--ink-soft); }

  /* clock panel */
  .clockpanel { display: grid; grid-template-columns: 1fr; gap: 1rem; }
  @media (min-width: 620px) { .clockpanel { grid-template-columns: 1.1fr 1fr; } }
  .clock-status { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.3rem; box-shadow: var(--shadow-sm); }
  .clock-state { font-family: "IBM Plex Mono", monospace; font-size: .68rem; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); }
  .clock-timer { font-family: "Fraunces", serif; font-weight: 600; font-size: 3rem; line-height: 1; margin: .35rem 0 .1rem; font-variant-numeric: tabular-nums; }
  .clock-since { font-size: .78rem; color: var(--muted); }
  .dot-live { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--good); margin-right: .4rem; }
  .dot-break { background: var(--warn); }
  @media (prefers-reduced-motion: no-preference) {
    .dot-live { animation: pulse 1.6s ease-in-out infinite; }
    @keyframes pulse { 0%,100%{opacity:1} 50%{opacity:.35} }
    .flash { animation: cell-flash .5s ease; }
    @keyframes cell-flash { from { background: var(--accent-soft); } to { background: transparent; } }
    .main-anim { animation: main-fade-in .22s ease-out; }
    @keyframes main-fade-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }
  }

  .grid-2 { display: grid; gap: 1.4rem; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
  .formrow { display: grid; gap: .95rem 1.1rem; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); align-items: end; }
  .empty { padding: 2.75rem 1rem; text-align: center; color: var(--muted); font-size: .85rem; }
  /* Key/value detail block. Capped width + left-aligned values so the value
     sits right next to its label instead of being flung to the far edge on
     wide cards. Long values wrap under, not across a huge gap. */
  .kv { display: grid; grid-template-columns: minmax(6rem, 12rem) minmax(0, 1fr);
        gap: .6rem 1.4rem; font-size: .86rem; max-width: 640px; align-items: baseline; }
  .kv dt { color: var(--muted); font-family: "IBM Plex Mono", monospace; font-size: .68rem;
           letter-spacing: .05em; text-transform: uppercase; }
  .kv dd { margin: 0; font-family: "IBM Plex Mono", monospace; font-variant-numeric: tabular-nums;
           text-align: left; overflow-wrap: anywhere; }
  .kv dd.big { font-family: "Fraunces", serif; font-size: 1.15rem; font-weight: 600; }
  /* opt-in: right-align a KV block's values (used where they're all numbers) */
  .kv.kv-nums dd { text-align: right; }
  @media (max-width: 560px) {
    .kv { grid-template-columns: 1fr; gap: .15rem .4rem; }
    .kv dt { margin-top: .5rem; }
  }

  /* CRUD — bulk bar + forms */
  .bulkbar {
    display: flex; align-items: center; gap: .5rem; flex-wrap: wrap;
    margin: 0 0 .8rem; padding: .55rem .8rem; font-size: .8rem;
    border: 1px solid var(--line-strong); border-radius: 8px;
    background: color-mix(in srgb, var(--accent) 8%, var(--surface));
  }
  .crud-form { grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); }
  .crud-form textarea { width: 100%; min-height: 3.2em; font: inherit; padding: .45rem .55rem; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); color: inherit; }
  table.grid td.rowsel, table.grid th.rowsel { width: 34px; text-align: center; padding-right: 0; }

  /* Roles & Permissions */
  .perm-cols { columns: 320px 2; column-gap: 1.4rem; padding: 1rem; }
  .perm-grp { break-inside: avoid; margin-bottom: 1rem; }
  .perm-grp h4 {
    margin: 0 0 .4rem; font-size: .7rem; text-transform: uppercase; letter-spacing: .06em;
    color: var(--muted); border-bottom: 1px solid var(--line); padding-bottom: .25rem;
  }
  .perm-row { display: grid; grid-template-columns: auto 1fr; gap: .1rem .5rem; align-items: baseline; padding: .28rem 0; font-size: .82rem; }
  .perm-row input { grid-row: span 2; align-self: center; width: auto; }
  .perm-row code { grid-column: 2; font-size: .68rem; color: var(--muted); }
  .role-members { padding: 1rem; border-top: 1px solid var(--line); }
  .chips { display: flex; flex-wrap: wrap; gap: .4rem; margin: .5rem 0 .8rem; }
  .chip {
    display: inline-flex; align-items: center; gap: .35rem; font-size: .78rem;
    background: var(--surface-2); border: 1px solid var(--line); border-radius: 999px; padding: .2rem .6rem;
  }
  .chip button { border: 0; background: none; color: var(--muted); cursor: pointer; font-size: 1rem; line-height: 1; padding: 0; }
  .chip button:hover { color: var(--bad); }

  /* Deals pipeline board */
  .pipeline { display: flex; gap: .8rem; overflow-x: auto; padding: .25rem 0 1rem; }
  .pipe-col { flex: 0 0 250px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px; padding: .6rem; }
  .pipe-h { font-size: .72rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); display: flex; justify-content: space-between; margin-bottom: .5rem; }
  .pipe-h span { color: var(--ink-soft); font-weight: 600; }
  .deal-card { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: .55rem .6rem; margin-bottom: .5rem; cursor: pointer; font-size: .8rem; }
  .deal-card:hover { border-color: var(--accent); }
  .deal-card.dc-due { border-color: var(--bad); box-shadow: inset 3px 0 0 var(--bad); }
  .deal-card b { display: block; margin-bottom: .2rem; }
  .dc-meta { color: var(--muted); font-size: .72rem; }
  .dc-foot { display: flex; justify-content: space-between; margin-top: .35rem; font-variant-numeric: tabular-nums; color: var(--ink-soft); }
  .dc-move { display: flex; gap: .2rem; margin-top: .45rem; flex-wrap: wrap; }
  .dc-move button { width: 22px; height: 22px; padding: 0; border: 1px solid var(--line); background: var(--surface-2); border-radius: 5px; font-size: .68rem; cursor: pointer; color: var(--muted); }
  .dc-move button:hover { border-color: var(--accent); color: var(--accent); }

  /* Quotation / invoice editor */
  .doc-foot { display: flex; justify-content: space-between; gap: 1.5rem; flex-wrap: wrap; padding: 1rem; border-top: 1px solid var(--line); }
  .doc-tot { min-width: 240px; margin-left: auto; font-size: .85rem; }
  .doc-tot > div { display: flex; justify-content: space-between; padding: .25rem 0; font-variant-numeric: tabular-nums; }
  .doc-tot .gr { border-top: 2px solid var(--line-strong); font-weight: 700; font-size: 1rem; margin-top: .3rem; padding-top: .5rem; }

  /* Attendance */
  .attbar { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; margin: 0 0 1rem; padding: .6rem .8rem; border: 1px solid var(--line); border-radius: 8px; background: var(--surface-2); }
  .attbar select { font: inherit; }
  tr.att-edit { background: color-mix(in srgb, var(--accent) 8%, var(--surface)); }
  tr.att-edit input, tr.att-edit select { font: inherit; padding: .25rem .35rem; }
  .calgrid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; padding: 1rem; }
  .cal-h { font-size: .68rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); text-align: center; padding: .3rem 0; }
  .cal-c { min-height: 68px; border: 1px solid var(--line); border-radius: 6px; padding: .3rem; font-size: .7rem; display: flex; flex-direction: column; gap: 2px; background: var(--surface); }
  .cal-c.cal-e { border: 0; background: transparent; }
  .cal-d { font-weight: 700; font-size: .78rem; }
  .cal-s { color: var(--ink-soft); }
  .cal-late { color: var(--bad); }
  .cal-ot { color: var(--accent); }
  .cal-present { background: color-mix(in srgb, var(--good) 14%, var(--surface)); }
  .cal-absent { background: color-mix(in srgb, var(--bad) 12%, var(--surface)); }
  .cal-leave { background: color-mix(in srgb, var(--accent) 12%, var(--surface)); }
  .cal-half { background: color-mix(in srgb, var(--warn) 16%, var(--surface)); }
  .cal-weekoff, .cal-holiday { background: var(--surface-2); color: var(--muted); }

  /* Boards (monday-style) */
  .bgroup { margin-bottom: 1.4rem; }
  .bgroup-h { display: flex; align-items: center; gap: .5rem; font-size: .95rem; margin-bottom: .4rem; }
  .bgroup-h button[data-bgcollapse] { border: 0; background: none; cursor: pointer; font-size: 1rem; color: inherit; }
  .bgroup-h span { color: var(--muted); font-size: .78rem; font-weight: 400; }
  table.bgrid td, table.bgrid th { border-bottom: 1px solid var(--line); padding: .35rem .55rem; font-size: .82rem; }
  table.bgrid .bc-title { min-width: 260px; display: flex; align-items: center; gap: .4rem; }
  .bgrip { width: 4px; align-self: stretch; min-height: 20px; border-radius: 2px; flex: none; }
  td.bc { text-align: center; }
  td.bc-text, td.bc-longtext, td.bc-link { text-align: left; }
  .bstatus { display: inline-block; min-width: 90px; padding: .3rem .5rem; border-radius: 4px; color: #fff; font-size: .76rem; font-weight: 600; }
  .bstatus-empty { background: var(--surface-3); color: var(--muted); }
  .btimeline { background: var(--accent); color: #fff; padding: .2rem .5rem; border-radius: 999px; font-size: .72rem; }
  td.bc input, td.bc select { font: inherit; padding: .2rem .3rem; }
  tr.bsum td { border-top: 2px solid var(--line-strong); border-bottom: 0; padding-top: .4rem; }
  .bsum-bar { display: flex; height: 10px; border-radius: 3px; overflow: hidden; background: var(--surface-3); }
  .bsum-bar span { display: block; }
  .bsum-num { font-weight: 700; font-variant-numeric: tabular-nums; }
  .bcol-list { padding: .5rem 1rem 1rem; }
  .bcol-row { border: 1px solid var(--line); border-radius: 8px; padding: .7rem; margin-bottom: .7rem; }
  .bcol-main { display: flex; align-items: center; gap: .4rem; flex-wrap: wrap; }
  .bcol-perm { margin-top: .6rem; display: flex; flex-direction: column; gap: .4rem; font-size: .8rem; }
  .bcol-perm > label { display: flex; gap: .5rem; align-items: center; }
  .bcol-perm input[type=text], .bcol-perm > label > input { flex: 1; max-width: 260px; }
  .bcol-roles { display: flex; flex-wrap: wrap; gap: .35rem; align-items: center; }
  .bcol-roles > span { color: var(--muted); font-size: .74rem; }

  /* ---- AI assistant bubble ---- */
  #aiWrap { position: fixed; left: 18px; bottom: 18px; z-index: 950; }
  .ai-fab { width: 46px; height: 46px; border-radius: 50%; border: none; cursor: pointer;
    background: var(--accent, #6c5ce7); color: #fff; display: flex; align-items: center; justify-content: center;
    box-shadow: 0 6px 20px rgba(0,0,0,.28); transition: transform .12s ease; }
  .ai-fab:hover { transform: scale(1.06); }
  .ai-panel { width: 360px; max-width: calc(100vw - 32px); max-height: min(74vh, 620px);
    display: flex; flex-direction: column; background: var(--surface-1, #fff); color: var(--text, #1a1a1a);
    border: 1px solid var(--line, #e2e2e2); border-radius: 14px; overflow: hidden;
    box-shadow: 0 12px 40px rgba(0,0,0,.32); }
  .ai-head { display: flex; align-items: center; gap: .5rem; padding: .6rem .8rem; border-bottom: 1px solid var(--line); }
  .ai-left { font-size: .72rem; color: var(--muted); }
  .ai-x { border: none; background: none; font-size: 1.15rem; line-height: 1; cursor: pointer; color: var(--muted); }
  .ai-empty, .ai-hint { padding: 1rem; font-size: .85rem; color: var(--muted); }
  .ai-modes { display: flex; gap: .35rem; padding: .6rem .7rem 0; flex-wrap: wrap; }
  .ai-chip { border: 1px solid var(--line); background: var(--surface-2, #f4f4f6); color: var(--text);
    border-radius: 999px; padding: .25rem .7rem; font-size: .76rem; cursor: pointer; }
  .ai-chip.on { background: var(--accent, #6c5ce7); color: #fff; border-color: transparent; }
  .ai-thread { flex: 1; overflow-y: auto; padding: .7rem; display: flex; flex-direction: column; gap: .55rem; min-height: 90px; }
  .ai-msg { font-size: .85rem; line-height: 1.42; }
  .ai-msg.ai-user .ai-tx { background: var(--surface-2, #eef); border-radius: 10px 10px 2px 10px; padding: .45rem .6rem; align-self: flex-end; }
  .ai-msg.ai-user { align-items: flex-end; display: flex; flex-direction: column; }
  .ai-msg.ai-assistant .ai-tx { background: var(--surface-3, #f5f5f7); border-radius: 10px 10px 10px 2px; padding: .5rem .65rem; white-space: pre-wrap; }
  .ai-typing { color: var(--muted); font-style: italic; }
  .ai-shot { max-width: 140px; border-radius: 8px; margin-bottom: .3rem; border: 1px solid var(--line); }
  .ai-refs { margin-top: .35rem; display: flex; flex-wrap: wrap; gap: .3rem; }
  .ai-ref { border: 1px solid var(--line); background: var(--surface-1); color: var(--accent, #6c5ce7);
    border-radius: 999px; font-size: .72rem; padding: .15rem .55rem; cursor: pointer; }
  .ai-acts { margin-top: .3rem; display: flex; gap: .4rem; }
  .ai-acts button { border: 1px solid var(--line); background: var(--surface-1); color: var(--text);
    border-radius: 6px; font-size: .72rem; padding: .12rem .5rem; cursor: pointer; }
  .ai-compose { border-top: 1px solid var(--line); padding: .6rem .7rem; display: flex; flex-direction: column; gap: .45rem; }
  .ai-compose textarea { width: 100%; resize: vertical; font: inherit; font-size: .85rem; border: 1px solid var(--line);
    border-radius: 8px; padding: .45rem .55rem; background: var(--surface-1); color: var(--text); }
  .ai-cbar { display: flex; align-items: center; gap: .4rem; flex-wrap: wrap; }
  .ai-attach { cursor: pointer; }
  .ai-imgchip { font-size: .74rem; background: var(--surface-2); border-radius: 6px; padding: .15rem .45rem; }
  .ai-imgchip button { border: none; background: none; cursor: pointer; font-size: .9rem; line-height: 1; }
  @media (prefers-color-scheme: dark) {
    .ai-panel { background: var(--surface-1, #1e1e22); color: var(--text, #eee); }
  }

  /* ---- team chat bubble (bottom-right) ---- */
  #chatWrap { position: fixed; right: 18px; bottom: 18px; z-index: 950; }
  .chat-fab {
    position: relative; width: 46px; height: 46px; border-radius: 50%; border: none; cursor: pointer;
    background: var(--accent); color: #fff; display: flex; align-items: center; justify-content: center;
    box-shadow: 0 6px 20px rgba(0,0,0,.28); transition: transform .12s ease;
  }
  .chat-fab:hover { transform: scale(1.06); }
  .chat-fab [data-ic-badge] { position: absolute; top: -3px; right: -3px; }
  .chat-fab .ic-badge {
    background: var(--bad); color: #fff; font-family: "IBM Plex Mono", monospace; font-size: .58rem; font-weight: 600;
    min-width: 16px; height: 16px; border-radius: 8px; display: inline-flex; align-items: center; justify-content: center; padding: 0 3px;
  }
  .chat-pop {
    width: 340px; max-width: calc(100vw - 32px); height: min(70vh, 560px); display: flex; flex-direction: column;
    background: var(--surface); color: var(--ink); border: 1px solid var(--line); border-radius: 14px;
    overflow: hidden; box-shadow: 0 14px 44px rgba(0,0,0,.32);
  }
  .cq-head { display: flex; align-items: center; gap: .5rem; padding: .7rem .85rem; border-bottom: 1px solid var(--line); font-size: .92rem; }
  .cq-back, .cq-x { border: none; background: none; cursor: pointer; color: var(--muted); font-size: 1.1rem; line-height: 1; padding: 0 .2rem; }
  .cq-list { flex: 1; overflow-y: auto; padding: .4rem; display: flex; flex-direction: column; gap: .15rem; }
  .cq-person {
    display: flex; align-items: center; gap: .6rem; width: 100%; text-align: left; border: none; background: none;
    cursor: pointer; padding: .55rem .6rem; border-radius: 9px; color: var(--ink); font: inherit;
  }
  .cq-person:hover { background: var(--surface-2); }
  .cq-person .avatar { width: 30px; height: 30px; font-size: .72rem; flex: none; }
  .cq-pn { min-width: 0; display: flex; flex-direction: column; flex: 1; }
  .cq-pn b { font-size: .85rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .cq-pn span { font-size: .74rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .cq-thread { flex: 1; overflow-y: auto; padding: .8rem; display: flex; flex-direction: column; gap: .4rem; }
  .cq-row { display: flex; }
  .cq-row.me { justify-content: flex-end; }
  .cq-b {
    max-width: 78%; font-size: .84rem; line-height: 1.4; padding: .45rem .65rem; border-radius: 12px;
    background: var(--surface-2); color: var(--ink); word-wrap: break-word;
  }
  .cq-row.me .cq-b { background: var(--accent); color: #fff; }
  .cq-file { display: block; margin-top: .15rem; font-size: .78rem; text-decoration: underline; color: inherit; word-break: break-all; }
  .cq-empty { padding: 1.4rem 1rem; text-align: center; color: var(--muted); font-size: .83rem; }
  .cq-compose { display: flex; gap: .5rem; padding: .6rem .7rem; border-top: 1px solid var(--line); align-items: flex-end; }
  .cq-compose textarea { flex: 1; resize: none; min-height: 2.2rem; max-height: 110px; font: inherit; font-size: .85rem; }
  .cq-compose .btn { flex: none; }

  /* ---- top-bar attendance control ---- */
  #clockSlot { position: relative; }
  #clockSlot:empty { display: none; }
  .clock-btn {
    display: inline-flex; align-items: center; gap: .4rem; height: 34px; padding: 0 .8rem; border-radius: 9px;
    border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink); cursor: pointer;
    font: inherit; font-size: .78rem; font-weight: 600; box-shadow: 0 3px 12px rgba(0,0,0,.12);
  }
  .clock-btn:hover { border-color: var(--accent); color: var(--accent-ink); }
  .clock-btn.is-in { background: var(--good-soft); border-color: color-mix(in srgb, var(--good) 40%, transparent); color: var(--good); }
  .clock-btn.is-in.on-brk { background: var(--warn-soft); border-color: color-mix(in srgb, var(--warn) 40%, transparent); color: var(--warn); }
  .clock-btn .cb-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); flex: none; }
  .clock-btn.is-in .cb-dot { background: var(--good); }
  .clock-btn .cb-dot.brk { background: var(--warn); }
  .clock-btn .cb-time { font-variant-numeric: tabular-nums; }
  @media (max-width: 640px) { .clock-btn .cb-lbl { display: none; } }
  @media (prefers-reduced-motion: no-preference) { .clock-btn.is-in .cb-dot { animation: pulse 1.6s ease-in-out infinite; } }

  .clock-pop {
    position: absolute; top: 42px; right: 0; min-width: 232px; background: var(--surface);
    border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 14px 40px rgba(0,0,0,.22);
    padding: .8rem; z-index: 860;
  }
  .clock-pop .cp-state {
    display: flex; align-items: center; gap: .45rem; font-family: "IBM Plex Mono", monospace;
    font-size: .66rem; letter-spacing: .07em; text-transform: uppercase; color: var(--muted); margin-bottom: .6rem;
  }
  .clock-pop .cp-state .cb-dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }
  .clock-pop .cp-state .cb-dot.in { background: var(--good); }
  .clock-pop .cp-state .cb-dot.brk { background: var(--warn); }
  .clock-pop .cp-state .cb-dot.off { background: var(--muted); }
  .clock-pop .cp-kv { display: grid; grid-template-columns: 1fr auto; gap: .3rem .9rem; margin: 0 0 .8rem; }
  .clock-pop .cp-kv dt { font-size: .78rem; color: var(--muted); }
  .clock-pop .cp-kv dd { margin: 0; font-size: .82rem; font-weight: 600; font-variant-numeric: tabular-nums; text-align: right; }
  .clock-pop .cp-actions { display: flex; flex-wrap: wrap; gap: .4rem; }
  .clock-pop .cp-actions .btn { flex: 1 1 auto; justify-content: center; }

  /* ---- appearance (skin/theme) menu, sidebar ---- */
  .theme-pop {
    position: fixed; min-width: 210px; z-index: 860;
    background: var(--surface); border: 1px solid var(--line); border-radius: 12px;
    box-shadow: 0 14px 40px rgba(0,0,0,.22); padding: .8rem;
  }
  .theme-pop .tp-row { margin-bottom: .8rem; }
  .theme-pop .tp-row:last-child { margin-bottom: 0; }
  .theme-pop .tp-label {
    display: block; margin-bottom: .35rem; font-family: "IBM Plex Mono", monospace;
    font-size: .6rem; letter-spacing: .08em; text-transform: uppercase; color: var(--muted);
  }
  .theme-pop .seg3 { width: 100%; }
  .theme-pop .seg3 button { flex: 1; }

  /* ---- inline status + assignee editing (Tasks list) ---- */
  .status-inline { font-family: "IBM Plex Mono", monospace; font-size: .66rem; font-weight: 600; padding: .22rem .5rem; border-radius: 4px; border: 1px solid transparent; cursor: pointer; }
  .status-inline.good { background: var(--good-soft); color: var(--good); border-color: currentColor; }
  .status-inline.warn { background: var(--warn-soft); color: var(--warn); border-color: currentColor; }
  .status-inline.bad  { background: var(--bad-soft);  color: var(--bad); border-color: currentColor; }
  .status-inline.info { background: var(--info-soft); color: var(--info); border-color: currentColor; }
  .status-inline.mute { background: var(--surface-3); color: var(--muted); }
  .assignee-inline { font-size: .78rem; padding: .22rem .4rem; }

