:root {
  --navy: #0f172a;
  --navy-2: #16213a;
  --bg: #f1f5f9;
  --card: #ffffff;
  --border: #e2e8f0;
  --text: #1e293b;
  --text-dim: #64748b;
  --blue: #2563eb;
  --blue-2: #1d4ed8;
  --blue-light: #dbeafe;
  --amber: #d97706;
  --amber-light: #fef3c7;
  --red: #dc2626;
  --red-light: #fee2e2;
  --green: #16a34a;
  --green-light: #dcfce7;
  --gray-light: #f1f5f9;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(15, 23, 42, 0.08), 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow-lg: 0 10px 30px rgba(15, 23, 42, 0.15);
  --shadow-blue: 0 8px 22px rgba(37, 99, 235, 0.3);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  overflow: hidden;
  transition: background .2s ease, color .2s ease;
}

h1, h2, h3, .brand-text strong, .stat-value, .case-card h3, .cal-label {
  font-family: 'Poppins', 'Segoe UI', sans-serif;
  letter-spacing: -0.01em;
}

.app { display: flex; height: 100vh; }
/* iOS Safari's address/tab bars make 100vh taller than the actual visible
   area, clipping content; dvh tracks the real visible viewport where
   supported, with the plain 100vh above as the fallback everywhere else. */
@supports (height: 100dvh) { .app { height: 100dvh; } }

/* Only shown as a slide-out drawer below the tablet breakpoint (see the
   900px media query) — a real button element, not a checkbox hack, so it
   works the same whether opened via mouse, touch, or keyboard. */
.menu-toggle { display: none; flex-shrink: 0; }

/* Hidden overlay behind the mobile drawer; only rendered visible while the
   sidebar is open (see .sidebar-backdrop.active in the 900px media query). */
.sidebar-backdrop {
  display: none; position: fixed; inset: 0; background: rgba(15,23,42,0.5);
  z-index: 149; opacity: 0; transition: opacity .2s ease;
}

/* ---------- Sidebar ---------- */
.sidebar {
  width: 250px;
  background: linear-gradient(180deg, var(--navy) 0%, var(--navy-2) 100%);
  color: #e2e8f0;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  padding: 22px 16px;
}

.brand { display: flex; align-items: center; gap: 12px; padding: 0 8px 24px; }
.brand-mark {
  width: 42px; height: 42px;
  background: linear-gradient(135deg, #b8860b, #d4af37);
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 20px;
  box-shadow: var(--shadow);
}
.brand-text { display: flex; flex-direction: column; line-height: 1.3; }
.brand-text strong { font-size: 17px; color: #fff; }
.brand-text span { font-size: 11px; color: #94a3b8; }

.nav { display: flex; flex-direction: column; gap: 4px; margin-top: 8px; }
.nav-item {
  display: flex; align-items: center; gap: 12px;
  background: none; border: none; color: #cbd5e1;
  padding: 11px 14px; border-radius: 10px;
  font-size: 14px; text-align: left; cursor: pointer;
  transition: background .15s, color .15s;
  position: relative;
  text-decoration: none; /* nav-item is also used on <a> (e.g. Admin link) */
  box-sizing: border-box;
}
.nav-item:hover { background: rgba(255,255,255,0.06); color: #fff; }
.nav-item.active { background: linear-gradient(90deg, rgba(37,99,235,0.32), rgba(37,99,235,0.12)); color: #fff; }
.nav-item.active::before {
  content: ""; position: absolute; left: -16px; top: 8px; bottom: 8px; width: 3px;
  background: #3b82f6; border-radius: 2px; box-shadow: 0 0 8px rgba(59,130,246,0.7);
}
.nav-icon { font-size: 16px; width: 20px; text-align: center; }
.nav-badge {
  margin-left: auto; background: var(--red); color: #fff;
  font-size: 11px; padding: 1px 7px; border-radius: 10px; font-weight: 600;
}

.sidebar-footer { margin-top: auto; display: flex; flex-direction: column; gap: 8px; }
.sidebar-footer .ghost-btn { color: #cbd5e1; border-color: rgba(255,255,255,0.15); }
.sidebar-footer .ghost-btn:hover { background: rgba(255,255,255,0.08); }
.user-chip {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 10px 12px; border-radius: 10px; background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.1);
}
.user-chip-name { font-size: 12.5px; color: #e2e8f0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-chip-actions { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.user-chip-logout { font-size: 11.5px; color: #93c5fd; text-decoration: none; font-weight: 600; flex-shrink: 0; }
.user-chip-logout:hover { text-decoration: underline; }

/* ---------- Main ---------- */
.main { flex: 1; display: flex; flex-direction: column; overflow: hidden; }

.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 16px 28px; background: var(--card); border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.search-wrap {
  display: flex; align-items: center; gap: 8px;
  background: var(--gray-light); border: 1px solid var(--border);
  border-radius: 10px; padding: 8px 14px; width: 360px;
  min-width: 0; /* lets it shrink below its content size in a flex row
    instead of forcing the topbar to overflow on narrow screens */
  transition: border-color .15s, box-shadow .15s;
}
.search-wrap:focus-within { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(37,99,235,0.15); }
.search-wrap input { border: none; background: none; outline: none; flex: 1; font-size: 14px; }
.search-icon { opacity: .6; }

.topbar-actions { display: flex; align-items: center; gap: 10px; }

.primary-btn {
  background: linear-gradient(135deg, var(--blue), var(--blue-2)); color: #fff; border: none;
  padding: 10px 18px; border-radius: 10px; font-size: 14px; font-weight: 600;
  cursor: pointer; transition: background .15s, transform .1s;
  box-shadow: var(--shadow);
}
.primary-btn:hover { background: linear-gradient(135deg, var(--blue-2), #1e40af); }
.primary-btn:active { transform: scale(0.97); }

.ghost-btn {
  background: transparent; border: 1px solid var(--border);
  padding: 8px 14px; border-radius: 10px; font-size: 13px;
  cursor: pointer; color: var(--text); transition: background .15s;
}
.ghost-btn:hover { background: var(--gray-light); }

/* Print deliberately breaks from the plain ghost-btn look (which reads too
   faint against the topbar) — solid blue, so it stays clearly visible. */
#printBtn { background: var(--blue); color: #fff; border-color: var(--blue); }
#printBtn:hover { background: var(--blue-2); }

.icon-btn {
  background: var(--gray-light); border: 1px solid var(--border);
  width: 32px; height: 32px; border-radius: 8px; cursor: pointer; font-size: 16px;
}
.icon-btn:hover { background: var(--border); }

.link-btn {
  background: none; border: none; color: var(--blue); font-size: 13px;
  cursor: pointer; font-weight: 600;
}
.link-btn:hover { text-decoration: underline; }

/* ---------- Views ---------- */
.view { display: none; padding: 26px 28px; overflow-y: auto; height: 100%; }
.view.active { display: block; animation: fadeIn .25s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(6px);} to { opacity: 1; transform: translateY(0);} }

.view-header { display: flex; align-items: flex-end; justify-content: space-between; margin-bottom: 22px; flex-wrap: wrap; gap: 12px; }
.view-header h1 { font-size: 24px; font-weight: 700; }
.subtitle { color: var(--text-dim); font-size: 13px; margin-top: 4px; }

/* ---------- Stat Cards ---------- */
.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 24px; }
.stat-card {
  background: var(--card); border-radius: var(--radius); padding: 18px;
  display: flex; align-items: center; gap: 14px; box-shadow: var(--shadow);
  border: 1px solid var(--border);
  transition: transform .15s, box-shadow .15s;
}
.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.stat-icon {
  width: 46px; height: 46px; border-radius: 12px;
  display: flex; align-items: center; justify-content: center; font-size: 20px;
}
.stat-icon.blue { background: var(--blue-light); }
.stat-icon.amber { background: var(--amber-light); }
.stat-icon.red { background: var(--red-light); }
.stat-icon.green { background: var(--green-light); }
.stat-info { display: flex; flex-direction: column; }
.stat-value { font-size: 22px; font-weight: 700; }
.stat-label { font-size: 12px; color: var(--text-dim); }

/* ---------- Dashboard grid ---------- */
.dash-quick-actions { display: flex; justify-content: flex-end; margin-bottom: 16px; }
.case-pick-row {
  display: flex; flex-direction: column; gap: 2px; padding: 10px; border: 1px solid var(--border);
  border-radius: 10px; cursor: pointer; margin-bottom: 8px;
}
.case-pick-row:hover { background: var(--gray-light); border-color: var(--blue); }
.case-pick-row strong { font-size: 13.5px; }
.case-pick-row small { color: var(--text-dim); font-size: 12px; }
.dash-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; }
@media (max-width: 1200px) { .dash-grid { grid-template-columns: 1fr 1fr; } }
.panel {
  background: var(--card); border-radius: var(--radius); padding: 18px;
  border: 1px solid var(--border); box-shadow: var(--shadow);
}
.panel.wide { grid-column: 1 / -1; }
.panel-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.panel-header h2 { font-size: 15px; font-weight: 700; }

.status-bars { display: flex; flex-direction: column; gap: 14px; }
.status-bar-row { display: flex; flex-direction: column; gap: 6px; }
.status-bar-label { display: flex; justify-content: space-between; font-size: 13px; color: var(--text-dim); }
.status-bar-track { height: 8px; background: var(--gray-light); border-radius: 6px; overflow: hidden; }
.status-bar-fill { height: 100%; border-radius: 6px; transition: width .4s ease; }

/* ---------- Date list ---------- */
.date-list { display: flex; flex-direction: column; gap: 10px; max-height: 340px; overflow-y: auto; }
.date-list.wide-list { max-height: none; }
.date-item {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px; border-radius: 10px; border: 1px solid var(--border);
  cursor: pointer; transition: background .15s;
}
.date-item:hover { background: var(--gray-light); }
.date-chip {
  min-width: 52px; text-align: center; padding: 6px 4px; border-radius: 8px;
  background: var(--blue-light); color: var(--blue); font-weight: 700; font-size: 12px; line-height: 1.3;
}
.date-chip.urgent { background: var(--red-light); color: var(--red); }
.date-chip.soon { background: var(--amber-light); color: var(--amber); }
.date-chip span { display: block; font-size: 15px; }
.date-item-info { flex: 1; min-width: 0; }
.date-item-info strong { display: block; font-size: 13.5px; }
.date-item-info small { color: var(--text-dim); font-size: 12px; }
.badge {
  font-size: 10.5px; font-weight: 700; padding: 3px 8px; border-radius: 20px; white-space: nowrap;
}
.badge.Active { background: var(--blue-light); color: var(--blue); }
.badge.Pending { background: var(--amber-light); color: var(--amber); }
.badge.Closed { background: var(--green-light); color: var(--green); }
.badge.General { background: var(--gray-light); color: var(--text-dim); }

.task-list-item.task-done { opacity: 0.55; }
.task-list-item.task-done .date-item-info strong { text-decoration: line-through; }
.task-list-item.no-case { cursor: default; }
.task-item-check { width: 17px; height: 17px; cursor: pointer; accent-color: var(--blue); flex-shrink: 0; }
.task-item-remove { background: none; border: none; cursor: pointer; color: var(--red); font-size: 15px; flex-shrink: 0; }

/* ---------- Mini table ---------- */
.mini-table { display: flex; flex-direction: column; }
.mini-row {
  display: grid; grid-template-columns: 1.5fr 1.5fr 1fr 1fr; gap: 10px;
  padding: 10px 6px; border-bottom: 1px solid var(--border); font-size: 13px; align-items: center;
  cursor: pointer;
}
.mini-row:hover { background: var(--gray-light); }
.mini-row.head { font-weight: 700; color: var(--text-dim); font-size: 11.5px; text-transform: uppercase; cursor: default; }
.mini-row.head:hover { background: none; }

/* ---------- Cases grid ---------- */
.filter-bar { display: flex; gap: 10px; }
.filter-bar select {
  padding: 8px 12px; border-radius: 8px; border: 1px solid var(--border);
  background: var(--card); font-size: 13px; cursor: pointer; transition: border-color .15s, box-shadow .15s;
}
.filter-bar select:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 3px rgba(37,99,235,0.15); }
.cases-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; }
.case-card {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px; cursor: pointer; box-shadow: var(--shadow); transition: transform .15s, box-shadow .15s;
  display: flex; flex-direction: column; gap: 10px;
}
.case-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); }
.case-card-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.case-card h3 { font-size: 15px; font-weight: 700; }
.case-card .client { font-size: 12.5px; color: var(--text-dim); margin-top: 2px; }
.case-card-meta { display: flex; flex-wrap: wrap; gap: 6px; font-size: 11.5px; color: var(--text-dim); }
.case-card-meta span { background: var(--gray-light); padding: 3px 8px; border-radius: 6px; }
.case-card-footer { display: flex; justify-content: space-between; align-items: center; margin-top: auto; font-size: 12px; color: var(--text-dim); }

/* ---------- Empty state ---------- */
.empty-state { text-align: center; padding: 60px 20px; color: var(--text-dim); }
.empty-icon { font-size: 40px; margin-bottom: 10px; }

/* ---------- Calendar ---------- */
.cal-controls { display: flex; align-items: center; gap: 10px; }
.cal-label { font-weight: 700; font-size: 15px; min-width: 150px; text-align: center; }
.calendar-wrap { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); }
.cal-weekdays { display: grid; grid-template-columns: repeat(7, 1fr); text-align: center; font-size: 12px; font-weight: 700; color: var(--text-dim); padding-bottom: 8px; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); grid-auto-rows: 100px; gap: 6px; }
.cal-day {
  border: 1px solid var(--border); border-radius: 10px; padding: 6px; cursor: pointer;
  display: flex; flex-direction: column; gap: 4px; overflow: hidden; transition: background .15s;
}
.cal-day:hover { background: var(--gray-light); }
.cal-day.other-month { opacity: 0.35; }
.cal-day.today { border-color: var(--blue); border-width: 2px; }
.cal-day-num { font-size: 12px; font-weight: 700; }
.cal-day.today .cal-day-num { color: var(--blue); }
.cal-event {
  font-size: 10.5px; background: var(--blue-light); color: var(--blue);
  padding: 2px 5px; border-radius: 5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.cal-event.urgent { background: var(--red-light); color: var(--red); }
.cal-more { font-size: 10px; color: var(--text-dim); }

/* ---------- Modal ---------- */
.modal-overlay {
  display: none; position: fixed; inset: 0; background: rgba(15,23,42,0.55);
  align-items: center; justify-content: center; z-index: 100; backdrop-filter: blur(2px);
}
.modal-overlay.active { display: flex; animation: fadeIn .15s ease; }
.modal {
  background: var(--card); border-radius: 16px; width: 520px; max-width: 92vw;
  max-height: 88vh; overflow-y: auto; overflow-x: hidden; box-shadow: var(--shadow-lg);
}
.modal.wide { width: 680px; }
.modal-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 18px 22px; border-bottom: 1px solid var(--border); position: sticky; top: 0; background: var(--card);
}
.modal-header h2 { font-size: 17px; }
.close-btn { background: none; border: none; font-size: 22px; cursor: pointer; color: var(--text-dim); line-height: 1; }
.close-btn:hover { color: var(--text); }

#caseForm { padding: 20px 22px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-bottom: 14px; }
/* min-width:0 overrides the grid/flex default of sizing to content — without
   it, a <select> with long option text (e.g. "Client Name — Case Title")
   forces its column wider than the modal itself, pushing the whole popup
   past the edge of narrow screens instead of letting the text truncate. */
.form-grid label, #caseForm > label.full { display: flex; flex-direction: column; gap: 6px; font-size: 12.5px; font-weight: 600; color: var(--text-dim); min-width: 0; }
.form-grid input, .form-grid select, #caseForm textarea {
  padding: 9px 11px; border-radius: 8px; border: 1px solid var(--border); font-size: 13.5px; font-family: inherit; color: var(--text);
  width: 100%; min-width: 0; box-sizing: border-box;
}
.form-grid input:focus, .form-grid select:focus, #caseForm textarea:focus { outline: 2px solid var(--blue); outline-offset: 1px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 16px; }

.detail-body {
  padding: 20px 22px;
  /* This is now the full-page case detail view's content card (formerly a
     modal body) — give it the same card look as the other panels. */
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow);
}
.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 20px; margin-bottom: 18px; }
.detail-grid div { font-size: 13px; }
.detail-grid label { display: block; font-size: 11px; text-transform: uppercase; color: var(--text-dim); font-weight: 700; margin-bottom: 2px; }
.detail-actions { display: flex; gap: 10px; margin-bottom: 18px; }
.hearing-sort-bar { display: flex; align-items: center; gap: 6px; margin-bottom: 10px; justify-content: flex-end; }
.hearing-sort-bar label { font-size: 11px; color: var(--text-dim); }
.hearing-sort-bar select { padding: 3px 6px; border-radius: 6px; border: 1px solid var(--border); background: var(--card); font-size: 11.5px; color: var(--text); }
.hearing-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 16px; }
.hearing-row {
  display: flex; align-items: center; gap: 10px; padding: 10px; border: 1px solid var(--border); border-radius: 10px;
}
.hearing-row .hd { font-weight: 700; font-size: 13px; min-width: 100px; }
.hearing-row .hdesc { flex: 1; font-size: 13px; color: var(--text-dim); }
.hearing-row button { background: none; border: none; cursor: pointer; color: var(--red); font-size: 15px; }
.hearing-row button[data-edit-hearing] { color: var(--blue); }
.add-hearing-form { display: flex; gap: 8px; }
.add-hearing-form input { flex: 1; padding: 9px 11px; border-radius: 8px; border: 1px solid var(--border); font-size: 13px; }
.add-hearing-form input[type="date"] { flex: none; width: 150px; }

.pagination { display: flex; align-items: center; justify-content: center; gap: 14px; margin: 4px 0 16px; }
.pagination-label { font-size: 12.5px; color: var(--text-dim); }
.pagination .ghost-btn:disabled { opacity: 0.4; cursor: not-allowed; }

.form-error { background: var(--red-light); color: var(--red); padding: 10px 12px; border-radius: 8px; font-size: 13px; }
.password-wrap { position: relative; }
.password-wrap input { padding-right: 38px !important; width: 100%; }
.pw-toggle {
  position: absolute; right: 4px; top: 50%; transform: translateY(-50%);
  background: none; border: none; cursor: pointer; font-size: 15px; padding: 6px 8px;
  color: var(--text-dim); line-height: 1;
}
.pw-toggle:hover { color: var(--text); }
.danger-btn { background: var(--red-light); color: var(--red); border: none; padding: 8px 14px; border-radius: 8px; cursor: pointer; font-size: 13px; font-weight: 600; }
.danger-btn:hover { background: #fecaca; }

/* ---------- Detail Tabs ---------- */
/* top: 0 (not offset by a modal-header height anymore) — the case detail
   is a full-page view now, and .view itself (not a modal) is the
   scrolling container these tabs stick within. */
.detail-tabs { display: flex; gap: 4px; padding: 0 22px; border-bottom: 1px solid var(--border); position: sticky; top: 0; background: var(--card); z-index: 1; border-radius: var(--radius) var(--radius) 0 0; }
.detail-tab {
  background: none; border: none; padding: 10px 14px; font-size: 13px; font-weight: 600;
  color: var(--text-dim); cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.detail-tab:hover { color: var(--text); }
.detail-tab.active { color: var(--blue); border-bottom-color: var(--blue); }
.detail-pane { display: none; }
.detail-pane.active { display: block; animation: fadeIn .2s ease; }

/* ---------- Tasks ---------- */
.task-row {
  display: flex; align-items: center; gap: 10px; padding: 10px; border: 1px solid var(--border); border-radius: 10px;
}
.task-row.done { opacity: 0.55; }
.task-row.done .task-text { text-decoration: line-through; }
.task-row input[type="checkbox"] { width: 17px; height: 17px; cursor: pointer; accent-color: var(--blue); flex-shrink: 0; }
.task-text { flex: 1; font-size: 13.5px; }
.task-due { font-size: 11.5px; color: var(--text-dim); white-space: nowrap; }
.task-due.overdue { color: var(--red); font-weight: 700; }
.task-row button { background: none; border: none; cursor: pointer; color: var(--red); font-size: 15px; }
.add-task-form { display: flex; gap: 8px; flex-wrap: wrap; }
.add-task-form input[type="text"] { flex: 1; min-width: 200px; padding: 9px 11px; border-radius: 8px; border: 1px solid var(--border); font-size: 13px; }
.add-task-form input[type="date"] { flex: none; width: 150px; padding: 9px 11px; border-radius: 8px; border: 1px solid var(--border); font-size: 13px; }
.checkbox-label { display: flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--text-dim); cursor: pointer; width: 100%; }
.checkbox-label input[type="checkbox"] { width: 15px; height: 15px; accent-color: var(--blue); cursor: pointer; }

/* ---------- Attachments ---------- */
.attachment-row {
  display: flex; align-items: center; gap: 10px; padding: 10px; border: 1px solid var(--border); border-radius: 10px;
}
.attachment-icon { font-size: 18px; }
.attachment-info { flex: 1; min-width: 0; }
.attachment-info strong { display: block; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.attachment-info small { color: var(--text-dim); font-size: 11.5px; }
.attachment-row a, .attachment-row button { background: none; border: none; cursor: pointer; font-size: 13px; color: var(--blue); text-decoration: none; }
.attachment-row button.remove-attachment { color: var(--red); font-size: 15px; }
.file-drop {
  border: 2px dashed var(--blue); border-radius: 10px; padding: 18px; text-align: center;
  background: var(--blue-light); color: var(--blue); font-size: 13px; font-weight: 600;
  cursor: pointer; transition: background .15s, border-color .15s;
}
.file-drop small { color: var(--text-dim); font-weight: 400; }
.file-drop:hover, .file-drop.dragover { background: #bfdbfe; border-color: #1d4ed8; }
.file-drop-compact { padding: 12px; font-size: 12.5px; }
.pending-file-list { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.pending-file-chip {
  display: flex; align-items: center; gap: 6px; background: var(--blue-light); color: var(--blue);
  border-radius: 20px; padding: 4px 6px 4px 10px; font-size: 12px; font-weight: 600;
}
.pending-file-chip button {
  background: none; border: none; cursor: pointer; color: var(--blue); font-size: 15px; line-height: 1; padding: 2px;
}
.pending-file-chip button:hover { color: var(--red); }

/* ---------- Timeline ---------- */
.timeline { display: flex; flex-direction: column; gap: 0; }
.timeline-item { display: flex; gap: 12px; padding: 10px 0; border-left: 2px solid var(--border); padding-left: 16px; margin-left: 6px; position: relative; }
.timeline-item::before {
  content: ""; position: absolute; left: -7px; top: 16px; width: 10px; height: 10px; border-radius: 50%;
  background: var(--blue); border: 2px solid var(--card);
}
.timeline-item:last-child { border-left-color: transparent; }
.timeline-text { font-size: 13px; }
.timeline-time { font-size: 11px; color: var(--text-dim); }

/* ---------- Analytics ---------- */
.glance-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.glance-item { text-align: center; padding: 14px 8px; background: var(--gray-light); border-radius: 10px; }
.glance-item .g-value { font-size: 20px; font-weight: 700; display: block; }
.glance-item .g-label { font-size: 11px; color: var(--text-dim); }
.bar-chart { display: flex; align-items: flex-end; gap: 12px; height: 160px; padding-top: 10px; }
.bar-chart-col { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: 6px; height: 100%; }
.bar-chart-bar { width: 100%; max-width: 40px; background: var(--blue); border-radius: 6px 6px 0 0; transition: height .4s ease; min-height: 2px; }
.bar-chart-count { font-size: 11px; font-weight: 700; color: var(--text-dim); }
.bar-chart-label { font-size: 11px; color: var(--text-dim); }

/* ---------- Storage notice ---------- */
.storage-notice {
  display: none; align-items: center; justify-content: space-between; gap: 14px;
  background: var(--amber-light); color: var(--amber); border-bottom: 1px solid var(--border);
  padding: 10px 22px; font-size: 13px; font-weight: 600; flex-shrink: 0;
}
.storage-notice.show { display: flex; animation: fadeIn .2s ease; }
.storage-notice span { flex: 1; }
.storage-notice-actions { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.storage-notice .ghost-btn { background: #fff; border-color: rgba(0,0,0,0.1); font-weight: 700; white-space: nowrap; }
.storage-notice .close-btn { color: var(--amber); }

/* ---------- Toast ---------- */
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%) translateY(20px);
  background: var(--navy); color: #fff; padding: 12px 22px; border-radius: 10px;
  font-size: 13.5px; opacity: 0; pointer-events: none; transition: all .25s ease; z-index: 200;
  box-shadow: var(--shadow-lg);
}
.toast { transition: opacity .3s ease, transform .35s cubic-bezier(.34,1.56,.64,1); }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* Scrollbars */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 6px; transition: background .15s; }
::-webkit-scrollbar-thumb:hover { background: var(--blue); }
::-webkit-scrollbar-track { background: transparent; }

@media (max-width: 900px) {
  .dash-grid { grid-template-columns: 1fr; }
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .form-grid { grid-template-columns: 1fr; }
  .detail-grid { grid-template-columns: 1fr; }

  /* Sidebar becomes an off-canvas drawer: hidden past the left edge, slid
     in via .open (toggled by the hamburger button in app.js), with a
     backdrop behind it to close on outside tap and to block interaction
     with the page underneath while it's open. */
  .menu-toggle { display: inline-flex; align-items: center; justify-content: center; }
  .sidebar {
    position: fixed; top: 0; left: 0; height: 100%; z-index: 150;
    transform: translateX(-100%); transition: transform .22s ease;
    box-shadow: var(--shadow-lg);
  }
  .sidebar.open { transform: translateX(0); }
  .sidebar-backdrop.active { display: block; opacity: 1; }

  .topbar { padding: 14px 16px; flex-wrap: wrap; }
  .search-wrap { flex: 1; width: auto; order: 3; }
  .topbar-actions { gap: 6px; }
  /* "Print" label takes too much room on narrow screens next to the icon
     buttons — the icon alone is enough once space is tight. */
  #printBtn span { display: none; }

  .view { padding: 18px 16px; }

  /* Recent Cases (and similarly shaped tables) keep their column
     proportions and scroll horizontally rather than squeezing every
     column down to unreadable widths. */
  .mini-table { overflow-x: auto; }
  .mini-row { min-width: 480px; }

  .cal-grid { grid-auto-rows: 72px; }
  .cal-event { display: none; } /* the count-style "+N more" still shows */
  .cal-day-num { font-size: 11px; }

  .add-hearing-form, .add-task-form { flex-wrap: wrap; }
  .add-hearing-form input[type="date"], .add-task-form input[type="date"] { width: 100%; }

  .modal.wide { width: 92vw; }
}

@media (max-width: 480px) {
  .stat-grid { grid-template-columns: 1fr; }
  .glance-stats { grid-template-columns: 1fr 1fr; }
  .cases-grid { grid-template-columns: 1fr; }
  .view-header { flex-direction: column; align-items: flex-start; }
  .filter-bar { width: 100%; }
  .filter-bar select { flex: 1; }
  .modal-header { padding: 14px 16px; }
  #caseForm, .detail-body { padding: 16px; }
}

/* ---------- Interactive animations ---------- */
@keyframes modalPop { from { opacity: 0; transform: scale(0.94) translateY(10px); } to { opacity: 1; transform: scale(1) translateY(0); } }
.modal-overlay.active .modal { animation: modalPop .28s cubic-bezier(.34,1.56,.64,1); transform-origin: center; }

/* Side-drawer variant (used for the Add/Edit Case form) — a full-height
   form panel docked to the right edge, not a dialog-style popup: no dark
   backdrop dimming the rest of the page, just the panel sliding in. */
.side-drawer-overlay { justify-content: flex-end; background: transparent; backdrop-filter: none; }
.modal-drawer {
  height: 100vh; max-height: 100vh; width: 480px; max-width: 92vw;
  border-radius: 16px 0 0 16px; box-shadow: -12px 0 40px rgba(15,23,42,0.25);
  border-left: 1px solid var(--border);
}
@keyframes slideInRight { from { transform: translateX(100%); } to { transform: translateX(0); } }
.side-drawer-overlay.active .modal-drawer { animation: slideInRight .3s cubic-bezier(.34,1.56,.64,1); transform-origin: right; }

@keyframes statIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
.stat-card { animation: statIn .45s ease both; }
.stat-card:nth-child(1) { animation-delay: .02s; }
.stat-card:nth-child(2) { animation-delay: .08s; }
.stat-card:nth-child(3) { animation-delay: .14s; }
.stat-card:nth-child(4) { animation-delay: .2s; }

/* Same fade-up entrance applied to every list/card item across the app —
   cases, dates, tasks, documents, timeline — with a small stagger for the
   first several so a full page of results doesn't feel like it just
   snapped into place. */
.case-card, .date-item, .hearing-row, .task-row, .attachment-row,
.timeline-item, .mini-row:not(.head) {
  animation: statIn .35s ease both;
}
.case-card:nth-child(1), .date-item:nth-child(1), .hearing-row:nth-child(1),
.task-row:nth-child(1), .attachment-row:nth-child(1), .timeline-item:nth-child(1),
.mini-row:nth-child(2) { animation-delay: .02s; }
.case-card:nth-child(2), .date-item:nth-child(2), .hearing-row:nth-child(2),
.task-row:nth-child(2), .attachment-row:nth-child(2), .timeline-item:nth-child(2),
.mini-row:nth-child(3) { animation-delay: .06s; }
.case-card:nth-child(3), .date-item:nth-child(3), .hearing-row:nth-child(3),
.task-row:nth-child(3), .attachment-row:nth-child(3), .timeline-item:nth-child(3),
.mini-row:nth-child(4) { animation-delay: .1s; }
.case-card:nth-child(4), .date-item:nth-child(4), .hearing-row:nth-child(4),
.task-row:nth-child(4), .attachment-row:nth-child(4), .timeline-item:nth-child(4),
.mini-row:nth-child(5) { animation-delay: .14s; }
.case-card:nth-child(5), .date-item:nth-child(5), .hearing-row:nth-child(5),
.task-row:nth-child(5), .attachment-row:nth-child(5), .timeline-item:nth-child(5),
.mini-row:nth-child(6) { animation-delay: .18s; }

@keyframes badgePulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.18); } }
.nav-badge.pulse { animation: badgePulse 1.8s ease-in-out infinite; }

.nav-item { transition: background .15s, color .15s, padding-left .18s ease; }
.nav-item:hover { padding-left: 19px; }

.primary-btn { transition: background .15s, transform .15s, box-shadow .15s; }
.primary-btn:hover { transform: translateY(-1px); box-shadow: var(--shadow-blue); }
.primary-btn:active { transform: scale(0.97) translateY(0); }

.ghost-btn, .icon-btn { transition: background .15s, transform .15s, box-shadow .15s; }
.ghost-btn:hover, .icon-btn:hover { transform: translateY(-1px); }
.ghost-btn:active, .icon-btn:active { transform: scale(0.94); }

.danger-btn { transition: background .15s, transform .15s; }
.danger-btn:active { transform: scale(0.95); }

.cal-day { transition: background .15s, transform .15s, box-shadow .15s; }
.cal-day:hover { transform: scale(1.03); box-shadow: var(--shadow-lg); z-index: 2; position: relative; }

.task-row { transition: opacity .3s ease, background .15s; }
.detail-tab { transition: color .15s, border-color .2s; }
.close-btn { transition: transform .15s, color .15s; }
.close-btn:hover { transform: rotate(90deg); }

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.001ms !important; animation-iteration-count: 1 !important; transition-duration: 0.001ms !important; }
}

/* ---------- Print ---------- */
#printArea { display: none; }
@media print {
  body * { visibility: hidden; }
  #printArea, #printArea * { visibility: visible; }
  #printArea {
    display: block !important; position: absolute; top: 0; left: 0; width: 100%;
    padding: 24px; color: #000; background: #fff;
  }
  .print-header { text-align: center; margin-bottom: 20px; border-bottom: 2px solid #000; padding-bottom: 10px; }
  .print-header h1 { font-size: 20px; margin-bottom: 4px; }
  .print-header h2 { font-size: 14px; font-weight: 600; color: #333; }
  .print-table { width: 100%; border-collapse: collapse; font-size: 12px; }
  .print-table th, .print-table td { border: 1px solid #999; padding: 6px 8px; text-align: left; }
  .print-table th { background: #eee; }
  .print-cal-table { width: 100%; border-collapse: collapse; table-layout: fixed; }
  .print-cal-table th, .print-cal-table td { border: 1px solid #999; vertical-align: top; padding: 4px; font-size: 10px; height: 90px; }
  .print-cal-table th { background: #eee; font-size: 11px; text-align: center; }
  .print-cal-day { font-weight: 700; font-size: 12px; margin-bottom: 4px; }
  .print-cal-event { font-size: 9px; margin-bottom: 2px; line-height: 1.3; }
  .print-cal-empty { background: #f5f5f5; }
}
