/* Emonics Legal — one stylesheet, no framework, no external fetch.
 *
 * Dense but readable: this is a working tool that people will have open all
 * day, not a marketing page. Table rows are 40px, the spacing scale is 8px,
 * and nothing moves under the cursor.
 *
 * A print stylesheet is at the foot. Every case tab prints: a lawyer taking a
 * case file into a room where the wifi does not reach is a real Tuesday.
 */

:root {
  --navy: #1E2A5E;
  --navy-700: #16214a;
  --navy-100: #eef1f8;
  --orange: #E65F3C;
  --orange-700: #c94a29;
  --orange-100: #fdeee9;

  --ink: #1f2430;
  --muted: #6b7280;
  --faint: #9ca3af;
  --line: #e5e7eb;
  --line-strong: #d1d5db;
  --paper: #f6f7f9;
  --white: #ffffff;

  --ok: #157f4a;
  --ok-bg: #e8f6ee;
  --warn: #9a6400;
  --warn-bg: #fdf3e0;
  --bad: #b3261e;
  --bad-bg: #fdecea;

  --s1: 4px; --s2: 8px; --s3: 16px; --s4: 24px; --s5: 32px; --s6: 48px;
  --row: 40px;
  --radius: 6px;
  --shadow: 0 1px 2px rgba(16,24,40,.06), 0 1px 3px rgba(16,24,40,.08);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica,
          Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--navy); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------------------------------------------------------------- chrome */

.topbar {
  background: var(--navy);
  color: #fff;
  display: flex; align-items: center; gap: var(--s3);
  padding: 0 var(--s4);
  height: 52px;
  position: sticky; top: 0; z-index: 40;
}
/* Height-only on the lockup, and flex:none so it is never squeezed. */
.topbar .lockup {
  display: flex; align-items: center; gap: var(--s2);
  height: 36px; flex: none;
}
.topbar .lockup .name { font-size: 16px; font-weight: 700; letter-spacing: .2px; }
.topbar .lockup .org  { font-size: 13px; color: #aab3d4; }
.topbar nav { display: flex; gap: var(--s3); margin-left: var(--s4); }
.topbar nav a { color: #d7dcee; font-size: 14px; }
.topbar nav a.active, .topbar nav a:hover { color: #fff; text-decoration: none; }
.topbar .spacer { flex: 1; }
.topbar .who { font-size: 13px; color: #aab3d4; }
.topbar .who a { color: #fff; }

.searchbox {
  position: relative; flex: none; width: 280px;
}
.searchbox input {
  width: 100%; height: 32px; border-radius: var(--radius);
  border: 1px solid #33406f; background: var(--navy-700);
  color: #fff; padding: 0 var(--s2) 0 var(--s3); font-size: 13px;
}
.searchbox input::placeholder { color: #8b95bd; }
.searchbox .hint {
  position: absolute; right: 8px; top: 7px; font-size: 11px; color: #8b95bd;
  border: 1px solid #3a4778; border-radius: 3px; padding: 0 4px;
}
.searchbox .results {
  position: absolute; top: 38px; left: 0; right: 0; background: #fff;
  border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); overflow: hidden; display: none; z-index: 50;
}
.searchbox .results a {
  display: block; padding: var(--s2) var(--s3); border-bottom: 1px solid var(--line);
  color: var(--ink); font-size: 13px;
}
.searchbox .results a:last-child { border-bottom: 0; }
.searchbox .results a:hover { background: var(--navy-100); text-decoration: none; }

main { padding: var(--s4); max-width: 1360px; margin: 0 auto; }

h1 { font-size: 20px; margin: 0 0 var(--s3); color: var(--navy); }
h2 { font-size: 16px; margin: var(--s4) 0 var(--s2); color: var(--navy); }
h3 { font-size: 14px; margin: var(--s3) 0 var(--s2); color: var(--ink); }

/* ----------------------------------------------------------------- cards */

.card {
  background: #fff; border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: var(--s3); margin-bottom: var(--s3);
}
.card > h2:first-child, .card > h3:first-child { margin-top: 0; }

.tiles { display: grid; grid-template-columns: repeat(5, 1fr); gap: var(--s3); }
.tile {
  background: #fff; border: 1px solid var(--line); border-radius: var(--radius);
  padding: var(--s3); box-shadow: var(--shadow);
}
.tile .n { font-size: 26px; font-weight: 700; color: var(--navy); line-height: 1.1; }
.tile .l { font-size: 12px; color: var(--muted); margin-top: var(--s1);
           text-transform: uppercase; letter-spacing: .4px; }
.tile.warn .n { color: var(--orange); }

/* ---------------------------------------------------------------- tables */

table.grid { width: 100%; border-collapse: collapse; background: #fff; }
table.grid th, table.grid td {
  height: var(--row); padding: 0 var(--s2);
  border-bottom: 1px solid var(--line); text-align: left; font-size: 13px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
table.grid th {
  background: var(--navy-100); color: var(--navy); font-weight: 600;
  font-size: 12px; text-transform: uppercase; letter-spacing: .4px;
  position: sticky; top: 52px; z-index: 10;
}
/* THE HEADER OFFSET IS FOR THE PAGE, NOT FOR A SCROLL BOX.
 *
 * `top: 52px` exists to clear the 52px topbar when a long table scrolls under
 * it. But `.table-scroll` sets `overflow-x: auto`, which makes `overflow-y`
 * compute to `auto` as well — so that wrapper is itself a scroll container,
 * and `position: sticky` resolves against IT rather than the viewport. The
 * header then slid 52px down inside its own box and, being opaque and
 * z-index 10, painted exactly over the first data row.
 *
 * Measured live on 2026-08-26: header rect and first-row rect were identical
 * (top 310.5, bottom 350.5) — a 40px overlap, the full row height. The list
 * said "1 case" and appeared to show none. The row was always in the DOM and
 * the query was always correct; it was covered up.
 *
 * Inside a scroll wrapper the header pins to the wrapper's own top, which is
 * where it belongs. */
.table-scroll table.grid th { top: 0; }
table.grid th a { color: var(--navy); }
table.grid tbody tr:hover { background: #fafbfd; }
table.grid td.num, table.grid th.num { text-align: right; font-variant-numeric: tabular-nums; }
table.grid td.wrap { white-space: normal; }
.table-scroll { overflow-x: auto; border: 1px solid var(--line);
                border-radius: var(--radius); }

/* --------------------------------------------------------------- badges */

.badge {
  display: inline-block; padding: 2px 8px; border-radius: 999px;
  font-size: 11px; font-weight: 600; letter-spacing: .3px;
  background: var(--navy-100); color: var(--navy); white-space: nowrap;
}
.badge.ok   { background: var(--ok-bg);   color: var(--ok); }
.badge.warn { background: var(--warn-bg); color: var(--warn); }
.badge.bad  { background: var(--bad-bg);  color: var(--bad); }
.badge.internal { background: var(--orange-100); color: var(--orange-700); }

.src {
  font-size: 11px; color: var(--faint); font-weight: 400;
  text-transform: none; letter-spacing: 0;
}

/* ---------------------------------------------------------- case header */

.case-header {
  position: sticky; top: 52px; z-index: 30;
  background: #fff; border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: var(--s3); margin-bottom: var(--s3);
}
.case-header .row1 { display: flex; align-items: baseline; gap: var(--s3);
                     flex-wrap: wrap; }
.case-header .num { font-family: var(--mono); font-size: 13px; color: var(--muted); }
.case-header .subject { font-size: 19px; font-weight: 700; color: var(--navy); }
.case-header .facts {
  display: flex; gap: var(--s4); flex-wrap: wrap; margin-top: var(--s2);
  font-size: 13px;
}
.case-header .facts div span { display: block; font-size: 11px; color: var(--muted);
  text-transform: uppercase; letter-spacing: .4px; }
.case-header .actions { display: flex; gap: var(--s2); margin-top: var(--s3);
                        flex-wrap: wrap; }

.banner {
  border-radius: var(--radius); padding: var(--s2) var(--s3);
  margin-bottom: var(--s3); font-size: 13px; border: 1px solid;
}
.banner.warn { background: var(--warn-bg); border-color: #f0d9a8; color: var(--warn); }
.banner.bad  { background: var(--bad-bg);  border-color: #f3c5c1; color: var(--bad); }
.banner.ok   { background: var(--ok-bg);   border-color: #bfe3cf; color: var(--ok); }

/* ------------------------------------------------------------ case body */

.case-layout { display: grid; grid-template-columns: 190px 1fr; gap: var(--s3); }
.rail { position: sticky; top: 150px; align-self: start; }
.rail a {
  display: block; padding: 9px var(--s3); border-radius: var(--radius);
  color: var(--ink); font-size: 13px; border-left: 3px solid transparent;
}
.rail a:hover { background: var(--navy-100); text-decoration: none; }
.rail a.active { background: var(--navy-100); color: var(--navy);
                 font-weight: 600; border-left-color: var(--orange); }
.rail a .count { float: right; color: var(--faint); font-size: 12px; }

/* --------------------------------------------------------- the checklist */

.checklist { display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--s2); }
.slot {
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: var(--s2) var(--s3); background: #fff;
}
.slot.present { border-left: 3px solid var(--ok); }
.slot.missing { border-left: 3px solid var(--warn); background: #fffdf7; }
.slot .name { font-size: 13px; font-weight: 600; }
.slot .state { font-size: 12px; color: var(--muted); margin-top: 2px; }
.slot.missing .state { color: var(--warn); }
.slot form { margin-top: var(--s2); }

/* ----------------------------------------------------------------- forms */

label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 4px;
        text-transform: uppercase; letter-spacing: .4px; }
input[type=text], input[type=email], input[type=search], input[type=number],
input[type=date], input[type=datetime-local], select, textarea {
  width: 100%; padding: 8px 10px; font-size: 14px; font-family: inherit;
  border: 1px solid var(--line-strong); border-radius: var(--radius);
  background: #fff; color: var(--ink);
}
input:focus, select:focus, textarea:focus {
  outline: 2px solid var(--navy); outline-offset: -1px; border-color: var(--navy);
}
textarea { min-height: 90px; resize: vertical; }
.field { margin-bottom: var(--s3); }
.field .err { color: var(--bad); font-size: 12px; margin-top: 4px; display: block; }
.field.bad input, .field.bad select, .field.bad textarea { border-color: var(--bad); }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s3); }
.row3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: var(--s3); }

.btn {
  display: inline-block; padding: 8px 16px; border-radius: var(--radius);
  border: 1px solid var(--navy); background: var(--navy); color: #fff;
  font-size: 13px; font-weight: 600; cursor: pointer; font-family: inherit;
}
.btn:hover { background: var(--navy-700); text-decoration: none; }
.btn.secondary { background: #fff; color: var(--navy); }
.btn.secondary:hover { background: var(--navy-100); }
.btn.accent { background: var(--orange); border-color: var(--orange); }
.btn.accent:hover { background: var(--orange-700); }
.btn.danger { background: #fff; color: var(--bad); border-color: #f3c5c1; }
.btn.small { padding: 5px 10px; font-size: 12px; }
.btn[disabled] { opacity: .55; cursor: not-allowed; }

/* --------------------------------------------------------- empty states */

.empty {
  padding: var(--s5) var(--s3); text-align: center; color: var(--muted);
  border: 1px dashed var(--line-strong); border-radius: var(--radius);
  background: #fff;
}
.empty strong { display: block; color: var(--ink); margin-bottom: var(--s1);
                font-size: 14px; }

.loading { color: var(--muted); font-size: 13px; }
.loading::after {
  content: ""; display: inline-block; width: 10px; text-align: left;
  animation: dots 1.2s steps(4, end) infinite;
}
@keyframes dots { 0% { content: ""; } 25% { content: "."; }
                  50% { content: ".."; } 75% { content: "..."; } }

/* ----------------------------------------------------------- key/value */

dl.kv { display: grid; grid-template-columns: 190px 1fr; gap: 0; margin: 0; }
dl.kv dt { padding: 7px var(--s2) 7px 0; font-size: 12px; color: var(--muted);
           border-bottom: 1px solid var(--line); text-transform: uppercase;
           letter-spacing: .4px; }
dl.kv dd { padding: 7px 0; margin: 0; font-size: 13px;
           border-bottom: 1px solid var(--line); }
dl.kv dd .src { margin-left: var(--s2); }

/* ------------------------------------------------------------- timeline */

.feed { list-style: none; margin: 0; padding: 0; }
.feed li {
  padding: var(--s2) 0 var(--s2) var(--s4); border-bottom: 1px solid var(--line);
  position: relative;
}
.feed li::before {
  content: ""; position: absolute; left: 6px; top: 16px; width: 7px; height: 7px;
  border-radius: 50%; background: var(--line-strong);
}
.feed li.status::before { background: var(--navy); }
.feed li.note::before { background: var(--orange); }
.feed li.document::before { background: var(--ok); }
.feed .when { font-size: 12px; color: var(--faint); }
.feed .title { font-size: 13px; font-weight: 600; }
.feed .body { font-size: 13px; color: var(--ink); white-space: pre-wrap; }

/* ------------------------------------------------------------ pagination */

.pager { display: flex; gap: var(--s2); align-items: center; margin-top: var(--s3);
         font-size: 13px; color: var(--muted); }

/* ------------------------------------------------------------- viewer */

.viewer { width: 100%; height: 78vh; border: 1px solid var(--line);
          border-radius: var(--radius); background: #fff; }

.dropzone {
  border: 2px dashed var(--line-strong); border-radius: var(--radius);
  padding: var(--s4); text-align: center; color: var(--muted);
  background: #fff; font-size: 13px;
}
.dropzone.over { border-color: var(--orange); background: var(--orange-100);
                 color: var(--orange-700); }
.progress { height: 6px; background: var(--line); border-radius: 3px;
            overflow: hidden; margin-top: var(--s2); }
.progress > i { display: block; height: 100%; width: 0; background: var(--orange);
                transition: width .2s; }

/* --------------------------------------------------------------- login */

.login-wrap { max-width: 400px; margin: 8vh auto; }
.login-wrap .card { padding: var(--s4); }
.login-wrap .lockup { display: flex; align-items: center; gap: var(--s2);
                      height: 36px; flex: none; margin-bottom: var(--s3); }
.login-wrap .lockup .name { font-size: 18px; font-weight: 700; color: var(--navy); }

.incident { font-family: var(--mono); font-size: 12px; color: var(--muted); }

/* -------------------------------------------------------------- tablet */

@media (max-width: 1100px) {
  .tiles { grid-template-columns: repeat(3, 1fr); }
  .checklist { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 860px) {
  .case-layout { grid-template-columns: 1fr; }
  .rail { position: static; display: flex; gap: var(--s1); overflow-x: auto; }
  .rail a { border-left: 0; border-bottom: 3px solid transparent; white-space: nowrap; }
  .rail a.active { border-left: 0; border-bottom-color: var(--orange); }
  .tiles { grid-template-columns: repeat(2, 1fr); }
  .row2, .row3 { grid-template-columns: 1fr; }
  .searchbox { width: 180px; }
  dl.kv { grid-template-columns: 1fr; }
  dl.kv dt { border-bottom: 0; padding-bottom: 0; }
}

/* --------------------------------------------------------------- print */

@media print {
  :root { --row: auto; }
  body { background: #fff; font-size: 11pt; }
  .topbar, .rail, .case-header .actions, .btn, .searchbox, .pager,
  .dropzone, form { display: none !important; }
  main { padding: 0; max-width: none; }
  .card, .tile, .case-header {
    box-shadow: none; border: 1px solid #999; break-inside: avoid;
  }
  .case-header { position: static; }
  table.grid th { position: static; background: #eee; }
  table.grid td, table.grid th { white-space: normal; height: auto; padding: 4px 6px; }
  .case-layout { display: block; }
  a { color: #000; text-decoration: none; }
  .feed li { break-inside: avoid; }
}

/* ---- case-header controls -------------------------------------------- */
/* Folded away by default: the header is a place people read at a glance, and
   two always-open forms would push the case itself below the fold. */
.hdr-panel {
  border-top: 1px solid var(--line);
  padding: 10px 16px 12px;
  background: var(--panel);
}
.hdr-form {
  display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end;
}
.hdr-form label {
  display: flex; flex-direction: column; gap: 4px;
  font-size: 11px; text-transform: uppercase; letter-spacing: .04em;
  color: var(--muted);
}
.hdr-form label.grow { flex: 1 1 220px; }
.hdr-form select, .hdr-form input[type=text] {
  font-size: 13px; padding: 6px 8px; text-transform: none; letter-spacing: 0;
  color: var(--ink);
}
#hdr-close-only { display: contents; }
