:root {
  --bg: #f5f7fb;
  --panel: #ffffff;
  --ink: #18202f;
  --muted: #687386;
  --line: #dfe5ef;
  --blue: #2454d6;
  --green: #157a50;
  --red: #c93838;
  --amber: #aa6a00;
  --shadow: 0 18px 45px rgba(27, 38, 62, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, Segoe UI, Arial, sans-serif;
  display: grid;
}

button,
input,
select,
textarea {
  font: inherit;
}

.shell {
  padding: 28px;
  display: grid;
  gap: 22px;
  width: 100%;
}

.topbar,
.panel-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.topbar h1,
.panel h2 {
  margin: 0;
}

.topbar h1 {
  font-family: "Segoe Script", "Lucida Handwriting", cursive;
  font-size: 32px;
  font-weight: 700;
  line-height: 1.15;
}

.server-chip {
  color: var(--muted);
  font-size: 13px;
  margin-top: 8px;
  overflow-wrap: anywhere;
}

.server-chip strong {
  color: var(--ink);
}

.topbar-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 8px;
}

.quick-link {
  align-items: center;
  background: #e8edf6;
  border-radius: 6px;
  color: var(--ink);
  display: inline-flex;
  font-weight: 700;
  min-height: 40px;
  padding: 10px 14px;
  text-decoration: none;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0;
  font-weight: 700;
}

.primary-button,
button {
  border: 0;
  background: var(--blue);
  color: #ffffff;
  border-radius: 6px;
  padding: 10px 14px;
  cursor: pointer;
  min-height: 40px;
}

button:hover {
  filter: brightness(0.96);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

.secondary-button {
  background: #e8edf6;
  color: var(--ink);
}

.danger-button {
  background: #b4232a;
  color: #ffffff;
}

.hearing-button {
  background: #6d28d9;
}

.task-button {
  background: #157a50;
}

.admin-shell {
  align-items: stretch;
  display: grid;
  grid-template-columns: 248px minmax(0, 1fr);
  min-height: 100vh;
  width: 100%;
}

.sidebar {
  background: #ffffff;
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 18px;
  height: 100vh;
  padding: 22px 18px;
  position: sticky;
  top: 0;
}

.brand {
  border-bottom: 1px solid var(--line);
  padding-bottom: 16px;
}

.brand strong {
  display: block;
  font-size: 18px;
  line-height: 1.25;
}

.brand span {
  color: var(--muted);
  display: block;
  font-size: 13px;
  margin-top: 4px;
}

.side-nav {
  display: grid;
  gap: 6px;
}

.nav-item {
  background: transparent;
  color: var(--ink);
  font-weight: 800;
  justify-content: flex-start;
  text-align: left;
  width: 100%;
}

.nav-item:hover,
.nav-item.active {
  background: #edf2ff;
  color: var(--blue);
  filter: none;
}

.quick-links {
  border-top: 1px solid var(--line);
  display: grid;
  gap: 8px;
  margin-top: auto;
  padding-top: 16px;
}

.main-panel {
  display: grid;
  gap: 22px;
  min-width: 0;
  padding: 28px;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}

.metrics article,
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.metrics article {
  padding: 18px;
}

.metrics span {
  color: var(--muted);
  font-size: 14px;
}

.metrics strong {
  display: block;
  margin-top: 10px;
  font-size: 32px;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 380px;
  gap: 18px;
  align-items: start;
}

.dashboard-grid,
.settings-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}

.wide {
  grid-column: 1 / -1;
}

.lower-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}

.panel {
  padding: 18px;
  min-width: 0;
}

.compact {
  align-items: flex-start;
}

#search {
  min-width: 260px;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  min-height: 40px;
  padding: 9px 10px;
  background: #ffffff;
  color: var(--ink);
}

textarea {
  resize: vertical;
}

.table-wrap {
  overflow-x: auto;
  margin-top: 14px;
}

.month-calendar {
  border-top: 1px solid var(--line);
  display: grid;
  gap: 12px;
  margin-top: 18px;
  padding-top: 18px;
}

.calendar-top,
.calendar-nav,
.calendar-legend,
.day-detail-heading {
  align-items: center;
  display: flex;
  gap: 10px;
}

.calendar-top {
  justify-content: space-between;
}

.calendar-nav {
  flex-wrap: wrap;
  justify-content: flex-end;
}

.calendar-nav button {
  min-height: 36px;
  padding: 8px 10px;
}

.calendar-workspace {
  align-items: start;
  display: grid;
  gap: 16px;
  grid-template-columns: minmax(0, 1fr) minmax(300px, 360px);
}

.calendar-board {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.calendar-legend {
  color: var(--muted);
  flex-wrap: wrap;
  font-size: 13px;
  font-weight: 700;
}

.calendar-legend span {
  align-items: center;
  display: inline-flex;
  gap: 6px;
}

.dot {
  border-radius: 999px;
  display: inline-block;
  height: 10px;
  width: 10px;
}

.dot.served,
.event-pill.served {
  background: #2563eb;
}

.dot.due,
.event-pill.due {
  background: #dc2626;
}

.dot.hearing,
.event-pill.hearing {
  background: #7c3aed;
}

.dot.task,
.event-pill.task {
  background: var(--green);
}

.calendar-weekdays,
.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 6px;
}

.calendar-weekdays span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-align: center;
  text-transform: uppercase;
}

.calendar-day {
  aspect-ratio: 1;
  background: #ffffff;
  border: 1px solid var(--line);
  color: var(--ink);
  display: grid;
  gap: 4px;
  min-height: 74px;
  padding: 8px;
  text-align: left;
}

.calendar-day:hover,
.calendar-day.selected {
  border-color: var(--blue);
  box-shadow: inset 0 0 0 1px var(--blue);
  filter: none;
}

.calendar-day.today .day-number {
  background: #facc15;
  color: #111827;
}

.calendar-day.today {
  background: #fffbea;
  border-color: #ca8a04;
}

.calendar-day.muted-day {
  background: #f8fafc;
  color: #a0a8b5;
}

.day-number {
  align-items: center;
  border-radius: 999px;
  display: inline-flex;
  font-weight: 800;
  height: 26px;
  justify-content: center;
  width: 26px;
}

.day-markers {
  align-items: end;
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.event-pill {
  border-radius: 999px;
  color: #ffffff;
  display: inline-flex;
  font-size: 11px;
  font-style: normal;
  font-weight: 800;
  min-width: 22px;
  padding: 3px 6px;
}

.calendar-day-detail {
  align-self: start;
  background: #fbfcff;
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 8px;
  max-height: calc(100vh - 210px);
  overflow: auto;
  padding: 12px;
  position: sticky;
  top: 18px;
}

.day-detail-heading {
  border-bottom: 1px solid var(--line);
  justify-content: space-between;
  padding-bottom: 10px;
}

.day-detail-heading .eyebrow {
  margin-bottom: 3px;
}

.calendar-empty-detail {
  background: #ffffff;
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
  display: grid;
  gap: 6px;
  padding: 14px;
}

.calendar-empty-detail strong {
  color: var(--ink);
}

.calendar-empty-detail p {
  margin: 0;
}

.calendar-accordions {
  display: grid;
  gap: 8px;
}

.calendar-accordion {
  background: #ffffff;
  border: 1px solid var(--line);
  border-left: 4px solid #cbd5e1;
  border-radius: 8px;
  padding: 0;
}

.calendar-accordion.served {
  border-left-color: #2563eb;
}

.calendar-accordion.due {
  border-left-color: #dc2626;
}

.calendar-accordion.hearing {
  border-left-color: #7c3aed;
}

.calendar-accordion.task {
  border-left-color: var(--green);
}

.calendar-accordion summary {
  align-items: center;
  color: var(--ink);
  cursor: pointer;
  display: flex;
  font-weight: 800;
  justify-content: space-between;
  list-style: none;
  padding: 11px 12px;
}

.calendar-accordion summary::-webkit-details-marker {
  display: none;
}

.calendar-accordion summary::before {
  color: var(--muted);
  content: "+";
  font-size: 18px;
  line-height: 1;
  margin-right: 8px;
}

.calendar-accordion[open] summary::before {
  content: "−";
}

.calendar-accordion summary span {
  margin-right: auto;
}

.calendar-accordion summary strong {
  background: #eef2f7;
  border-radius: 999px;
  font-size: 12px;
  min-width: 28px;
  padding: 4px 8px;
  text-align: center;
}

.calendar-accordion-body {
  border-top: 1px solid var(--line);
  display: grid;
  gap: 8px;
  padding: 10px;
}

.calendar-empty-row {
  color: var(--muted);
  font-size: 13px;
  padding: 4px 2px;
}

.calendar-event {
  background: #ffffff;
  border: 1px solid var(--line);
  color: var(--ink);
  display: grid;
  gap: 3px;
  min-height: auto;
  padding: 10px;
  text-align: left;
}

.calendar-event:hover {
  border-color: var(--blue);
  filter: none;
}

.calendar-event span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.calendar-event.served span {
  color: #2563eb;
}

.calendar-event.due span {
  color: #dc2626;
}

.calendar-event.hearing span {
  color: #7c3aed;
}

.calendar-event.task span {
  color: var(--green);
}

.calendar-event em {
  color: var(--muted);
  font-size: 13px;
  font-style: normal;
  overflow-wrap: anywhere;
}

table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 11px 8px;
  text-align: left;
  vertical-align: top;
  overflow-wrap: anywhere;
}

th {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
}

th:nth-child(1),
td:nth-child(1) {
  width: 32%;
}

th:nth-child(2),
td:nth-child(2) {
  width: 38%;
}

th:nth-child(3),
td:nth-child(3) {
  width: 18%;
}

th:nth-child(4),
td:nth-child(4) {
  width: 12%;
}

tr {
  cursor: pointer;
}

tr.selected,
tbody tr:hover {
  background: #f0f4ff;
}

.muted {
  color: var(--muted);
  font-size: 13px;
}

.badge {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 5px 9px;
  font-size: 12px;
  font-weight: 700;
  background: #edf2ff;
  color: var(--blue);
}

.badge.urgent {
  background: #fff0ef;
  color: var(--red);
}

.badge.review {
  background: #fff6df;
  color: var(--amber);
}

.badge.done {
  background: #e9f8f1;
  color: var(--green);
}

.detail-form,
#create-form,
#hearing-form,
#case-form,
#task-form {
  display: grid;
  gap: 12px;
  margin-top: 12px;
}

.empty-detail {
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
  margin-top: 12px;
  padding: 18px;
  text-align: center;
}

[hidden] {
  display: none !important;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.split {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.full {
  width: 100%;
}

.stack {
  display: grid;
  gap: 10px;
  margin-top: 12px;
}

.stack-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fbfcff;
}

.event-link {
  color: var(--ink);
  display: grid;
  gap: 4px;
  min-height: auto;
  text-align: left;
  width: 100%;
}

.event-link.notification {
  border-left: 4px solid #2563eb;
}

.event-link.hearing {
  border-left: 4px solid #7c3aed;
}

.event-link.task {
  border-left: 4px solid var(--green);
}

.stack-item strong {
  display: block;
  margin-bottom: 4px;
}

.pdf-panel {
  border-top: 1px solid var(--line);
  margin-top: 18px;
  padding-top: 18px;
}

.case-records-panel {
  border-top: 1px solid var(--line);
  display: grid;
  gap: 14px;
  margin-top: 18px;
  padding-top: 18px;
}

.record-actions,
.record-card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.record-actions button {
  flex: 1 1 110px;
}

.record-card {
  border: 1px solid #d9e1ee;
  border-radius: 8px;
  background: linear-gradient(180deg, #ffffff 0%, #fbfcff 100%);
  display: grid;
  gap: 14px;
  padding: 14px;
  box-shadow: 0 10px 24px rgba(27, 38, 62, 0.05);
}

.record-card:has(.badge.done) {
  background: #f7faf8;
  border-color: #cfdfd7;
}

.record-card > div:first-child {
  display: grid;
  gap: 5px;
}

.record-card > div:first-child strong {
  color: var(--ink);
  font-size: 15px;
  line-height: 1.35;
}

.record-card > div:first-child .muted {
  color: #4f5c70;
  font-size: 13px;
  font-weight: 650;
  margin: 0;
}

.record-card.notification {
  border-left: 4px solid #2563eb;
}

.record-card.hearing {
  border-left: 4px solid #7c3aed;
}

.record-card.task {
  border-left: 4px solid var(--green);
}

.record-type {
  color: var(--muted);
  display: block;
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.record-card .badge {
  justify-self: start;
  margin-top: 2px;
}

.record-notes {
  background: #ffffff;
  border-color: #d7dfec;
  min-height: 86px;
  resize: vertical;
}

.record-card label {
  color: #465469;
}

.record-card-actions {
  border-top: 1px solid #e6ebf3;
  padding-top: 12px;
}

.record-card-actions button {
  min-height: 38px;
}

.record-card-actions .preview-record-pdf {
  border-color: #c7d6f8;
  color: var(--blue);
  font-weight: 800;
}

.record-card-actions .save-record-notes {
  font-weight: 800;
}

.task-list {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.task-row {
  align-items: center;
  background: #fbfcff;
  border: 1px solid var(--line);
  border-left: 4px solid var(--green);
  border-radius: 8px;
  display: flex;
  gap: 12px;
  justify-content: space-between;
  padding: 12px;
}

.task-row.completed {
  background: #f7faf8;
  opacity: 0.86;
}

.admin-status {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-top: 14px;
}

.admin-status div {
  background: #fbfcff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
}

.admin-status span {
  color: var(--muted);
  display: block;
  font-size: 12px;
  font-weight: 800;
  margin-bottom: 4px;
  text-transform: uppercase;
}

.admin-status strong {
  overflow-wrap: anywhere;
}

.command-grid {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.command-grid code {
  background: #f4f6fb;
  border: 1px solid var(--line);
  border-radius: 6px;
  display: block;
  overflow-wrap: anywhere;
  padding: 10px;
}

.create-pdf-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcff;
  display: grid;
  gap: 12px;
  padding: 14px;
}

.create-pdf-panel strong {
  display: block;
}

.create-pdf-tools {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 140px;
  gap: 8px;
}

.create-pdf-tools input {
  padding: 7px 10px;
}

.pdf-panel h3 {
  margin: 0;
  font-size: 18px;
}

#pdf-status {
  display: grid;
  gap: 4px;
  overflow-wrap: anywhere;
}

#pdf-status a {
  color: var(--blue);
  font-weight: 700;
}

.pdf-review {
  margin-top: 12px;
}

.pdf-preview-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcff;
  display: grid;
  gap: 10px;
  padding: 10px;
}

.pdf-preview-toolbar {
  align-items: center;
  display: flex;
  gap: 10px;
  justify-content: space-between;
}

.pdf-pages {
  background: #eef2f7;
  border: 1px solid var(--line);
  border-radius: 6px;
  display: grid;
  gap: 12px;
  max-height: 520px;
  overflow: auto;
  padding: 10px;
}

.pdf-page {
  margin: 0;
}

.pdf-page img {
  background: #ffffff;
  border: 1px solid var(--line);
  box-shadow: 0 10px 24px rgba(27, 38, 62, 0.12);
  display: block;
  height: auto;
  margin: 0 auto;
  max-width: 100%;
}

.pdf-preview-card.large {
  border: 0;
  border-radius: 0;
  box-shadow: none;
}

.pdf-preview-card.large .pdf-pages {
  border: 0;
  border-radius: 0;
  max-height: min(82vh, 900px);
}

.pdf-page.large img {
  max-width: min(100%, 980px);
}

.suggestion-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcff;
  padding: 12px;
  display: grid;
  gap: 12px;
}

.suggestion-card.approved {
  border-color: #b8e4ce;
  background: #f4fbf8;
}

.suggestion-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.diagnostic-summary {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.diagnostic-summary div,
.diagnostic-grid div {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #ffffff;
  padding: 9px;
}

.diagnostic-summary span,
.diagnostic-grid span {
  color: var(--muted);
  display: block;
  font-size: 12px;
  font-weight: 700;
  margin-bottom: 4px;
}

.diagnostic-summary strong,
.diagnostic-grid strong {
  display: block;
  overflow-wrap: anywhere;
}

.diagnostic-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.diagnostic-grid .found strong {
  color: var(--green);
}

.diagnostic-grid .missing strong {
  color: var(--red);
}

.suggestion-fields {
  display: grid;
  gap: 8px;
  margin: 0;
}

.suggestion-fields div {
  display: grid;
  grid-template-columns: 110px minmax(0, 1fr);
  gap: 10px;
}

.suggestion-fields dt {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.suggestion-fields dd {
  margin: 0;
  overflow-wrap: anywhere;
}

.suggested-tasks {
  display: grid;
  gap: 8px;
}

.warning-list {
  margin: 0;
  padding-left: 18px;
  color: var(--amber);
  font-size: 13px;
}

details:not(.calendar-accordion) {
  border-top: 1px solid var(--line);
  padding-top: 10px;
}

details:not(.calendar-accordion) > summary {
  cursor: pointer;
  color: var(--blue);
  font-weight: 700;
}

pre {
  max-height: 260px;
  overflow: auto;
  white-space: pre-wrap;
  background: #f4f6fb;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px;
  font-size: 12px;
}

dialog {
  border: 0;
  border-radius: 8px;
  width: min(720px, calc(100vw - 32px));
  padding: 0;
  box-shadow: 0 30px 80px rgba(15, 23, 42, 0.28);
}

.preview-dialog {
  width: min(1180px, calc(100vw - 28px));
}

.preview-dialog .dialog-heading {
  padding: 14px 16px;
}

#pdf-preview-frame-large {
  display: block;
  min-height: min(82vh, 900px);
  width: 100%;
}

dialog::backdrop {
  background: rgba(15, 23, 42, 0.45);
}

#create-form,
#hearing-form,
#case-form,
#task-form {
  padding: 20px;
}

.dialog-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.dialog-heading h2 {
  margin: 0;
}

.dialog-heading button,
menu button:first-child {
  background: #e8edf6;
  color: var(--ink);
}

menu {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 0;
  margin: 4px 0 0;
}

@media (max-width: 1100px) {
  .workspace,
  .lower-grid,
  .metrics,
  .dashboard-grid,
  .settings-grid,
  .calendar-workspace {
    grid-template-columns: 1fr;
  }

  .calendar-day-detail {
    max-height: none;
    position: static;
  }
}

@media (max-width: 980px) {
  .admin-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    border-bottom: 1px solid var(--line);
    border-right: 0;
    height: auto;
    padding: 14px 18px;
    position: sticky;
    z-index: 10;
  }

  .brand {
    border-bottom: 0;
    padding-bottom: 0;
  }

  .side-nav {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding-bottom: 2px;
  }

  .nav-item {
    flex: 0 0 auto;
    white-space: nowrap;
    width: auto;
  }

  .quick-links {
    display: flex;
    margin-top: 0;
    padding-top: 12px;
  }

  .main-panel {
    padding: 18px;
  }
}

@media (max-width: 680px) {
  .shell {
    padding: 18px;
  }

  .topbar,
  .panel-heading,
  .calendar-top,
  .split,
  .create-pdf-tools,
  .diagnostic-summary,
  .diagnostic-grid,
  .pdf-preview-toolbar {
    grid-template-columns: 1fr;
    display: grid;
  }

  .topbar-actions {
    justify-content: stretch;
  }

  .topbar-actions button {
    width: 100%;
  }

  .topbar-actions .quick-link {
    justify-content: center;
    width: 100%;
  }

  .calendar-nav {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    width: 100%;
  }

  .calendar-nav button {
    width: 100%;
  }

  .calendar-weekdays,
  .calendar-grid {
    gap: 4px;
  }

  .calendar-day {
    min-height: 58px;
    padding: 5px;
  }

  .day-number {
    height: 22px;
    width: 22px;
  }

  #search {
    min-width: 0;
  }
}
