:root {
  --ink: #1c1915;
  --muted: #5c564c;
  --line: #e4dccb;
  --paper: #f7f3ea;
  --card: #fffdf8;
  --navy: #1e3a5f;
  --navy-2: #16304f;
  --gold: #a7843f;
  --danger: #8a2b2b;
}
* { box-sizing: border-box; }
body { margin: 0; font-family: "Segoe UI", Georgia, serif; color: var(--ink); background: var(--paper); }
.top {
  background: linear-gradient(180deg, var(--navy), var(--navy-2));
  color: #f4efe4; padding: 22px 28px 18px;
  display: flex; justify-content: space-between; gap: 24px; align-items: end;
  border-bottom: 4px solid var(--gold);
}
.brand { display: flex; gap: 14px; align-items: center; }
.mark { width: 48px; height: 48px; border: 1px solid var(--gold); display: grid; place-items: center; font-weight: 700; }
.kicker { margin: 0; letter-spacing: 0.14em; text-transform: uppercase; font-size: 11px; color: #d7c49a; }
h1 { margin: 2px 0 0; font-size: 28px; font-weight: 600; }
.disclaimer { max-width: 420px; margin: 0; font-size: 13px; line-height: 1.45; color: #e7dfd0; }
.tabs { display: flex; background: #efe8da; border-bottom: 1px solid var(--line); padding: 0 18px; overflow-x: auto; }
.tab { background: transparent; border: 0; border-bottom: 3px solid transparent; padding: 14px 18px; font: inherit; cursor: pointer; color: var(--muted); white-space: nowrap; }
.tab.active { color: var(--navy); border-bottom-color: var(--gold); font-weight: 650; }
main { padding: 22px 28px 80px; max-width: 1280px; }
.workspace { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 16px; align-items: start; }
#draft-pane { position: sticky; top: 16px; background: var(--card); border: 1px solid var(--line); padding: 14px; }
#draft-pane button { width: 100%; margin-bottom: 10px; }
#draft-pane button:disabled { opacity: 0.5; cursor: not-allowed; }
.invoice-form { display: grid; gap: 6px; margin-bottom: 10px; }
.invoice-form input { width: 100%; }
.cal-head { display: flex; align-items: center; justify-content: space-between; margin: 18px 0 8px; }
.cal-head h2 { margin: 0; font-size: 18px; }
.cal { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; }
.cal .head, .cal .day { background: var(--card); border: 1px solid var(--line); padding: 6px; font-size: 12px; }
.cal .head { font-weight: 650; text-align: center; }
.cal .day { min-height: 78px; }
.cal .day.empty { background: transparent; }
.cal .day strong { display: block; }
.cal .item { margin-top: 4px; color: var(--navy); }
.cal .item.due { color: var(--danger); }
body.calendar-page .workspace { grid-template-columns: 1fr; }
body.calendar-page #draft-pane,
body.calendar-page #status,
body.calendar-page #meta,
body.calendar-page #results,
body.calendar-page #detail { display: none; }
body.calendar-page .cal .day { min-height: 110px; font-size: 14px; }
#matter-table select { padding: 6px; }
.panel { display: none; }
.panel.active { display: block; }
.card, .detail { background: var(--card); border: 1px solid var(--line); padding: 18px; }
.card { display: grid; grid-template-columns: repeat(4, minmax(140px, 1fr)); gap: 14px; align-items: end; }
label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--muted); }
input, select, button { font: inherit; font-size: 16px; color: var(--ink); border: 1px solid #cfc6b4; background: white; padding: 12px 10px; }
button { background: var(--navy); color: white; border-color: var(--navy); cursor: pointer; }
button.ghost { background: white; color: var(--navy); }
.status { min-height: 1.4em; color: var(--muted); }
.status.error { color: var(--danger); }
.meta { margin: 8px 0; font-size: 14px; }
.table-wrap { overflow-x: auto; border: 1px solid var(--line); background: white; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { background: #f3eee4; font-weight: 650; }
a { color: var(--navy); }
.detail { margin-top: 16px; }
.case-card { border-top: 1px solid var(--line); padding-top: 16px; margin-top: 16px; }
.case-card:first-child { border-top: 0; margin-top: 0; padding-top: 0; }
.detail h2, .case-card h2 { margin: 0 0 8px; font-size: 22px; }
.facts { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin: 12px 0 18px; }
.facts div { background: #f7f3ea; padding: 10px; }
.facts span { display: block; font-size: 12px; color: var(--muted); }
.cols { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.cols h3 { margin: 0 0 8px; font-size: 15px; }
.party { padding: 6px 0; border-bottom: 1px solid var(--line); }
.party em { color: var(--muted); font-style: normal; }
.mail { background: #f7f3ea; padding: 12px; white-space: pre-wrap; }
.mail p { margin: 8px 0 0; }
footer {
  position: fixed; left: 0; right: 0; bottom: 0;
  display: flex; justify-content: space-between;
  background: #efe8da; border-top: 1px solid var(--line);
  padding: 8px 28px; font-size: 12px; color: var(--muted);
}
@media (max-width: 800px) {
  .top, .facts, .cols, .card, .workspace { display: block; }
  .card > * { margin-bottom: 10px; }
  main { padding: 12px 12px 96px; }
  #draft-pane { position: static; margin: 12px 0; }
  footer { flex-direction: column; gap: 4px; }
  h1 { font-size: 22px; }
}
