:root {
  --ink: #0c100e;
  --panel: #141a16;
  --panel-2: #1b231e;
  --panel-3: #232c26;
  --line: rgba(232, 220, 196, 0.12);
  --text: #f6f1e6;
  --muted: #a39888;
  --faint: #6f675c;
  --brass: #e0c08a;
  --brass-deep: #b8894e;
  --saffron: #e08a45;
  --sage: #8eae86;
  --rose: #d86b58;
  --sky: #8eb4c9;
  --paper: #f3ead7;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.35);
  --serif: "Fraunces", "Iowan Old Style", Georgia, serif;
  --sans: "Outfit", "Avenir Next", sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, monospace;
  --nav: 72px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --space-1: 6px;
  --space-2: 10px;
  --space-3: 14px;
  --space-4: 18px;
  --space-5: 24px;
  --gap: 14px;
  --radius: 16px;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background:
    radial-gradient(900px 480px at 90% -10%, rgba(224, 192, 138, 0.08), transparent 50%),
    linear-gradient(180deg, #101612 0%, var(--ink) 40%);
  color: var(--text);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.45;
  letter-spacing: 0.01em;
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font-family: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--brass); }
p { margin: 0; }
b, strong { font-weight: 600; }

.app { min-height: 100%; }

/* Login */
.login {
  min-height: 100%;
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
}
.login-story {
  padding: 36px 48px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  border-right: 1px solid var(--line);
  background:
    linear-gradient(160deg, rgba(224, 192, 138, 0.08), transparent 40%),
    #101612;
}
.mark {
  display: flex;
  align-items: center;
  gap: 12px;
  font-weight: 560;
  letter-spacing: 0.18em;
  font-size: 12px;
  text-transform: uppercase;
}
.seal {
  width: 36px;
  height: 36px;
  border: 1px solid var(--brass);
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: var(--brass);
  font-family: var(--serif);
  font-size: 16px;
  flex-shrink: 0;
}
.login h1 {
  font-family: var(--serif);
  font-weight: 460;
  font-size: clamp(40px, 5vw, 68px);
  line-height: 0.95;
  margin: 24px 0 12px;
  max-width: 10ch;
}
.login h1 em { font-style: italic; color: var(--brass); }
.lede { max-width: 42ch; color: var(--muted); line-height: 1.55; }
.docket-preview {
  margin-top: 36px;
  border: 1px solid var(--line);
  background: rgba(20, 26, 22, 0.7);
  border-radius: var(--radius);
  overflow: hidden;
}
.docket-preview header,
.panel header.bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  min-height: 44px;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.panel header.bar > span:first-child {
  min-width: 0;
  overflow-wrap: anywhere;
}
.row-item {
  display: grid;
  grid-template-columns: 72px 1fr auto;
  gap: 10px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  align-items: center;
}
.row-item:last-child { border-bottom: 0; }
.time { font-family: var(--mono); font-size: 12px; color: var(--brass); white-space: nowrap; }
.login-panel {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 28px 20px;
}
.card {
  width: min(420px, 100%);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 22px;
  box-shadow: var(--shadow);
}
.card h2 { font-family: var(--serif); font-weight: 500; margin: 0 0 6px; font-size: 28px; line-height: 1.15; }
.sub { color: var(--muted); margin: 0 0 18px; line-height: 1.45; }
label { display: block; font-size: 12px; color: var(--muted); margin: 12px 0 6px; letter-spacing: 0.04em; }
input, select, textarea {
  width: 100%;
  background: var(--ink);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 11px 12px;
  outline: none;
  line-height: 1.35;
}
textarea { min-height: 90px; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--brass-deep); }
.roles { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 8px 0 14px; }
.role-btn, .btn, .btn-ghost, .chip {
  border-radius: 999px;
  border: 1px solid var(--line);
  background: transparent;
  padding: 10px 14px;
  line-height: 1.2;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  white-space: nowrap;
}
.role-btn.active, .chip.active {
  background: var(--paper);
  color: #1b140c;
  border-color: var(--paper);
}
.btn {
  background: var(--brass);
  color: #1c140c;
  border-color: var(--brass);
  font-weight: 600;
  width: 100%;
}
.btn.inline, .btn-ghost { width: auto; }
.btn-ghost { color: var(--text); }
.btn-ghost.danger { color: var(--rose); border-color: rgba(216, 107, 88, 0.4); }
.fine { margin-top: 12px; color: var(--faint); font-size: 12px; line-height: 1.4; }

/* Shell */
.shell { display: grid; grid-template-columns: 228px 1fr; min-height: 100%; }
.side {
  border-right: 1px solid var(--line);
  padding: 18px 12px 24px;
  position: sticky;
  top: 0;
  height: 100vh;
  background: rgba(12, 16, 14, 0.92);
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.side nav { display: flex; flex-direction: column; gap: 2px; margin-top: 22px; }
.nav-btn {
  text-align: left;
  background: transparent;
  border: 0;
  color: var(--muted);
  padding: 10px 12px;
  border-radius: 10px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  line-height: 1.25;
  min-width: 0;
}
.nav-btn.active { background: var(--panel-2); color: var(--text); }
.nav-btn span.count {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--brass);
  flex-shrink: 0;
}
.side .foot {
  margin-top: auto;
  padding: 12px 10px 4px;
  color: var(--faint);
  font-size: 12px;
  line-height: 1.45;
  overflow-wrap: anywhere;
}
.main { min-width: 0; display: flex; flex-direction: column; }
.top {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  background: rgba(12, 16, 14, 0.9);
  backdrop-filter: blur(10px);
  z-index: 5;
}
.search {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0 14px;
  min-height: 42px;
}
.search .mono {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  color: var(--faint);
  flex-shrink: 0;
}
.search input {
  border: 0;
  background: transparent;
  padding: 10px 0;
  min-width: 0;
  flex: 1;
}
.who {
  font-size: 13px;
  color: var(--muted);
  white-space: nowrap;
  line-height: 1.3;
  display: flex;
  align-items: center;
}
.content {
  padding: 18px 18px 96px;
  display: flex;
  flex-direction: column;
  gap: 0;
  min-width: 0;
}
.kicker {
  color: var(--brass);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  font-size: 11px;
  margin: 0 0 8px;
  line-height: 1.35;
}
h1.page, h2.page {
  font-family: var(--serif);
  font-weight: 500;
  margin: 0;
  letter-spacing: -0.02em;
  line-height: 1.12;
  overflow-wrap: anywhere;
}
h1.page { font-size: clamp(30px, 3.6vw, 44px); }
.page-head {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: center;
  margin: 10px 0 16px;
  flex-wrap: wrap;
  min-width: 0;
}
.page-head > div { min-width: 0; flex: 1 1 220px; }
.page-head > .stamp,
.page-head > .btn,
.page-head > .btn-ghost {
  flex-shrink: 0;
  align-self: center;
}
.content > .btn-ghost[data-action="back"] {
  align-self: flex-start;
  margin: 4px 0 0;
  padding: 8px 12px;
}

.grid-2, .grid-3, .matter-hero {
  align-items: stretch;
}
.grid-2 { display: grid; grid-template-columns: 1.35fr 0.85fr; gap: var(--gap); }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--gap); }
.matter-hero {
  display: grid;
  grid-template-columns: 1.35fr 0.85fr;
  gap: var(--gap);
  margin-bottom: var(--gap);
}
.grid-2 + .grid-2,
.matter-hero + .grid-2,
.grid-3 + .grid-2,
.grid-3 + .panel,
.filters + .panel {
  margin-top: 0;
}

.panel {
  background: rgba(20, 26, 22, 0.88);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  min-width: 0;
  display: flex;
  flex-direction: column;
}
.panel .pad {
  padding: 16px 16px 14px;
  min-width: 0;
}
.panel.pad {
  padding: 16px;
}
.stat {
  padding: 16px;
  gap: 6px;
}
.stat b {
  display: block;
  font-family: var(--serif);
  font-size: 28px;
  font-weight: 500;
  line-height: 1.1;
  margin-top: 4px;
  overflow-wrap: anywhere;
}
.stat span {
  color: var(--muted);
  font-size: 12px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  line-height: 1.3;
}
.stamp {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 11px;
  letter-spacing: 0.04em;
  color: var(--paper);
  text-transform: uppercase;
  line-height: 1.2;
  white-space: nowrap;
  height: fit-content;
}
.stamp.pending { color: var(--brass); border-color: rgba(224, 192, 138, 0.4); }
.stamp.hearing { color: var(--sky); border-color: rgba(142, 180, 201, 0.45); }
.stamp.overdue, .stamp.risk { color: var(--rose); border-color: rgba(216, 107, 88, 0.45); }
.stamp.ok, .stamp.paid { color: var(--sage); border-color: rgba(142, 174, 134, 0.45); }

.list-btn {
  width: 100%;
  text-align: left;
  background: transparent;
  border: 0;
  border-bottom: 1px solid var(--line);
  padding: 14px 16px;
  display: grid;
  gap: 6px;
  align-content: start;
  min-width: 0;
  line-height: 1.35;
}
.list-btn:last-child { border-bottom: 0; }
.list-btn:hover { background: rgba(255,255,255,0.03); }
.list-btn > b {
  overflow-wrap: anywhere;
  line-height: 1.35;
}
.list-btn > .actions {
  margin-top: 4px;
  justify-content: flex-start;
}
.meta {
  color: var(--muted);
  font-size: 12px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
  line-height: 1.4;
  min-width: 0;
  overflow-wrap: anywhere;
}
.mono { font-family: var(--mono); font-size: 12px; }

/* Multi-line detail blocks must NOT use flex meta */
.detail-block {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.65;
  overflow-wrap: anywhere;
}
.detail-block strong,
.panel.pad > p:first-child {
  color: var(--text);
  font-size: 14px;
  line-height: 1.45;
  margin: 0;
  overflow-wrap: anywhere;
}
.panel.pad > .actions {
  margin-top: 16px;
}

.tabs { display: flex; gap: 8px; flex-wrap: wrap; margin: 8px 0 14px; }
.filters {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin: 0 0 14px;
  align-items: center;
}

.timeline { display: flex; flex-direction: column; }
.tl {
  position: relative;
  display: grid;
  grid-template-columns: 16px 1fr;
  gap: 12px;
  padding: 0 16px 16px;
  align-items: start;
  min-width: 0;
}
.tl:first-of-type { padding-top: 14px; }
.tl:last-child { padding-bottom: 16px; }
.tl::before {
  content: "";
  position: absolute;
  left: 19px;
  top: 0;
  bottom: 0;
  width: 1px;
  background: var(--line);
}
.tl:first-of-type::before { top: 20px; }
.tl:last-child::before { bottom: 16px; }
.tl > .dot { position: relative; z-index: 1; }
.tl > div:last-child {
  min-width: 0;
  display: grid;
  gap: 4px;
  padding-top: 0;
}
.tl > div:last-child > b {
  line-height: 1.35;
  overflow-wrap: anywhere;
}
.tl .meta {
  display: block;
  line-height: 1.45;
}
.dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--brass);
  margin-top: 5px;
  margin-left: 3px;
  box-shadow: 0 0 0 4px rgba(224, 192, 138, 0.12);
  flex-shrink: 0;
}

.modal-back {
  position: fixed; inset: 0;
  background: rgba(5, 7, 6, 0.72);
  display: grid; place-items: center;
  z-index: 20;
  padding: 16px;
}
.modal {
  width: min(560px, 100%);
  background: #171e19;
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 18px;
  max-height: min(88vh, 760px);
  overflow: auto;
}
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-grid .full { grid-column: 1 / -1; }
.form-grid label { margin-top: 0; }
.actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  align-items: center;
  flex-wrap: wrap;
  margin-top: 14px;
}
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--nav) + var(--safe-b) + 12px);
  transform: translateX(-50%);
  background: var(--paper);
  color: #1b140c;
  padding: 10px 14px;
  border-radius: 999px;
  z-index: 30;
  font-size: 13px;
  line-height: 1.3;
}
.bottom-nav, .menu-btn { display: none; }
.search-pop {
  position: absolute;
  top: 58px;
  left: 246px;
  right: 18px;
  background: #171e19;
  border: 1px solid var(--line);
  border-radius: 14px;
  z-index: 8;
  max-height: 320px;
  overflow: auto;
  box-shadow: var(--shadow);
}
.ai-log { display: flex; flex-direction: column; gap: 10px; }
.bubble {
  padding: 12px 14px;
  border-radius: 14px;
  line-height: 1.5;
  border: 1px solid var(--line);
  overflow-wrap: anywhere;
}
.bubble.user { background: #243028; margin-left: 18%; }
.bubble.bot { background: #151b17; margin-right: 8%; }
.note { color: var(--faint); font-size: 12px; line-height: 1.45; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td {
  text-align: left;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
  line-height: 1.4;
  overflow-wrap: anywhere;
}
th { color: var(--muted); font-weight: 500; font-size: 11px; letter-spacing: 0.06em; text-transform: uppercase; }
tr:last-child td { border-bottom: 0; }
.split { display: grid; grid-template-columns: 280px 1fr; min-height: 60vh; align-items: stretch; }
.side-list { border-right: 1px solid var(--line); min-width: 0; }
.empty {
  padding: 24px 16px;
  color: var(--muted);
  line-height: 1.5;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}
.portal-banner {
  background: linear-gradient(90deg, rgba(224, 192, 138, 0.15), transparent);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px 16px;
  margin-bottom: 12px;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

@media (max-width: 980px) {
  .login { grid-template-columns: 1fr; }
  .login-story { display: none; }
  .shell { grid-template-columns: 1fr; }
  .side { display: none; }
  .side.open {
    display: flex;
    position: fixed;
    inset: 0 auto 0 0;
    width: min(280px, 86vw);
    z-index: 15;
    height: 100%;
  }
  .menu-btn, .bottom-nav { display: flex; }
  .grid-2, .grid-3, .matter-hero, .split, .form-grid { grid-template-columns: 1fr; }
  .search-pop { left: 12px; right: 12px; }
  .content { padding: 14px 14px 110px; }
  .bottom-nav {
    position: fixed;
    left: 0; right: 0; bottom: 0;
    height: calc(var(--nav) + var(--safe-b));
    padding-bottom: var(--safe-b);
    background: rgba(12, 16, 14, 0.96);
    border-top: 1px solid var(--line);
    z-index: 12;
    justify-content: space-around;
    align-items: center;
  }
  .bottom-nav button {
    background: transparent;
    border: 0;
    color: var(--faint);
    font-size: 11px;
    letter-spacing: 0.04em;
    padding: 8px;
    line-height: 1.2;
  }
  .bottom-nav button.active { color: var(--brass); }
  .row-item { grid-template-columns: 64px 1fr; }
  .row-item .hide-sm { display: none; }
}

.btn-ghost.tiny, .tiny {
  padding: 5px 10px;
  font-size: 11px;
  letter-spacing: 0.04em;
  min-height: 28px;
}
header.bar .btn-ghost.tiny,
header.bar .tiny {
  margin-left: auto;
  flex-shrink: 0;
}
.passage {
  margin-top: 6px;
  line-height: 1.55;
  color: var(--text);
  font-size: 13px;
  overflow-wrap: anywhere;
}
.doc-body {
  margin-top: 12px;
  padding: 14px;
  background: var(--ink);
  border: 1px solid var(--line);
  border-radius: 12px;
  line-height: 1.55;
  white-space: pre-wrap;
  min-height: 120px;
  overflow-wrap: anywhere;
}
.draft-out {
  white-space: pre-wrap;
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1.5;
  color: var(--muted);
  min-height: 48px;
  margin: 0;
  overflow-wrap: anywhere;
}
.settings-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--gap);
  margin-top: 14px;
}
.chips-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 12px;
  align-items: center;
}
.ai-form {
  margin-top: 12px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}
.ai-form select { max-width: 260px; }
.ai-form input { flex: 1; min-width: 180px; }
.bar-track {
  height: 6px;
  background: var(--panel-3);
  border-radius: 999px;
  overflow: hidden;
  margin-top: 8px;
}
.bar-fill {
  height: 100%;
  background: var(--brass);
  border-radius: 999px;
}
.modal h2 {
  font-family: var(--serif);
  font-weight: 500;
  margin: 0 0 14px;
  font-size: 26px;
  line-height: 1.15;
}
.modal textarea { min-height: 110px; }
.demo-accounts { margin-top: 8px; }
.login .roles { margin-top: 4px; }

.tenancy-chip {
  margin-top: 14px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  display: grid;
  gap: 4px;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.35;
}
.tenancy-chip .mono { color: var(--brass); }
.tenancy-card {
  margin-top: 28px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  background: rgba(20, 26, 22, 0.7);
}
.tenancy-card header {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.tenancy-row {
  display: grid;
  grid-template-columns: 140px 1fr;
  gap: 10px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  font-size: 13px;
  color: var(--muted);
}
.tenancy-row:last-child { border-bottom: 0; }
.tenancy-row b { color: var(--text); font-weight: 560; }

.upload-zone {
  border: 1px dashed rgba(224, 192, 138, 0.35);
  border-radius: 14px;
  padding: 14px;
  display: grid;
  gap: 8px;
  background: rgba(12, 16, 14, 0.35);
}
.upload-zone input[type="file"] {
  padding: 8px 0;
  border: 0;
  background: transparent;
}
.cyber-box {
  margin-top: 14px;
  padding: 14px;
  border: 1px solid rgba(224, 138, 69, 0.35);
  border-radius: 14px;
  background: rgba(224, 138, 69, 0.06);
}
.cyber-box.hidden { display: none; }
.suggest-box {
  border-top: 1px solid var(--line);
  background: rgba(12, 16, 14, 0.35);
}
.search-inline {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
  margin: 12px 0 14px;
}
.search-inline input { flex: 1; min-width: 200px; }
.compare-list { display: grid; gap: 12px; }
.compare-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(20, 26, 22, 0.88);
  padding: 14px 16px;
  display: grid;
  gap: 10px;
}
.compare-cols {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 12px;
  align-items: start;
}
.compare-arrow {
  color: var(--brass);
  font-family: var(--serif);
  font-size: 22px;
  padding-top: 18px;
}
.table-wrap { overflow: auto; }
.table-wrap table { min-width: 720px; }

@media (max-width: 980px) {
  .settings-grid { grid-template-columns: 1fr; }
  .modal-back { place-items: end center; }
  .modal { border-radius: 18px 18px 12px 12px; width: 100%; }
  .page-head { align-items: flex-start; }
  .tl::before { left: 19px; }
  .compare-cols { grid-template-columns: 1fr; }
  .compare-arrow { padding-top: 0; transform: rotate(90deg); justify-self: center; }
  .tenancy-row { grid-template-columns: 1fr; }
  .side { width: min(300px, 90vw); }
}
