:root {
  --bg: #f4f6f9;
  --surface: #ffffff;
  --border: #dde3ec;
  --text: #1a2332;
  --muted: #5c6b7f;
  --primary: #1a5fb4;
  --primary-hover: #154a8f;
  --success: #1a7f37;
  --error: #c01c28;
  --shadow: 0 1px 3px rgba(26, 35, 50, 0.08);
  --radius: 10px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

header {
  background: linear-gradient(135deg, #0f3d73, #1a5fb4);
  color: #fff;
  padding: 2rem 1.5rem;
}

.header-inner {
  max-width: 1100px;
  margin: 0 auto;
}

header h1 {
  margin: 0 0 0.35rem;
  font-size: 1.75rem;
  font-weight: 600;
}

header p {
  margin: 0;
  opacity: 0.9;
  max-width: 640px;
}

main {
  max-width: 1100px;
  margin: 0 auto;
  padding: 1.5rem;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem 1.5rem;
  margin-bottom: 1.25rem;
  box-shadow: var(--shadow);
}

.card h2 {
  margin: 0 0 1rem;
  font-size: 1.1rem;
}

.drop-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 2rem;
  text-align: center;
  color: var(--muted);
  transition: border-color 0.15s, background 0.15s;
  margin-bottom: 1rem;
}

.drop-zone.dragover {
  border-color: var(--primary);
  background: #eef4fc;
}

.link-btn {
  background: none;
  border: none;
  color: var(--primary);
  cursor: pointer;
  font: inherit;
  text-decoration: underline;
  padding: 0;
}

.btn {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  padding: 0.55rem 1rem;
  border-radius: 8px;
  cursor: pointer;
  font: inherit;
}

.btn:hover {
  background: #f0f3f8;
}

.btn.primary {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

.btn.primary:hover:not(:disabled) {
  background: var(--primary-hover);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.status {
  margin-top: 0.75rem;
  padding: 0.65rem 0.85rem;
  border-radius: 8px;
  font-size: 0.95rem;
}

.status.success {
  background: #e8f5ec;
  color: var(--success);
}

.status.error {
  background: #fdecea;
  color: var(--error);
}

.search-bar {
  display: flex;
  gap: 0.75rem;
}

.search-bar input {
  flex: 1;
  padding: 0.65rem 0.85rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  font: inherit;
}

.search-bar input:focus {
  outline: 2px solid #b8d4f5;
  border-color: var(--primary);
}

.hint {
  margin: 0.75rem 0 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.results-grid {
  display: grid;
  gap: 1rem;
}

.result-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.result-card:hover {
  border-color: #b8d4f5;
  box-shadow: 0 4px 12px rgba(26, 35, 50, 0.1);
}

.result-card .top-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  margin-bottom: 0.5rem;
}

.result-card h3 {
  margin: 0;
  font-size: 1rem;
}

.badge {
  display: inline-block;
  padding: 0.15rem 0.55rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  white-space: nowrap;
}

.badge.claim {
  background: #e8f0fa;
  color: #1a5fb4;
}

.badge.remit {
  background: #f0e8fa;
  color: #6b3fa0;
}

.result-card .meta {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 0.35rem 1rem;
  font-size: 0.9rem;
  color: var(--muted);
}

.result-card .meta strong {
  color: var(--text);
  font-weight: 500;
}

.empty-state {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--muted);
}

dialog {
  border: none;
  border-radius: var(--radius);
  padding: 0;
  width: min(900px, 92vw);
  max-height: 85vh;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.2);
}

dialog::backdrop {
  background: rgba(15, 30, 50, 0.45);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
}

.modal-header h2 {
  margin: 0;
  font-size: 1.1rem;
}

.icon-btn {
  background: none;
  border: none;
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
  color: var(--muted);
  padding: 0.25rem 0.5rem;
}

.modal-body {
  padding: 1rem 1.25rem;
  overflow: auto;
  max-height: calc(85vh - 60px);
}

.detail-section {
  margin-bottom: 1.25rem;
}

.detail-section:last-child {
  margin-bottom: 0;
}

.detail-section h3 {
  margin: 0 0 0.65rem;
  font-size: 0.85rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--primary);
  border-bottom: 1px solid var(--border);
  padding-bottom: 0.35rem;
}

.field-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 0.5rem 1.25rem;
}

.field {
  font-size: 0.9rem;
}

.field .label {
  display: block;
  font-size: 0.75rem;
  color: var(--muted);
  margin-bottom: 0.1rem;
}

.field .value {
  color: var(--text);
  font-weight: 500;
}

.field .value.money,
.money {
  color: var(--success);
  font-weight: 600;
}

.summary-banner {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem 2rem;
  background: #f0f5fb;
  border: 1px solid #d4e3f5;
  border-radius: 8px;
  padding: 0.85rem 1rem;
  margin-bottom: 1.25rem;
}

.summary-item .label {
  font-size: 0.75rem;
  color: var(--muted);
}

.summary-item .value {
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--text);
}

.tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.tag {
  background: #eef2f7;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.2rem 0.55rem;
  font-size: 0.82rem;
  font-family: "Cascadia Code", "Consolas", monospace;
}

.detail-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}

.detail-table th,
.detail-table td {
  padding: 0.5rem 0.65rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

.detail-table th {
  background: #f7f9fc;
  font-weight: 600;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--muted);
}

.detail-table tr:last-child td {
  border-bottom: none;
}

.claim-block {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1rem;
  margin-bottom: 1rem;
}

.claim-block:last-child {
  margin-bottom: 0;
}

.claim-block-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.75rem;
  gap: 0.75rem;
}

.claim-block-header h4 {
  margin: 0;
  font-size: 0.95rem;
}

.status-pill {
  font-size: 0.75rem;
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
  font-weight: 600;
}

.status-pill.paid {
  background: #e8f5ec;
  color: var(--success);
}

.status-pill.denied {
  background: #fdecea;
  color: var(--error);
}

.adj-list {
  font-size: 0.8rem;
  color: var(--muted);
}

@media (max-width: 600px) {
  .search-bar {
    flex-direction: column;
  }

  .result-card .top-row {
    flex-direction: column;
  }
}
