:root {
  color-scheme: light;
  --brand: #176b55;
  --brand-dark: #0f4e3e;
  --surface: #ffffff;
  --page: #f4f7f6;
  --border: #cbd5d1;
  --text: #1d2925;
  --muted: #60706a;
  --authorized: #dff2e6;
  --authorized-hover: #d2ebdc;
  --rejected: #f7dddd;
  --rejected-hover: #f2cece;
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--page); color: var(--text); font-family: system-ui, -apple-system, "Segoe UI", sans-serif; }
.page-shell { width: min(1440px, calc(100% - 2rem)); margin-inline: auto; }
.site-header { background: var(--brand-dark); color: #fff; box-shadow: 0 2px 8px rgb(0 0 0 / 16%); }
.header-content { min-height: 64px; display: flex; align-items: center; justify-content: space-between; }
.brand, .brand:hover { color: #fff; font-size: 1.15rem; font-weight: 700; text-decoration: none; }
.link-button { border: 0; background: transparent; color: #fff; text-decoration: underline; cursor: pointer; }
.page-heading { display: flex; justify-content: space-between; margin: 2rem 0 1rem; }
.page-heading h1 { margin: 0; font-size: clamp(1.45rem, 3vw, 2rem); text-transform: uppercase; }
.client-id { margin: .35rem 0 0; color: var(--muted); }

.filter-panel { display: grid; grid-template-columns: repeat(4, minmax(145px, 1fr)) auto auto; align-items: end; gap: .8rem; padding: 1rem; border: 1px solid var(--border); border-radius: .6rem; background: var(--surface); }
.filter-field, .login-field { display: grid; gap: .3rem; }
.filter-field label, .login-field label { font-weight: 650; }
.filter-field input, .filter-field select, .login-field input { width: 100%; min-height: 42px; padding: .45rem .6rem; border: 1px solid #9caaa5; border-radius: .35rem; background: #fff; }
.primary-button, .secondary-button { min-height: 42px; display: inline-flex; align-items: center; justify-content: center; padding: .55rem .9rem; border: 1px solid var(--brand); border-radius: .35rem; font-weight: 650; text-decoration: none; cursor: pointer; }
.primary-button { background: var(--brand); color: #fff; }
.primary-button:hover { background: var(--brand-dark); }
.secondary-button { background: #fff; color: var(--brand-dark); }
.secondary-button:hover { background: #edf5f2; }
.full-width { width: 100%; margin-top: 1rem; }

.result-summary { margin: 1rem 0 .5rem; color: var(--muted); }
.table-scroll { overflow-x: auto; border: 1px solid var(--border); border-radius: .5rem; background: #fff; }
.documents-table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.documents-table th { background: #e6eeeb; text-align: left; white-space: nowrap; }
.documents-table th, .documents-table td { padding: .65rem; border-bottom: 1px solid var(--border); }
.documents-table tbody tr:last-child td { border-bottom: 0; }
.documents-table .document-authorized { background: var(--authorized); }
.documents-table .document-authorized:hover { background: var(--authorized-hover); }
.documents-table .document-rejected { background: var(--rejected); }
.documents-table .document-rejected:hover { background: var(--rejected-hover); }
.access-key { white-space: nowrap; font-family: ui-monospace, monospace; font-size: .82rem; }
.authorization-cell, .date-cell, .document-number { white-space: nowrap; }
.download-link { font-weight: 700; color: #075f91; }
.empty-result { padding: 2rem !important; text-align: center; color: var(--muted); }

.login-card { width: min(430px, 100%); margin: 4rem auto; padding: 2rem; border-radius: .8rem; background: #fff; box-shadow: 0 8px 28px rgb(0 0 0 / 12%); }
.login-card h1 { text-align: center; margin: .5rem 0 1.5rem; }
.login-card form { display: grid; gap: 1rem; }
.login-logo { display: block; width: 7rem; height: 7rem; margin: auto; }
.app-message { margin-top: 1rem; padding: .8rem 1rem; border-radius: .4rem; background: #fff3cd; }

@media (max-width: 1100px) { .filter-panel { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 620px) {
  .page-shell { width: min(100% - 1rem, 1440px); }
  .header-content { min-height: 56px; }
  .brand { font-size: 1rem; }
  .page-heading { margin: 1.25rem 0 .8rem; }
  .page-heading h1 { font-size: 1.35rem; line-height: 1.15; }
  .filter-panel { grid-template-columns: 1fr; }
  .primary-button, .secondary-button { width: 100%; }

  .table-scroll { overflow: visible; border: 0; background: transparent; }
  .documents-table, .documents-table tbody { display: block; }
  .documents-table thead {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
  }
  .documents-table tbody { display: grid; gap: .75rem; }
  .documents-table tbody tr {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    overflow: hidden;
    border: 1px solid var(--border);
    border-radius: .6rem;
    box-shadow: 0 2px 5px rgb(0 0 0 / 7%);
  }
  .documents-table td {
    min-width: 0;
    padding: .55rem .7rem;
    border-bottom: 1px solid rgb(0 0 0 / 8%);
  }
  .documents-table td::before {
    content: attr(data-label);
    display: block;
    margin-bottom: .15rem;
    color: var(--muted);
    font-size: .7rem;
    font-weight: 750;
    letter-spacing: .035em;
    text-transform: uppercase;
  }
  .documents-table .access-key,
  .documents-table .authorization-cell,
  .documents-table .document-number {
    grid-column: 1 / -1;
  }
  .documents-table .access-key span,
  .documents-table .authorization-cell span {
    display: block;
    overflow-x: auto;
    padding-bottom: .15rem;
    white-space: nowrap;
    scrollbar-width: thin;
  }
  .documents-table .download-cell { text-align: center; }
  .documents-table .download-link {
    display: inline-flex;
    min-height: 40px;
    align-items: center;
    justify-content: center;
    padding: .35rem 1.25rem;
    border: 1px solid #075f91;
    border-radius: .35rem;
    text-decoration: none;
  }
  .documents-table .empty-result { display: block; grid-column: 1 / -1; }
  .documents-table .empty-result::before { content: none; }
}
