/* ============================================================
   Chambers of Atharva Kotwal
   Ivory paper, warm ink, claret and brass. Cormorant Garamond
   letterhead with Inter for everything you read and tap.
   ============================================================ */

:root {
  /* paper & ink */
  --paper: #f5f1e8;
  --paper-2: #efe8da;
  --surface: #fffdf8;
  --ink: #1d1915;
  --text: #2c2721;
  --muted: #7a7064;
  --line: #e6ddcc;
  --line-strong: #d5c8b1;

  /* claret (primary) */
  --claret: #6d1a2a;
  --claret-700: #571421;
  --claret-900: #350b13;
  --claret-50: #f7ebec;

  /* brass (accent) */
  --brass: #a8834b;
  --brass-light: #cfae72;
  --brass-dark: #7d6034;
  --brass-50: #f5eddd;

  /* signals */
  --sage: #2f6b4f;
  --sage-50: #e8f1eb;
  --rust: #b03a2e;
  --rust-50: #faeae6;
  --amber-bg: #fbf3e1;
  --amber-line: #ead7ab;

  /* sidebar */
  --side-top: #251e19;
  --side-bottom: #15110e;
  --side-text: #d8cdbb;
  --side-dim: #9a8e7c;

  /* aliases used in templates */
  --primary: var(--claret);
  --danger: var(--rust);
  --success: var(--sage);
  --border: var(--line);
  --border-strong: var(--line-strong);
  --bg: var(--paper);

  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 1px 2px rgba(45, 30, 15, 0.05), 0 6px 22px rgba(45, 30, 15, 0.06);
  --shadow-pop: 0 14px 40px rgba(30, 18, 8, 0.22);

  --font-display: "Cormorant Garamond", "Cormorant", Baskerville, "Iowan Old Style", Georgia, serif;
  --font-body: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }

/* Cormorant's default old-style figures look uneven in counts and dates. */
.page-title, h2, .stat-value, .listing-banner .big, .lc-item strong, .brand-title, .login-card h1 {
  font-variant-numeric: lining-nums;
  font-feature-settings: "lnum" 1;
}

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

a { color: var(--claret); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }
h1, h2, h3 { color: var(--ink); }
h2 { font-family: var(--font-display); font-weight: 700; font-size: 22px; letter-spacing: 0.005em; margin: 0 0 10px; }
h3 { font-size: 13px; text-transform: uppercase; letter-spacing: 0.09em; color: var(--brass-dark); margin: 20px 0 8px; }
code { background: var(--paper-2); padding: 1px 6px; border-radius: 5px; font-size: 12.5px; }
.small { font-size: 12px; }
.muted { color: var(--muted); font-size: 13px; }
.prewrap { white-space: pre-wrap; }

/* ---------- Shell ---------- */

.shell { display: flex; min-height: 100vh; }

.sidebar {
  width: 248px;
  flex-shrink: 0;
  background: linear-gradient(180deg, var(--side-top) 0%, var(--side-bottom) 100%);
  color: var(--side-text);
  display: flex;
  flex-direction: column;
  padding: 26px 16px 20px;
  position: sticky;
  top: 0;
  height: 100vh;
  border-right: 1px solid rgba(207, 174, 114, 0.18);
}

.brand { display: flex; align-items: center; gap: 12px; margin: 0 6px 30px; color: #fff; }
.brand:hover { text-decoration: none; }
.brand-mark {
  width: 46px; height: 46px; flex-shrink: 0;
  border-radius: 50%;
  background: radial-gradient(circle at 30% 25%, #8a2537 0%, var(--claret) 55%, var(--claret-900) 100%);
  box-shadow: inset 0 0 0 1.5px var(--brass-light), 0 4px 14px rgba(0, 0, 0, 0.35);
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--brass-light);
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 19px;
  letter-spacing: 0.02em;
}
img.brand-mark { object-fit: cover; border: 1.5px solid var(--brass-light); box-shadow: 0 4px 14px rgba(0, 0, 0, 0.35); }
.brand-name { display: flex; flex-direction: column; line-height: 1.05; }
.brand-kicker {
  font-size: 9.5px; font-weight: 600; letter-spacing: 0.24em; text-transform: uppercase;
  color: var(--brass-light);
}
.brand-title { font-family: var(--font-display); font-weight: 700; font-size: 21px; color: #f6efe3; margin-top: 3px; }

.side-nav { display: flex; flex-direction: column; gap: 2px; }
.side-nav a {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px; border-radius: var(--radius-sm);
  color: var(--side-dim); font-weight: 500; font-size: 14px;
  border-left: 2px solid transparent;
  transition: background 0.15s, color 0.15s;
}
.side-nav a svg { width: 19px; height: 19px; opacity: 0.85; }
.side-nav a:hover { background: rgba(255, 255, 255, 0.05); color: #fff; text-decoration: none; }
.side-nav a.active {
  background: linear-gradient(90deg, rgba(207, 174, 114, 0.16), rgba(207, 174, 114, 0.02));
  color: var(--brass-light);
  border-left-color: var(--brass-light);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}
.side-nav a.active svg { opacity: 1; }
.side-bottom { margin-top: auto; display: flex; flex-direction: column; gap: 12px; }
.side-logout {
  width: 100%; background: transparent;
  border: 1px solid rgba(207, 174, 114, 0.25); color: var(--side-dim);
  border-radius: var(--radius-sm); padding: 8px 12px; font: inherit; font-size: 13px; cursor: pointer;
}
.side-logout:hover { color: #fff; border-color: var(--brass-light); }

.content { flex: 1; min-width: 0; }
.content-inner { max-width: 1080px; margin: 0 auto; padding: 36px 40px 80px; }

/* ---------- Letterhead on every page ---------- */

.masthead { display: flex; align-items: center; gap: 18px; margin: -6px 0 26px; }
.mast-rule { flex: 1; height: 1px; background: linear-gradient(90deg, transparent, var(--brass) 30%, var(--brass) 70%, transparent); }
.mast-text { display: flex; flex-direction: column; align-items: center; color: var(--ink); line-height: 1.05; }
.mast-text:hover { text-decoration: none; }
.mast-kicker { font-size: 10.5px; font-weight: 600; letter-spacing: 0.32em; text-transform: uppercase; color: var(--brass-dark); }
.mast-name { font-family: var(--font-display); font-weight: 700; font-size: 30px; letter-spacing: 0.04em; color: var(--claret-700); margin-top: 3px; }

/* ---------- Page headers ---------- */

.page-title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 36px;
  line-height: 1.1;
  letter-spacing: 0.005em;
  margin: 0 0 6px;
  color: var(--ink);
}
/* Case names are long and often in capitals: smaller, tighter, no shouting. */
.case-title { font-size: clamp(22px, 2.6vw, 30px); line-height: 1.2; text-transform: none; max-width: 900px; overflow-wrap: anywhere; }
.page-sub { color: var(--muted); font-size: 14px; margin: 0 0 24px; }
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; margin-bottom: 22px; }
.page-actions { display: flex; gap: 8px; flex-wrap: nowrap; flex-shrink: 0; }

/* ---------- Cards ---------- */

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 22px;
  box-shadow: var(--shadow);
}
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 14px; }
.card-head h2 { margin: 0; }
.card-head form { margin: 0; }
.card-warn { background: var(--amber-bg); border-color: var(--amber-line); }
.empty { color: var(--muted); padding: 6px 0; font-size: 13.5px; }
.empty-state { text-align: center; padding: 40px 20px; color: var(--muted); }

/* ---------- Track card (dashboard hero) ---------- */

.track-card {
  background:
    radial-gradient(900px 260px at 105% -30%, rgba(207, 174, 114, 0.28), transparent 60%),
    linear-gradient(140deg, #7a1f31 0%, var(--claret) 45%, var(--claret-900) 100%);
  border: none;
  color: #efe4d4;
  padding: 30px 28px;
  box-shadow: 0 10px 30px rgba(53, 11, 19, 0.28);
}
.track-card h2 { color: #fbf5ea; font-size: 28px; margin-bottom: 4px; }
.track-card .muted { color: #d9c3b4; font-size: 13.5px; }
.track-card input[type="text"], .track-card select {
  background: rgba(255, 253, 248, 0.97); border: none; height: 46px; font-size: 15px; border-radius: 10px; color: var(--ink);
}
.track-card .inline-form { margin: 16px 0 0; }
.track-card .btn-primary {
  height: 46px; padding: 0 22px; border-radius: 10px;
  background: linear-gradient(140deg, var(--brass-light) 0%, var(--brass) 100%);
  border: none; color: #2a1c0c; font-weight: 700; font-size: 15px;
}
.track-card .btn-primary:hover { filter: brightness(1.06); }
.track-card .small { color: #d9c3b4; }

.track-tabs { display: flex; gap: 6px; margin: 4px 0 14px; }
.forum-tabs { flex-wrap: wrap; margin-top: 16px; }
.track-tab {
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid rgba(255, 255, 255, 0.16);
  color: #eadccb;
  padding: 7px 15px; border-radius: 999px;
  font: inherit; font-size: 13px; font-weight: 600; cursor: pointer;
}
.track-tab:hover { background: rgba(255, 255, 255, 0.13); }
.track-tab.active { background: linear-gradient(140deg, var(--brass-light), var(--brass)); border-color: transparent; color: #2a1c0c; }
.sub-tabs .track-tab { padding: 5px 12px; font-size: 12px; }
.track-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-top: 6px; }
.track-grid .span-2 { grid-column: span 2; }
.track-grid select, .track-grid input[type="text"] { width: 100%; }
.forum-pane[hidden] { display: none !important; }

/* ---------- Stats ---------- */

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 14px; margin-bottom: 22px; }
.stat {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px 18px; box-shadow: var(--shadow); border-top: 3px solid var(--line-strong);
}
.stat-label { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.1em; color: var(--muted); }
.stat-value { font-family: var(--font-display); font-weight: 700; font-size: 34px; color: var(--ink); line-height: 1.15; }
.stat-value.small-val { font-size: 24px; }
.stat-open { border-top-color: var(--claret); }
.stat-open .stat-value { color: var(--claret); }
.stat-hold { border-top-color: var(--brass); }
.stat-hold .stat-value { color: var(--brass-dark); }
.stat-closed .stat-value { color: var(--muted); }

/* ---------- Tables ---------- */

.table { width: 100%; border-collapse: collapse; }
.table th, .table td { padding: 11px 12px; text-align: left; border-bottom: 1px solid var(--line); font-size: 13.5px; vertical-align: top; }
.table th {
  font-weight: 600; color: var(--muted); font-size: 11px;
  text-transform: uppercase; letter-spacing: 0.09em; border-bottom: 1px solid var(--line-strong);
}
.table tbody tr:hover { background: var(--paper); }
.table tr:last-child td { border-bottom: none; }
.table td a { font-weight: 600; }
.row-actions { text-align: right; white-space: nowrap; }

/* ---------- Pills, links ---------- */

.pill {
  display: inline-block; padding: 2px 10px; border-radius: 999px;
  font-size: 11.5px; font-weight: 600; text-transform: capitalize; letter-spacing: 0.02em;
}
.pill-open { background: var(--brass-50); color: var(--brass-dark); box-shadow: inset 0 0 0 1px rgba(168, 131, 75, 0.35); }
.pill-closed { background: var(--paper-2); color: var(--muted); }
.pill-on_hold { background: var(--amber-bg); color: #8a5a12; }
.gcal-link { font-size: 12px; font-weight: 600; color: var(--brass-dark); }
.link-btn { background: none; border: none; padding: 0; color: var(--muted); font: inherit; font-size: 12.5px; cursor: pointer; }
.link-btn:hover { color: var(--rust); text-decoration: underline; }

/* ---------- Forms ---------- */

.filters { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 18px; }
.filters input[type="search"] { flex: 1; min-width: 240px; }
.filters select { width: auto; flex: 0 0 190px; }
input[type="text"], input[type="search"], input[type="date"], input[type="password"],
input[type="file"], select, textarea {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: #fff;
  font: inherit;
  color: var(--ink);
  transition: border-color 0.15s, box-shadow 0.15s;
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--brass); box-shadow: 0 0 0 3px rgba(168, 131, 75, 0.2);
}
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 18px; }
.form-grid label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; font-weight: 600; color: var(--text); }
.form-grid label span { color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: 0.06em; }
.form-grid .full { grid-column: 1 / -1; }
.form-actions { margin-top: 18px; display: flex; gap: 8px; }
.inline-form { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.inline-form input[type="date"], .inline-form select { width: auto; }
.inline-form input[type="file"] { width: auto; padding: 7px; }
.check-label { display: flex !important; flex-direction: row !important; align-items: center; gap: 8px; align-self: end; padding-bottom: 10px; }
.check-label input { width: auto; }
.add-row { margin-top: 12px; }
.add-details { margin-top: 14px; }
.add-details summary { cursor: pointer; color: var(--claret); font-weight: 600; font-size: 13.5px; }
.add-details .form-grid { margin-top: 12px; }
details summary { cursor: pointer; }

/* ---------- Buttons ---------- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 9px 16px; border-radius: var(--radius-sm);
  border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink);
  font: inherit; font-weight: 600; font-size: 13.5px; cursor: pointer;
  box-shadow: 0 1px 1px rgba(45, 30, 15, 0.05);
  transition: background 0.15s, border-color 0.15s, filter 0.15s;
}
.btn:hover { background: var(--paper); text-decoration: none; border-color: var(--brass); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-sm { padding: 6px 12px; font-size: 12.5px; }
.btn-block { width: 100%; }
.btn-primary { background: var(--claret); border-color: var(--claret); color: #fbf5ea; }
.btn-primary:hover { background: var(--claret-700); border-color: var(--claret-700); }
.btn-gold { background: linear-gradient(140deg, var(--brass-light), var(--brass)); border: none; color: #2a1c0c; }
.btn-danger { background: var(--rust); border-color: var(--rust); color: #fff; }
.btn-danger:hover { filter: brightness(0.95); background: var(--rust); }
.btn-quiet-danger { background: transparent; border-color: var(--line-strong); color: var(--rust); box-shadow: none; }
.btn-quiet-danger:hover { background: var(--rust-50); border-color: var(--rust); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--muted); box-shadow: none; }

/* ---------- Key/value, client ---------- */

.kv { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px 28px; margin: 0; }
.kv > div { border-bottom: 1px dashed var(--line); padding-bottom: 8px; }
.kv dt, .kv > .muted { font-size: 11px; text-transform: uppercase; letter-spacing: 0.09em; color: var(--muted); font-weight: 600; margin-bottom: 3px; }
.kv dd { margin: 0; color: var(--ink); font-weight: 500; }
.client-ask {
  margin-top: 16px; padding: 12px 14px; display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  background: var(--brass-50); border: 1px solid rgba(168, 131, 75, 0.35); border-radius: var(--radius-sm);
  font-weight: 600; color: var(--brass-dark);
}

/* ---------- Flash messages ---------- */

.flashes { margin-bottom: 18px; }
.flash { padding: 11px 14px; border-radius: var(--radius-sm); margin-bottom: 8px; font-size: 13.5px; }
.flash-success { background: var(--sage-50); color: var(--sage); border: 1px solid #bcd8c7; }
.flash-error { background: var(--rust-50); color: var(--rust); border: 1px solid #efc4bb; }
.flash-info { background: var(--brass-50); color: var(--text); border: 1px solid var(--amber-line); line-height: 1.5; }

/* ---------- Live display board ---------- */

.live-card { border-top: 3px solid var(--claret); }
.live-card h2 { display: flex; align-items: center; gap: 8px; }
.live-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--rust); box-shadow: 0 0 0 0 rgba(176, 58, 46, .6); animation: live-pulse 1.6s infinite; }
@keyframes live-pulse { 70% { box-shadow: 0 0 0 9px rgba(176, 58, 46, 0); } 100% { box-shadow: 0 0 0 0 rgba(176, 58, 46, 0); } }
.live-rows { display: grid; gap: 10px; }
.live-row { display: flex; gap: 14px; align-items: center; padding: 12px 14px; border-radius: 12px; background: #fff;
  border: 1px solid var(--line); border-left: 4px solid var(--brass-light); color: var(--text); }
.live-row:hover { text-decoration: none; border-color: var(--brass); }
.live-row.is-soon { border-left-color: var(--claret); background: var(--claret-50); }
.live-row.is-now { border-left-color: var(--sage); background: var(--sage-50); }
.live-row.is-done, .live-row.is-passed { opacity: .65; }
.lr-eff { width: 64px; flex-shrink: 0; text-align: center; }
.lr-big { display: block; font-family: var(--font-display); font-size: 34px; font-weight: 700; line-height: 1; color: var(--claret); }
.live-row.is-now .lr-big { color: var(--sage); font-size: 26px; }
.lr-cap { display: block; font-size: 10px; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); margin-top: 3px; }
.lr-main { min-width: 0; flex: 1; }
.lr-name { font-weight: 700; color: var(--ink); }
.lr-meta { font-size: 12.5px; color: var(--muted); margin-top: 3px; }
.lr-meta b, .lr-now b { color: var(--claret); }
.lr-now { font-size: 13px; margin-top: 4px; }
.live-foot { margin: 10px 0 0; }

/* ---------- Calendar ---------- */

.cal-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 6px; }
.cal-nav { display: flex; align-items: center; gap: 6px; }
.cal-title { font-family: var(--font-display); font-size: 40px; font-weight: 600; color: var(--ink); margin: 0 6px; line-height: 1; min-width: 7.5ch; text-align: center; }
.cal-title span { color: var(--brass); font-weight: 500; }
.cal-arrow {
  width: 38px; height: 38px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center;
  color: var(--claret); background: var(--surface); box-shadow: inset 0 0 0 1px var(--line-strong);
}
.cal-arrow:hover { background: var(--claret-50); text-decoration: none; }
.cal-arrow svg { width: 18px; height: 18px; }
.cal-tools { display: flex; gap: 8px; }
.cal-summary { color: var(--muted); font-size: 13.5px; margin: 6px 0 16px; display: flex; flex-wrap: wrap; gap: 4px 14px; align-items: center; }
.cal-summary strong { color: var(--text); }
.cal-legend { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; margin-left: auto; }
.cal-legend .dot { margin-left: 6px; }
.dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; }
.dot-listed { background: var(--claret); }
.dot-fixed { background: var(--brass-light); }

.cal-grid {
  display: grid; grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: var(--radius);
  overflow: hidden; box-shadow: var(--shadow);
}
.cal-head { background: var(--paper-2); padding: 9px 8px; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.1em; color: var(--muted); text-align: center; }
.cal-head .ds { display: none; }
.cal-cell { position: relative; background: var(--surface); min-height: 112px; padding: 8px 7px; min-width: 0; }
.cal-weekend { background: #fcf9f2; }
.cal-other { background: var(--paper); }
.cal-other .cal-date { opacity: 0.45; }
.cal-today { background: var(--brass-50); }
.cal-date { font-size: 12px; font-weight: 700; color: var(--muted); width: 24px; height: 24px; display: flex; align-items: center; justify-content: center; border-radius: 50%; margin: -2px 0 2px -2px; }
.cal-today .cal-date { background: var(--claret); color: #fbf5ea; }
.cal-dots, .cal-hit { display: none; }
.cal-event {
  display: block; margin-top: 4px; padding: 4px 7px; border-radius: 7px; line-height: 1.25;
  font-size: 11.5px; border-left: 3px solid; min-width: 0;
}
.cal-event:hover { text-decoration: none; filter: brightness(0.97); }
.cal-event .ce-name { display: block; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cal-event .ce-forum { display: block; font-size: 10.5px; font-weight: 500; opacity: 0.8; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cal-event.is-listed { background: var(--claret-50); color: var(--claret); border-color: var(--claret); }
.cal-event.is-fixed { background: var(--brass-50); color: var(--brass-dark); border-color: var(--brass-light); }
.cal-past .cal-event { opacity: 0.6; }
.cal-link { color: inherit; }

.cal-agenda { display: none; }

/* ---------- Code ---------- */

.codeblock { background: var(--paper-2); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 12px; font-size: 11.5px; white-space: pre-wrap; word-break: break-all; }
kbd { background: var(--paper-2); border: 1px solid var(--line-strong); border-bottom-width: 2px; border-radius: 5px; padding: 1px 6px; font-family: ui-monospace, Menlo, monospace; font-size: 11.5px; }

/* ---------- Listings & next-date banner ---------- */

.listing-banner { display: flex; gap: 28px; align-items: center; flex-wrap: wrap; border-left: 4px solid var(--line-strong); }
.listing-banner.is-listed { border-left-color: var(--brass); background: linear-gradient(90deg, var(--brass-50), var(--surface) 65%); }
.listing-banner.is-past { border-left-color: var(--rust); background: linear-gradient(90deg, var(--rust-50), var(--surface) 60%); }
.listing-banner .big { font-family: var(--font-display); font-size: 30px; font-weight: 700; color: var(--ink); line-height: 1.1; }
.listing-where { display: flex; gap: 6px 22px; flex-wrap: wrap; align-items: baseline; flex: 1; }
.listing-where strong { font-size: 18px; color: var(--claret); }
.listing-where .bench { flex-basis: 100%; font-size: 13px; color: var(--text); }

.board h3 { margin-top: 18px; }
.listing-cards { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.listing-cards li { display: flex; gap: 16px; align-items: flex-start; border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 12px 14px; background: #fff; }
.listing-cards li.is-today { border-color: var(--brass); background: var(--brass-50); }
.lc-when { min-width: 120px; border-right: 1px solid var(--line); padding-right: 12px; }
.lc-date { font-weight: 700; color: var(--ink); }
.lc-court { font-size: 13px; color: var(--muted); }
.lc-item strong { font-family: var(--font-display); font-size: 22px; color: var(--claret); }
.lc-what a { font-weight: 600; }
.plain-list { margin: 0; padding-left: 18px; }
.plain-list li { margin: 5px 0; }
.overdue-text, .overdue-text strong { color: var(--rust); }

.needs-list { list-style: none; margin: 0; padding: 0; }
.needs-list li { display: flex; align-items: center; gap: 12px; padding: 11px 0; border-bottom: 1px solid var(--amber-line); }
.needs-list li:last-child { border-bottom: none; }
.nd-what { flex: 1; min-width: 0; }
.nd-what a { font-weight: 600; }

/* ---------- Dashboard ---------- */

.dash-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; margin-bottom: 22px; }
.dash-date { font-size: 11px; font-weight: 600; letter-spacing: 0.16em; text-transform: uppercase; color: var(--brass-dark); margin-bottom: 4px; }
.listed-count { color: var(--claret); }
.add-case { margin-bottom: 22px; }
.add-case > summary { display: none; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.dash-grid { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 22px; align-items: start; }
.dash-side .card { padding: 18px; }
.dash-side h2 { font-size: 20px; }
.quiet-card { background: var(--paper-2); box-shadow: none; }

.day-block { margin-bottom: 22px; }
.day-head { display: flex; align-items: baseline; gap: 10px; margin: 0 2px 10px; }
.day-head h2 { margin: 0; font-size: 26px; }
.day-block.is-today .day-head h2 { color: var(--claret); }
.matters { display: grid; gap: 10px; }

.matter {
  display: flex; gap: 14px; align-items: stretch; justify-content: space-between;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 12px 14px; color: var(--text); box-shadow: 0 1px 2px rgba(45, 30, 15, 0.04);
  border-left: 4px solid var(--line-strong); transition: border-color .15s, transform .15s;
}
.matter:hover { text-decoration: none; border-color: var(--brass); transform: translateY(-1px); }
.matter.listed { border-left-color: var(--claret); }
.matter.status { border-left-color: var(--brass); }
.matter.likely { border-left-color: var(--brass-light); border-style: solid dashed solid solid; }
.matter.big { padding: 16px 18px; box-shadow: var(--shadow); }
.matter.big.listed { background: linear-gradient(90deg, var(--claret-50), var(--surface) 55%); }
.m-main { min-width: 0; flex: 1; }
.m-name { font-weight: 700; color: var(--ink); font-size: 15px; overflow: hidden; text-overflow: ellipsis; }
.matter.big .m-name { font-family: var(--font-display); font-size: 21px; line-height: 1.2; }
.m-meta { font-size: 12px; color: var(--muted); margin-top: 3px; }
.forum-chip {
  display: inline-block; font-size: 11px; font-weight: 700; letter-spacing: 0.03em; color: var(--brass-dark);
  background: var(--brass-50); border: 1px solid rgba(168, 131, 75, 0.3); border-radius: 6px; padding: 0 6px; margin-right: 4px;
}
.m-bench { font-size: 12px; color: var(--text); margin-top: 5px; opacity: .85; }
.m-where { text-align: right; min-width: 130px; display: flex; flex-direction: column; align-items: flex-end; gap: 2px; justify-content: center; }
.m-court { font-weight: 700; color: var(--ink); font-size: 14px; }
.m-item { font-size: 13px; color: var(--muted); }
.m-item strong { font-family: var(--font-display); font-size: 26px; color: var(--claret); line-height: 1; font-variant-numeric: lining-nums; }
.matter:not(.big) .m-item strong { font-size: 20px; }
.m-time { font-size: 12px; color: var(--muted); }
.m-board { display: flex; flex-wrap: wrap; gap: 4px 10px; margin-top: 6px; font-size: 12px; color: var(--brass-dark); font-weight: 600; }
.m-board .live { color: var(--sage); }
.badge { display: inline-block; font-size: 10.5px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; border-radius: 999px; padding: 2px 9px; }
.badge-listed { background: var(--claret); color: #fbf5ea; }
.badge-status { background: var(--brass-50); color: var(--brass-dark); box-shadow: inset 0 0 0 1px rgba(168,131,75,.4); }
.badge-likely { background: transparent; color: var(--brass-dark); box-shadow: inset 0 0 0 1px var(--brass-light); }
.badge-fixed { background: var(--paper-2); color: var(--muted); }

.day-row { display: grid; grid-template-columns: 110px 1fr; gap: 14px; padding: 12px 0; border-top: 1px solid var(--line); }
.day-row:first-of-type { border-top: none; padding-top: 0; }
.day-label { display: flex; flex-direction: column; }
.day-label strong { color: var(--ink); }
.day-label span { font-size: 12px; color: var(--muted); }

.mini-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.mini-stats a {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 10px;
  text-align: center; color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .08em;
}
.mini-stats a:hover { text-decoration: none; border-color: var(--brass); }
.mini-stats strong { display: block; font-family: var(--font-display); font-size: 26px; color: var(--ink); letter-spacing: 0; font-variant-numeric: lining-nums; }

/* ---------- Tasks, fees, documents, more ---------- */

.task-list { list-style: none; margin: 0 0 12px; padding: 0; }
.task-list li { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.task-list li:last-child { border-bottom: none; }
.task-list form { margin: 0; }
.task-body { flex: 1; min-width: 0; }
.task-title { font-weight: 500; color: var(--ink); }
.task-list li.done .task-title { text-decoration: line-through; color: var(--muted); }
.task-list li.overdue .task-title { color: var(--rust); }
.check {
  width: 24px; height: 24px; border-radius: 7px; border: 2px solid var(--line-strong);
  background: #fff; color: #fff; font-weight: 700; cursor: pointer; padding: 0; line-height: 1;
}
.check:hover { border-color: var(--brass); }
.task-list li.done .check { background: var(--sage); border-color: var(--sage); }
.fee-sum { display: flex; gap: 24px; flex-wrap: wrap; margin-bottom: 10px; font-weight: 600; }
.amt-in { color: var(--sage); }
.doc-list { list-style: none; margin: 0; padding: 0; }
.doc-list li { display: flex; gap: 10px; align-items: baseline; padding: 7px 0; border-bottom: 1px solid var(--line); }
.doc-list li a { flex: 1; word-break: break-all; }
.more-list { padding: 0; overflow: hidden; }
.more-list a { display: flex; justify-content: space-between; padding: 16px 18px; border-bottom: 1px solid var(--line); color: var(--ink); font-weight: 500; font-size: 15px; }
.more-list a:last-child { border-bottom: none; }
.more-list a:hover { background: var(--paper); text-decoration: none; }
.more-list a span { color: var(--brass); }

/* ---------- Fetch-from-court ---------- */

.captcha-box { display: flex; align-items: center; gap: 14px; margin: 14px 0; flex-wrap: wrap; }
.captcha-box img { height: 64px; min-width: 150px; border: 1px solid var(--line-strong); border-radius: 8px; background: #fff; image-rendering: pixelated; }
.captcha-text {
  font: 700 30px/1 ui-monospace, Menlo, monospace; letter-spacing: 0.2em; color: var(--claret);
  background: #fff; border: 1px solid var(--line-strong); border-radius: 8px; padding: 14px 20px;
}

/* ---------- Login (letterhead) ---------- */

.login-body {
  min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 16px;
  background:
    radial-gradient(800px 400px at 50% -10%, rgba(207, 174, 114, 0.25), transparent 70%),
    linear-gradient(180deg, var(--side-top), var(--side-bottom));
}
.login-card {
  width: 100%; max-width: 380px; background: var(--surface); border-radius: 18px;
  box-shadow: var(--shadow-pop); padding: 36px 30px 30px; text-align: center;
  border-top: 4px solid var(--brass);
}
.login-card .brand-mark { width: 64px; height: 64px; font-size: 26px; }
.login-kicker { margin-top: 18px; font-size: 10.5px; font-weight: 600; letter-spacing: 0.28em; text-transform: uppercase; color: var(--brass-dark); }
.login-card h1 { font-family: var(--font-display); font-size: 32px; font-weight: 700; margin: 2px 0 6px; }
.login-rule { width: 56px; height: 1px; background: var(--brass); margin: 0 auto 22px; }
.login-card .form { text-align: left; display: flex; flex-direction: column; gap: 10px; }
.login-card label { font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); }

/* ---------- Phone ---------- */

.tabbar, .only-phone { display: none; }
.case-cards, .case-jump { display: none; }
.add-task > summary { display: none; }
.add-task { list-style: none; }
.show-more { display: none; }

@media (max-width: 860px) {
  .shell { flex-direction: column; }
  .sidebar {
    width: 100%; height: auto; position: sticky; top: 0; z-index: 20;
    flex-direction: row; align-items: center;
    padding: calc(10px + env(safe-area-inset-top)) 16px 10px; gap: 14px;
    border-right: none; border-bottom: 1px solid rgba(207, 174, 114, 0.25);
  }
  .brand { margin: 0; }
  .brand-mark { width: 36px; height: 36px; font-size: 15px; }
  .brand-kicker { font-size: 8.5px; }
  .brand-title { font-size: 18px; margin-top: 1px; }
  .side-nav, .side-bottom { display: none; }

  .tabbar {
    display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
    background: rgba(255, 253, 248, 0.97); backdrop-filter: blur(8px);
    border-top: 1px solid var(--line); box-shadow: 0 -4px 18px rgba(45, 30, 15, 0.07);
    padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
    justify-content: space-around; align-items: center;
  }
  .tabbar a { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; color: var(--muted); font-size: 10.5px; font-weight: 600; padding: 4px 0; }
  .tabbar a:hover { text-decoration: none; }
  .tabbar a svg { width: 23px; height: 23px; }
  .tabbar a.active { color: var(--claret); }
  .tabbar .tab-add {
    flex: 0 0 auto; width: 52px; height: 52px; margin-top: -20px; border-radius: 50%;
    background: radial-gradient(circle at 30% 25%, #8a2537, var(--claret) 55%, var(--claret-900));
    box-shadow: inset 0 0 0 2px var(--brass-light), 0 6px 16px rgba(53, 11, 19, 0.35);
    justify-content: center;
  }
  .tabbar .tab-add svg { width: 26px; height: 26px; color: var(--brass-light) !important; }
  .only-phone { display: block; margin-top: 8px; }

  .btn-block { width: auto; }
  .content-inner { padding: 20px 16px calc(96px + env(safe-area-inset-bottom)); }
  .page-title { font-size: 30px; }
  .masthead { display: none; }  /* the phone top bar is the letterhead */
  .mast-name { font-size: 22px; }
  .mast-kicker { font-size: 9px; }
  .dash-head { flex-direction: column; align-items: stretch; }
  .dash-grid { grid-template-columns: 1fr; }
  .matter.big .m-name { font-size: 18px; }
  .day-row { grid-template-columns: 1fr; gap: 6px; }
  .case-title { font-size: 21px; }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .form-grid { grid-template-columns: 1fr; }
  .kv { grid-template-columns: 1fr; }
  .page-head { flex-direction: column; align-items: stretch; }
  .page-actions { flex-wrap: wrap; }
  .card { padding: 16px; }
  .track-card { padding: 22px 16px; }
  .track-card h2 { font-size: 24px; }
  .forum-tabs { display: grid; grid-template-columns: 1fr 1fr; }
  .track-grid { grid-template-columns: 1fr 1fr; }
  .track-grid .span-2, .track-grid .btn-primary { grid-column: span 2; }
  .table { display: block; overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .table th, .table td { white-space: nowrap; }
  .table td:nth-child(2) { white-space: normal; min-width: 180px; }
  .inline-form { flex-wrap: wrap; }
  .track-card input[type="text"], .inline-form input[type="text"] { min-width: 0 !important; width: 100% !important; flex: 1 1 100% !important; }
  .listing-banner { gap: 10px; }
  .lc-when { min-width: 96px; }
  /* Calendar: compact month with dots, then the matters day by day. */
  .cal-top { flex-wrap: nowrap; }
  .cal-title { font-size: 27px; min-width: 0; margin: 0 2px; }
  .cal-arrow { width: 34px; height: 34px; }
  .cal-legend { margin-left: 0; }
  .cal-grid { background: var(--surface); gap: 0; padding: 6px 4px 8px; }
  .cal-head { background: transparent; padding: 6px 0 8px; font-size: 11px; letter-spacing: 0.04em; }
  .cal-head .dl { display: none; }
  .cal-head .ds { display: inline; }
  .cal-cell, .cal-weekend, .cal-other, .cal-today { background: transparent; min-height: 46px; padding: 2px 0; display: flex; flex-direction: column; align-items: center; }
  .cal-date { margin: 0; width: 32px; height: 32px; font-size: 15px; font-weight: 600; color: var(--text); }
  .cal-past .cal-date { color: var(--muted); }
  .cal-other .cal-date { opacity: 0.3; }
  .has-events .cal-date { font-weight: 800; }
  .cal-today .cal-date { color: #fbf5ea; }
  .cal-event { display: none; }
  .cal-dots { display: flex; gap: 3px; height: 7px; }
  .cal-dots .dot { width: 5px; height: 5px; }
  .cal-hit { display: block; position: absolute; inset: 0; border-radius: 10px; }
  .cal-hit:active { background: var(--claret-50); }

  .cal-agenda { display: block; margin-top: 18px; }
  .ag-day { display: flex; gap: 12px; padding: 12px 0; border-top: 1px solid var(--line); scroll-margin-top: 90px; }
  .ag-day:first-child { border-top: none; }
  .ag-day:target .ag-num { color: var(--claret); }
  .ag-day:target .ag-items { animation: ag-flash 1.4s ease-out; }
  @keyframes ag-flash { from { box-shadow: 0 0 0 3px var(--brass-light); border-radius: 12px; } to { box-shadow: 0 0 0 3px transparent; } }
  .ag-day.is-past { opacity: 0.55; }
  .ag-date { width: 46px; flex-shrink: 0; text-align: center; padding-top: 2px; }
  .ag-dow { display: block; font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.1em; color: var(--muted); }
  .ag-num { display: block; font-family: var(--font-display); font-size: 30px; font-weight: 600; line-height: 1; color: var(--ink); }
  .ag-mon { display: block; font-size: 11px; color: var(--muted); }
  .ag-day.is-today .ag-dow { color: var(--claret); }
  .ag-day.is-today .ag-num { color: var(--claret); }
  .ag-items { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 8px; }
  .ag-item {
    display: block; padding: 11px 13px; border-radius: 12px; background: var(--surface);
    box-shadow: var(--shadow); border-left: 4px solid var(--brass-light); color: var(--text);
  }
  .ag-item:hover, .ag-item:active { text-decoration: none; background: #fff; }
  .ag-item.is-listed { border-left-color: var(--claret); }
  .ag-name { display: block; font-weight: 650; font-size: 15px; line-height: 1.3; color: var(--ink); }
  .ag-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; margin-top: 6px; font-size: 12.5px; color: var(--muted); }
  .ag-forum { font-size: 10.5px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; padding: 2px 8px; border-radius: 999px; background: var(--paper-2); color: var(--brass-dark); }
  .ag-item.is-listed .ag-forum { background: var(--claret); color: #fbf5ea; }
  .ag-where b { color: var(--claret); font-size: 14px; }
  .ag-empty { color: var(--muted); text-align: center; padding: 28px 0; }
  .ag-earlier { margin-top: 10px; border-top: 1px solid var(--line); }
  .ag-earlier summary { cursor: pointer; padding: 14px 2px; font-size: 13px; font-weight: 600; color: var(--muted); list-style: none; }
  .ag-earlier summary::before { content: "▸ "; color: var(--brass); }
  .ag-earlier[open] summary::before { content: "▾ "; }
  /* ---- Phone: lists as cards, no sideways scrolling ---- */
  .hide-phone { display: none !important; }
  input[type="file"] { max-width: 100%; min-width: 0; font-size: 14px !important; }

  /* Cases list */
  .filters { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
  .filters input[type="search"] { grid-column: 1 / -1; min-width: 0; }
  .filters .btn { display: none; }
  .filters .btn-ghost { display: inline-flex; grid-column: 1 / -1; justify-content: center; }
  .case-cards { display: grid; gap: 10px; }
  .case-card {
    display: block; padding: 13px 14px; border-radius: 12px; background: var(--surface);
    border: 1px solid var(--line); border-left: 4px solid var(--line-strong); color: var(--text);
    box-shadow: 0 1px 2px rgba(45, 30, 15, 0.04);
  }
  .case-card:hover, .case-card:active { text-decoration: none; background: #fff; }
  .case-card.is-open { border-left-color: var(--brass-light); }
  .case-card.is-listed { border-left-color: var(--claret); }
  .case-card.is-closed { opacity: 0.65; }
  .cc-top { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
  .cc-no { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
  .cc-top .pill { margin-left: auto; }
  .cc-name { font-weight: 650; font-size: 15.5px; line-height: 1.3; color: var(--ink); margin-top: 7px; }
  .cc-next { display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; margin-top: 6px; font-size: 13px; }
  .cc-next:empty { display: none; }
  .cc-date { font-weight: 700; color: var(--claret); }
  .cc-where { color: var(--muted); }
  .cc-where b { color: var(--claret); }

  /* Case page */
  .case-actions { display: grid; grid-template-columns: 1fr auto auto; gap: 8px; }
  .case-actions form { display: contents; }
  .case-jump {
    display: flex; gap: 6px; overflow-x: auto; margin: 0 -16px 14px; padding: 2px 16px 8px;
    position: sticky; top: calc(56px + env(safe-area-inset-top)); z-index: 10;
    background: linear-gradient(var(--paper) 80%, transparent); scrollbar-width: none;
  }
  .case-jump::-webkit-scrollbar { display: none; }
  .case-jump a {
    flex-shrink: 0; padding: 6px 12px; border-radius: 999px; font-size: 13px; font-weight: 600;
    background: var(--surface); color: var(--text); box-shadow: inset 0 0 0 1px var(--line-strong);
  }
  .case-jump a b { color: var(--claret); margin-left: 2px; }
  .card[id] { scroll-margin-top: 120px; }
  .listing-banner .big { font-size: 26px; }
  .listing-banner { flex-direction: column; align-items: flex-start; }
  .listing-where { flex: none; width: 100%; }
  .more-row { display: none !important; }
  .show-all .more-row { display: flex !important; }
  .show-more { display: inline-flex; margin-top: 10px; width: 100%; justify-content: center; }

  /* Tables that become cards */
  .table.stack { display: block; overflow: visible; }
  .table.stack thead { display: none; }
  .table.stack tbody { display: grid; gap: 8px; }
  .table.stack tr {
    display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 10px;
    padding: 11px 12px; border: 1px solid var(--line); border-radius: 10px; background: #fff;
  }
  .table.stack td { display: block; border: none; padding: 0; white-space: normal !important; min-width: 0 !important; }
  .table.stack td:empty { display: none; }
  .table.stack .st-head { order: 1; font-weight: 700; color: var(--ink); }
  .table.stack .st-sub { order: 2; font-size: 12px; color: var(--muted); }
  .table.stack .st-inline { order: 3; font-size: 13px; color: var(--text); }
  .table.stack .st-amt { order: 4; margin-left: auto; font-weight: 700; font-size: 15px; }
  .table.stack .st-link { order: 5; margin-left: auto; font-weight: 600; }
  .table.stack .st-body { order: 6; flex-basis: 100%; font-size: 13.5px; color: var(--text); margin-top: 4px; }
  .table.stack .row-actions { order: 7; flex-basis: 100%; text-align: right; font-size: 12px; }

  /* Add forms inside a case */
  .fee-add, .task-add { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
  .fee-add > *, .task-add > * { width: 100% !important; min-width: 0 !important; }
  .fee-add input[name="note"], .task-add input[name="title"] { grid-column: 1 / -1; order: -1; }
  .task-add input[name="title"] { order: -2; }
  .fee-add .btn, .task-add .btn { grid-column: 1 / -1; justify-content: center; }

  /* Tasks page */
  .add-task { padding: 0; background: transparent; box-shadow: none; border: none; margin-bottom: 16px; }
  .add-task > summary { display: flex; justify-content: center; list-style: none; }
  .add-task > summary::-webkit-details-marker { display: none; }
  .add-task[open] > summary { margin-bottom: 12px; background: var(--surface); color: var(--claret); box-shadow: inset 0 0 0 1px var(--line-strong); }
  .add-task[open] > form { background: var(--surface); padding: 16px; border-radius: var(--radius); box-shadow: var(--shadow); }
  .task-list li { align-items: flex-start; }
  .task-title { font-weight: 600; line-height: 1.35; }

  /* Home: the card stacks so names use the full width */
  .matter { flex-direction: column; gap: 0; }
  .m-where {
    flex-direction: row; flex-wrap: wrap; align-items: center; justify-content: flex-start; text-align: left;
    gap: 4px 10px; min-width: 0; margin-top: 10px; padding-top: 9px; border-top: 1px dashed var(--line);
  }
  .m-where .m-court { font-size: 13.5px; }
  .m-item strong, .matter:not(.big) .m-item strong { font-size: 19px; }
  .m-name { white-space: normal; line-height: 1.3; }
  .m-bench { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

  /* 16px inputs stop iOS Safari zooming in on focus */
  input, select, textarea { font-size: 16px !important; }
}
