/* Legacy Case Manager — navy & gold, matching the Legacy Law Partners identity */
:root {
  --navy-950: #12161f;
  --navy-900: #181d29;
  --navy-800: #202737;
  --navy-700: #2a3347;
  --navy-100: #e8ebf2;
  --gold: #c9a45c;
  --gold-bright: #dcb96f;
  --gold-dim: #8a7340;
  --ink: #1d2433;
  --ink-soft: #55607a;
  --ink-faint: #8b94a8;
  --paper: #f4f5f8;
  --card: #ffffff;
  --line: #e3e6ee;
  --green: #2e7d52;
  --green-bg: #e3f2ea;
  --red: #b3423a;
  --red-bg: #fbeae8;
  --amber: #9a6b1f;
  --amber-bg: #faf0da;
  --blue: #2f5f9e;
  --blue-bg: #e7eff9;
  --purple: #6b4d9e;
  --purple-bg: #efe9f8;
  --shadow: 0 1px 3px rgba(18, 22, 31, .08), 0 4px 16px rgba(18, 22, 31, .06);
  --radius: 10px;
  --sidebar-w: 232px;
  font-size: 15px;
}
* { box-sizing: border-box; margin: 0; }
html, body { height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  color: var(--ink);
  background: var(--paper);
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, .brand-font { font-family: Georgia, "Times New Roman", serif; }
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------- auth screens ---------- */
.auth-wrap {
  flex: 1; width: 100%;
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: radial-gradient(1200px 700px at 70% -10%, #2a3347 0%, var(--navy-950) 60%);
  padding: 24px;
}
.auth-card {
  background: var(--card); border-radius: 14px; box-shadow: 0 24px 80px rgba(0,0,0,.45);
  width: 100%; max-width: 420px; padding: 38px 36px 32px; animation: rise .35s ease;
}
.auth-card.wide { max-width: 560px; }
@keyframes rise { from { opacity: 0; transform: translateY(10px); } }
.auth-logo { text-align: center; margin-bottom: 26px; }
.auth-logo .pillar { font-size: 34px; color: var(--gold); }
.auth-logo h1 { font-size: 24px; letter-spacing: 3px; color: var(--ink); margin-top: 6px; }
.auth-logo .sub { font-size: 11px; letter-spacing: 3.5px; color: var(--ink-faint); text-transform: uppercase; margin-top: 3px; }
.auth-links { text-align: center; margin-top: 18px; font-size: 13.5px; color: var(--ink-soft); }

/* ---------- app shell ---------- */
#app { display: flex; min-height: 100vh; }
.sidebar {
  width: var(--sidebar-w); background: linear-gradient(180deg, var(--navy-900), var(--navy-950));
  color: #aeb6c8; position: fixed; inset: 0 auto 0 0; display: flex; flex-direction: column;
  z-index: 40;
}
.side-brand { padding: 20px 18px 16px; border-bottom: 1px solid rgba(255,255,255,.07); }
.side-brand .pillar { color: var(--gold); font-size: 22px; }
.side-brand h1 { color: #fff; font-size: 15.5px; letter-spacing: 1.6px; margin-top: 4px; }
.side-brand .sub { font-size: 9.5px; letter-spacing: 2.4px; color: var(--gold); text-transform: uppercase; margin-top: 2px; opacity: .85; }
.side-nav { flex: 1; overflow-y: auto; padding: 10px 10px 20px; }
.side-nav .group { font-size: 10px; letter-spacing: 1.8px; text-transform: uppercase; color: #5d6880; padding: 14px 10px 6px; }
.side-nav a {
  display: flex; align-items: center; gap: 10px; color: #b6bdcd; padding: 8px 10px;
  border-radius: 8px; font-size: 13.5px; margin-bottom: 1px;
}
.side-nav a:hover { background: rgba(255,255,255,.06); text-decoration: none; color: #fff; }
.side-nav a.active { background: rgba(201,164,92,.14); color: var(--gold-bright); font-weight: 600; }
.side-nav a .ico { width: 20px; text-align: center; font-size: 15px; }
.side-user { padding: 12px 14px; border-top: 1px solid rgba(255,255,255,.07); font-size: 12.5px; }
.side-user .nm { color: #fff; font-weight: 600; }
.side-user .rl { color: var(--gold); font-size: 11px; text-transform: capitalize; }

.main { flex: 1; margin-left: var(--sidebar-w); display: flex; flex-direction: column; min-width: 0; }
.topbar {
  background: var(--card); border-bottom: 1px solid var(--line); padding: 10px 26px;
  display: flex; align-items: center; gap: 16px; position: sticky; top: 0; z-index: 30;
}
.topbar .search { position: relative; flex: 1; max-width: 420px; }
.topbar .search input {
  width: 100%; padding: 8px 12px 8px 34px; border: 1px solid var(--line); border-radius: 8px;
  background: var(--paper); font-size: 13.5px;
}
.topbar .search .mag { position: absolute; left: 11px; top: 8px; color: var(--ink-faint); }
.search-results {
  position: absolute; top: 42px; left: 0; right: 0; background: var(--card); border-radius: 10px;
  box-shadow: var(--shadow), 0 12px 40px rgba(0,0,0,.14); max-height: 420px; overflow: auto; z-index: 60;
  border: 1px solid var(--line);
}
.search-results .sr-group { font-size: 10.5px; letter-spacing: 1.4px; text-transform: uppercase; color: var(--ink-faint); padding: 10px 14px 4px; }
.search-results a { display: block; padding: 8px 14px; color: var(--ink); font-size: 13.5px; }
.search-results a:hover { background: var(--paper); text-decoration: none; }
.topbar .spacer { flex: 1; }
.topbar .who { font-size: 13px; color: var(--ink-soft); text-align: right; line-height: 1.25; }
.topbar .who b { color: var(--ink); }

.content { padding: 26px; max-width: 1280px; width: 100%; margin: 0 auto; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head h2 { font-size: 22px; }
.page-head .crumb { color: var(--ink-faint); font-size: 13px; margin-bottom: 4px; }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- widgets ---------- */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 14px; margin-bottom: 22px; }
.stat {
  background: var(--card); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow);
  border-top: 3px solid var(--gold);
}
.stat .v { font-size: 26px; font-weight: 700; font-family: Georgia, serif; }
.stat .l { font-size: 12px; color: var(--ink-soft); margin-top: 2px; }
.stat.warn { border-top-color: var(--red); }
.stat.warn .v { color: var(--red); }

.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); margin-bottom: 20px; }
.card .card-head { padding: 14px 18px; border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.card .card-head h3 { font-size: 15.5px; }
.card .card-body { padding: 16px 18px; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; align-items: start; }
@media (max-width: 980px) { .two-col { grid-template-columns: 1fr; } }

table.grid { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.grid th {
  text-align: left; padding: 10px 14px; font-size: 11px; letter-spacing: 1.2px; text-transform: uppercase;
  color: var(--ink-faint); border-bottom: 1px solid var(--line); white-space: nowrap;
}
table.grid td { padding: 11px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.grid tr:last-child td { border-bottom: 0; }
table.grid tr.rowlink { cursor: pointer; }
table.grid tr.rowlink:hover { background: #f8f9fc; }
table.grid td.num, table.grid th.num { text-align: right; font-variant-numeric: tabular-nums; }
.table-scroll { overflow-x: auto; }
.empty { padding: 34px; text-align: center; color: var(--ink-faint); font-size: 14px; }
.empty .big { font-size: 30px; margin-bottom: 8px; }

.badge {
  display: inline-block; padding: 3px 9px; border-radius: 20px; font-size: 11.5px; font-weight: 600;
  white-space: nowrap;
}
.b-green { background: var(--green-bg); color: var(--green); }
.b-red { background: var(--red-bg); color: var(--red); }
.b-amber { background: var(--amber-bg); color: var(--amber); }
.b-blue { background: var(--blue-bg); color: var(--blue); }
.b-purple { background: var(--purple-bg); color: var(--purple); }
.b-grey { background: #eef0f4; color: var(--ink-soft); }
.b-gold { background: #f5ecd9; color: var(--gold-dim); }

button, .btn {
  font: inherit; border: 0; cursor: pointer; border-radius: 8px; padding: 8px 16px; font-size: 13.5px;
  font-weight: 600; transition: filter .12s ease; display: inline-flex; align-items: center; gap: 7px;
}
button:hover, .btn:hover { filter: brightness(1.06); }
.btn-primary { background: var(--navy-800); color: #fff; }
.btn-gold { background: var(--gold); color: var(--navy-950); }
.btn-ghost { background: transparent; color: var(--ink-soft); border: 1px solid var(--line); }
.btn-danger { background: var(--red-bg); color: var(--red); }
.btn-sm { padding: 4px 10px; font-size: 12.5px; }
.btn-block { width: 100%; justify-content: center; padding: 11px; font-size: 14.5px; }
button:disabled { opacity: .55; cursor: default; }

/* ---------- forms ---------- */
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 12.5px; font-weight: 600; color: var(--ink-soft); margin-bottom: 5px; }
.field label .req { color: var(--red); }
.field input, .field select, .field textarea {
  width: 100%; padding: 9px 11px; border: 1px solid #d4d9e3; border-radius: 8px; font: inherit;
  font-size: 13.5px; background: #fff; color: var(--ink);
}
.field textarea { resize: vertical; min-height: 74px; }
.field input:focus, .field select:focus, .field textarea:focus {
  outline: 2px solid rgba(201,164,92,.4); border-color: var(--gold);
}
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
.form-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 0 14px; }
@media (max-width: 640px) { .form-row, .form-row-3 { grid-template-columns: 1fr; } }
.form-error { background: var(--red-bg); color: var(--red); padding: 10px 13px; border-radius: 8px; font-size: 13px; margin-bottom: 14px; }
.form-note { background: var(--blue-bg); color: var(--blue); padding: 10px 13px; border-radius: 8px; font-size: 13px; margin-bottom: 14px; }
.check-line { display: flex; align-items: center; gap: 8px; font-size: 13.5px; margin-bottom: 14px; }
.check-line input { width: auto; }

/* ---------- modal ---------- */
.modal-back {
  position: fixed; inset: 0; background: rgba(18,22,31,.55); z-index: 80; display: flex;
  align-items: flex-start; justify-content: center; padding: 40px 16px; overflow-y: auto;
}
.modal {
  background: var(--card); border-radius: 14px; width: 100%; max-width: 560px;
  box-shadow: 0 30px 90px rgba(0,0,0,.4); animation: rise .22s ease;
}
.modal.wide { max-width: 760px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 22px; border-bottom: 1px solid var(--line); }
.modal-head h3 { font-size: 17px; }
.modal-head .x { background: none; font-size: 21px; color: var(--ink-faint); padding: 2px 8px; }
.modal-body { padding: 20px 22px; }

/* ---------- filter bar / tabs ---------- */
.filters { display: flex; gap: 8px; margin-bottom: 16px; flex-wrap: wrap; align-items: center; }
.filters select, .filters input {
  padding: 7px 10px; border: 1px solid var(--line); border-radius: 8px; font-size: 13px; background: #fff;
}
.tabs { display: flex; gap: 2px; border-bottom: 2px solid var(--line); margin-bottom: 18px; flex-wrap: wrap; }
.tabs button {
  background: none; border-radius: 8px 8px 0 0; padding: 9px 16px; color: var(--ink-soft); font-weight: 600;
  border-bottom: 2px solid transparent; margin-bottom: -2px;
}
.tabs button.active { color: var(--navy-800); border-bottom-color: var(--gold); }

/* ---------- calendar ---------- */
.cal-head { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.cal-head h3 { font-size: 17px; min-width: 170px; text-align: center; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.cal-dow { font-size: 11px; letter-spacing: 1px; text-transform: uppercase; color: var(--ink-faint); text-align: center; padding: 4px 0; }
.cal-cell {
  background: var(--card); border-radius: 8px; min-height: 92px; padding: 6px; font-size: 12px;
  border: 1px solid var(--line);
}
.cal-cell.dim { opacity: .45; }
.cal-cell.today { border-color: var(--gold); box-shadow: 0 0 0 1px var(--gold); }
.cal-cell .d { font-weight: 700; font-size: 12.5px; margin-bottom: 4px; color: var(--ink-soft); }
.cal-ev {
  display: block; background: var(--blue-bg); color: var(--blue); border-radius: 5px; padding: 2px 6px;
  margin-bottom: 3px; font-size: 11px; cursor: pointer; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.cal-ev.done { background: #eef0f4; color: var(--ink-faint); text-decoration: line-through; }

/* ---------- misc ---------- */
.timeline { list-style: none; }
.timeline li { padding: 10px 0 10px 18px; border-left: 2px solid var(--line); position: relative; margin-left: 6px; }
.timeline li::before {
  content: ''; position: absolute; left: -6px; top: 16px; width: 10px; height: 10px; border-radius: 50%;
  background: var(--gold); border: 2px solid #fff;
}
.timeline .t-meta { font-size: 12px; color: var(--ink-faint); margin-bottom: 2px; }
.muted { color: var(--ink-faint); font-size: 12.5px; }
.kv { display: grid; grid-template-columns: 150px 1fr; gap: 7px 14px; font-size: 13.5px; }
.kv dt { color: var(--ink-faint); }
.kv dd { font-weight: 500; }
.toast {
  position: fixed; bottom: 24px; right: 24px; background: var(--navy-900); color: #fff; padding: 12px 20px;
  border-radius: 10px; box-shadow: 0 10px 40px rgba(0,0,0,.3); z-index: 100; font-size: 13.5px;
  animation: rise .25s ease; border-left: 3px solid var(--gold);
}
.toast.err { border-left-color: var(--red); }
.mini-bar { display: flex; align-items: center; gap: 8px; font-size: 12.5px; margin-bottom: 6px; }
.mini-bar .bar { height: 9px; border-radius: 5px; background: var(--gold); min-width: 2px; }
.mini-bar .lbl { width: 130px; color: var(--ink-soft); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mini-bar .val { font-variant-numeric: tabular-nums; white-space: nowrap; }

/* research (Claude AI) */
.research-wrap { display: grid; grid-template-columns: 260px 1fr; gap: 16px; align-items: start; }
@media (max-width: 900px) { .research-wrap { grid-template-columns: 1fr; } }
.research-list { max-height: 70vh; overflow-y: auto; }
.r-chat { display: block; padding: 10px 14px; border-bottom: 1px solid var(--line); cursor: pointer; color: var(--ink); }
.r-chat:hover { background: var(--paper); text-decoration: none; }
.r-chat.active { background: #f5ecd9; border-left: 3px solid var(--gold); }
.r-chat .r-title { font-size: 13px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.research-main { display: flex; flex-direction: column; min-height: 70vh; }
.r-messages { flex: 1; overflow-y: auto; padding: 18px; max-height: 60vh; }
.r-msg { max-width: 88%; padding: 12px 16px; border-radius: 12px; margin-bottom: 12px; font-size: 13.5px; line-height: 1.55; }
.r-msg.user { background: var(--navy-800); color: #fff; margin-left: auto; border-bottom-right-radius: 4px; white-space: pre-wrap; }
.r-msg.assistant { background: var(--paper); border: 1px solid var(--line); border-bottom-left-radius: 4px; }
.r-msg .ai-h { font-weight: 700; font-size: 14px; margin: 10px 0 4px; font-family: Georgia, serif; }
.r-msg .ai-li { margin: 2px 0 2px 8px; }
.r-msg .ai-code { background: #eef0f4; border-radius: 8px; padding: 10px 12px; font-size: 12.5px; overflow-x: auto; white-space: pre-wrap; font-family: ui-monospace, Menlo, monospace; margin: 8px 0; }
.r-composer { display: flex; gap: 10px; padding: 14px; border-top: 1px solid var(--line); }
.r-composer textarea { flex: 1; resize: none; padding: 10px 12px; border: 1px solid #d4d9e3; border-radius: 10px; font: inherit; font-size: 13.5px; }
.r-composer textarea:focus { outline: 2px solid rgba(201,164,92,.4); border-color: var(--gold); }

/* invoice print view */
.inv-paper { background: #fff; padding: 34px 38px; border-radius: var(--radius); box-shadow: var(--shadow); max-width: 820px; }
.inv-top { display: flex; justify-content: space-between; gap: 20px; border-bottom: 3px solid var(--gold); padding-bottom: 18px; margin-bottom: 18px; }
.inv-top h2 { letter-spacing: 2px; }
@media print {
  .sidebar, .topbar, .page-actions, .no-print { display: none !important; }
  .main { margin-left: 0; }
  .content { padding: 0; max-width: none; }
  .inv-paper { box-shadow: none; padding: 0; }
  body { background: #fff; }
}

@media (max-width: 860px) {
  .sidebar { position: static; width: 100%; height: auto; }
  #app { flex-direction: column; }
  .main { margin-left: 0; }
  .side-nav { display: flex; flex-wrap: wrap; gap: 2px; }
  .side-nav .group { display: none; }
}
