:root {
  --ink: #172033;
  --muted: #667085;
  --line: #e4e7ec;
  --paper: #ffffff;
  --canvas: #f4f6f9;
  --primary: #1859c9;
  --primary-dark: #0e429f;
  --success: #087443;
  --warning: #a15c00;
  --danger: #b42318;
  --radius: 12px;
  --shadow: 0 8px 24px rgba(16, 24, 40, 0.07);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--canvas);
}

body {
  min-height: 100%;
  margin: 0;
  color: var(--ink);
  background: var(--canvas);
  font-family:
    Inter, "PingFang SC", "Microsoft YaHei", system-ui, -apple-system, BlinkMacSystemFont,
    "Segoe UI", sans-serif;
  font-size: 14px;
  line-height: 1.55;
}

a {
  color: var(--primary);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

.app-shell {
  min-height: 100vh;
}

.topbar {
  position: sticky;
  z-index: 20;
  top: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 62px;
  padding: 0 26px;
  color: #fff;
  background: #101828;
  box-shadow: 0 2px 8px rgba(16, 24, 40, 0.22);
}

.brand {
  color: #fff;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.brand:hover {
  text-decoration: none;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 14px;
  color: #d0d5dd;
}

.layout {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  min-height: calc(100vh - 62px);
}

.sidebar {
  padding: 20px 14px;
  border-right: 1px solid var(--line);
  background: #fff;
}

.nav-group {
  margin-bottom: 18px;
}

.nav-title {
  margin: 0 10px 7px;
  color: #98a2b3;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
}

.nav-subtitle {
  margin: 12px 10px 5px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

.nav-link {
  display: block;
  margin: 2px 0;
  padding: 8px 10px;
  border-radius: 8px;
  color: #344054;
}

.nav-link:hover {
  color: var(--primary);
  background: #eff4ff;
  text-decoration: none;
}

.main {
  min-width: 0;
  padding: 28px;
}

.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 20px;
}

.page-header h1,
.page-header h2 {
  margin: 0;
}

.page-header p {
  margin: 5px 0 0;
  color: var(--muted);
}

h1 {
  font-size: 25px;
}

h2 {
  font-size: 19px;
}

h3 {
  font-size: 16px;
}

.card {
  margin-bottom: 18px;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--paper);
  box-shadow: var(--shadow);
}

.review-queue-bar,
.workflow-next-card,
.workflow-empty-step {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}

.review-queue-bar {
  padding: 12px 16px;
  background: #f8fbff;
}

.review-queue-bar > div:first-child {
  display: flex;
  align-items: baseline;
  gap: 12px;
}

.review-complete-card {
  display: block;
  max-width: 700px;
  margin: 40px auto;
  text-align: center;
}

.review-complete-icon {
  width: 52px;
  height: 52px;
  display: grid;
  place-items: center;
  margin: 0 auto 14px;
  border-radius: 50%;
  color: #fff;
  background: #12b76a;
  font-size: 30px;
  font-weight: 700;
}

.review-complete-card .actions {
  justify-content: center;
  margin-top: 22px;
}

.workflow-stepper {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin: 0 0 20px;
}

.workflow-step {
  display: grid;
  grid-template-columns: 30px minmax(0, 1fr);
  column-gap: 8px;
  align-items: center;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  color: var(--muted);
}

.workflow-step span {
  grid-row: span 2;
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: #f2f4f7;
  color: var(--muted);
  font-weight: 700;
}

.workflow-step strong,
.workflow-step small {
  display: block;
}

.workflow-step small {
  margin-top: 2px;
  font-size: 11px;
}

.workflow-step.active {
  border-color: var(--primary);
  color: var(--primary);
  background: #eff8ff;
}

.workflow-step.active span {
  color: #fff;
  background: var(--primary);
}

.card h2,
.card h3 {
  margin-top: 0;
}

.grid {
  display: grid;
  gap: 18px;
}

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

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

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

.metric {
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
}

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

.metric-value {
  margin-top: 3px;
  font-size: 28px;
  font-weight: 750;
}

.metric a {
  color: inherit;
}

.metric a:hover {
  color: var(--primary);
  text-decoration: none;
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 10px;
}

table {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
}

th,
td {
  padding: 11px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
  white-space: nowrap;
}

th {
  color: #475467;
  background: #f9fafb;
  font-size: 12px;
  font-weight: 700;
}

tr:last-child td {
  border-bottom: 0;
}

.wrap {
  white-space: normal;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: 10px;
  margin-bottom: 16px;
}

.toolbar .field {
  margin: 0;
}

.selection-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
}

.selection-bar label {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-weight: 650;
}

.selection-count {
  color: var(--muted);
}

.selection-reason {
  display: inline-flex;
  align-items: center;
  gap: 7px;
}

.selection-reason select {
  width: auto;
  min-height: 36px;
}

.selection-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-left: auto;
}

.field {
  margin-bottom: 15px;
}

.field label,
form > p > label {
  display: block;
  margin-bottom: 6px;
  color: #344054;
  font-weight: 650;
}

input,
select,
textarea {
  width: 100%;
  min-height: 40px;
  padding: 8px 10px;
  border: 1px solid #cfd4dc;
  border-radius: 8px;
  color: var(--ink);
  background: #fff;
  font: inherit;
}

input[type="checkbox"],
input[type="radio"] {
  width: auto;
  min-height: 0;
}

input:focus,
select:focus,
textarea:focus {
  outline: 3px solid rgba(24, 89, 201, 0.12);
  border-color: var(--primary);
}

.button,
button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  padding: 8px 14px;
  border: 1px solid transparent;
  border-radius: 8px;
  color: #fff;
  background: var(--primary);
  font: inherit;
  font-weight: 650;
  cursor: pointer;
}

.button:hover,
button:hover {
  color: #fff;
  background: var(--primary-dark);
  text-decoration: none;
}

.button.secondary,
button.secondary {
  color: #344054;
  border-color: #d0d5dd;
  background: #fff;
}

.button.secondary:hover,
button.secondary:hover {
  color: #101828;
  background: #f9fafb;
}

.button.danger,
button.danger {
  background: var(--danger);
}

.button.small,
button.small {
  min-height: 30px;
  padding: 5px 9px;
  font-size: 12px;
}

.inline-form {
  display: inline;
}

.badge {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 999px;
  color: #344054;
  background: #eef1f5;
  font-size: 12px;
  font-weight: 650;
}

.badge.success {
  color: #05603a;
  background: #dff7ea;
}

.badge.warning {
  color: #8a4a00;
  background: #fff1d6;
}

.badge.danger {
  color: #9b1c13;
  background: #fee4e2;
}

.badge.info {
  color: #174ea6;
  background: #e4edff;
}

.messages {
  margin-bottom: 18px;
}

.message,
.alert {
  margin-bottom: 10px;
  padding: 12px 14px;
  border: 1px solid #b9cbee;
  border-radius: 9px;
  color: #153c75;
  background: #edf4ff;
}

.message.success,
.alert.success {
  color: #075b36;
  border-color: #9bd4b8;
  background: #eaf8f0;
}

.message.error,
.alert.error {
  color: #8f1d14;
  border-color: #f1a9a4;
  background: #fff0ef;
}

.message.warning,
.alert.warning {
  color: #7a4300;
  border-color: #edcb8d;
  background: #fff8e8;
}

.muted {
  color: var(--muted);
}

.danger-text {
  color: var(--danger);
}

.success-text {
  color: var(--success);
}

.mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.copy-row {
  display: flex;
  align-items: stretch;
  gap: 8px;
}

.copy-row input {
  min-width: 0;
}

.definition-list {
  display: grid;
  grid-template-columns: 160px minmax(0, 1fr);
  gap: 9px 18px;
  margin: 0;
}

.definition-list dt {
  color: var(--muted);
}

.definition-list dd {
  margin: 0;
  word-break: break-word;
}

.errors,
.errorlist {
  margin: 6px 0;
  padding-left: 20px;
  color: var(--danger);
}

.empty {
  padding: 35px 20px;
  color: var(--muted);
  text-align: center;
}

.pre {
  overflow: auto;
  max-height: 440px;
  padding: 14px;
  border-radius: 8px;
  color: #d1e0ff;
  background: #111827;
  white-space: pre-wrap;
  word-break: break-word;
}

.public-body {
  min-height: 100vh;
  background:
    radial-gradient(circle at 12% 8%, rgba(147, 197, 253, 0.28), transparent 34%),
    radial-gradient(circle at 90% 18%, rgba(196, 181, 253, 0.25), transparent 36%),
    linear-gradient(145deg, #f4f7fb 0%, #edf3fa 52%, #f7f4fb 100%);
  font-family:
    Inter, "PingFang SC", "Microsoft YaHei", system-ui, -apple-system, BlinkMacSystemFont,
    "Segoe UI", sans-serif;
}

.public-shell {
  width: min(780px, calc(100% - 28px));
  margin: 0 auto;
  padding: 42px 0 70px;
}

.public-card {
  position: relative;
  overflow: hidden;
  padding: 34px 42px 42px;
  border: 1px solid rgba(255, 255, 255, 0.82);
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.84);
  box-shadow:
    0 24px 70px rgba(54, 72, 102, 0.16),
    inset 0 1px 0 rgba(255, 255, 255, 0.86);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
}

.public-card h1 {
  margin-top: 0;
}

.public-window-controls {
  display: flex;
  gap: 8px;
  margin-bottom: 30px;
}

.window-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.08);
}

.window-dot-red {
  background: #ff5f57;
}

.window-dot-yellow {
  background: #febc2e;
}

.window-dot-green {
  background: #28c840;
}

.public-invoice-header {
  margin: 0 auto 30px;
  text-align: center;
}

.public-invoice-header h1 {
  margin-bottom: 7px;
  color: #1f2937;
  font-size: clamp(24px, 4.2vw, 32px);
  font-weight: 650;
  letter-spacing: -0.025em;
}

.public-invoice-header p {
  margin: 0;
  color: #6b7280;
  font-size: 14px;
}

.invoice-info-card {
  margin-bottom: 28px;
  padding: 20px;
  border: 1px solid rgba(226, 232, 240, 0.9);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.68);
  box-shadow: 0 8px 24px rgba(64, 83, 115, 0.07);
}

.invoice-section-title,
.application-form-title {
  margin: 0 0 16px;
  color: #374151;
  font-size: 18px;
  font-weight: 600;
}

.invoice-section-title {
  display: flex;
  align-items: center;
}

.invoice-section-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  margin-right: 8px;
  border: 2px solid #3b82f6;
  border-radius: 50%;
  color: #3b82f6;
  font-family: Georgia, serif;
  font-size: 13px;
  font-weight: 700;
}

.invoice-info-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px 24px;
}

.invoice-info-row {
  display: grid;
  grid-template-columns: 88px minmax(0, 1fr);
  gap: 8px;
  font-size: 14px;
}

.invoice-info-row > span {
  color: #9ca3af;
}

.invoice-info-row > strong {
  min-width: 0;
  color: #374151;
  font-weight: 550;
  overflow-wrap: anywhere;
}

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

.invoice-info-link {
  color: #2563eb !important;
}

.invoice-notice {
  margin-top: 18px;
  padding: 12px 14px;
  border-left: 3px solid #60a5fa;
  border-radius: 8px;
  color: #4b5563;
  background: rgba(239, 246, 255, 0.75);
  font-size: 14px;
  line-height: 1.7;
}

.invoice-notice strong {
  color: #2563eb;
}

.invoice-duplicate-warning {
  margin-bottom: 24px;
  padding: 16px 18px;
  border: 1px solid #f4c574;
  border-radius: 12px;
  color: #744300;
  background: rgba(255, 248, 232, 0.9);
}

.invoice-duplicate-warning h2 {
  margin: 0 0 6px;
  font-size: 16px;
}

.invoice-duplicate-warning p {
  margin: 0 0 12px;
}

.duplicate-match {
  padding: 10px 0;
  border-top: 1px solid rgba(161, 92, 0, 0.18);
}

.duplicate-match > div {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 8px;
}

.duplicate-match span {
  color: #8a5c19;
  font-size: 12px;
}

.duplicate-match ul {
  margin: 5px 0 0;
  padding-left: 20px;
}

.application-form-title {
  padding-bottom: 10px;
  border-bottom: 1px solid #edf0f4;
}

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

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

.application-field label {
  display: block;
  margin-bottom: 6px;
  color: #374151;
  font-size: 14px;
  font-weight: 600;
}

.application-field label span {
  color: #ef4444;
}

.application-field label em {
  color: #9ca3af;
  font-size: 12px;
  font-style: normal;
  font-weight: 400;
}

.application-field input,
.application-field textarea {
  width: 100%;
  border: 1px solid #d9dee7;
  border-radius: 9px;
  color: #1f2937;
  background: rgba(255, 255, 255, 0.88);
  box-shadow:
    inset 0 1px 2px rgba(15, 23, 42, 0.03),
    0 1px 0 rgba(255, 255, 255, 0.75);
  transition:
    border-color 150ms ease,
    box-shadow 150ms ease,
    background 150ms ease;
}

.application-field input {
  min-height: 43px;
}

.application-field textarea {
  min-height: 74px;
  resize: vertical;
}

.application-field input:focus,
.application-field textarea:focus {
  border-color: #60a5fa;
  background: #fff;
  box-shadow: 0 0 0 3px rgba(96, 165, 250, 0.16);
}

.application-field input[readonly] {
  color: #4b5563;
  border-color: #e2e8f0;
  background: rgba(241, 245, 249, 0.9);
  cursor: not-allowed;
}

.application-field small {
  display: block;
  margin-top: 5px;
  color: #8b95a5;
  font-size: 12px;
}

.mono-input {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace !important;
  letter-spacing: 0.03em;
}

.amount-input-wrap {
  position: relative;
}

.amount-input-wrap > span {
  position: absolute;
  z-index: 1;
  top: 50%;
  left: 12px;
  color: #6b7280;
  transform: translateY(-50%);
}

.amount-input-wrap input {
  padding-left: 31px;
}

.history-email-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 7px;
}

.history-email-chip {
  width: auto;
  min-height: 28px;
  padding: 4px 9px;
  border: 1px solid #dbe5f3;
  border-radius: 999px;
  color: #365d91;
  background: #f4f8fd;
  font-size: 11px;
  font-weight: 500;
}

.history-email-chip:hover {
  color: #1f4f8f;
  background: #e9f2fd;
}

.public-submit-row {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 14px;
  margin-top: 28px;
}

.public-submit-row button {
  min-width: 132px;
  min-height: 42px;
  border-radius: 9px;
  box-shadow: 0 5px 14px rgba(24, 89, 201, 0.18);
}

.public-secondary-link {
  color: #667085;
  font-size: 13px;
}

.success-checkmark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 54px;
  height: 54px;
  margin: 0 auto 14px;
  border-radius: 50%;
  color: #fff;
  background: linear-gradient(145deg, #34d399, #16a36a);
  box-shadow: 0 10px 24px rgba(22, 163, 106, 0.22);
  font-size: 28px;
  font-weight: 700;
}

.public-actions {
  display: flex;
  gap: 10px;
  margin-top: 20px;
}

.request-card {
  margin: 10px 0;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
}

.request-card-header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.compact-header {
  margin-bottom: 16px;
}

.compact-header h2 {
  margin-bottom: 4px;
}

.evidence-upload-panel {
  margin: 18px 0;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #f8fafc;
}

.evidence-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 16px;
  margin: 12px 0 20px;
}

.evidence-card {
  overflow: hidden;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
}

.evidence-preview {
  display: flex;
  height: 190px;
  margin: -12px -12px 12px;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  background: #eef2f7;
}

.evidence-preview img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.evidence-meta {
  display: grid;
  gap: 5px;
  margin-bottom: 10px;
}

.hash-text {
  display: block;
  max-width: 100%;
  overflow: hidden;
  color: var(--muted);
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.filter-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(140px, 1fr)) auto;
  gap: 12px;
  align-items: end;
}

.filter-action {
  min-width: 90px;
}

.metric-card {
  display: grid;
  gap: 5px;
  text-align: center;
}

.metric-card strong {
  font-size: 30px;
}

.text-danger {
  color: #b42318;
}

@media (max-width: 1100px) {
  .grid-6 {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

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

@media (max-width: 820px) {
  .layout {
    display: block;
  }

  .sidebar {
    overflow-x: auto;
    padding: 9px 12px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
    white-space: nowrap;
  }

  .nav-group,
  .nav-title,
  .nav-subtitle,
  .nav-link {
    display: inline-block;
    margin: 0;
  }

  .nav-title {
    display: none;
  }

  .nav-subtitle {
    display: none;
  }

  .main {
    padding: 18px 14px;
  }

  .grid-2,
  .grid-3,
  .grid-6,
  .filter-grid,
  .workflow-stepper {
    grid-template-columns: 1fr;
  }

  .review-queue-bar,
  .workflow-next-card,
  .workflow-empty-step {
    display: block;
  }

  .review-queue-bar .actions,
  .workflow-next-card .actions,
  .workflow-empty-step .actions {
    margin-top: 12px;
  }

  .page-header {
    display: block;
  }

  .page-header .actions {
    margin-top: 12px;
  }

  .definition-list {
    grid-template-columns: 1fr;
    gap: 3px;
  }

  .definition-list dd {
    margin-bottom: 10px;
  }
}

@media (max-width: 520px) {
  .topbar {
    padding: 0 14px;
  }

  .topbar-actions span {
    display: none;
  }

  .public-shell {
    width: min(100% - 18px, 780px);
    padding: 18px 0 28px;
  }

  .public-card {
    padding: 20px 17px 26px;
    border-radius: 16px;
  }

  .public-actions {
    display: grid;
  }

  .public-window-controls {
    margin-bottom: 22px;
  }

  .invoice-info-grid,
  .application-grid {
    grid-template-columns: 1fr;
  }

  .invoice-info-wide,
  .application-field-wide {
    grid-column: auto;
  }

  .invoice-info-row {
    grid-template-columns: 82px minmax(0, 1fr);
  }

  .public-submit-row {
    display: grid;
    grid-template-columns: 1fr;
  }

  .public-submit-row button {
    order: -1;
  }

  .public-secondary-link {
    text-align: center;
  }

  .button,
  button {
    width: 100%;
  }

  .inline-form .button,
  .inline-form button,
  td .button,
  td button {
    width: auto;
  }

  .history-email-chip {
    width: auto;
  }
}
