/* EPRA Matters: white, near-black text, one green accent, coloured status labels. */
:root {
  --bg: #ffffff;
  --bg-soft: #fafaf9;
  --text: #1b1f1d;
  --muted: #5b6360;
  --line: #e5e7e6;
  --line-soft: #eef0ef;
  --accent: #064e3b;
  --accent-hover: #0a6b51;
  --accent-soft: #eef3f0;
  --sel: #f1f4f2;
  --error: #b3261e;
  --r: 6px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 15px;
  line-height: 1.55;
  color: var(--text);
  background: var(--bg);
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg-soft); }
a { color: var(--accent); }
a:hover { color: var(--accent-hover); }
h1, h2, h3 { letter-spacing: -0.01em; }
button, input, select { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.pad { padding: 0 12px; }
.error { color: var(--error); }
[hidden] { display: none !important; }

/* ---- controls ---- */
.btn { display: inline-flex; align-items: center; gap: 6px; min-height: 40px; padding: 0 14px; border: 1px solid #cfd4d2; border-radius: var(--r);
  background: #fff; color: var(--text); text-decoration: none; cursor: pointer; white-space: nowrap; }
.btn:hover:not(:disabled) { background: var(--sel); color: var(--text); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.btn.primary:hover:not(:disabled) { background: var(--accent-hover); color: #fff; }
.btn.small { min-height: 32px; padding: 0 10px; font-size: 13px; }
.btn.big { min-height: 48px; padding: 0 22px; font-size: 16px; }
.btn:disabled { opacity: 0.55; cursor: default; }
.icon-btn { display: inline-flex; align-items: center; justify-content: center; width: 36px; height: 36px; border: 0; border-radius: var(--r); background: transparent; color: var(--muted); cursor: pointer; }
.icon-btn:hover { background: var(--sel); color: var(--text); }
.link-btn { border: 0; background: none; color: var(--accent); cursor: pointer; padding: 4px 0; text-decoration: underline; text-underline-offset: 2px; }
.input { height: 40px; padding: 0 10px; border: 1px solid #cfd4d2; border-radius: var(--r); background: #fff; min-width: 0; }
select.input { padding-right: 6px; }
.check { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; }
.check input { width: 16px; height: 16px; accent-color: var(--accent); }

/* ---- labels ---- */
.lbl { display: inline-block; font-size: 12px; font-weight: 600; line-height: 20px; padding: 0 8px; border-radius: 999px; border: 1px solid; white-space: nowrap; }
.lbl.filed { background: #e3f1e9; color: #0b5a3e; border-color: #c4e1d1; }
.lbl.unfiled { background: #fdeccc; color: #7a4a00; border-color: #f2d39a; }
.lbl.doc { background: #eef0ef; color: #3f4744; border-color: #dfe3e1; }
.lbl.copy { background: #eef2fb; color: #2f4a8a; border-color: #d6dff3; margin-left: 8px; }

/* ---- start screens ---- */
.center { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; }
.card { width: 100%; max-width: 480px; background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 32px; display: flex; flex-direction: column; gap: 12px; align-items: flex-start; }
.card h1 { margin: 0 0 4px; font-size: 24px; }
.card p { margin: 0; }
.loading { display: flex; align-items: center; gap: 10px; padding: 16px; color: var(--muted); }
.spin { width: 16px; height: 16px; border: 2px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spin { animation-duration: 2.4s; } }

/* ---- shell ---- */
#app { min-height: 100vh; display: flex; flex-direction: column; }
.top { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 12px; padding: 8px 20px; min-height: 56px; background: #fff; border-bottom: 1px solid var(--line); }
.brand { font-size: 17px; font-weight: 650; letter-spacing: -0.01em; margin-right: 8px; white-space: nowrap; }
.top-search { flex: 1 1 0; min-width: 0; max-width: 420px; margin-left: auto; display: flex; align-items: center; gap: 8px; height: 40px; padding: 0 12px; background: #f3f4f4; border-radius: var(--r); color: var(--muted); }
.top-search .input { border: 0; background: transparent; height: 38px; padding: 0; flex: 1; color: var(--text); }
.avatar { width: 36px; height: 36px; border-radius: 50%; border: 1px solid var(--line); background: #fff; font-size: 13px; font-weight: 600; cursor: pointer; }
.layout { flex: 1; display: flex; flex-wrap: wrap; align-items: stretch; }
#sidebar { flex: 1 1 240px; max-width: 100%; background: #fff; border-right: 1px solid var(--line); padding: 16px 10px; display: flex; flex-direction: column; gap: 6px; }
@media (max-width: 899px) { #sidebar { flex-basis: 100%; max-height: 38vh; overflow-y: auto; border-right: 0; border-bottom: 1px solid var(--line); } .brand { font-size: 16px; margin-right: 0; } .top { padding: 8px 12px; gap: 8px; } }
@media (min-width: 900px) { #sidebar { flex: 0 0 280px; position: sticky; top: 56px; height: calc(100vh - 56px); overflow-y: auto; } }
.side-head { display: flex; align-items: center; justify-content: space-between; padding: 0 6px 6px; }
.side-head h2 { margin: 0; font-size: 13px; font-weight: 600; color: var(--muted); }
.matter-list { display: flex; flex-direction: column; gap: 2px; }
.matter { text-align: left; min-height: 40px; padding: 8px 10px; border: 0; border-radius: var(--r); background: transparent; cursor: pointer; overflow-wrap: anywhere; }
.matter:hover { background: var(--sel); }
.matter.on { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.side-foot { margin-top: auto; padding: 8px 6px 0; font-size: 12px; }
#main { flex: 999 1 560px; min-width: 0; padding: 28px 32px 64px; }
@media (max-width: 640px) { #main { padding: 20px 16px 48px; } }
.empty { max-width: 560px; margin: 64px auto; text-align: center; }
.empty h1 { font-size: 22px; margin: 0 0 6px; }

/* ---- matter header ---- */
.matter-head, .notice, .tabs-row, .timeline, .docs { max-width: 920px; margin-left: auto; margin-right: auto; }
.matter-head { display: flex; gap: 16px; align-items: flex-start; flex-wrap: wrap; }
.mh-text { flex: 1 1 360px; min-width: 0; }
.matter-head h1 { margin: 0; font-size: 26px; line-height: 1.25; font-weight: 650; letter-spacing: -0.015em; }
.people { margin: 6px 0 0; }
.mh-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.notice { margin-top: 16px; padding: 14px 16px; border: 1px solid #f2d39a; background: #fffaf0; border-radius: 8px; display: flex; gap: 16px; align-items: center; flex-wrap: wrap; }
.notice p { margin: 0; flex: 1 1 320px; }
.tabs-row { margin-top: 20px; display: flex; align-items: center; gap: 12px; flex-wrap: wrap; justify-content: space-between; }
.tabs { display: flex; gap: 6px; flex-wrap: wrap; }
.tab { min-height: 36px; padding: 0 14px; border: 1px solid #d9dddb; border-radius: 999px; background: #fff; cursor: pointer; }
.tab .count { margin-left: 6px; color: var(--muted); }
.tab.on { background: var(--text); border-color: var(--text); color: #fff; }
.tab.on .count { color: #d6dad8; }

/* ---- timeline ---- */
.timeline { margin-top: 12px; display: flex; flex-direction: column; gap: 6px; }
.day { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }
.day-label { margin: 0; font-size: 13px; font-weight: 600; color: var(--muted); }
.item { background: #fff; border: 1px solid var(--line); border-radius: 8px; }
.item.open { border-color: #9fb8ac; }
.item-head { display: grid; grid-template-columns: 72px minmax(0, 1fr) auto; gap: 16px; align-items: start; width: 100%; padding: 14px 18px; border: 0; background: transparent; text-align: left; cursor: pointer; border-radius: 8px; }
.item-head:hover { background: var(--bg-soft); }
.time { font-size: 14px; color: var(--muted); font-variant-numeric: tabular-nums; padding-top: 1px; }
.item-main { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.who { font-size: 14px; color: var(--muted); overflow-wrap: anywhere; }
.subject { font-weight: 600; overflow-wrap: anywhere; }
.preview { font-size: 14px; color: var(--muted); display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden; }
.atts { display: inline-flex; align-items: center; gap: 4px; font-size: 13px; color: var(--muted); }
.item-body { padding: 0 18px 18px 106px; display: flex; flex-direction: column; gap: 14px; }
@media (max-width: 640px) { .item-head { grid-template-columns: minmax(0, 1fr) auto; } .time { display: none; } .item-body { padding: 0 14px 14px; } }
.meta { margin: 0; display: grid; grid-template-columns: 72px minmax(0, 1fr); gap: 2px 12px; font-size: 14px; }
.meta dt { color: var(--muted); }
.meta dd { margin: 0; overflow-wrap: anywhere; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.file-to { display: inline-flex; align-items: center; gap: 8px; font-size: 14px; color: var(--muted); }
.mail-frame { width: 100%; height: 240px; border: 0; border-top: 1px solid var(--line-soft); padding-top: 12px; background: #fff; }
.att-list h3 { margin: 0 0 6px; font-size: 13px; font-weight: 600; color: var(--muted); }
.att-list ul { list-style: none; margin: 0; padding: 0; }
.att-list li { display: flex; align-items: center; gap: 12px; padding: 8px 0; border-top: 1px solid var(--line-soft); }
.att-name { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.empty-list { padding: 24px 0; }

/* ---- documents ---- */
.docs { margin-top: 16px; display: flex; flex-direction: column; gap: 12px; }
.docs-bar { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.docs-bar > .input { flex: 0 1 280px; }
.spacer { flex: 1; }
.table-wrap { overflow-x: auto; background: #fff; border: 1px solid var(--line); border-radius: 8px; }
table { width: 100%; min-width: 720px; border-collapse: collapse; font-size: 14px; }
th { text-align: left; font-size: 13px; font-weight: 600; color: var(--muted); border-bottom: 1px solid var(--line); padding: 0 12px; }
.th-btn { border: 0; background: none; padding: 10px 0; color: inherit; font-weight: 600; cursor: pointer; }
td { padding: 12px; border-bottom: 1px solid var(--line-soft); vertical-align: top; }
tr:last-child td { border-bottom: 0; }
td.name a { color: var(--text); font-weight: 600; text-decoration: none; }
td.name a:hover { color: var(--accent); text-decoration: underline; }
td.num { font-variant-numeric: tabular-nums; white-space: nowrap; }

/* ---- dialogs ---- */
.modal-back { position: fixed; inset: 0; z-index: 20; background: rgba(20, 24, 22, 0.35); display: flex; align-items: flex-start; justify-content: center; padding: 6vh 16px; overflow-y: auto; }
.modal { width: 100%; max-width: 520px; background: #fff; border-radius: 10px; border: 1px solid var(--line); box-shadow: 0 12px 40px rgba(0, 0, 0, 0.12); }
.modal.wide { max-width: 720px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 16px 14px 20px; border-bottom: 1px solid var(--line); }
.modal-head h2 { margin: 0; font-size: 17px; font-weight: 650; }
.modal-body { padding: 18px 20px 20px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; margin-top: 8px; }
.form { display: flex; flex-direction: column; gap: 14px; }
.form label:not(.check) { display: flex; flex-direction: column; gap: 4px; font-size: 14px; font-weight: 600; }
.form label .input { font-weight: 400; }
.form p { margin: 0; }
.form fieldset { border: 1px solid var(--line); border-radius: 8px; padding: 12px 14px 14px; margin: 0; display: flex; flex-direction: column; gap: 10px; }
.form legend { font-weight: 650; padding: 0 4px; }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
@media (max-width: 560px) { .grid2 { grid-template-columns: minmax(0, 1fr); } }
.row { display: flex; align-items: center; gap: 12px; justify-content: space-between; }
.people-edit { display: flex; flex-direction: column; gap: 8px; align-items: flex-start; }
.person-row { display: grid; grid-template-columns: 160px minmax(0, 1fr) minmax(0, 1.3fr) 36px; gap: 8px; width: 100%; }
@media (max-width: 640px) { .person-row { grid-template-columns: minmax(0, 1fr) 36px; } .person-row select { grid-column: 1 / -1; } }
.query { display: block; margin-top: 6px; padding: 8px 10px; background: var(--bg-soft); border: 1px solid var(--line); border-radius: var(--r); font-size: 12px; white-space: pre-wrap; overflow-wrap: anywhere; }
details summary { cursor: pointer; color: var(--accent); font-size: 14px; }

/* ---- picker ---- */
.picker { display: flex; flex-direction: column; gap: 10px; }
.pick-list { display: flex; flex-direction: column; gap: 4px; max-height: 50vh; overflow-y: auto; }
.pick-row { display: flex; align-items: center; gap: 8px; width: 100%; min-height: 44px; padding: 8px 10px; border: 1px solid var(--line); border-radius: var(--r); background: #fff; text-align: left; cursor: pointer; color: var(--text); }
.pick-row:hover { border-color: var(--accent); }
.pick-text { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.pick-text small { color: var(--muted); overflow-wrap: anywhere; }
.pick-back { display: flex; align-items: center; gap: 6px; }

/* ---- notices ---- */
.toast { position: fixed; left: 50%; bottom: 20px; transform: translate(-50%, 16px); opacity: 0; visibility: hidden; pointer-events: none; z-index: 30; max-width: min(560px, calc(100vw - 32px)); display: flex; gap: 14px; align-items: center;
  padding: 10px 16px; background: var(--text); color: #fff; border-radius: 8px; box-shadow: 0 8px 24px rgba(0,0,0,.18); transition: transform .2s ease, opacity .2s ease, visibility .2s; }
.toast.show { transform: translate(-50%, 0); opacity: 1; visibility: visible; pointer-events: auto; }
.toast.warn { background: #6b4a00; }
.toast.error { background: var(--error); }
.toast a { color: #fff; font-weight: 600; white-space: nowrap; }
.update-bar { display: flex; align-items: center; justify-content: center; gap: 12px; padding: 8px 16px; background: #fdeccc; color: #5a3700; font-size: 14px; }
