:root {
  color-scheme: light;
  --ink: #132238;
  --muted: #64748b;
  --line: #d9e1ec;
  --soft: #f4f7fb;
  --panel: #ffffff;
  --navy: #0e1a2e;
  --blue: #2f65e8;
  --green: #1fa971;
  --amber: #a76608;
  --red: #b33434;
  --shadow: 0 18px 45px rgba(20, 32, 50, 0.09);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: #f6f8fb;
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  overflow-x: hidden;
}

button,
input,
select {
  font: inherit;
}

[hidden] {
  display: none !important;
}

.topbar {
  min-height: 190px;
  padding: 28px clamp(20px, 4vw, 52px);
  background: var(--navy);
  color: white;
  display: grid;
  grid-template-columns: minmax(320px, 0.9fr) minmax(340px, 1.1fr);
  gap: 22px 28px;
  align-items: start;
}

.brand {
  display: flex;
  align-items: center;
  gap: 20px;
}

.brand-mark {
  width: 76px;
  height: 76px;
  border-radius: 22px;
  background: var(--blue);
  display: grid;
  place-items: center;
  box-shadow: 0 16px 35px rgba(47, 101, 232, 0.32);
}

.brand-mark svg,
.search-box svg {
  width: 42px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.brand h1 {
  margin: 0;
  font-size: 3rem;
  line-height: 1;
  letter-spacing: 0;
}

.brand p {
  margin: 12px 0 0;
  color: #93a4bb;
  font-size: 0.95rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

main {
  padding-bottom: 48px;
}

.controls,
.workbench {
  width: min(1760px, calc(100% - 40px));
  margin: 28px auto 0;
}

.case-note,
.folder-links,
.controls,
.record-card {
  box-shadow: var(--shadow);
}

.case-note {
  grid-column: 1;
  border-radius: 0;
  padding: 0;
  background: transparent;
  border: 0;
  box-shadow: none;
}

.case-note span {
  display: block;
  color: var(--blue);
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0;
  font-size: 0.8rem;
}

.case-note strong {
  display: block;
  margin-top: 8px;
  color: white;
  font-size: 1.25rem;
}

.case-note p {
  margin: 10px 0 0;
  color: #a8b6ca;
  line-height: 1.55;
}

.folder-links {
  grid-column: 2;
  grid-row: 1 / span 2;
  align-self: stretch;
  border-radius: 8px;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  background: transparent;
  border: 0;
  box-shadow: none;
}

.folder-links a {
  border: 1px solid rgba(147, 164, 187, 0.24);
  border-radius: 7px;
  padding: 12px;
  color: white;
  text-decoration: none;
  font-weight: 800;
  background: rgba(255, 255, 255, 0.06);
  display: flex;
  align-items: center;
}

.controls {
  border-radius: 8px;
  padding: 24px;
}

.search-box {
  min-height: 72px;
  border: 2px solid var(--line);
  border-radius: 8px;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 20px;
  color: var(--blue);
  background: linear-gradient(180deg, white, #fbfdff);
}

.search-box input {
  width: 100%;
  border: 0;
  outline: 0;
  color: var(--ink);
  font-size: 1.28rem;
  font-weight: 750;
  background: transparent;
}

.filter-grid {
  margin-top: 18px;
  display: grid;
  grid-template-columns: repeat(7, minmax(150px, 1fr));
  gap: 12px;
}

.filter-grid label,
.filter-field {
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 900;
  letter-spacing: 0;
  text-transform: uppercase;
}

.filter-field {
  position: relative;
}

.filter-grid select,
.filter-grid input,
.filter-popover-button {
  margin-top: 7px;
  width: 100%;
  height: 46px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fbfdff;
  color: var(--ink);
  padding: 0 10px;
  font-weight: 750;
}

.filter-popover-button {
  text-align: left;
  cursor: pointer;
}

.filter-popover-button[aria-expanded="true"] {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(53, 111, 230, 0.13);
}

.control-footer {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.checkbox-panel {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  z-index: 40;
  width: min(520px, 72vw);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdff;
  padding: 12px;
  box-shadow: 0 18px 38px rgba(18, 33, 56, 0.16);
}

.compact-panel {
  width: min(360px, 72vw);
}

.date-panel {
  width: min(430px, 72vw);
}

.checkbox-panel::before {
  content: "";
  position: absolute;
  top: -7px;
  left: 22px;
  width: 12px;
  height: 12px;
  border-left: 1px solid var(--line);
  border-top: 1px solid var(--line);
  background: #fbfdff;
  transform: rotate(45deg);
}

.checkbox-panel-head,
.saved-filter-create,
.saved-filter-list {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.checkbox-panel-head {
  justify-content: space-between;
  margin-bottom: 10px;
}

.checkbox-panel-head button {
  border: 0;
  background: transparent;
  color: var(--blue);
  font-weight: 850;
  cursor: pointer;
}

.checkbox-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.checkbox-option {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 34px;
  border: 1px solid #e1e8f2;
  border-radius: 7px;
  background: white;
  color: var(--ink);
  padding: 0 10px;
  font-size: 0.88rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: none;
}

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

.month-range label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 900;
  text-transform: uppercase;
}

.month-range input {
  margin-top: 0;
  width: 100%;
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: white;
  color: var(--ink);
  padding: 0 10px;
  font-weight: 750;
}

.filter-grid .checkbox-option {
  color: var(--ink);
  font-size: 0.88rem;
  text-transform: none;
}

.control-footer {
  margin-top: 16px;
  align-items: flex-start;
  justify-content: space-between;
}

.control-popover {
  position: relative;
  display: inline-flex;
  gap: 8px;
  flex-wrap: wrap;
}

.export-popover {
  margin-left: auto;
}

.subtle-action,
.control-popover-panel button {
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: white;
  color: var(--ink);
  padding: 0 11px;
  font-size: 0.82rem;
  font-weight: 850;
  cursor: pointer;
}

.subtle-action:hover,
.control-popover-panel button:hover {
  border-color: #b8cced;
  background: #edf4ff;
  color: #194cba;
}

.control-popover-panel {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  z-index: 45;
  min-width: 260px;
  border: 1px solid #dbe5f2;
  border-radius: 8px;
  background: #fbfdff;
  padding: 10px;
  box-shadow: 0 18px 38px rgba(18, 33, 56, 0.16);
}

.export-popover .control-popover-panel {
  right: 0;
  left: auto;
}

.saved-filter-panel {
  width: min(420px, 80vw);
}

.export-panel {
  display: grid;
  gap: 8px;
}

.export-status {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
}

.export-status a {
  width: fit-content;
  color: var(--blue);
  font-weight: 900;
}

.download-ready {
  position: fixed;
  left: -9999px;
  top: 0;
}

.saved-filter-create input {
  min-height: 36px;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 0 12px;
  font-weight: 750;
}

.favorite-filter button,
.favorite-empty {
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: white;
  color: var(--ink);
  padding: 0 12px;
  font-size: 0.82rem;
  font-weight: 850;
}

.saved-filter-create {
  margin-bottom: 8px;
}

.favorite-filter {
  display: inline-flex;
  align-items: center;
}

.favorite-filter button:first-child {
  border-radius: 7px 0 0 7px;
}

.favorite-filter button:last-child {
  border-left: 0;
  border-radius: 0 7px 7px 0;
  color: #8a3a3a;
}

.favorite-empty {
  color: var(--muted);
  display: inline-flex;
  align-items: center;
}

.result-count {
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 900;
  letter-spacing: 0;
  text-transform: uppercase;
}

.workbench {
  display: block;
}

.records {
  display: grid;
  gap: 10px;
}

.record-card {
  border-radius: 8px;
  padding: 14px;
  display: grid;
  grid-template-columns: 180px minmax(0, 1fr) 72px;
  gap: 16px;
  align-items: center;
}

.document-preview {
  width: 180px;
  min-height: 118px;
  border: 1px solid #d8e2ef;
  border-radius: 8px;
  background: linear-gradient(180deg, #ffffff 0%, #f5f8fc 100%);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.85);
  color: inherit;
  padding: 14px;
  position: relative;
  overflow: hidden;
  display: grid;
  align-content: space-between;
  gap: 12px;
  text-decoration: none;
  cursor: pointer;
  transition: border-color 150ms ease, box-shadow 150ms ease, transform 150ms ease;
}

.document-preview:hover,
.document-preview:focus-visible {
  border-color: #2f65e8;
  box-shadow: 0 14px 28px rgba(47, 101, 232, 0.16), inset 0 0 0 1px rgba(255, 255, 255, 0.85);
  transform: translateY(-1px);
  outline: none;
}

.drive-thumbnail {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: #eef3f8;
  z-index: 2;
}

.document-preview:not(.thumbnail-failed):has(.drive-thumbnail) {
  border-color: #cbd8e8;
}

.document-preview:not(.thumbnail-failed):has(.drive-thumbnail)::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0) 34%, rgba(12, 24, 41, 0.62) 100%);
  z-index: 3;
}

.preview-fold {
  position: absolute;
  top: 0;
  right: 0;
  width: 32px;
  height: 32px;
  background: linear-gradient(135deg, #dbe7f5 50%, #ffffff 50%);
  border-left: 1px solid #d8e2ef;
  border-bottom: 1px solid #d8e2ef;
  z-index: 4;
}

.preview-fold::after {
  content: "";
  position: absolute;
  top: 8px;
  right: 7px;
  width: 8px;
  height: 8px;
  border-top: 2px solid #2f65e8;
  border-right: 2px solid #2f65e8;
  opacity: 0;
  transform: translate(-2px, 2px);
  transition: opacity 150ms ease, transform 150ms ease;
}

.document-preview:hover .preview-fold::after,
.document-preview:focus-visible .preview-fold::after {
  opacity: 1;
  transform: translate(0, 0);
}

.preview-icon {
  width: fit-content;
  min-width: 52px;
  min-height: 32px;
  border-radius: 7px;
  display: inline-grid;
  place-items: center;
  padding: 0 10px;
  color: white;
  background: #506780;
  font-size: 0.82rem;
  font-weight: 950;
  position: relative;
  z-index: 5;
}

.preview-pdf .preview-icon {
  background: #c24136;
}

.preview-doc .preview-icon {
  background: #2563c9;
}

.preview-image .preview-icon {
  background: #16805f;
}

.preview-link .preview-icon {
  background: #7c5bbd;
}

.preview-lines {
  display: grid;
  gap: 6px;
  position: relative;
  z-index: 5;
}

.preview-lines span {
  display: block;
  height: 10px;
  border-radius: 999px;
  background: #dbe4ef;
  color: transparent;
  overflow: hidden;
}

.preview-lines span:first-child {
  width: 100%;
}

.preview-lines span:nth-child(2) {
  width: 78%;
}

.preview-lines span:nth-child(3) {
  width: 56%;
}

.document-preview:not(.thumbnail-failed):has(.drive-thumbnail) .preview-lines span {
  background: rgba(255, 255, 255, 0.74);
}

.record-main h3 {
  margin: 0 0 12px;
  font-size: 1.22rem;
  line-height: 1.2;
}

.meta-row,
.tag-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  border-radius: 7px;
  border: 1px solid #e3eaf3;
  background: #f8fbff;
  color: #64758b;
  padding: 0 10px;
  font-size: 0.82rem;
  font-weight: 850;
}

.date-chip {
  width: 72px;
  height: 62px;
  border-radius: 7px;
  border: 1px solid #d8e4f2;
  background: #f8fbff;
  color: #52657d;
  display: grid;
  place-items: center;
  align-items: center;
  padding: 6px;
  font-weight: 850;
}

.calendar-page {
  width: 54px;
  min-width: 54px;
  height: 50px;
  border: 1px solid #cbd8e8;
  border-radius: 7px;
  overflow: hidden;
  display: grid;
  grid-template-rows: 14px 23px 13px;
  background: white;
  box-shadow: 0 1px 0 rgba(19, 34, 56, 0.04);
}

.calendar-page span {
  display: grid;
  place-items: center;
  background: #2f65e8;
  color: white;
  font-size: 0.58rem;
  line-height: 1;
  font-weight: 950;
  text-transform: uppercase;
}

.calendar-page strong {
  display: grid;
  place-items: center;
  color: #183a72;
  font-size: 1.1rem;
  line-height: 1;
}

.calendar-page em {
  display: grid;
  place-items: start center;
  color: #98a8bb;
  font-size: 0.58rem;
  font-weight: 900;
  font-style: normal;
  line-height: 1;
}

.certified-icon {
  width: 30px;
  height: 30px;
  border-radius: 7px;
  border: 1px solid #bce9d5;
  background: #eafaf3;
  color: #11835b;
  display: inline-grid;
  place-items: center;
}

.certified-icon svg,
.icon-button svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.pill.petitioner {
  color: #9b3363;
  background: #fff0f7;
  border-color: #f7cfe2;
}

.pill.respondent {
  color: #1b5aaa;
  background: #eef5ff;
  border-color: #cfe1fb;
}

.pill.court {
  color: #72511a;
  background: #fff7e6;
  border-color: #f4dfaf;
}

.pill.exhibit-pill {
  color: #183a72;
  background: #eef5ff;
  border-color: #cfe1fb;
}

.pill.status-pill,
.note-indicator {
  color: #59449a;
  background: #f4f0ff;
  border-color: #ddd2ff;
}

.note-indicator {
  min-height: 28px;
  border-radius: 7px;
  border: 1px solid #ddd2ff;
  display: inline-flex;
  align-items: center;
  padding: 0 10px;
  font-size: 0.82rem;
  font-weight: 850;
}

.record-editor {
  margin-top: 10px;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.editor-label {
  color: #7a8aa0;
  font-size: 0.75rem;
  font-weight: 900;
}

.star-editor {
  display: inline-flex;
  align-items: center;
  gap: 2px;
}

.star-editor button {
  width: 26px;
  height: 26px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: #b9c5d4;
  display: grid;
  place-items: center;
  cursor: pointer;
}

.star-editor button:hover,
.star-editor button:focus-visible,
.star-editor button.active {
  color: #d89b0d;
  background: #fff7df;
  outline: none;
}

.star-editor svg {
  width: 18px;
  height: 18px;
  fill: currentColor;
  stroke: currentColor;
  stroke-width: 1.5;
  stroke-linejoin: round;
}

.parse-note {
  margin: 10px 0 0;
  color: #6c7b90;
  font-size: 0.9rem;
  line-height: 1.45;
}

.record-actions {
  display: grid;
  grid-template-rows: 62px 38px 38px;
  gap: 7px;
  align-self: center;
}

.secondary-button,
.icon-button {
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #f9fbfe;
  color: #43536a;
  font-weight: 850;
  cursor: pointer;
}

.secondary-button {
  min-height: 42px;
}

.icon-button {
  width: 72px;
  height: 38px;
  display: grid;
  place-items: center;
  transition: background 150ms ease, border-color 150ms ease, color 150ms ease;
}

.icon-button:hover,
.icon-button:focus-visible {
  border-color: #b8cced;
  background: #edf4ff;
  color: #194cba;
  outline: none;
}

.icon-button.copied {
  border-color: #bce9d5;
  background: #eafaf3;
  color: #11835b;
}

dialog {
  width: min(860px, calc(100% - 30px));
  border: 0;
  border-radius: 8px;
  box-shadow: 0 28px 80px rgba(13, 24, 42, 0.32);
  padding: 0;
}

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

.dialog-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 18px 22px;
  border-bottom: 1px solid var(--line);
}

.dialog-head h2 {
  margin: 0;
  font-size: 1.2rem;
}

.dialog-head button {
  border: 1px solid var(--line);
  background: white;
  border-radius: 7px;
  width: 38px;
  height: 38px;
  font-weight: 900;
}

.detail-body {
  padding: 20px 22px 24px;
  display: grid;
  gap: 12px;
}

.detail-row {
  display: grid;
  grid-template-columns: 180px minmax(0, 1fr);
  gap: 12px;
  border-bottom: 1px solid #edf1f7;
  padding-bottom: 10px;
}

.detail-row span {
  color: var(--muted);
  font-weight: 850;
}

.edit-panel {
  margin-top: 4px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
  display: grid;
  gap: 12px;
}

.edit-panel h3 {
  margin: 0;
  font-size: 1rem;
}

.edit-panel label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 850;
}

.edit-panel select,
.edit-panel textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fbfdff;
  color: var(--ink);
  padding: 10px;
  font: inherit;
}

.edit-panel textarea {
  resize: vertical;
  min-height: 92px;
}

.empty-state {
  padding: 48px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  text-align: center;
  color: var(--muted);
  background: white;
}

@media (max-width: 1180px) {
  .topbar {
    grid-template-columns: 1fr;
  }

  .case-note,
  .folder-links {
    grid-column: auto;
    grid-row: auto;
  }

  .filter-grid {
    grid-template-columns: repeat(3, minmax(150px, 1fr));
  }
}

@media (max-width: 760px) {
  .topbar {
    padding: 22px 18px;
  }

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

  .brand-mark {
    width: 58px;
    height: 58px;
    border-radius: 16px;
  }

  .brand-mark svg {
    width: 32px;
  }

  .brand p {
    letter-spacing: 0;
  }

  .brand h1 {
    font-size: 2.05rem;
  }

  .search-box input {
    font-size: 1rem;
  }

  .record-main h3 {
    font-size: 1.08rem;
  }

  .controls,
  .workbench {
    width: min(100% - 24px, 1760px);
  }

  .folder-links,
  .filter-grid,
  .record-card {
    grid-template-columns: 1fr;
  }

  .checkbox-panel {
    position: static;
    width: 100%;
    margin-top: 8px;
    box-shadow: none;
  }

  .checkbox-panel::before {
    display: none;
  }

  .record-card {
    align-items: start;
    gap: 12px;
    padding: 12px;
  }

  .document-preview {
    width: 100%;
    min-height: 112px;
  }

  .record-actions {
    width: 100%;
    grid-template-columns: 72px 72px 72px;
    grid-template-rows: 62px;
    align-items: start;
  }

  .detail-row {
    grid-template-columns: 1fr;
  }
}
