:root {
  --ink: #182024;
  --ink-soft: #3f494c;
  --paper: #f6f2e9;
  --paper-deep: #ece5d8;
  --white: #fffdf8;
  --line: #d9d0c0;
  --brass: #b58a4b;
  --brass-dark: #8f6830;
  --green: #2f6657;
  --green-soft: #e3eee8;
  --red: #9b493f;
  --red-soft: #f5e8e3;
  --shadow: 0 20px 60px rgba(25, 31, 32, 0.09);
  --sans: "DM Sans", system-ui, sans-serif;
  --serif: "Libre Caslon Display", Georgia, serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html { min-width: 320px; background: var(--paper); }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    radial-gradient(circle at 80% -10%, rgba(181, 138, 75, 0.13), transparent 34rem),
    var(--paper);
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
}

button, input, textarea { font: inherit; }
button { color: inherit; }

button:focus-visible, input:focus-visible, textarea:focus-visible, a:focus-visible {
  outline: 3px solid rgba(181, 138, 75, 0.34);
  outline-offset: 2px;
}

.app-shell { min-height: 100vh; }

.topbar {
  min-height: 72px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 34px;
  border-bottom: 1px solid rgba(217, 208, 192, 0.75);
  background: rgba(246, 242, 233, 0.9);
  backdrop-filter: blur(16px);
  position: sticky;
  top: 0;
  z-index: 20;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0;
  color: var(--ink);
  text-decoration: none;
  position: relative;
}

.brand-mark {
  width: clamp(240px, 26vw, 300px);
  height: 64px;
  max-height: 64px;
  display: grid;
  place-items: center;
  color: var(--ink);
  background: transparent;
  border-radius: 0;
}

.brand-mark img { display: block; width: auto; max-width: 100%; height: auto; max-height: 64px; object-fit: contain; object-position: left center; }
.brand > span:last-child { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.brand strong { display: block; letter-spacing: .16em; font-size: 13px; line-height: 1.1; }
.brand small { display: block; color: #747a78; font-size: 9px; letter-spacing: .19em; margin-top: 4px; }

.topbar-actions { display: flex; align-items: center; gap: 14px; }
.privacy-chip { display: inline-flex; align-items: center; gap: 7px; color: #6a716f; font-size: 12px; }
.privacy-chip svg { width: 15px; fill: none; stroke: currentColor; stroke-width: 1.5; }

.account-menu { position: relative; }
.account-trigger {
  min-height: 46px;
  max-width: min(390px, 42vw);
  display: inline-flex;
  align-items: center;
  gap: 9px;
  padding: 4px 10px 4px 5px;
  border: 1px solid transparent;
  border-radius: 999px;
  background: transparent;
  cursor: pointer;
  text-align: left;
}
.account-trigger:hover,
.account-trigger[aria-expanded="true"] { border-color: var(--line); background: rgba(255, 253, 248, .72); }
.account-avatar {
  flex: 0 0 36px;
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: #fff;
  background: var(--green);
  font-size: 13px;
  font-weight: 700;
}
.account-trigger-copy { min-width: 0; display: grid; }
.account-trigger-copy strong { overflow: hidden; color: var(--ink); font-size: 12px; font-weight: 700; text-overflow: ellipsis; white-space: nowrap; }
.account-trigger-copy small { margin-top: 1px; color: #6a716f; font-size: 10px; }
.account-status { flex: 0 0 auto; padding: 4px 7px; border-radius: 999px; color: var(--green); background: var(--green-soft); font-size: 9px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; }
.account-trigger > svg { flex: 0 0 16px; width: 16px; fill: none; stroke: currentColor; stroke-width: 1.7; }
.account-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 60;
  width: min(260px, calc(100vw - 28px));
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 15px;
  background: var(--white);
  box-shadow: 0 18px 48px rgba(24, 32, 36, .18);
}
.account-dropdown a { display: block; padding: 11px 12px; border-radius: 10px; color: var(--ink); font-size: 13px; font-weight: 600; text-decoration: none; }
.account-dropdown a:hover,
.account-dropdown a:focus-visible { background: var(--paper-deep); }

.btn {
  border: 0;
  border-radius: 999px;
  min-height: 44px;
  padding: 0 20px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-weight: 700;
  font-size: 13px;
  text-decoration: none;
  cursor: pointer;
  transition: transform .18s ease, background .18s ease, color .18s ease, box-shadow .18s ease;
}
.btn:hover { transform: translateY(-1px); }
.btn-primary { color: #fff; background: var(--ink); box-shadow: 0 8px 20px rgba(24, 32, 36, .15); }
.btn-primary:hover { background: #2b373b; }
.btn-brass { color: #fff; background: var(--brass-dark); box-shadow: 0 8px 20px rgba(143, 104, 48, .18); }
.btn-brass:hover { background: #785526; }
.btn-quiet { background: transparent; border: 1px solid var(--line); }
.btn-quiet:hover { background: var(--paper-deep); }
.btn-delete-neutral { color: #51483f; background: transparent; border: 1px solid #b8ad9b; box-shadow: none; }
.btn-delete-neutral:hover { color: var(--ink); background: var(--paper-deep); }
.btn-delete-confirm { color: #fff; background: var(--ink); box-shadow: 0 8px 20px rgba(24, 32, 36, .18); }
.btn-delete-confirm:hover { background: #2b373b; }
.btn:disabled { cursor: wait; transform: none; opacity: .65; }

.workspace { display: grid; grid-template-columns: 290px minmax(0, 1fr); min-height: calc(100vh - 72px); }

.sidebar {
  border-right: 1px solid var(--line);
  padding: 28px 20px 20px;
  display: flex;
  flex-direction: column;
  background: rgba(240, 234, 222, .45);
  min-height: calc(100vh - 72px);
  position: sticky;
  top: 72px;
  height: calc(100vh - 72px);
}

.sidebar-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; padding: 0 8px 17px; }
.sidebar-heading h2 { font-family: var(--serif); font-weight: 400; font-size: 23px; margin: 5px 0 0; }
.eyebrow { color: var(--brass-dark); text-transform: uppercase; letter-spacing: .16em; font-weight: 700; font-size: 10px; }

.icon-btn {
  width: 38px;
  height: 38px;
  flex: 0 0 auto;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: rgba(255,255,255,.5);
  cursor: pointer;
  display: grid;
  place-items: center;
  font-size: 22px;
  line-height: 1;
}
.icon-btn:hover { background: var(--white); }

.search-box { position: relative; margin-bottom: 17px; }
.search-box svg { position: absolute; left: 13px; top: 50%; width: 16px; transform: translateY(-50%); fill: none; stroke: #777e7b; stroke-width: 1.5; }
.search-box input { width: 100%; height: 42px; padding: 0 12px 0 39px; border: 1px solid var(--line); border-radius: 12px; background: rgba(255, 253, 248, .75); color: var(--ink); }

.matter-list { display: flex; flex-direction: column; gap: 7px; overflow: auto; padding-right: 3px; }
.matter-item {
  width: 100%;
  border: 1px solid transparent;
  border-radius: 14px;
  background: transparent;
  padding: 13px 13px 12px;
  text-align: left;
  cursor: pointer;
  transition: background .16s ease, border-color .16s ease;
}
.matter-item:hover { background: rgba(255,253,248,.6); }
.matter-item.active { background: var(--white); border-color: var(--line); box-shadow: 0 7px 24px rgba(38, 40, 36, .05); }
.matter-item strong { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 13px; }
.matter-item span { display: flex; justify-content: space-between; gap: 8px; color: #707775; font-size: 11px; margin-top: 7px; }
.matter-item b { color: var(--green); font-weight: 700; }
.matter-list-empty { text-align: center; color: #7a807e; font-size: 12px; padding: 26px 16px; border: 1px dashed var(--line); border-radius: 14px; }

.sidebar-footer { margin-top: auto; border-top: 1px solid var(--line); padding: 17px 8px 0; }
.sidebar-footer p { color: #7b807e; font-size: 10px; line-height: 1.5; margin: 9px 0 0; }
.text-btn { display: inline-flex; align-items: center; gap: 8px; border: 0; padding: 0; color: var(--ink); background: transparent; font-weight: 700; font-size: 12px; cursor: pointer; }
.text-btn:hover { color: var(--brass-dark); }
.text-btn svg { width: 16px; fill: none; stroke: currentColor; stroke-width: 1.5; }

.main-content { min-width: 0; padding: 42px clamp(24px, 4vw, 68px) 80px; }

.empty-state { max-width: 930px; min-height: 650px; margin: 0 auto; display: grid; place-items: center; }
.empty-inner { text-align: center; max-width: 690px; }
.seal { width: 76px; height: 76px; margin: 0 auto 28px; border: 1px solid var(--brass); border-radius: 50%; display: grid; place-items: center; position: relative; }
.seal::after { content: ""; position: absolute; inset: 5px; border: 1px solid rgba(181,138,75,.45); border-radius: 50%; }
.seal svg { width: 38px; fill: none; stroke: var(--brass-dark); stroke-width: 1.3; stroke-linecap: round; stroke-linejoin: round; }
.empty-state h1 { font-family: var(--serif); font-size: clamp(46px, 5vw, 72px); font-weight: 400; line-height: .98; letter-spacing: -.035em; margin: 0; }
.empty-state p { max-width: 590px; margin: 22px auto 28px; color: #626967; line-height: 1.7; font-size: 15px; }
.feature-row { display: flex; justify-content: center; flex-wrap: wrap; gap: 12px 24px; margin-top: 33px; }
.feature-row span { display: inline-flex; align-items: center; gap: 7px; font-size: 12px; color: #626967; }
.feature-row svg { width: 17px; color: var(--green); fill: none; stroke: currentColor; stroke-width: 1.7; }

.matter-header { display: flex; justify-content: space-between; gap: 30px; align-items: flex-start; max-width: 1180px; margin: 0 auto 30px; }
.matter-title-wrap { min-width: 0; }
.matter-title-wrap h1 { font-family: var(--serif); font-size: clamp(36px, 4vw, 56px); line-height: 1.05; font-weight: 400; letter-spacing: -.025em; margin: 6px 0 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.case-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 7px 16px; color: #69706e; font-size: 12px; }
.case-meta span { display: inline-flex; align-items: center; gap: 6px; }
.case-meta span + span::before { content: ""; width: 3px; height: 3px; margin-right: 9px; background: var(--brass); border-radius: 50%; }
.header-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 10px; padding-top: 9px; }
.header-edit-button { width: auto; min-height: 40px; padding-inline: 15px; border-radius: 12px; white-space: nowrap; }

.status-line { display: inline-flex; align-items: center; gap: 7px; color: var(--green); font-size: 11px; font-weight: 700; margin-top: 10px; }
.status-line::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 4px var(--green-soft); }

.summary-grid { max-width: 1180px; margin: 0 auto 24px; display: grid; grid-template-columns: 1.55fr repeat(3, 1fr); gap: 12px; }
.summary-card { min-height: 126px; border: 1px solid var(--line); background: rgba(255,253,248,.74); border-radius: 18px; padding: 20px; position: relative; overflow: hidden; }
.summary-card.primary { color: #fff; background: var(--ink); border-color: var(--ink); padding: 22px 25px; }
.summary-card.primary::after { content: ""; position: absolute; width: 130px; height: 130px; border: 1px solid rgba(181,138,75,.32); border-radius: 50%; right: -48px; top: -53px; box-shadow: 0 0 0 14px rgba(181,138,75,.05), 0 0 0 30px rgba(181,138,75,.035); }
.summary-card label { display: block; color: #727976; font-size: 10px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; }
.summary-card.primary label { color: #cfc8bb; }
.summary-card strong { display: block; font-family: var(--serif); font-size: 31px; font-weight: 400; margin-top: 17px; letter-spacing: -.02em; }
.summary-card.primary strong { font-size: 38px; color: #fff; margin-top: 12px; }
.summary-card small { display: block; color: #787e7c; font-size: 10px; margin-top: 8px; }
.summary-card.primary small { color: #aeb6b3; }

.content-grid { max-width: 1180px; margin: 0 auto; display: grid; grid-template-columns: minmax(0, 1.65fr) minmax(300px, .75fr); gap: 20px; align-items: start; }
.panel { border: 1px solid var(--line); background: rgba(255,253,248,.8); border-radius: 20px; overflow: hidden; box-shadow: 0 12px 45px rgba(38, 40, 36, .035); }
.panel-header { display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 22px 24px; border-bottom: 1px solid var(--line); }
.panel-header h2 { font-family: var(--serif); font-weight: 400; font-size: 25px; margin: 0; }
.panel-header p { color: #747a78; font-size: 11px; margin: 5px 0 0; }
.ledger-actions { display: flex; gap: 8px; align-items: center; }
.inline-entry-editor-mount { border-bottom: 1px solid var(--line); }
.inline-entry-editor { background: #faf7f0; }
.inline-entry-editor[hidden] { display: none; }
.inline-entry-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; padding: 20px 24px 15px; }
.inline-entry-header h2 { margin: 4px 0 0; font-family: var(--serif); font-size: 24px; font-weight: 400; }
.inline-entry-body { padding: 0 24px 4px; }
.inline-entry-actions { display: flex; justify-content: flex-end; padding: 0 24px 18px; }
.date-view-toggle { display: inline-flex; align-items: center; gap: 8px; flex-shrink: 0; padding: 7px 13px; border: 1px solid var(--line); border-radius: 999px; background: var(--white); color: var(--ink); font-family: inherit; font-size: 11px; font-weight: 700; letter-spacing: .01em; white-space: nowrap; cursor: pointer; transition: border-color .16s ease, color .16s ease, background .16s ease; }
.date-view-toggle .date-view-icon { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.date-view-toggle:hover { border-color: var(--brass); color: var(--brass-dark); }
.date-view-toggle.is-newest { border-color: var(--brass); color: var(--brass-dark); background: var(--paper-deep); }
.date-view-toggle:focus-visible { outline: 3px solid var(--brass); outline-offset: 3px; box-shadow: 0 0 0 5px rgba(181, 138, 75, 0.22); }

.as-of-control { display: flex; align-items: center; gap: 10px; padding: 12px 24px; background: #f0ebe1; border-bottom: 0; }
.as-of-control label { font-size: 11px; font-weight: 700; color: #646b69; }
.as-of-control input { border: 1px solid var(--line); background: var(--white); border-radius: 9px; padding: 7px 9px; color: var(--ink); }
.as-of-control span { margin-left: auto; color: #7b817e; font-size: 10px; }

.ledger-list-toolbar { display: flex; justify-content: flex-end; align-items: center; padding: 4px 24px 10px; border-bottom: 1px solid var(--line); }

.ledger-empty { text-align: center; padding: 70px 24px; }
.compact-ledger-empty { padding: 22px; }
.ledger-empty .empty-icon { width: 53px; height: 53px; border-radius: 50%; display: grid; place-items: center; margin: 0 auto 15px; background: var(--paper-deep); color: var(--brass-dark); font-size: 24px; }
.ledger-empty h3 { font-family: var(--serif); font-size: 23px; font-weight: 400; margin: 0 0 7px; }
.ledger-empty p { color: #737a77; font-size: 12px; margin: 0; }

.ledger-list { margin: 0; padding: 0; list-style: none; }
.ledger-row { display: grid; grid-template-columns: 44px minmax(0, 1fr) auto auto auto; gap: 14px; align-items: center; padding: 18px 24px; border-bottom: 1px solid #e5ded1; }
.ledger-row:last-child { border-bottom: 0; }
.entry-type-icon { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; font-size: 20px; font-weight: 500; }
.entry-type-icon.cost { color: var(--red); background: var(--red-soft); }
.entry-type-icon.payment { color: var(--green); background: var(--green-soft); }
.entry-main { min-width: 0; }
.entry-main strong { display: block; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.entry-main span { display: flex; align-items: center; flex-wrap: wrap; gap: 7px; color: #767d7a; font-size: 10px; margin-top: 6px; }
.evidence-badge, .ccp-badge { border-radius: 99px; padding: 3px 7px; font-weight: 700; font-style: normal; }
.evidence-badge { color: var(--brass-dark) !important; background: #f2e8d7; }
.ccp-badge { color: var(--green); background: var(--green-soft); }
.entry-amount, .entry-balance { text-align: right; }
.entry-amount strong, .entry-balance strong { display: block; font-family: var(--serif); font-size: 19px; font-weight: 400; }
.entry-amount small, .entry-balance small { display: block; margin-top: 4px; font-size: 9px; text-transform: uppercase; letter-spacing: .08em; color: #7b817e; }
.entry-menu { position: relative; display: flex; gap: 2px; }
.entry-menu > button { border: 0; width: 32px; height: 32px; border-radius: 50%; background: transparent; cursor: pointer; font-size: 18px; }
.entry-menu > button:hover { background: var(--paper-deep); }
.entry-details { grid-column: 2 / -1; display: flex; flex-wrap: wrap; gap: 8px; margin-top: -3px; }
.evidence-button { border: 1px solid var(--line); background: #fff; border-radius: 8px; padding: 6px 9px; font-size: 10px; cursor: pointer; max-width: 210px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.evidence-button:hover { border-color: var(--brass); color: var(--brass-dark); }

.calculation-panel { position: sticky; top: 104px; }
.calculation-body { padding: 22px 24px; }
.calc-list { display: grid; gap: 9px; margin: 0; }
.calc-row { display: flex; align-items: baseline; justify-content: space-between; gap: 14px; font-size: 12px; line-height: 1.28; }
.calc-row dt { color: #69706e; }
.calc-row dt small { display: block; margin-top: 2px; color: #69706e; font-size: 9px; font-weight: 700; }
.calc-row dd { margin: 0; font-weight: 700; text-align: right; }
.calc-row.total { border-top: 1px solid var(--line); padding-top: 15px; margin-top: 2px; }
.calc-row.total dt { color: var(--ink); font-weight: 700; }
.calc-row.total dd { font-family: var(--serif); font-size: 22px; font-weight: 400; }
.method-note { margin: 19px 0 0; padding: 14px; border-radius: 12px; background: var(--paper-deep); color: #666d6a; font-size: 10px; line-height: 1.55; }
.method-note a { color: var(--brass-dark); }
.document-summary { border-top: 1px solid var(--line); padding: 18px 24px; }
.document-summary div { display: flex; align-items: center; justify-content: space-between; }
.document-summary strong { font-size: 12px; }
.document-summary span { color: #747a78; font-size: 11px; }
.panel-footer-actions { display: grid; grid-template-columns: repeat(auto-fit, minmax(112px, 1fr)); gap: 8px; border-top: 1px solid var(--line); padding: 17px 20px; }
.panel-footer-actions .btn { min-height: 38px; padding-inline: 12px; font-size: 12px; line-height: 1.15; white-space: nowrap; }
.judgment-action-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); row-gap: 13px; }
.judgment-action-grid .delete-judgment-button { grid-column: 1 / -1; justify-self: center; width: min(170px, calc(50% - 4px)); }

.legal-footer { max-width: 1180px; margin: 28px auto 0; color: #7b817e; font-size: 10px; line-height: 1.6; }
.legal-footer a { color: var(--brass-dark); }

.modal { width: min(700px, calc(100vw - 28px)); max-height: calc(100vh - 30px); padding: 0; border: 0; border-radius: 22px; color: var(--ink); background: var(--white); box-shadow: 0 35px 100px rgba(18, 24, 25, .28); }
.modal::backdrop { background: rgba(20, 26, 28, .62); backdrop-filter: blur(5px); }
.modal-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; padding: 25px 28px 20px; border-bottom: 1px solid var(--line); }
.modal-header h2 { font-family: var(--serif); font-size: 30px; font-weight: 400; margin: 5px 0 0; }
.modal-body { padding: 23px 28px; overflow: auto; }
.creation-status { margin: 0 0 18px; padding: 13px 15px; border: 1px solid #d9b668; border-radius: 11px; color: var(--ink); background: #fff8e8; }
.creation-status:focus { outline: 3px solid rgba(133, 93, 11, .28); outline-offset: 2px; }
.creation-status strong { display: block; margin-bottom: 4px; }
.creation-status p { margin: 0; color: var(--ink-soft); font-size: 13px; line-height: 1.55; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 17px; }
.hidden { display: none !important; }
.field { position: relative; margin-bottom: 17px; }
.form-grid .field { margin-bottom: 0; }
.field.full { margin-bottom: 17px; }
.field label { display: flex; justify-content: space-between; align-items: center; gap: 8px; font-size: 11px; font-weight: 700; margin-bottom: 7px; }
.field label span { color: #8b8f8c; font-size: 9px; text-transform: uppercase; letter-spacing: .06em; }
.field input, .field textarea { width: 100%; border: 1px solid var(--line); border-radius: 11px; background: #fffefa; color: var(--ink); padding: 11px 12px; }
.field input { height: 43px; }
.field textarea { resize: vertical; min-height: 74px; }
.field input:focus, .field textarea:focus { border-color: var(--brass); }
.field-hint { margin: 7px 0 0; color: #7a807e; font-size: 9px; line-height: 1.45; }
.ccp-options-menu {
  display: grid;
  gap: 4px;
  max-height: 214px;
  overflow: auto;
  margin-top: 8px;
  padding: 7px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fffefa;
  box-shadow: 0 13px 30px rgba(24, 32, 36, .12);
}
.ccp-options-menu[hidden] { display: none; }
.ccp-option {
  width: 100%;
  border: 0;
  border-radius: 9px;
  background: transparent;
  padding: 9px 10px;
  color: var(--ink);
  cursor: pointer;
  font-size: 11px;
  line-height: 1.35;
  text-align: left;
}
.ccp-option:hover, .ccp-option:focus { background: var(--paper-deep); outline: none; }
.ccp-option-empty { padding: 10px; color: #7a807e; font-size: 10px; line-height: 1.45; }
.money-field input { padding-left: 29px; }
.rate-field input { padding-right: 31px; }
.field-prefix, .field-suffix { position: absolute; bottom: 12px; color: #717775; font-size: 13px; }
.field-prefix { left: 12px; }
.field-suffix { right: 12px; }
.rate-note { display: flex; align-items: flex-start; gap: 10px; margin: 18px 0; padding: 13px 14px; border-radius: 11px; background: #f4ecdf; color: #5f625f; }
.rate-note svg { flex: 0 0 auto; width: 17px; fill: none; stroke: var(--brass-dark); stroke-width: 1.5; }
.rate-note p { font-size: 10px; line-height: 1.55; margin: 0; }
.modal-actions { display: flex; justify-content: flex-end; gap: 9px; padding: 16px 28px 21px; border-top: 1px solid var(--line); background: #faf7f0; }
.destructive-modal { width: min(610px, calc(100vw - 28px)); }
.destructive-modal .modal-header { border-top: 5px solid var(--red); }
.destructive-modal .modal-body p { margin: 0 0 14px; color: var(--ink-soft); font-size: 13px; line-height: 1.65; }
.destructive-modal .modal-body p:last-child { margin-bottom: 0; }
.destructive-modal .deletion-error { padding: 12px 14px; border-radius: 11px; color: var(--red); background: var(--red-soft); font-weight: 700; }

.entry-modal { width: min(590px, calc(100vw - 28px)); }
.entry-toggle { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; padding: 5px; margin-top: 17px; margin-bottom: 20px; background: var(--paper-deep); border-radius: 13px; }
.entry-type-button { min-width: 0; border: 0; display: grid; place-items: center; min-height: 39px; border-radius: 9px; color: #626866; background: transparent; font-size: 12px; font-weight: 700; cursor: pointer; }
.entry-type-button[aria-pressed="true"] { color: var(--ink); background: var(--white); box-shadow: 0 3px 12px rgba(24,32,36,.08); }
.entry-type-button:focus-visible { outline: 3px solid rgba(181, 138, 75, 0.38); outline-offset: 2px; }
.entry-fast-submit { width: 100%; margin: 0 0 20px; }
.entry-submit-button:focus-visible { outline: 3px solid var(--brass); outline-offset: 3px; box-shadow: 0 0 0 5px rgba(181, 138, 75, 0.22); }
.upload-zone { display: flex; align-items: center; gap: 13px; border: 1px dashed #c9baa2; border-radius: 13px; padding: 16px; background: #faf6ee; cursor: pointer; }
.upload-zone:hover { border-color: var(--brass); }
.upload-zone input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.upload-icon { flex: 0 0 auto; width: 40px; height: 40px; border-radius: 11px; display: grid; place-items: center; background: #ecdfcb; color: var(--brass-dark); }
.upload-icon svg { width: 21px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.upload-zone strong, .upload-zone small { display: block; }
.upload-zone strong { font-size: 12px; }
.upload-zone small { color: #777d7a; font-size: 9px; margin-top: 5px; }
.upload-disclosure { display: flex; align-items: flex-start; gap: 8px; margin: 10px 0 0; padding: 9px 11px; border-radius: 10px; background: #f4ecdf; color: #6a5324; }
.upload-disclosure svg { flex: 0 0 auto; width: 15px; margin-top: 1px; fill: none; stroke: var(--brass-dark); stroke-width: 1.5; }
.upload-disclosure span { font-size: 10px; line-height: 1.55; font-weight: 600; }
.selected-files { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 10px; }
.selected-file { display: inline-flex; align-items: center; gap: 6px; border-radius: 99px; background: var(--green-soft); color: var(--green); padding: 5px 9px; font-size: 9px; max-width: 320px; white-space: nowrap; }
.selected-file button { border: 0; padding: 0 1px; background: transparent; color: currentColor; font: inherit; font-size: 13px; line-height: 1; cursor: pointer; }
.existing-files { margin-top: 8px; }
.selected-file-note { background: var(--paper-deep); color: #6f7572; }
.entry-help { margin: 14px 0 0; color: #7a807e; font-size: 9px; line-height: 1.5; }

.toast-region { position: fixed; right: 20px; bottom: 20px; z-index: 100; display: grid; gap: 8px; }
.toast { color: #fff; background: var(--ink); border: 1px solid rgba(255,255,255,.12); border-radius: 12px; padding: 11px 15px; box-shadow: var(--shadow); font-size: 11px; animation: toast-in .22s ease both; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }

.mock-flow-overlay {
  position: fixed;
  inset: 0;
  z-index: 260;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(20, 26, 28, .66);
  backdrop-filter: blur(6px);
}
.mock-flow-card {
  width: min(920px, 100%);
  max-height: calc(100vh - 48px);
  overflow: auto;
  border-radius: 24px;
  background: var(--white);
  box-shadow: 0 35px 100px rgba(18, 24, 25, .32);
}
.mock-flow-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  padding: 27px 30px 21px;
  border-bottom: 1px solid var(--line);
}
.mock-flow-header h2 {
  font-family: var(--serif);
  font-weight: 400;
  font-size: 34px;
  margin: 5px 0 4px;
}
.mock-flow-header p { margin: 0; color: #707775; font-size: 12px; }
.mock-draft-summary {
  display: grid;
  grid-template-columns: 1.4fr 1fr 1fr;
  gap: 1px;
  margin: 0 30px;
  border: 1px solid var(--line);
  border-radius: 16px;
  overflow: hidden;
  background: var(--line);
}
.mock-draft-summary div, .mock-checkout-summary div, .mock-success-grid div {
  padding: 13px 15px;
  background: #faf6ee;
}
.mock-draft-summary span, .mock-checkout-summary span, .mock-success-grid span {
  display: block;
  color: #737a77;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
}
.mock-draft-summary strong, .mock-checkout-summary strong, .mock-success-grid strong {
  display: block;
  margin-top: 6px;
  font-size: 13px;
}
.mock-flow-body { padding: 24px 30px 30px; }
.mock-todo-note {
  margin-bottom: 18px;
  padding: 12px 14px;
  border: 1px dashed #d4bd92;
  border-radius: 13px;
  background: #fff8ea;
  color: #75684f;
  font-size: 10px;
  line-height: 1.55;
}
.mock-flow-error {
  margin: 18px 30px 0;
  padding: 11px 13px;
  border-radius: 12px;
  color: var(--red);
  background: var(--red-soft);
  font-size: 11px;
  font-weight: 700;
}
.mock-flow-actions { display: flex; justify-content: flex-end; gap: 9px; margin-top: 20px; }
.mock-plan-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}
.mock-plan-card {
  display: flex;
  flex-direction: column;
  min-height: 222px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(250, 246, 238, .82);
}
.mock-plan-card span { color: var(--brass-dark); font-size: 11px; font-weight: 700; }
.mock-plan-card h3 { font-family: var(--serif); font-size: 24px; font-weight: 400; line-height: 1.05; margin: 12px 0 9px; }
.mock-plan-card p { color: #6f7673; font-size: 11px; line-height: 1.5; margin: 0 0 18px; }
.mock-plan-card .btn { margin-top: auto; width: 100%; padding-inline: 10px; }
.mock-checkout-summary, .mock-success-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1px;
  margin-bottom: 18px;
  border: 1px solid var(--line);
  border-radius: 16px;
  overflow: hidden;
  background: var(--line);
}
.mock-confirmation-copy { color: #68706d; font-size: 12px; line-height: 1.7; margin: 0; }
.mock-trial-note { margin: 0 0 14px; padding: 10px 12px; border-radius: 12px; background: var(--paper-deep); color: var(--brass-dark); font-size: 12px; font-weight: 700; }

.export-options-overlay {
  position: fixed;
  inset: 0;
  z-index: 250;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(20, 26, 28, .66);
  backdrop-filter: blur(6px);
}
.export-options-card {
  width: min(980px, 100%);
  max-height: calc(100vh - 48px);
  overflow: auto;
  border-radius: 24px;
  background: var(--white);
  box-shadow: 0 35px 100px rgba(18, 24, 25, .32);
}
.export-options-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  padding: 27px 30px 21px;
  border-bottom: 1px solid var(--line);
}
.export-options-header h2 {
  font-family: var(--serif);
  font-weight: 400;
  font-size: 34px;
  margin: 5px 0 4px;
}
.export-options-header p { margin: 0; color: #707775; font-size: 12px; }
.export-mode-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  padding: 22px 30px;
}
.export-mode-grid label {
  min-height: 132px;
  display: block;
  border: 1px solid var(--line);
  border-radius: 17px;
  background: #faf6ee;
  padding: 15px;
  cursor: pointer;
}
.export-mode-grid input { margin: 0 0 10px; accent-color: var(--brass-dark); }
.export-mode-grid strong, .export-mode-grid small { display: block; }
.export-mode-grid strong { font-family: var(--serif); font-size: 20px; font-weight: 400; line-height: 1.08; }
.export-mode-grid small { margin-top: 8px; color: #707775; font-size: 10px; line-height: 1.45; }

/* Saved-dashboard Generate Report modal (mirrors the approved public modal). */
.report-scope-overlay { position: fixed; inset: 0; z-index: 270; display: grid; place-items: center; padding: 24px; background: rgba(20, 26, 28, .66); backdrop-filter: blur(6px); }
.report-scope-card { width: min(560px, 100%); max-height: calc(100vh - 48px); overflow: auto; border-radius: 24px; background: var(--white); box-shadow: 0 35px 100px rgba(18, 24, 25, .32); }
.report-scope-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; padding: 26px 28px 18px; border-bottom: 1px solid var(--line); }
.report-scope-header h2 { font-family: var(--serif); font-weight: 400; font-size: 30px; margin: 6px 0 5px; }
.report-scope-header p { margin: 0; color: #707775; font-size: 12.5px; line-height: 1.5; }
.report-scope-body { padding: 22px 28px 26px; }
.report-scope-options { display: grid; gap: 12px; }
.report-scope-option { display: flex; gap: 12px; align-items: flex-start; padding: 14px 16px; border: 1px solid var(--line); border-radius: 14px; cursor: pointer; transition: border-color .16s ease, background .16s ease; }
.report-scope-option input[type="radio"], .report-scope-docs input[type="checkbox"] { flex: 0 0 auto; width: auto; min-height: 0; margin: 2px 0 0; padding: 0; accent-color: var(--brass); }
.report-scope-option > span, .report-scope-docs > span { min-width: 0; }
.report-scope-option strong, .report-scope-docs strong { display: block; font-size: 14px; }
.report-scope-option small, .report-scope-docs small { display: block; margin-top: 3px; color: #707775; font-size: 11.5px; line-height: 1.45; }
.report-scope-option.is-selected { border-color: var(--brass); background: var(--paper-deep); }
.report-scope-range { margin-top: 16px; }
.report-scope-docs { display: flex; gap: 12px; align-items: flex-start; margin-top: 16px; padding: 14px 16px; border: 1px solid var(--line); border-radius: 14px; cursor: pointer; }
.report-scope-docs[hidden] { display: none; }
.report-scope-docs-none { margin: 14px 0 0; color: #707775; font-size: 11.5px; }
.report-scope-error { margin: 10px 0 0; color: var(--red); font-size: .82rem; font-weight: 700; }
.report-scope-actions { display: flex; justify-content: flex-end; gap: 9px; margin-top: 22px; }
.report-scope-overlay .btn:focus-visible, .report-scope-overlay .icon-btn:focus-visible { outline: 3px solid var(--brass); outline-offset: 3px; }
@media (max-width: 700px) { .report-scope-overlay { padding: 12px; } }
.export-doc-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin: 0 30px;
  padding: 14px 0;
  border-top: 1px solid var(--line);
}
.export-doc-toolbar strong, .export-doc-toolbar span { display: block; }
.export-doc-toolbar strong { font-size: 13px; }
.export-doc-toolbar span { color: #747a78; font-size: 10px; margin-top: 3px; }
.export-doc-toolbar > div:last-child { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 12px; }
.export-warning, .export-merge-note, .export-empty-docs {
  margin: 0 30px 12px;
  padding: 11px 13px;
  border-radius: 12px;
  font-size: 10px;
  line-height: 1.55;
}
.export-warning { color: var(--red); background: var(--red-soft); }
.export-merge-note { color: #75684f; background: #fff8ea; border: 1px dashed #d4bd92; }
.export-empty-docs { color: #737a77; background: var(--paper-deep); text-align: center; }
.export-doc-list {
  display: grid;
  gap: 8px;
  margin: 0 30px 14px;
}
.export-doc-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) minmax(190px, auto) auto;
  gap: 12px;
  align-items: center;
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fffefa;
}
.export-doc-row input { accent-color: var(--brass-dark); }
.export-doc-main { min-width: 0; }
.export-doc-main strong, .export-doc-main small, .export-doc-main em { display: block; }
.export-doc-main strong { font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.export-doc-main small { margin-top: 4px; color: #717775; font-size: 9px; }
.export-doc-main em { margin-top: 4px; color: #7f8582; font-size: 9px; font-style: normal; }
.export-doc-status {
  justify-self: end;
  border-radius: 999px;
  padding: 5px 8px;
  font-size: 9px;
  font-weight: 700;
  text-align: right;
}
.export-doc-status.can-append { color: var(--green); background: var(--green-soft); }
.export-doc-status.cannot-append { color: var(--red); background: var(--red-soft); }
.export-options-actions {
  display: flex;
  justify-content: flex-end;
  gap: 9px;
  padding: 17px 30px 25px;
  border-top: 1px solid var(--line);
  background: #faf7f0;
}

.report-overlay { position: fixed; inset: 0; z-index: 200; display: grid; grid-template-rows: 72px 1fr; background: #d8d4cc; }
.report-toolbar { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 20px; padding: 0 24px; color: #fff; background: var(--ink); box-shadow: 0 5px 22px rgba(0,0,0,.18); }
.report-toolbar-title { min-width: 0; text-align: center; }
.report-toolbar strong, .report-toolbar span { display: block; }
.report-toolbar strong { font-family: var(--serif); font-size: 17px; font-weight: 400; }
.report-toolbar span { margin-top: 3px; color: #aeb6b3; font-size: 9px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.report-toolbar .report-export-note { color: #f1d9ac; }
.report-toolbar .btn:first-child { justify-self: start; color: #fff; border-color: rgba(255,255,255,.25); }
.report-toolbar-actions { justify-self: end; display: flex; justify-content: flex-end; gap: 8px; }
.report-toolbar-actions .btn-quiet { color: #fff; border-color: rgba(255,255,255,.25); }
.report-toolbar-actions .btn-primary { background: var(--brass-dark); }
.report-overlay iframe { width: 100%; height: 100%; border: 0; background: #d8d4cc; }
.print-root { display: none; }

@media (max-width: 1050px) {
  .workspace { grid-template-columns: 245px minmax(0, 1fr); }
  .summary-grid { grid-template-columns: 1.4fr 1fr; }
  .content-grid { grid-template-columns: 1fr; }
  .calculation-panel { position: static; }
  .mock-plan-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .export-mode-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .export-doc-row { grid-template-columns: auto minmax(0, 1fr); }
  .export-doc-status, .export-doc-row .text-btn { justify-self: start; grid-column: 2; }
}

@media (max-width: 760px) {
  .topbar { min-height: 70px; height: 70px; padding: 0 16px; }
  .brand-mark { width: min(190px, 50vw); height: 46px; max-height: 46px; }
  .brand-mark img { max-height: 46px; }
  .brand strong { font-size: 11px; }
  .brand small, .privacy-chip { display: none; }
  .topbar-actions { gap: 8px; }
  .account-trigger { max-width: none; padding-right: 5px; }
  .account-trigger-copy, .account-status, .account-trigger > svg { display: none; }
  .topbar .btn { min-height: 40px; padding: 0 14px; }
  .workspace { display: block; }
  .sidebar { position: static; height: auto; min-height: 0; padding: 12px 14px; border-right: 0; border-bottom: 1px solid var(--line); }
  .sidebar-heading, .search-box, .sidebar-footer { display: none; }
  .matter-list { flex-direction: row; overflow-x: auto; padding-bottom: 2px; }
  .matter-item { min-width: 195px; background: rgba(255,253,248,.55); padding: 10px 12px; }
  .main-content { padding: 27px 16px 55px; }
  .empty-state { min-height: 560px; }
  .empty-state h1 { font-size: 44px; }
  .matter-header { display: block; }
  .matter-title-wrap h1 { white-space: normal; font-size: 38px; }
  .header-actions { justify-content: flex-start; }
  .summary-grid { grid-template-columns: 1fr 1fr; }
  .summary-card.primary { grid-column: 1 / -1; }
  .summary-card { min-height: 110px; padding: 17px; }
  .summary-card strong { font-size: 25px; }
  .summary-card:last-child { grid-column: 1 / -1; }
  .panel-header { align-items: flex-start; padding: 19px; }
  .panel-header .btn { font-size: 0; width: 42px; padding: 0; }
  .panel-header .btn::first-letter { font-size: 16px; }
  .as-of-control { padding: 11px 19px; flex-wrap: wrap; }
  .inline-entry-header { padding: 18px 19px 13px; }
  .inline-entry-body { padding-left: 19px; padding-right: 19px; }
  .inline-entry-actions { padding-left: 19px; padding-right: 19px; }
  .as-of-control span { width: 100%; margin: 0; }
  .ledger-row { grid-template-columns: 40px minmax(0,1fr) auto; gap: 10px; padding: 15px 17px; }
  .entry-balance { grid-column: 2 / -1; text-align: left; }
  .entry-menu { display: flex; }
  .entry-details { grid-column: 2 / -1; }
  .modal-body, .modal-header, .modal-actions { padding-left: 20px; padding-right: 20px; }
  .form-grid { grid-template-columns: 1fr; }
  .report-toolbar { grid-template-columns: auto 1fr; gap: 8px; padding: 0 12px; }
  .report-toolbar-title { display: none; }
  .report-toolbar-actions { display: flex; justify-self: end; }
  .report-toolbar-actions [data-browser-print] { display: none; }
  .report-toolbar .btn { min-height: 40px; padding-inline: 12px; }
  .mock-flow-overlay { padding: 12px; }
  .mock-flow-header, .mock-flow-body { padding-left: 20px; padding-right: 20px; }
  .mock-draft-summary, .mock-checkout-summary, .mock-success-grid, .mock-plan-grid { grid-template-columns: 1fr; }
  .mock-draft-summary { margin: 0 20px; }
  .export-options-overlay { padding: 12px; }
  .export-options-header { padding-left: 20px; padding-right: 20px; }
  .export-mode-grid { grid-template-columns: 1fr; padding-left: 20px; padding-right: 20px; }
  .export-doc-toolbar { display: block; margin-left: 20px; margin-right: 20px; }
  .export-doc-toolbar > div:last-child { justify-content: flex-start; margin-top: 10px; }
  .export-doc-list, .export-warning, .export-merge-note, .export-empty-docs { margin-left: 20px; margin-right: 20px; }
  .export-options-actions { padding-left: 20px; padding-right: 20px; }
}

@media (max-width: 480px) {
  #newMatterBtn { width: 40px; padding: 0; font-size: 0; }
  #newMatterBtn span { font-size: 16px; }
  .judgment-action-grid { grid-template-columns: 1fr; }
  .judgment-action-grid .delete-judgment-button { grid-column: auto; width: 100%; margin-top: 2px; }
}

@media print {
  body.printing-report { background: #fff; }
  body.printing-report > :not(.print-root) { display: none !important; }
  body.printing-report .print-root { display: block !important; }
  .topbar, .sidebar, .header-actions, .panel-footer-actions, .ledger-actions { display: none !important; }
  .workspace, .content-grid { display: block; }
  .main-content { padding: 0; }
  .panel, .summary-card { box-shadow: none; break-inside: avoid; }
  .calculation-panel { margin-top: 18px; }
}

/* ---------------------------------------------------------------------------
   Auth gate: sign-in, expired-trial lock, and unavailable screens for /dashboard
   --------------------------------------------------------------------------- */

.auth-gate {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 32px 20px;
  background: var(--paper);
}

.auth-gate[hidden] { display: none; }

.auth-gate-inner { width: min(560px, 100%); }

/* The sign-in card reuses the saved-ledger overlay chrome. */
.auth-gate .mock-flow-overlay {
  position: static;
  padding: 0;
  background: transparent;
  backdrop-filter: none;
}

.auth-note {
  margin: 10px 0 0;
  padding: 10px 12px;
  border-radius: 12px;
  background: var(--paper-deep);
  color: var(--ink);
  font-size: 12px;
}

.auth-note[hidden] { display: none; }

.locked-card,
.save-error-card {
  padding: 34px 32px 30px;
  border-radius: 20px;
  border: 1px solid var(--line);
  background: var(--white);
  box-shadow: 0 26px 60px rgba(23, 27, 29, 0.16);
  text-align: left;
}

.locked-card h1,
.save-error-card h1 {
  margin: 10px 0 14px;
  font-family: "Libre Caslon Display", serif;
  font-size: 26px;
  line-height: 1.25;
}

.locked-preserved { margin: 0 0 10px; font-size: 14px; font-weight: 600; }
.locked-choose { margin: 0 0 20px; color: var(--ink-soft); font-size: 13px; line-height: 1.7; }
.locked-card .btn,
.save-error-card .btn { width: 100%; justify-content: center; }
.locked-card .btn[disabled] { opacity: 0.65; cursor: not-allowed; }
.locked-note { margin: 12px 0 0; color: var(--ink-soft); font-size: 11px; text-align: center; }

.locked-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 24px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
  color: var(--ink-soft);
  font-size: 12px;
}

#signOutBtn[hidden] { display: none; }

@media print {
  .auth-gate { display: none; }
}
