:root {
  --ink: #17221f;
  --muted: #68746f;
  --line: #dfe5e1;
  --canvas: #f3f5f2;
  --paper: #fff;
  --nav: #102923;
  --nav-muted: #9bb0aa;
  --accent: #0f8a70;
  --accent-dark: #076c58;
  --accent-soft: #e1f4ee;
  --gold: #d69d38;
  --gold-soft: #fff3db;
  --danger: #c64747;
  --danger-soft: #fde9e7;
  --blue: #3d73c6;
  --blue-soft: #e9f0fc;
  --shadow: 0 12px 34px rgba(27, 48, 41, .08);
  --radius: 14px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--canvas);
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body { background: var(--canvas); font-size: 14px; }
button, input, select, textarea { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; }
a { color: inherit; text-decoration: none; }

.app-shell { display: grid; grid-template-columns: 240px minmax(0, 1fr); min-height: 100vh; }
.sidebar { position: sticky; top: 0; height: 100vh; padding: 22px 14px 16px; background: var(--nav); color: #fff; display: flex; flex-direction: column; z-index: 30; }
.brand { display: flex; gap: 11px; align-items: center; padding: 0 9px 25px; }
.brand-mark { width: 36px; height: 36px; border-radius: 11px; display: grid; place-items: center; background: linear-gradient(145deg, #45c2a2, #128069); font-family: Georgia, serif; font-size: 22px; box-shadow: inset 0 0 0 1px rgba(255,255,255,.25); }
.brand strong, .brand span { display: block; }
.brand strong { font-family: Georgia, serif; font-size: 18px; font-weight: 600; letter-spacing: .1px; }
.brand span { color: var(--nav-muted); font-size: 11px; margin-top: 1px; }
nav { display: grid; gap: 4px; }
nav a, .sidebar-bottom > a { min-height: 42px; padding: 0 12px; border-radius: 9px; display: flex; align-items: center; gap: 11px; color: #c2d0cc; font-weight: 550; transition: .18s ease; }
nav a > span, .sidebar-bottom > a > span { width: 19px; text-align: center; color: #91aaa3; font-size: 17px; }
nav a:hover, .sidebar-bottom > a:hover { background: rgba(255,255,255,.06); color: #fff; }
nav a.active, .sidebar-bottom > a.active { background: rgba(54, 194, 155, .16); color: #effff9; }
nav a.active > span { color: #4bd2ad; }
.nav-badge { margin-left: auto; min-width: 22px; height: 20px; padding: 0 6px; border-radius: 99px; background: #d9a242; color: #17221f; display: grid; place-items: center; font-size: 11px; }
.sidebar-bottom { margin-top: auto; display: grid; gap: 13px; }
.demo-user { border-top: 1px solid rgba(255,255,255,.1); padding: 16px 8px 2px; display: flex; align-items: center; gap: 10px; }
.demo-user strong, .demo-user span { display: block; }
.demo-user strong { font-size: 12px; }
.demo-user span { font-size: 10px; color: var(--nav-muted); margin-top: 2px; }
.avatar { flex: 0 0 auto; width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; background: #d4eae3; color: #164b3f; font-weight: 750; font-size: 11px; }
.avatar.small { width: 32px; height: 32px; }

.main-shell { min-width: 0; }
.topbar { height: 65px; padding: 0 30px; border-bottom: 1px solid var(--line); background: rgba(255,255,255,.92); backdrop-filter: blur(14px); display: flex; align-items: center; justify-content: space-between; position: sticky; top: 0; z-index: 20; }
.global-search { display: flex; align-items: center; gap: 8px; width: min(430px, 50vw); color: var(--muted); }
.global-search input { border: 0; outline: 0; background: transparent; width: 100%; color: var(--ink); }
.topbar-actions { display: flex; gap: 12px; align-items: center; }
.environment-pill { padding: 7px 10px; display: flex; align-items: center; gap: 6px; border: 1px solid #d5e5df; background: #f3faf7; border-radius: 99px; color: #37675b; font-size: 11px; font-weight: 650; }
.environment-pill i { width: 6px; height: 6px; border-radius: 50%; background: #29a37f; box-shadow: 0 0 0 3px rgba(41,163,127,.14); }
.icon-button { border: 1px solid var(--line); background: var(--paper); width: 34px; height: 34px; border-radius: 9px; color: var(--ink); display: grid; place-items: center; }
.icon-button:hover { background: #f7f9f7; }
.page { padding: 30px; max-width: 1600px; margin: 0 auto; }
.mobile-only { display: none; }

.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; margin-bottom: 25px; }
.eyebrow { color: var(--accent); text-transform: uppercase; letter-spacing: .11em; font-size: 10px; font-weight: 800; margin-bottom: 7px; }
h1, h2, h3, p { margin-top: 0; }
h1 { font-family: Georgia, serif; font-weight: 500; font-size: clamp(27px, 3vw, 38px); line-height: 1.08; margin-bottom: 7px; letter-spacing: -.5px; }
h2 { font-family: Georgia, serif; font-weight: 550; font-size: 21px; margin-bottom: 5px; }
h3 { font-size: 14px; margin-bottom: 6px; }
.page-head p, .section-head p, .muted { color: var(--muted); }
.page-head p { margin: 0; max-width: 670px; }
.actions { display: flex; gap: 9px; flex-wrap: wrap; }
.button { border: 1px solid var(--line); background: var(--paper); color: var(--ink); min-height: 38px; padding: 0 14px; border-radius: 9px; font-weight: 650; display: inline-flex; align-items: center; justify-content: center; gap: 7px; }
.button:hover { border-color: #bac7c2; transform: translateY(-1px); }
.button.primary { background: var(--accent); color: #fff; border-color: var(--accent); box-shadow: 0 5px 15px rgba(15,138,112,.18); }
.button.primary:hover { background: var(--accent-dark); }
.button.danger { color: var(--danger); border-color: #efcaca; }
.button.small { min-height: 31px; padding: 0 10px; font-size: 12px; }
.button.ghost { border-color: transparent; background: transparent; }

.metric-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-bottom: 22px; }
.metric { padding: 18px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--paper); box-shadow: 0 2px 2px rgba(10,40,30,.01); }
.metric-top { display: flex; justify-content: space-between; align-items: center; color: var(--muted); font-size: 11px; font-weight: 650; }
.metric-icon { width: 29px; height: 29px; border-radius: 9px; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; }
.metric strong { display: block; font-family: Georgia, serif; font-size: 28px; font-weight: 550; margin: 9px 0 2px; }
.metric small { color: var(--muted); }
.metric.warning .metric-icon { background: var(--gold-soft); color: #9a6815; }
.metric.danger .metric-icon { background: var(--danger-soft); color: var(--danger); }
.metric.blue .metric-icon { background: var(--blue-soft); color: var(--blue); }

.two-col { display: grid; grid-template-columns: minmax(0, 1.65fr) minmax(280px, .85fr); gap: 18px; }
.three-col { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.card { border: 1px solid var(--line); border-radius: var(--radius); background: var(--paper); overflow: hidden; box-shadow: 0 2px 3px rgba(20,40,32,.015); }
.card-pad { padding: 19px; }
.section-head { padding: 17px 19px; display: flex; justify-content: space-between; align-items: center; gap: 12px; border-bottom: 1px solid var(--line); }
.section-head h2, .section-head h3, .section-head p { margin: 0; }
.section-head p { font-size: 11px; margin-top: 3px; }
.section-title { display: flex; gap: 10px; align-items: center; }
.section-title .count { padding: 3px 7px; border-radius: 99px; background: #eef2ef; color: var(--muted); font: 700 10px/1 sans-serif; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { height: 39px; padding: 0 16px; text-align: left; border-bottom: 1px solid var(--line); color: var(--muted); background: #fafbfa; text-transform: uppercase; letter-spacing: .06em; font-size: 9px; white-space: nowrap; }
td { padding: 13px 16px; border-bottom: 1px solid #edf0ee; vertical-align: middle; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr.clickable { cursor: pointer; }
tbody tr.clickable:hover { background: #f8fbf9; }
.person-cell { display: flex; align-items: center; gap: 10px; min-width: 160px; }
.person-cell .avatar { width: 31px; height: 31px; background: #edf3f0; color: #47635c; }
.person-cell strong, .person-cell small { display: block; }
.person-cell strong { font-size: 12px; }
.person-cell small { color: var(--muted); margin-top: 2px; }
.subtle { color: var(--muted); font-size: 11px; }
.nowrap { white-space: nowrap; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 11px; }

.badge { display: inline-flex; align-items: center; min-height: 23px; padding: 0 8px; border-radius: 99px; background: #edf1ef; color: #51615c; font-size: 10px; font-weight: 750; text-transform: capitalize; white-space: nowrap; }
.badge.green { background: var(--accent-soft); color: #08705b; }
.badge.gold { background: var(--gold-soft); color: #8a5a0c; }
.badge.red { background: var(--danger-soft); color: #a63d3d; }
.badge.blue { background: var(--blue-soft); color: #365f9f; }
.badge.purple { background: #f0eafb; color: #6a4ca3; }
.dot { width: 7px; height: 7px; border-radius: 50%; display: inline-block; margin-right: 5px; background: currentColor; }

.filter-bar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; padding: 12px 14px; border-bottom: 1px solid var(--line); background: #fbfcfb; }
.input, .select, textarea { border: 1px solid #d6ded9; background: #fff; border-radius: 8px; color: var(--ink); outline: 0; }
.input, .select { height: 36px; padding: 0 11px; }
.input:focus, .select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(15,138,112,.09); }
.filter-bar .input { min-width: 220px; }

.empty { padding: 45px 20px; text-align: center; color: var(--muted); }
.empty-icon { width: 43px; height: 43px; border-radius: 13px; background: #eef3f0; display: grid; place-items: center; margin: 0 auto 12px; color: #628077; font-size: 19px; }
.skeleton { border-radius: 7px; min-height: 14px; background: linear-gradient(90deg, #eef1ef 25%, #f7f8f7 45%, #eef1ef 65%); background-size: 400% 100%; animation: shimmer 1.4s infinite; }
@keyframes shimmer { to { background-position: -100% 0; } }

.pipeline { display: grid; gap: 11px; padding: 17px 19px 21px; }
.pipeline-row { display: grid; grid-template-columns: 100px minmax(0,1fr) 28px; gap: 10px; align-items: center; font-size: 11px; }
.track { height: 8px; border-radius: 99px; background: #edf1ef; overflow: hidden; }
.track > i { height: 100%; display: block; border-radius: inherit; background: linear-gradient(90deg, #26a986, #0f8a70); }

.timeline { padding: 6px 18px 18px; }
.timeline-item { position: relative; padding: 15px 0 0 29px; }
.timeline-item::before { content: ""; position: absolute; left: 8px; top: 28px; bottom: -15px; border-left: 1px solid #dfe5e1; }
.timeline-item:last-child::before { display: none; }
.timeline-dot { position: absolute; left: 0; top: 20px; width: 17px; height: 17px; display: grid; place-items: center; border-radius: 50%; background: var(--accent-soft); color: var(--accent); font-size: 8px; border: 2px solid #fff; box-shadow: 0 0 0 1px #cfe2dc; }
.timeline-item p { margin: 3px 0 0; color: var(--muted); font-size: 11px; line-height: 1.5; }
.timeline-item time { color: #87918e; font-size: 9px; }

.matter-hero { padding: 20px; display: flex; align-items: center; justify-content: space-between; gap: 18px; border: 1px solid var(--line); background: var(--paper); border-radius: var(--radius); margin-bottom: 16px; }
.matter-client { display: flex; gap: 13px; align-items: center; }
.matter-client .avatar { width: 45px; height: 45px; font-size: 13px; }
.matter-client h1 { font-size: 25px; margin: 0 0 3px; }
.matter-meta { display: flex; flex-wrap: wrap; gap: 12px; color: var(--muted); font-size: 11px; }
.matter-tabs { display: flex; gap: 3px; padding: 0 4px; border-bottom: 1px solid var(--line); overflow-x: auto; }
.matter-tabs button { border: 0; padding: 13px 12px 11px; background: transparent; color: var(--muted); border-bottom: 2px solid transparent; font-weight: 650; white-space: nowrap; }
.matter-tabs button.active { color: var(--accent); border-bottom-color: var(--accent); }
.tab-content { padding: 18px; }
.kv-grid { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 14px; }
.kv { padding: 12px; background: #f7f9f7; border-radius: 9px; min-height: 61px; }
.kv label { display: block; color: var(--muted); text-transform: uppercase; font-size: 8px; font-weight: 750; letter-spacing: .06em; margin-bottom: 6px; }
.kv span { line-height: 1.4; }
.section-block { padding: 16px; border: 1px solid var(--line); border-radius: 11px; margin-bottom: 12px; }
.section-block-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 13px; }
.section-block-head h3 { margin: 0; }

.task-list { display: grid; }
.task-row { padding: 13px 16px; display: grid; grid-template-columns: 25px minmax(0,1fr) auto; gap: 10px; align-items: start; border-bottom: 1px solid #edf0ee; }
.task-row:last-child { border-bottom: 0; }
.task-check { width: 20px; height: 20px; border-radius: 50%; border: 1px solid #b8c5c0; background: #fff; color: #fff; display: grid; place-items: center; margin-top: 1px; }
.task-check:hover, .task-check.done { background: var(--accent); border-color: var(--accent); }
.task-body.done { color: var(--muted); text-decoration: line-through; }
.task-body small { display: block; color: var(--muted); margin-top: 4px; }
.overdue { color: var(--danger) !important; font-weight: 650; }

.integration-grid { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 13px; }
.integration-card { padding: 17px; border: 1px solid var(--line); background: #fff; border-radius: 12px; }
.integration-top { display: flex; justify-content: space-between; gap: 12px; align-items: start; }
.integration-logo { width: 35px; height: 35px; border-radius: 9px; background: #edf5f2; display: grid; place-items: center; color: var(--accent); font-weight: 850; }
.integration-card p { color: var(--muted); font-size: 11px; min-height: 33px; margin: 11px 0; line-height: 1.45; }
.capabilities { display: flex; flex-wrap: wrap; gap: 5px; }
.capabilities span { padding: 3px 6px; border-radius: 5px; background: #f2f4f3; color: #63706c; font-size: 9px; }

.report-grid { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 14px; }
.report-card { padding: 18px; border: 1px solid var(--line); background: #fff; border-radius: 12px; display: flex; flex-direction: column; min-height: 160px; }
.report-card .report-icon { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; background: var(--blue-soft); color: var(--blue); margin-bottom: 13px; }
.report-card p { color: var(--muted); font-size: 11px; line-height: 1.5; flex: 1; }
.report-card .actions { justify-content: space-between; }

.api-callout { padding: 22px; background: linear-gradient(135deg, #102923, #174338); color: #fff; border-radius: var(--radius); box-shadow: var(--shadow); }
.api-callout h2 { color: #fff; }
.api-callout p { color: #b9ccc6; max-width: 760px; line-height: 1.55; }
.api-callout code { display: block; padding: 13px 15px; background: rgba(0,0,0,.22); border: 1px solid rgba(255,255,255,.11); border-radius: 9px; color: #a9f2dd; overflow-x: auto; }
.api-callout .button { margin-top: 14px; }
.disclaimer { padding: 13px 15px; border-radius: 9px; background: var(--gold-soft); color: #6e4d14; border: 1px solid #f0d9aa; line-height: 1.5; font-size: 11px; }

.modal-backdrop { position: fixed; inset: 0; z-index: 100; background: rgba(8, 25, 20, .48); backdrop-filter: blur(3px); display: grid; place-items: center; padding: 20px; animation: fade .12s ease; }
@keyframes fade { from { opacity: 0; } }
.modal { width: min(620px, 100%); max-height: calc(100vh - 40px); overflow: auto; background: #fff; border-radius: 16px; box-shadow: 0 30px 80px rgba(8,25,20,.25); }
.modal.wide { width: min(840px, 100%); }
.modal-head { padding: 19px 21px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; align-items: flex-start; }
.modal-head h2 { margin: 0; }
.modal-head p { color: var(--muted); font-size: 11px; margin: 4px 0 0; }
.modal-close { border: 0; background: #f1f4f2; border-radius: 8px; width: 30px; height: 30px; }
.modal-body { padding: 20px; }
.modal-foot { position: sticky; bottom: 0; padding: 14px 20px; background: rgba(255,255,255,.96); border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 8px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 14px; }
.field { display: grid; gap: 6px; }
.field.full { grid-column: 1 / -1; }
.field label { font-size: 10px; color: #50615b; font-weight: 750; }
.field .input, .field .select { width: 100%; }
.field textarea { width: 100%; min-height: 90px; padding: 10px 11px; resize: vertical; }
.field small { color: var(--muted); font-size: 9px; }

.toast-stack { position: fixed; right: 20px; bottom: 20px; z-index: 200; display: grid; gap: 8px; width: min(350px, calc(100vw - 40px)); }
.toast { padding: 13px 14px; border-radius: 10px; color: #fff; background: #163c32; box-shadow: var(--shadow); animation: toast-in .2s ease; display: flex; justify-content: space-between; gap: 10px; }
.toast.error { background: #9d3939; }
.toast button { color: inherit; border: 0; background: transparent; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }

@media (max-width: 1100px) {
  .metric-grid { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .integration-grid, .report-grid { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .three-col { grid-template-columns: 1fr; }
}

@media (max-width: 800px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; left: -250px; transition: left .2s ease; width: 240px; box-shadow: 20px 0 45px rgba(0,0,0,.18); }
  .sidebar.open { left: 0; }
  .mobile-only { display: grid; }
  .topbar { padding: 0 16px; gap: 10px; }
  .global-search { width: auto; flex: 1; }
  .environment-pill { display: none; }
  .page { padding: 20px 15px; }
  .page-head { display: grid; }
  .two-col { grid-template-columns: 1fr; }
  .kv-grid { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .matter-hero { align-items: flex-start; flex-direction: column; }
}

@media (max-width: 560px) {
  .metric-grid, .integration-grid, .report-grid, .form-grid, .kv-grid { grid-template-columns: 1fr; }
  .field.full { grid-column: auto; }
  .topbar .avatar { display: none; }
  .filter-bar .input { min-width: 100%; }
  td, th { padding-left: 11px; padding-right: 11px; }
  .page { padding-top: 17px; }
}
