:root {
  --ink: #1f252b;
  --muted: #66727e;
  --line: #d8e0e7;
  --panel: #ffffff;
  --surface: #f3f6f7;
  --field: #fbfcfd;
  --teal: #0f766e;
  --blue: #285f86;
  --red: #b43737;
  --amber: #9a6500;
  --green: #16724f;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
body { margin: 0; color: var(--ink); background: var(--surface); }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; border: 0; touch-action: manipulation; }
input, select, textarea { font-size: 16px; }
svg { width: 21px; height: 21px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

.app-shell { display: grid; grid-template-columns: minmax(330px, 410px) 1fr; min-height: 100vh; }
.sidebar { padding: 22px; background: #eef3f2; border-right: 1px solid var(--line); overflow: auto; }
.workspace { padding: 24px; overflow: auto; }
.brand { display: grid; grid-template-columns: 48px 1fr; gap: 13px; margin-bottom: 18px; }
.brand-mark { display: grid; place-items: center; width: 48px; height: 48px; border-radius: 8px; background: #dcebe8; color: var(--teal); }
h1, h2, p { margin: 0; }
h1 { font-size: 1.2rem; line-height: 1.25; }
.brand p, .eyebrow, label span, .meta, .empty, .group-count, .summary-grid span { color: var(--muted); }
.brand p { margin-top: 5px; font-size: .9rem; line-height: 1.4; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 16px; box-shadow: 0 16px 34px rgba(24, 38, 52, .07); }
.panel + .panel { margin-top: 16px; }
.panel h2 { margin-bottom: 12px; font-size: 1rem; }
.case-form { display: grid; gap: 10px; }
label { display: grid; gap: 6px; }
.check-row { grid-template-columns: 18px 1fr; align-items: center; min-height: 40px; }
.check-row input { width: 18px; min-height: 18px; padding: 0; }
label span { font-size: .82rem; font-weight: 800; }
input, select, textarea { width: 100%; min-height: 40px; border: 1px solid var(--line); border-radius: 8px; background: var(--field); padding: 9px 11px; color: var(--ink); }
textarea { min-height: 72px; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--blue); outline: 3px solid rgba(40, 95, 134, .16); }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.button-row, .actions { display: flex; gap: 10px; flex-wrap: wrap; }
.primary, .secondary, .danger { display: inline-flex; align-items: center; justify-content: center; min-height: 40px; padding: 0 14px; border-radius: 8px; font-weight: 850; }
.primary.small, .secondary.small, .danger.small { min-height: 30px; padding: 0 10px; font-size: .78rem; }
.primary { background: var(--teal); color: #fff; }
.secondary { background: #e8eef2; color: #26323d; border: 1px solid #c7d2da; }
.danger { background: #ffe5e5; color: var(--red); border: 1px solid #f3baba; }
.topbar { display: flex; justify-content: space-between; gap: 16px; align-items: center; margin-bottom: 16px; }
.eyebrow { margin-bottom: 4px; font-size: .78rem; font-weight: 850; text-transform: uppercase; letter-spacing: 0; }
.topbar h2 { font-size: clamp(1.35rem, 2vw, 2rem); line-height: 1.15; }
.actions input { width: min(390px, 100%); }
.actions select { min-height: 42px; border: 1px solid var(--line); border-radius: 8px; background: #fbfcfd; padding: 9px 11px; color: var(--ink); }
.summary-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(145px, 1fr)); gap: 12px; margin-bottom: 16px; }
.summary-grid div { display: grid; gap: 4px; min-height: 78px; align-content: center; padding: 14px; background: #fff; border: 1px solid var(--line); border-radius: 8px; }
.summary-grid strong { font-size: 1.65rem; }
.summary-grid span { font-size: .8rem; font-weight: 850; }
.backup-panel { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; padding: 12px; background: #fff; border: 1px solid var(--line); border-radius: 8px; }
.backup-panel strong { display: block; margin-bottom: 3px; }
.backup-panel span { color: var(--muted); font-size: .86rem; }
.backup-actions { display: flex; align-items: end; flex-wrap: wrap; gap: 8px; }
.restore-label input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.restore-label .secondary { cursor: pointer; }
.calendar-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; padding: 12px; background: #fff; border: 1px solid var(--line); border-radius: 8px; }
.calendar-nav { display: flex; flex-wrap: wrap; gap: 8px; }
.calendar-period { font-weight: 950; }
.tabs { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.tabs button { min-height: 38px; padding: 0 12px; border-radius: 8px; background: #fff; color: #33404b; border: 1px solid var(--line); font-weight: 850; }
.tabs button.active { background: var(--ink); color: #fff; border-color: var(--ink); }
.view-title { margin-bottom: 12px; font-weight: 900; }
.case-list { display: grid; gap: 14px; }
.group { display: grid; gap: 10px; }
.group-header { display: flex; justify-content: space-between; align-items: center; padding: 10px 12px; border-radius: 8px; background: #dde8ea; font-weight: 900; }
.case-card { display: grid; gap: 10px; background: #fff; border: 1px solid var(--line); border-left: 5px solid var(--teal); border-radius: 8px; padding: 14px; }
.case-card.closed { border-left-color: var(--muted); opacity: .92; }
.case-card.stale { border-left-color: var(--amber); }
.case-card.overdue { border-left-color: var(--red); }
.case-head { display: flex; justify-content: space-between; gap: 14px; align-items: start; }
.case-title { font-weight: 950; overflow-wrap: anywhere; }
.badges { display: flex; flex-wrap: wrap; gap: 6px; justify-content: flex-end; }
.badge { display: inline-flex; align-items: center; min-height: 28px; padding: 0 9px; border-radius: 999px; font-size: .78rem; font-weight: 900; background: #eef3f5; color: #40505d; }
.badge.red { background: #ffe5e5; color: var(--red); }
.badge.amber { background: #fff1d8; color: var(--amber); }
.badge.green { background: #dff3eb; color: var(--green); }
.details-grid { display: grid; grid-template-columns: repeat(4, minmax(130px, 1fr)); gap: 9px; }
.detail { padding: 9px; background: #f7f9fa; border: 1px solid #e4ebef; border-radius: 8px; }
.detail span { display: block; color: var(--muted); font-size: .76rem; font-weight: 850; margin-bottom: 2px; }
.case-extra { display: none; gap: 10px; }
.case-extra.open { display: grid; }
.case-extra h3 { margin: 4px 0 0; font-size: .95rem; }
.proceedings, .hearing-list, .misc-list, .ledger-list, .todo-list { display: grid; gap: 7px; }
.proceeding, .hearing-entry, .misc-entry, .ledger-entry, .todo-entry, .strategy-entry { padding: 9px; background: #fbfcfd; border: 1px solid #e4ebef; border-radius: 8px; line-height: 1.45; }
.strategy-entry { background: #f7fbff; border-color: #cfe0ee; }
.hearing-entry.misc { background: #fffaf0; border-color: #f0d9a8; }
.misc-entry { background: #fffaf0; border-color: #f0d9a8; }
.misc-entry.done { opacity: .72; background: #f4f7f8; border-color: #d7e0e7; }
.todo-entry.overdue { background: #fff5f5; border-color: #efb4b4; }
.todo-entry.done { opacity: .72; background: #f4f7f8; }
.mini-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.card-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.empty { min-height: 160px; display: grid; place-items: center; background: #fff; border: 1px dashed var(--line); border-radius: 8px; text-align: center; padding: 20px; }
.calendar-grid { display: grid; grid-template-columns: repeat(7, minmax(110px, 1fr)); gap: 1px; overflow: auto; border: 1px solid var(--line); background: var(--line); border-radius: 8px; }
.calendar-day-head { min-height: 38px; padding: 10px; background: #e8eef2; font-size: .8rem; font-weight: 950; text-align: center; }
.calendar-cell { display: grid; align-content: start; gap: 7px; min-height: 122px; padding: 8px; background: #fff; color: var(--ink); text-align: left; border-radius: 0; }
.calendar-cell.muted { background: #f7f9fa; color: var(--muted); }
.calendar-cell.today { outline: 2px solid var(--teal); outline-offset: -2px; }
.calendar-date { font-weight: 950; }
.calendar-events { display: grid; gap: 4px; }
.calendar-event, .calendar-more { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; border-radius: 6px; padding: 3px 6px; font-size: .74rem; font-style: normal; font-weight: 850; }
.calendar-event.teal { background: #dff3ef; color: #0f766e; }
.calendar-event.blue { background: #e3eef7; color: #285f86; }
.calendar-event.green { background: #dff3eb; color: #16724f; }
.calendar-event.amber { background: #fff1d8; color: #9a6500; }
.calendar-event.red { background: #ffe5e5; color: #b43737; }
.calendar-more { background: #eef3f5; color: #40505d; }
@media (max-width: 1050px) { .app-shell { grid-template-columns: 1fr; } .sidebar { border-right: 0; border-bottom: 1px solid var(--line); } .details-grid, .summary-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 680px) { .sidebar, .workspace { padding: 15px; } .topbar, .case-head, .calendar-toolbar, .backup-panel { flex-direction: column; align-items: stretch; } .details-grid, .summary-grid, .two-col { grid-template-columns: 1fr; } .actions input, .actions select, .primary, .secondary, .danger { width: 100%; } .calendar-grid { grid-template-columns: repeat(7, minmax(92px, 1fr)); } }
@media (max-width: 820px) {
  body { -webkit-text-size-adjust: 100%; }
  .app-shell { min-height: auto; }
  .sidebar, .workspace { padding-left: max(14px, env(safe-area-inset-left)); padding-right: max(14px, env(safe-area-inset-right)); }
  .panel { padding: 14px; box-shadow: none; }
  .brand { grid-template-columns: 42px 1fr; }
  .brand-mark { width: 42px; height: 42px; }
  input, select, textarea, .primary, .secondary, .danger { min-height: 46px; }
  textarea { min-height: 96px; }
  .tabs, .calendar-nav { flex-wrap: nowrap; overflow-x: auto; padding-bottom: 4px; -webkit-overflow-scrolling: touch; }
  .tabs button, .calendar-nav button { flex: 0 0 auto; min-height: 44px; }
  .calendar-grid { grid-template-columns: repeat(7, minmax(118px, 1fr)); overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .calendar-cell { min-height: 118px; }
  .case-card { padding: 13px; }
}
@media (max-width: 430px) {
  .details-grid, .summary-grid { grid-template-columns: 1fr; }
  .badges, .actions, .button-row, .card-actions, .mini-actions { justify-content: stretch; }
}
