:root {
  --ink: #1f2933;
  --muted: #697586;
  --brand: #9a0000;
  --brand-dark: #6f0000;
  --line: #d9dee7;
  --soft: #f5f7fa;
  --panel: #ffffff;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: #eef2f6;
  color: var(--ink);
  font-family: Arial, Helvetica, sans-serif;
  font-size: 14px;
}

a {
  color: var(--brand);
  word-break: break-word;
}

.hidden {
  display: none !important;
}

.app-header {
  min-height: 74px;
  padding: 12px 28px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  display: grid;
  grid-template-columns: 260px 1fr auto;
  align-items: center;
  gap: 20px;
}

.brand-logo {
  width: 220px;
  height: auto;
}

.header-title {
  text-align: center;
}

.header-title h1 {
  margin: 0;
  color: var(--brand);
  font-size: 24px;
}

.header-title span {
  display: block;
  margin-top: 3px;
  color: var(--muted);
}

.header-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
}

.login-shell,
.statement-shell,
.workspace {
  width: min(1220px, calc(100% - 32px));
  margin: 22px auto;
}

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

.panel,
.statement-sheet {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 6px;
}

.panel {
  padding: 22px;
}

.login-panel {
  max-width: 420px;
  margin: 80px auto;
}

h2,
h3 {
  margin: 0 0 14px;
  color: var(--brand-dark);
}

h2 {
  font-size: 22px;
}

h3 {
  font-size: 18px;
}

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

.section-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.section-heading h2 {
  margin: 0;
}

.section-heading.compact {
  margin-bottom: 12px;
}

.form-stack,
.form-grid {
  display: grid;
  gap: 16px;
}

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

.field label {
  display: block;
  margin-bottom: 6px;
  color: #334155;
  font-weight: 700;
}

input,
select {
  width: 100%;
  min-height: 40px;
  border: 1px solid #bcccdc;
  border-radius: 4px;
  padding: 8px 10px;
  color: #102a43;
  background: #fff;
  font: inherit;
}

input[readonly] {
  background: #f3f5f7;
}

.actions {
  display: flex;
  align-items: end;
}

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

.primary-button,
.secondary-button {
  min-height: 38px;
  border: 0;
  border-radius: 4px;
  padding: 0 14px;
  color: #fff;
  font-weight: 700;
  cursor: pointer;
}

.primary-button {
  background: var(--brand);
}

.secondary-button {
  background: var(--brand-dark);
}

.link-button {
  border: 0;
  padding: 0;
  background: transparent;
  color: var(--brand);
  cursor: pointer;
  font: inherit;
  font-weight: 700;
}

.error-message {
  border: 1px solid #f2b8b5;
  border-radius: 4px;
  padding: 10px 12px;
  background: #fff5f5;
  color: #b42318;
}

.account-list {
  display: grid;
  gap: 8px;
}

.account-card {
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 10px;
  background: #fff;
}

.account-card span,
.account-card strong,
.account-card code {
  display: block;
}

.account-card span {
  color: var(--muted);
  font-size: 12px;
}

.account-card strong {
  margin-top: 2px;
}

.account-card code {
  margin-top: 5px;
  color: var(--brand-dark);
}

.data-link {
  display: inline-block;
  margin-top: 16px;
  font-weight: 700;
}

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

.lookup-block h3 {
  margin-bottom: 10px;
  font-size: 16px;
}

.lookup-form label {
  display: block;
  margin-bottom: 6px;
  color: #334155;
  font-weight: 700;
}

.lookup-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
}

.lookup-form .error-message {
  margin-top: 10px;
}

.statement-sheet {
  min-height: 900px;
  padding: 30px 34px 24px;
}

.sheet-header {
  display: grid;
  grid-template-columns: 245px minmax(0, 1fr) 128px;
  align-items: center;
  gap: 18px;
}

.sheet-logo {
  width: 225px;
}

.sheet-heading {
  text-align: center;
}

.sheet-heading h2 {
  margin: 0;
  color: var(--brand);
  font-size: 30px;
}

.sheet-heading span {
  display: block;
  margin-top: 4px;
  color: var(--muted);
}

.qr-code {
  width: 128px;
  height: 128px;
}

.details-block,
.transactions-block,
.document-url-block {
  margin-top: 28px;
}

.document-url-block {
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 10px 12px;
  background: #fff;
}

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

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

.details-table th,
.details-table td,
.transactions-table th,
.transactions-table td {
  border: 1px solid var(--line);
  padding: 7px 8px;
  text-align: left;
}

.details-table th {
  width: 17%;
  background: #dedede;
  font-weight: 700;
}

.details-table td {
  width: 33%;
}

.file-name-value {
  word-break: break-all;
  font-size: 12px;
}

.transactions-table th {
  background: var(--brand);
  color: #fff;
  font-weight: 700;
}

.transactions-table tbody tr:nth-child(even) {
  background: var(--soft);
}

.numeric {
  text-align: right !important;
}

.sheet-footer {
  margin-top: 360px;
  display: flex;
  justify-content: space-between;
  color: #111;
}

.load-error {
  margin: 80px auto;
  max-width: 520px;
  padding: 24px;
  background: #fff;
  border: 1px solid var(--line);
}

@media (max-width: 920px) {
  .app-header,
  .workspace,
  .sheet-header,
  .form-grid {
    grid-template-columns: 1fr;
  }

  .header-title,
  .sheet-heading {
    text-align: left;
  }

  .sheet-footer {
    margin-top: 80px;
  }
}

@media (max-width: 640px) {
  .login-shell,
  .statement-shell,
  .workspace {
    width: min(100% - 20px, 1220px);
  }

  .panel,
  .statement-sheet {
    padding: 18px;
  }

  .brand-logo,
  .sheet-logo {
    width: min(100%, 235px);
  }

  .sheet-heading h2 {
    font-size: 26px;
  }

  .details-table,
  .details-table tbody {
    display: block;
  }

  .details-table tr {
    display: grid;
    grid-template-columns: minmax(112px, 38%) minmax(0, 1fr);
  }

  .details-table th,
  .details-table td {
    width: auto;
    min-width: 0;
    word-break: break-word;
  }

  .details-table th:nth-child(3) {
    grid-column: 1;
  }

  .details-table td:nth-child(4) {
    grid-column: 2;
  }

  .transactions-table th,
  .transactions-table td {
    padding: 7px 6px;
    font-size: 12px;
  }

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

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

  .app-header {
    display: none;
  }

  .statement-shell {
    width: 100%;
    margin: 0;
  }

  .statement-sheet {
    border: 0;
    border-radius: 0;
    min-height: auto;
    padding: 18mm 14mm 12mm;
  }
}
