/* ──────────────────────────────────────────────────────────────────────
   case-workspace.css — Clients & Cases redesign (Phase 1: case workspace).
   Recreated from the Claude Design bundle (cc-*.jsx). The design's cooler
   green-grey palette + court/meet/task accent colours are scoped to the
   .ccx wrapper on #matter-detail-view so the rest of the app (warm grey +
   gold) is untouched. All component classes are cc-* prefixed to avoid
   colliding with dx-* (js/diary-cal.js) or the global design system.
   ────────────────────────────────────────────────────────────────────── */

.ccx {
  --paper:      #eef1f0;
  --paper-2:    #ffffff;
  --paper-3:    #e6ebe9;
  --line:       #c2ccc9;
  --card-line:  #d3dcda;
  --line-soft:  #e6ecea;
  --ink:        #14201e;
  --ink-2:      #1c2b28;
  --ink-3:      #41504d;
  --ink-4:      #5b6967;
  --ink-5:      #8a9794;
  --gold-line:  #c9a85e;
  --cc-serif:   'EB Garamond', Georgia, serif;
  --cc-sans:    'DM Sans', system-ui, sans-serif;
  --c-court:    #b23b4e;
  --c-meet:     #2f5aa8;
  --c-task:     #15803d;
  --c-other:    #b45309;

  font-family: var(--cc-sans);
  color: var(--ink-2);
  background: var(--paper);
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

/* When the new workspace is active, hide the legacy matter markup. */
#matter-detail-view.cc-active > *:not(.ccx) { display: none !important; }
#matter-detail-view:not(.cc-active) > .ccx { display: none; }

.ccx *, .ccx *::before, .ccx *::after { box-sizing: border-box; }
.ccx button { font: inherit; color: inherit; cursor: pointer; }
.ccx a { color: var(--c-meet); text-decoration: none; }
.ccx a:hover { color: var(--ink); text-decoration: underline; }
.ccx mark { background: #f2e3bd; }

/* ── Scroll body + max width ───────────────────────────────────────── */
.cc-scroll { flex: 1; min-height: 0; overflow-y: auto; }
.cc-wrap { padding: 1.1rem 1.75rem 2.4rem; max-width: none; margin: 0 auto; }
.cc-grid { display: grid; grid-template-columns: minmax(0,1fr) 380px; gap: 1.4rem; align-items: start; }
.cc-col { display: flex; flex-direction: column; gap: 1.3rem; min-width: 0; }
.cc-rail { position: sticky; top: 0; display: flex; flex-direction: column; gap: 1rem; }
@media (max-width: 1080px) { .cc-grid { grid-template-columns: 1fr; } .cc-rail { position: static; } }

/* ── Header ────────────────────────────────────────────────────────── */
.cc-head { background: var(--paper-2); border-bottom: 1px solid var(--card-line); flex-shrink: 0; }
.cc-head-inner { padding: .8rem 1.75rem .1rem; max-width: 1600px; margin: 0 auto; }
.cc-crumbs { display: flex; align-items: center; gap: .4rem; font-size: 12.5px; color: var(--ink-5); margin-bottom: .4rem; flex-wrap: wrap; }
.cc-title { font-family: var(--cc-serif); font-size: 27px; font-weight: 600; color: var(--ink); margin: 0; line-height: 1.15; }
.cc-head-sub { font-size: 13px; color: var(--ink-4); margin: .3rem 0 0; }
.cc-tabs { display: flex; gap: 1.1rem; margin-top: .6rem; overflow-x: auto; scrollbar-width: none; }
.cc-tabs::-webkit-scrollbar { height: 0; }
.cc-tab { display: inline-flex; align-items: center; gap: .35rem; border: 0; background: transparent; padding: .45rem .1rem; font-size: 13.5px; font-weight: 600; color: var(--ink-4); border-bottom: 2.5px solid transparent; white-space: nowrap; }
.cc-tab:hover { color: var(--ink-2); }
.cc-tab[data-active="1"] { color: var(--ink); font-weight: 700; border-bottom-color: var(--ink); }
.cc-tab .cc-vtag { font-size: 10px; font-weight: 700; color: var(--ink-5); }

/* ── Panels / cards ───────────────────────────────────────────────── */
.cc-panel { background: var(--paper-2); border: 1px solid var(--card-line); border-radius: 11px; }
.cc-ai { background: var(--paper-2); border: 1px solid var(--card-line); border-radius: 11px; box-shadow: inset 2.5px 0 0 var(--gold-line); padding: .8rem .9rem .85rem; }
.cc-ai-label { display: inline-flex; align-items: center; gap: .35rem; font-size: 10.5px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; color: #8a6628; }
.cc-doc { background: var(--paper-2); border: 1px solid var(--card-line); border-radius: 11px; padding: .9rem 1rem; font-size: 14px; color: var(--ink-3); line-height: 1.65; font-family: var(--cc-serif); }

/* ── Section label ─────────────────────────────────────────────────── */
.cc-seclabel { display: flex; align-items: baseline; gap: .6rem; margin-bottom: .5rem; }
.cc-seclabel > span:first-child { font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-5); }
.cc-seclabel .cc-rule { flex: 1; height: 1px; background: var(--card-line); }

/* ── Buttons ───────────────────────────────────────────────────────── */
.cc-btn { display: inline-flex; align-items: center; gap: .42rem; border: 1.3px solid var(--line); background: var(--paper-2); color: var(--ink-2); border-radius: 10px; padding: .5rem .8rem; font-weight: 600; font-size: 13.2px; white-space: nowrap; flex-shrink: 0; transition: background .14s, border-color .14s; }
.cc-btn:hover { background: var(--paper-3); border-color: var(--ink-3); }
.cc-btn.primary { background: var(--ink); color: #fff; border-color: var(--ink); }
.cc-btn.primary:hover { background: #25352f; border-color: #25352f; }
.cc-btn.sm { padding: .36rem .6rem; font-size: 12.5px; border-radius: 9px; }
.cc-btn:disabled { opacity: .45; cursor: default; }
.cc-icon { width: 36px; height: 36px; border-radius: 10px; border: 1.3px solid var(--line); background: var(--paper-2); color: var(--ink-3); display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; transition: background .14s, color .14s, border-color .14s; }
.cc-icon:hover { background: var(--paper-3); color: var(--ink); border-color: var(--ink-3); }
.cc-icon.sm { width: 30px; height: 30px; border-radius: 9px; }
.cc-linkbtn { border: 0; background: transparent; padding: 0; color: var(--ink-4); font-size: 12.8px; font-weight: 600; display: inline-flex; align-items: center; gap: .3rem; }
.cc-linkbtn:hover { color: var(--ink); text-decoration: underline; }

/* ── Chips ─────────────────────────────────────────────────────────── */
.cc-chip { display: inline-flex; align-items: center; gap: .32rem; padding: .16rem .5rem; border-radius: 999px; background: var(--paper-2); border: 1.2px solid var(--line); color: var(--ink-4); font-size: 11.5px; font-weight: 600; white-space: nowrap; line-height: 1.6; max-width: 100%; }
.cc-chip > span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cc-chip .cc-chip-dot { width: 6px; height: 6px; border-radius: 999px; background: currentColor; flex-shrink: 0; }
.cc-chip.tone-live { color: #b23b4e; border-color: #e2b6bd; }
.cc-chip.tone-ai   { color: #6a4f1a; border-color: #dcc79a; }
.cc-chip.tone-ok   { color: #15803d; border-color: #a8cdb4; }
.cc-chip.tone-warn { color: #b45309; border-color: #e0c19a; }
.cc-chip.tone-info { color: #2f5aa8; border-color: #adc0dd; }
button.cc-chip { transition: background .14s, border-color .14s, color .14s; }
button.cc-chip:hover { border-color: var(--ink-3); }
button.cc-chip[data-active="1"] { background: var(--ink); border-color: var(--ink); color: #fff; }

/* ── Segmented control ─────────────────────────────────────────────── */
.cc-seg { display: inline-flex; align-items: center; background: var(--paper-3); border: 1.3px solid var(--line); border-radius: 11px; padding: 3px; gap: 2px; flex-shrink: 0; }
.cc-seg-btn { border: 0; background: transparent; color: var(--ink-4); font-weight: 600; padding: .36rem .6rem; border-radius: 8px; white-space: nowrap; font-size: 13px; }
.cc-seg-btn:hover { color: var(--ink-2); }
.cc-seg-btn[data-active="1"] { background: var(--paper-2); color: var(--ink); box-shadow: 0 1px 2px rgba(0,0,0,.12); font-weight: 700; }

/* ── Rows ──────────────────────────────────────────────────────────── */
.cc-mrow { display: flex; align-items: center; gap: .75rem; width: 100%; background: transparent; border: 0; border-radius: 9px; padding: .6rem .7rem; text-align: left; }
.cc-mrow + .cc-mrow { border-top: 1px solid var(--line-soft); }
button.cc-mrow:hover { background: var(--paper-3); }
.cc-rowbtn { display: flex; align-items: center; gap: .6rem; width: 100%; background: var(--paper-2); border: 1px solid var(--card-line); border-radius: 10px; padding: .55rem .65rem; text-align: left; transition: background .14s; }
.cc-rowbtn:hover { background: var(--paper-3); }
.cc-hit { display: flex; align-items: flex-start; gap: .5rem; width: 100%; border: 0; background: transparent; border-radius: 8px; padding: .35rem .4rem; transition: background .14s; text-align: left; }
.cc-hit:hover { background: var(--paper-3); }

/* ── Stats ─────────────────────────────────────────────────────────── */
.cc-stat { padding: .6rem .75rem; min-width: 0; }
.cc-stat-l { font-size: 10.5px; font-weight: 800; letter-spacing: .07em; text-transform: uppercase; color: var(--ink-5); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cc-stat-v { font-family: var(--cc-serif); font-size: 23px; font-weight: 600; color: var(--ink); margin-top: .1rem; font-variant-numeric: tabular-nums; }

/* ── Mode tag / health / stage rail ────────────────────────────────── */
.cc-modetag { font-size: 10.5px; font-weight: 800; letter-spacing: .07em; text-transform: uppercase; border-radius: 5px; padding: .08rem .32rem; white-space: nowrap; flex-shrink: 0; }
.cc-modetag.lit { color: var(--c-court); border: 1.1px solid #e2b6bd; }
.cc-modetag.non { color: var(--c-meet); border: 1.1px solid #adc0dd; }
.cc-health { display: inline-flex; align-items: center; gap: .32rem; font-size: 11.5px; font-weight: 700; white-space: nowrap; }
.cc-health .cc-dot { width: 6px; height: 6px; border-radius: 999px; background: currentColor; }
.cc-health.ok { color: var(--c-task); }
.cc-health.attention { color: var(--c-other); }
.cc-health.urgent { color: var(--c-court); }
.cc-stagerail { display: flex; gap: 3px; align-items: center; min-width: 0; }
.cc-stagerail .seg { height: 5px; min-width: 14px; border-radius: 99px; background: var(--line-soft); }
.cc-stagerail .seg.done { background: var(--ink-3); }
.cc-stagerail .seg.at { flex: 1.6; }
.cc-stagerail .lbl { font-size: 11.5px; font-weight: 700; color: var(--ink-3); margin-left: .4rem; white-space: nowrap; }

/* ── Avatars ───────────────────────────────────────────────────────── */
.cc-av { border-radius: 999px; color: #fff; font-weight: 700; display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; text-transform: uppercase; }
.cc-avstack { display: inline-flex; align-items: center; }
.cc-avstack .cc-av { box-shadow: 0 0 0 2px var(--paper-2); }
.cc-avstack .cc-av + .cc-av { margin-left: -6px; }

/* ── Brief document ────────────────────────────────────────────────── */
.cc-brief-doc { padding: 1.6rem 2rem 1.9rem; max-width: 820px; }
.cc-brief-doc h2 { font-family: var(--cc-serif); font-size: 27px; font-weight: 600; color: var(--ink); margin: .3rem 0 .25rem; line-height: 1.15; }
.cc-brief-doc h3 { font-family: var(--cc-serif); font-size: 19px; font-weight: 600; color: var(--ink); margin: 0; }
.cc-brief-eyebrow { font-size: 10.5px; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; color: var(--ink-5); }
.cc-brief-header { border-bottom: 1px solid var(--card-line); padding-bottom: .9rem; margin-bottom: 1.2rem; }
.cc-inshort { background: var(--paper); border: 1px solid var(--card-line); border-radius: 10px; box-shadow: inset 2.5px 0 0 var(--gold-line); padding: .9rem 1rem; margin-bottom: 1.4rem; }
.cc-inshort p { font-family: var(--cc-serif); font-size: 16.5px; line-height: 1.68; color: var(--ink-2); margin: 0; }
.cc-brief-sec { margin-bottom: 1.3rem; }
.cc-brief-sec-head { display: flex; align-items: baseline; gap: .6rem; margin-bottom: .4rem; }
.cc-brief-sec-head .cc-rule { flex: 1; height: 1px; background: var(--line-soft); }
.cc-brief-sec p { font-family: var(--cc-serif); font-size: 15.5px; line-height: 1.72; color: var(--ink-3); margin: 0; }
.cc-brief-sec ul { font-family: var(--cc-serif); font-size: 15.5px; line-height: 1.7; color: var(--ink-3); margin: .2rem 0 0; padding-left: 1.2rem; }
.cc-brief-sec li { margin-bottom: .3rem; }
.cc-brief-foot { border-top: 1px solid var(--card-line); padding-top: .9rem; display: flex; align-items: center; gap: .7rem; flex-wrap: wrap; }

/* source ref chips inside brief prose */
.cc-src { border: 0; background: #f5efe0; border-radius: 4px; padding: 0 .25rem; font-family: var(--cc-sans); font-size: 11px; font-weight: 700; color: var(--ink-3); margin-left: .2rem; }
.cc-src:hover { background: var(--gold-line); color: #fff; }

/* ── Issues breakdown bar ─────────────────────────────────────────── */
.cc-issue { padding: .65rem .7rem; }
.cc-issue + .cc-issue { border-top: 1px solid var(--line-soft); }
.cc-issue-bar { flex: 1; height: 5px; border-radius: 99px; background: var(--line-soft); overflow: hidden; }
.cc-issue-bar > span { display: block; height: 100%; }
.cc-issue-bar.strong > span { background: var(--c-task); }
.cc-issue-bar.mixed  > span { background: var(--c-other); }
.cc-issue-bar.weak   > span { background: var(--c-court); }

/* ── Next-up cards ─────────────────────────────────────────────────── */
.cc-nextup { padding: .75rem .85rem; display: flex; gap: .7rem; align-items: flex-start; box-shadow: inset 2.5px 0 0 var(--line); }
.cc-nextup.can { box-shadow: inset 2.5px 0 0 var(--gold-line); }
.cc-nextup .n { font-family: var(--cc-serif); font-size: 15px; font-weight: 600; color: var(--ink-5); width: 16px; flex-shrink: 0; line-height: 1.5; }

/* ── Lex working panel (right rail) ────────────────────────────────── */
.cc-lex { display: flex; flex-direction: column; min-height: 0; max-height: calc(100vh - 250px); background: var(--paper-2); border: 1px solid var(--card-line); border-radius: 12px; overflow: hidden; box-shadow: inset 0 2.5px 0 var(--gold-line); }
.cc-lex-head { padding: .7rem .85rem .6rem; border-bottom: 1px solid var(--line-soft); display: flex; align-items: center; gap: .5rem; }
.cc-lex-body { padding: .85rem; display: flex; flex-direction: column; gap: .7rem; overflow-y: auto; min-height: 0; }
.cc-input { width: 100%; background: var(--paper-2); border: 1.3px solid var(--line); border-radius: 9px; padding: .55rem .7rem; font-size: 13.5px; color: var(--ink-2); font-family: var(--cc-sans); transition: border-color .14s, box-shadow .14s; }
.cc-input::placeholder { color: var(--ink-5); }
.cc-input:focus { outline: none; border-color: var(--ink-3); box-shadow: 0 0 0 3px rgba(47,90,168,.12); }
.cc-lex-msg { background: var(--paper-3); border-radius: 10px 10px 10px 3px; padding: .45rem .6rem; font-size: 13px; color: var(--ink-2); line-height: 1.5; }
.cc-lex-answer { font-size: 13.5px; line-height: 1.6; color: var(--ink-3); }
.cc-lex-answer p { margin: 0 0 .6rem; }

/* ── Search box ────────────────────────────────────────────────────── */
.cc-search { display: flex; align-items: center; gap: .5rem; flex: 1; background: var(--paper-2); border: 1.3px solid var(--line); border-radius: 10px; padding: .5rem .7rem; color: var(--ink-4); }
.cc-search input { flex: 1; border: 0; background: transparent; outline: none; font-size: 13.5px; min-width: 0; color: var(--ink-2); font-family: var(--cc-sans); }

/* ── Timeline (chronology) ─────────────────────────────────────────── */
.cc-tl-row { display: flex; gap: .9rem; }
.cc-tl-date { width: 88px; flex-shrink: 0; text-align: right; font-size: 12px; font-weight: 700; color: var(--ink-3); padding-top: 1px; }
.cc-tl-rail { position: relative; width: 12px; flex-shrink: 0; display: flex; justify-content: center; }
.cc-tl-rail .node { width: 9px; height: 9px; border-radius: 999px; background: var(--ink-3); margin-top: 4px; z-index: 1; }
.cc-tl-rail .line { position: absolute; top: 12px; bottom: -12px; width: 1.5px; background: var(--card-line); }

/* ── Empty / loading states ────────────────────────────────────────── */
.cc-empty { padding: 2.2rem; text-align: center; font-size: 13.5px; color: var(--ink-4); }
.cc-empty-cta { padding: 2rem 1.5rem; text-align: center; }

/* ── Popover ───────────────────────────────────────────────────────── */
.cc-pop { position: absolute; z-index: 120; background: #fff; border: 1px solid var(--card-line); border-radius: 12px; box-shadow: 0 14px 36px rgba(20,30,28,.18); padding: 4px; min-width: 220px; top: calc(100% + 6px); right: 0; }
.cc-pop-row { display: flex; align-items: center; gap: .55rem; width: 100%; border: 0; background: transparent; border-radius: 8px; padding: .5rem .6rem; font-size: 13.2px; font-weight: 600; color: var(--ink-2); text-align: left; white-space: nowrap; }
.cc-pop-row:hover { background: var(--paper-3); }
.cc-pop-row svg { color: var(--ink-4); flex-shrink: 0; }

/* ── Analysing overlay + progress pill ─────────────────────────────── */
.cc-analyse { position: fixed; inset: 0; z-index: 300; background: var(--paper); display: flex; flex-direction: column; animation: cc-fade .2s ease-out; }
.cc-analyse-head { position: sticky; top: 0; background: rgba(238,241,240,.86); backdrop-filter: blur(10px); border-bottom: 1px solid var(--card-line); }
.cc-analyse-head-inner { max-width: 1320px; margin: 0 auto; padding: 0 clamp(1.25rem,4vw,2.5rem); height: 64px; display: flex; align-items: center; gap: 1rem; }
.cc-analyse-bar { height: 3px; background: var(--card-line); position: relative; overflow: hidden; }
.cc-analyse-bar > span { position: absolute; left: 0; top: 0; bottom: 0; background: linear-gradient(90deg, #8a6628, var(--gold-line)); transition: width .35s ease; }
.cc-analyse-bar.done > span { background: var(--c-task); }
.cc-analyse-main { flex: 1; min-height: 0; overflow-y: auto; }
.cc-analyse-grid { max-width: 1320px; margin: 0 auto; padding: 1.6rem clamp(1.25rem,4vw,2.5rem) 5rem; display: grid; grid-template-columns: minmax(0,1.55fr) minmax(330px,1fr); gap: 1.6rem; align-items: start; }
@media (max-width: 900px) { .cc-analyse-grid { grid-template-columns: 1fr; } }
.cc-finding { background: #fff; border: 1px solid var(--card-line); border-radius: 11px; padding: .95rem 1.1rem; box-shadow: inset 3px 0 0 var(--gold-line); }
.cc-hero { background: var(--ink); color: var(--paper); border-radius: 14px; padding: 1.4rem 1.5rem; position: relative; overflow: hidden; }
.cc-hero .stat-v { font-family: var(--cc-serif); font-size: 34px; line-height: 1; color: var(--gold-line); font-variant-numeric: tabular-nums; }
.cc-hero .stat-l { margin-top: .4rem; font-size: 10.5px; font-weight: 800; letter-spacing: .07em; text-transform: uppercase; color: rgba(238,241,240,.6); }
.cc-pill { position: fixed; right: 24px; bottom: 24px; z-index: 320; display: flex; align-items: center; gap: .8rem; background: var(--paper-2); border: 1px solid var(--card-line); border-radius: 999px; padding: .55rem .8rem .55rem .6rem; box-shadow: 0 12px 30px rgba(16,26,24,.2); animation: cc-fade .2s; }

@keyframes cc-fade { from { opacity: 0 } to { opacity: 1 } }
@keyframes cc-up { from { transform: translateY(8px); opacity: 0 } to { transform: none; opacity: 1 } }
@keyframes cc-dots { 0%,100% { opacity: .25 } 50% { opacity: 1 } }
@keyframes cc-pulse { 0%,100% { opacity: 1 } 50% { opacity: .4 } }
.cc-fade-up { animation: cc-up .28s ease-out; }
.cc-dotpulse { animation: cc-dots 1s infinite; }

/* ── Clients list (Phase 5a) + client detail (Phase 5b) ────────────── */
#clients-list-view.cc-active > *:not(.ccx) { display: none !important; }
#clients-list-view:not(.cc-active) > .ccx { display: none; }
#client-detail-view.cc-active > *:not(.ccx) { display: none !important; }
#client-detail-view:not(.cc-active) > .ccx { display: none; }
.cc-clients { flex: 1; min-height: 0; overflow-y: auto; }
.cc-clients-wrap { padding: 1.2rem 1.75rem 2.2rem; max-width: none; margin: 0 auto; }
.cc-head-inner { max-width: none; }
.cc-clients-grid { display: grid; grid-template-columns: minmax(200px,1.9fr) minmax(240px,3fr) minmax(130px,1.4fr) 96px 30px; gap: .9rem; align-items: center; }
.cc-clients-headrow { padding: .55rem .9rem; background: var(--paper-3); border-bottom: 1px solid var(--card-line); font-size: 10.5px; font-weight: 800; letter-spacing: .07em; text-transform: uppercase; color: var(--ink-5); }
.cc-crow { padding: .7rem .9rem; cursor: pointer; }
.cc-crow:hover { background: var(--paper); }
.cc-crow.open { background: var(--paper-3); }
.cc-typeglyph { width: 30px; height: 30px; border: 1px solid var(--card-line); background: var(--paper-3); color: var(--ink-4); font-size: 10px; font-weight: 700; letter-spacing: .03em; display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; }
.cc-caselink { display: flex; align-items: center; gap: .45rem; border: 0; background: transparent; padding: 0; min-width: 0; text-align: left; width: 100%; }
.cc-caselink:hover .cc-caselink-title { text-decoration: underline; }
.cc-caselink-title { flex: 1 1 auto; min-width: 0; font-size: 13px; color: var(--ink-2); font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cc-hdot { width: 7px; height: 7px; border-radius: 999px; flex-shrink: 0; }

.ccx ::-webkit-scrollbar { width: 8px; height: 8px; }
.ccx ::-webkit-scrollbar-thumb { background: rgba(0,0,0,.14); border-radius: 99px; }
.ccx ::-webkit-scrollbar-track { background: transparent; }
