:root {
  color-scheme: light;
  --bg: #eef1f4;
  --ink: #16202a;
  --muted: #65717e;
  --panel: #ffffff;
  --line: #c9d2dc;
  --accent: #1f6f8b;
  --accent-strong: #154d63;
  --gold: #b2872b;
  --soft: #f5f7f9;
  --danger: #9a2f2f;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "Times New Roman", Georgia, serif;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

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

.topbar {
  min-height: 96px;
  padding: 18px 24px;
  color: #fff;
  background:
    linear-gradient(90deg, rgba(12, 45, 58, 0.96), rgba(20, 88, 112, 0.9)),
    repeating-linear-gradient(135deg, rgba(255,255,255,0.08) 0 1px, transparent 1px 12px);
  display: flex;
  justify-content: space-between;
  gap: 24px;
  align-items: center;
}

.topbar h1,
.panel h2,
.case-view h2,
dialog h2 {
  margin: 0;
  letter-spacing: 0;
}

.topbar h1 {
  font-size: clamp(20px, 2.2vw, 28px);
  line-height: 1.1;
}

.eyebrow {
  margin: 0 0 5px;
  color: inherit;
  font-size: 13px;
  letter-spacing: 0;
  text-transform: uppercase;
  opacity: 0.74;
}

.status-strip {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.status-strip span {
  border: 1px solid rgba(255,255,255,0.35);
  border-radius: 4px;
  padding: 7px 10px;
  background: rgba(255,255,255,0.09);
}

.workspace {
  flex: 1;
  display: grid;
  grid-template-columns: 190px minmax(0, 1fr) 330px;
  gap: 14px;
  padding: 14px;
  min-height: 0;
}

.sidebar,
.panel,
.case-view {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 6px;
  min-width: 0;
}

.sidebar {
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.nav-button,
.quick-actions button,
.primary-button,
#closeHistoryButton {
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--soft);
  color: var(--ink);
}

.nav-button {
  text-align: left;
  padding: 8px 10px;
}

.nav-button.active,
.primary-button {
  border-color: var(--accent-strong);
  background: var(--accent);
  color: #fff;
}

.panel {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.panel-header,
.results-toolbar,
.dialog-header,
.case-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
}

.case-actions {
  display: flex;
  gap: 8px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--line);
}

.case-actions button {
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--soft);
  padding: 6px 10px;
}

.quick-actions {
  display: flex;
  gap: 8px;
}

.quick-actions button,
#closeHistoryButton {
  padding: 0 12px;
}

.view {
  display: none;
  padding: 16px;
}

.view.active {
  display: block;
}

.welcome-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 16px;
  align-items: stretch;
}

.welcome-copy,
.summary-grid,
.utility-grid {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--soft);
  padding: 16px;
}

.welcome-copy h3 {
  margin: 0 0 8px;
  font-size: 24px;
}

.welcome-copy p {
  margin: 0;
  color: var(--muted);
  line-height: 1.5;
}

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

.summary-number {
  display: block;
  color: var(--accent-strong);
  font-size: 30px;
  font-weight: 700;
}

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

.search-form {
  border-bottom: 1px solid var(--line);
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(160px, 1fr));
  gap: 12px;
}

label span {
  display: block;
  margin-bottom: 5px;
  color: var(--muted);
  font-size: 13px;
}

input,
select {
  width: 100%;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: #fff;
  color: var(--ink);
  padding: 8px 10px;
}

input:focus,
select:focus,
button:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 1px;
}

.option-row {
  margin-top: 14px;
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
}

.check-option {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 34px;
}

.check-option input {
  width: 16px;
  min-height: 16px;
}

.primary-button {
  margin-left: auto;
  padding: 0 18px;
}

.utility-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(190px, 1fr));
  gap: 8px 16px;
}

.results-block {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.results-toolbar {
  background: #f9fafb;
}

.results-toolbar label {
  min-width: min(360px, 100%);
}

.table-wrap {
  overflow: auto;
  min-height: 280px;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 15px;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 9px 10px;
  text-align: left;
  vertical-align: top;
}

th {
  position: sticky;
  top: 0;
  background: #dde7ee;
  color: #15242e;
  z-index: 1;
}

tbody tr {
  background: #fff;
}

tbody tr:nth-child(even) {
  background: #f8fafb;
}

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

.case-view {
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.case-details {
  overflow: auto;
  padding: 16px;
  line-height: 1.5;
}

.judgement-view {
  color: #111;
  background: #fff;
  font-family: "Times New Roman", Georgia, serif;
  font-size: 17px;
  line-height: 1.55;
}

.judgement-court {
  text-align: center;
  font-weight: 700;
  text-transform: uppercase;
  margin-bottom: 12px;
}

.judgement-view h1 {
  margin: 0 0 12px;
  text-align: center;
  font-size: 22px;
  line-height: 1.35;
}

.judgement-view h1 span {
  display: block;
  margin: 5px 0;
  font-size: 15px;
  font-weight: 400;
  text-transform: uppercase;
}

.judgement-view .meta-line {
  text-align: center;
  margin-bottom: 8px;
}

.judgement-view section {
  margin-top: 16px;
}

.judgement-view h2 {
  margin: 0 0 6px;
  font-size: 18px;
  text-align: left;
}

.judgement-view p {
  margin: 0;
  text-align: justify;
}

.case-details dl {
  margin: 0;
}

.case-details dt {
  margin-top: 12px;
  color: var(--muted);
  font-size: 13px;
  text-transform: uppercase;
}

.case-details dd {
  margin: 2px 0 0;
}

.badge {
  display: inline-block;
  border-radius: 4px;
  padding: 3px 7px;
  background: #efe4c7;
  color: #553f10;
}

dialog {
  width: min(760px, calc(100vw - 28px));
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0;
}

dialog::backdrop {
  background: rgba(16, 24, 32, 0.45);
}

#historyBody td:first-child {
  width: 130px;
}

@media (max-width: 1180px) {
  .workspace {
    grid-template-columns: 170px minmax(0, 1fr);
  }

  .case-view {
    grid-column: 1 / -1;
  }

  .form-grid,
  .welcome-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 760px) {
  .topbar,
  .panel-header,
  .results-toolbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .workspace {
    grid-template-columns: 1fr;
    padding: 8px;
  }

  .sidebar {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .form-grid,
  .welcome-grid,
  .summary-grid,
  .utility-grid {
    grid-template-columns: 1fr;
  }

  .primary-button {
    margin-left: 0;
    width: 100%;
  }
}

@media print {
  body {
    background: #fff;
  }

  .topbar,
  .sidebar,
  .panel,
  .case-header,
  .case-actions {
    display: none !important;
  }

  .workspace {
    display: block;
    padding: 0;
  }

  .case-view {
    display: block;
    border: 0;
  }

  .case-details {
    padding: 0;
    overflow: visible;
  }

  .judgement-view {
    font-size: 13pt;
  }
}
